babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392
  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.vector" {
  1937. import { Viewport } from "babylonjs/Maths/math.viewport";
  1938. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1939. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1940. /**
  1941. * Class representing a vector containing 2 coordinates
  1942. */
  1943. export class Vector2 {
  1944. /** defines the first coordinate */
  1945. x: number;
  1946. /** defines the second coordinate */
  1947. y: number;
  1948. /**
  1949. * Creates a new Vector2 from the given x and y coordinates
  1950. * @param x defines the first coordinate
  1951. * @param y defines the second coordinate
  1952. */
  1953. constructor(
  1954. /** defines the first coordinate */
  1955. x?: number,
  1956. /** defines the second coordinate */
  1957. y?: number);
  1958. /**
  1959. * Gets a string with the Vector2 coordinates
  1960. * @returns a string with the Vector2 coordinates
  1961. */
  1962. toString(): string;
  1963. /**
  1964. * Gets class name
  1965. * @returns the string "Vector2"
  1966. */
  1967. getClassName(): string;
  1968. /**
  1969. * Gets current vector hash code
  1970. * @returns the Vector2 hash code as a number
  1971. */
  1972. getHashCode(): number;
  1973. /**
  1974. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1975. * @param array defines the source array
  1976. * @param index defines the offset in source array
  1977. * @returns the current Vector2
  1978. */
  1979. toArray(array: FloatArray, index?: number): Vector2;
  1980. /**
  1981. * Copy the current vector to an array
  1982. * @returns a new array with 2 elements: the Vector2 coordinates.
  1983. */
  1984. asArray(): number[];
  1985. /**
  1986. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1987. * @param source defines the source Vector2
  1988. * @returns the current updated Vector2
  1989. */
  1990. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the Vector2 coordinates with the given floats
  1993. * @param x defines the first coordinate
  1994. * @param y defines the second coordinate
  1995. * @returns the current updated Vector2
  1996. */
  1997. copyFromFloats(x: number, y: number): Vector2;
  1998. /**
  1999. * Sets the Vector2 coordinates with the given floats
  2000. * @param x defines the first coordinate
  2001. * @param y defines the second coordinate
  2002. * @returns the current updated Vector2
  2003. */
  2004. set(x: number, y: number): Vector2;
  2005. /**
  2006. * Add another vector with the current one
  2007. * @param otherVector defines the other vector
  2008. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2009. */
  2010. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2011. /**
  2012. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2013. * @param otherVector defines the other vector
  2014. * @param result defines the target vector
  2015. * @returns the unmodified current Vector2
  2016. */
  2017. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2018. /**
  2019. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2020. * @param otherVector defines the other vector
  2021. * @returns the current updated Vector2
  2022. */
  2023. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2024. /**
  2025. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2026. * @param otherVector defines the other vector
  2027. * @returns a new Vector2
  2028. */
  2029. addVector3(otherVector: Vector3): Vector2;
  2030. /**
  2031. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2032. * @param otherVector defines the other vector
  2033. * @returns a new Vector2
  2034. */
  2035. subtract(otherVector: Vector2): Vector2;
  2036. /**
  2037. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2038. * @param otherVector defines the other vector
  2039. * @param result defines the target vector
  2040. * @returns the unmodified current Vector2
  2041. */
  2042. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2043. /**
  2044. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2045. * @param otherVector defines the other vector
  2046. * @returns the current updated Vector2
  2047. */
  2048. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2049. /**
  2050. * Multiplies in place the current Vector2 coordinates by the given ones
  2051. * @param otherVector defines the other vector
  2052. * @returns the current updated Vector2
  2053. */
  2054. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2063. * @param otherVector defines the other vector
  2064. * @param result defines the target vector
  2065. * @returns the unmodified current Vector2
  2066. */
  2067. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2070. * @param x defines the first coordinate
  2071. * @param y defines the second coordinate
  2072. * @returns a new Vector2
  2073. */
  2074. multiplyByFloats(x: number, y: number): Vector2;
  2075. /**
  2076. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2077. * @param otherVector defines the other vector
  2078. * @returns a new Vector2
  2079. */
  2080. divide(otherVector: Vector2): Vector2;
  2081. /**
  2082. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2083. * @param otherVector defines the other vector
  2084. * @param result defines the target vector
  2085. * @returns the unmodified current Vector2
  2086. */
  2087. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2088. /**
  2089. * Divides the current Vector2 coordinates by the given ones
  2090. * @param otherVector defines the other vector
  2091. * @returns the current updated Vector2
  2092. */
  2093. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2094. /**
  2095. * Gets a new Vector2 with current Vector2 negated coordinates
  2096. * @returns a new Vector2
  2097. */
  2098. negate(): Vector2;
  2099. /**
  2100. * Negate this vector in place
  2101. * @returns this
  2102. */
  2103. negateInPlace(): Vector2;
  2104. /**
  2105. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2106. * @param result defines the Vector3 object where to store the result
  2107. * @returns the current Vector2
  2108. */
  2109. negateToRef(result: Vector2): Vector2;
  2110. /**
  2111. * Multiply the Vector2 coordinates by scale
  2112. * @param scale defines the scaling factor
  2113. * @returns the current updated Vector2
  2114. */
  2115. scaleInPlace(scale: number): Vector2;
  2116. /**
  2117. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2118. * @param scale defines the scaling factor
  2119. * @returns a new Vector2
  2120. */
  2121. scale(scale: number): Vector2;
  2122. /**
  2123. * Scale the current Vector2 values by a factor to a given Vector2
  2124. * @param scale defines the scale factor
  2125. * @param result defines the Vector2 object where to store the result
  2126. * @returns the unmodified current Vector2
  2127. */
  2128. scaleToRef(scale: number, result: Vector2): Vector2;
  2129. /**
  2130. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2131. * @param scale defines the scale factor
  2132. * @param result defines the Vector2 object where to store the result
  2133. * @returns the unmodified current Vector2
  2134. */
  2135. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2136. /**
  2137. * Gets a boolean if two vectors are equals
  2138. * @param otherVector defines the other vector
  2139. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2140. */
  2141. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2142. /**
  2143. * Gets a boolean if two vectors are equals (using an epsilon value)
  2144. * @param otherVector defines the other vector
  2145. * @param epsilon defines the minimal distance to consider equality
  2146. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2147. */
  2148. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2149. /**
  2150. * Gets a new Vector2 from current Vector2 floored values
  2151. * @returns a new Vector2
  2152. */
  2153. floor(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 from current Vector2 floored values
  2156. * @returns a new Vector2
  2157. */
  2158. fract(): Vector2;
  2159. /**
  2160. * Gets the length of the vector
  2161. * @returns the vector length (float)
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Gets the vector squared length
  2166. * @returns the vector squared length (float)
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalize the vector
  2171. * @returns the current updated Vector2
  2172. */
  2173. normalize(): Vector2;
  2174. /**
  2175. * Gets a new Vector2 copied from the Vector2
  2176. * @returns a new Vector2
  2177. */
  2178. clone(): Vector2;
  2179. /**
  2180. * Gets a new Vector2(0, 0)
  2181. * @returns a new Vector2
  2182. */
  2183. static Zero(): Vector2;
  2184. /**
  2185. * Gets a new Vector2(1, 1)
  2186. * @returns a new Vector2
  2187. */
  2188. static One(): Vector2;
  2189. /**
  2190. * Gets a new Vector2 set from the given index element of the given array
  2191. * @param array defines the data source
  2192. * @param offset defines the offset in the data source
  2193. * @returns a new Vector2
  2194. */
  2195. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2196. /**
  2197. * Sets "result" from the given index element of the given array
  2198. * @param array defines the data source
  2199. * @param offset defines the offset in the data source
  2200. * @param result defines the target vector
  2201. */
  2202. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2203. /**
  2204. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2205. * @param value1 defines 1st point of control
  2206. * @param value2 defines 2nd point of control
  2207. * @param value3 defines 3rd point of control
  2208. * @param value4 defines 4th point of control
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * 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".
  2215. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2216. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2217. * @param value defines the value to clamp
  2218. * @param min defines the lower limit
  2219. * @param max defines the upper limit
  2220. * @returns a new Vector2
  2221. */
  2222. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2223. /**
  2224. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2225. * @param value1 defines the 1st control point
  2226. * @param tangent1 defines the outgoing tangent
  2227. * @param value2 defines the 2nd control point
  2228. * @param tangent2 defines the incoming tangent
  2229. * @param amount defines the interpolation factor
  2230. * @returns a new Vector2
  2231. */
  2232. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2233. /**
  2234. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2235. * @param start defines the start vector
  2236. * @param end defines the end vector
  2237. * @param amount defines the interpolation factor
  2238. * @returns a new Vector2
  2239. */
  2240. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2241. /**
  2242. * Gets the dot product of the vector "left" and the vector "right"
  2243. * @param left defines first vector
  2244. * @param right defines second vector
  2245. * @returns the dot product (float)
  2246. */
  2247. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2248. /**
  2249. * Returns a new Vector2 equal to the normalized given vector
  2250. * @param vector defines the vector to normalize
  2251. * @returns a new Vector2
  2252. */
  2253. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2254. /**
  2255. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2256. * @param left defines 1st vector
  2257. * @param right defines 2nd vector
  2258. * @returns a new Vector2
  2259. */
  2260. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2261. /**
  2262. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2263. * @param left defines 1st vector
  2264. * @param right defines 2nd vector
  2265. * @returns a new Vector2
  2266. */
  2267. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2268. /**
  2269. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2270. * @param vector defines the vector to transform
  2271. * @param transformation defines the matrix to apply
  2272. * @returns a new Vector2
  2273. */
  2274. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2275. /**
  2276. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2277. * @param vector defines the vector to transform
  2278. * @param transformation defines the matrix to apply
  2279. * @param result defines the target vector
  2280. */
  2281. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2282. /**
  2283. * Determines if a given vector is included in a triangle
  2284. * @param p defines the vector to test
  2285. * @param p0 defines 1st triangle point
  2286. * @param p1 defines 2nd triangle point
  2287. * @param p2 defines 3rd triangle point
  2288. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2289. */
  2290. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2291. /**
  2292. * Gets the distance between the vectors "value1" and "value2"
  2293. * @param value1 defines first vector
  2294. * @param value2 defines second vector
  2295. * @returns the distance between vectors
  2296. */
  2297. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2298. /**
  2299. * Returns the squared distance between the vectors "value1" and "value2"
  2300. * @param value1 defines first vector
  2301. * @param value2 defines second vector
  2302. * @returns the squared distance between vectors
  2303. */
  2304. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2305. /**
  2306. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2307. * @param value1 defines first vector
  2308. * @param value2 defines second vector
  2309. * @returns a new Vector2
  2310. */
  2311. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2312. /**
  2313. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2314. * @param p defines the middle point
  2315. * @param segA defines one point of the segment
  2316. * @param segB defines the other point of the segment
  2317. * @returns the shortest distance
  2318. */
  2319. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2320. }
  2321. /**
  2322. * Class used to store (x,y,z) vector representation
  2323. * A Vector3 is the main object used in 3D geometry
  2324. * It can represent etiher the coordinates of a point the space, either a direction
  2325. * Reminder: js uses a left handed forward facing system
  2326. */
  2327. export class Vector3 {
  2328. /**
  2329. * Defines the first coordinates (on X axis)
  2330. */
  2331. x: number;
  2332. /**
  2333. * Defines the second coordinates (on Y axis)
  2334. */
  2335. y: number;
  2336. /**
  2337. * Defines the third coordinates (on Z axis)
  2338. */
  2339. z: number;
  2340. private static _UpReadOnly;
  2341. private static _ZeroReadOnly;
  2342. /**
  2343. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2344. * @param x defines the first coordinates (on X axis)
  2345. * @param y defines the second coordinates (on Y axis)
  2346. * @param z defines the third coordinates (on Z axis)
  2347. */
  2348. constructor(
  2349. /**
  2350. * Defines the first coordinates (on X axis)
  2351. */
  2352. x?: number,
  2353. /**
  2354. * Defines the second coordinates (on Y axis)
  2355. */
  2356. y?: number,
  2357. /**
  2358. * Defines the third coordinates (on Z axis)
  2359. */
  2360. z?: number);
  2361. /**
  2362. * Creates a string representation of the Vector3
  2363. * @returns a string with the Vector3 coordinates.
  2364. */
  2365. toString(): string;
  2366. /**
  2367. * Gets the class name
  2368. * @returns the string "Vector3"
  2369. */
  2370. getClassName(): string;
  2371. /**
  2372. * Creates the Vector3 hash code
  2373. * @returns a number which tends to be unique between Vector3 instances
  2374. */
  2375. getHashCode(): number;
  2376. /**
  2377. * Creates an array containing three elements : the coordinates of the Vector3
  2378. * @returns a new array of numbers
  2379. */
  2380. asArray(): number[];
  2381. /**
  2382. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2383. * @param array defines the destination array
  2384. * @param index defines the offset in the destination array
  2385. * @returns the current Vector3
  2386. */
  2387. toArray(array: FloatArray, index?: number): Vector3;
  2388. /**
  2389. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2390. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2391. */
  2392. toQuaternion(): Quaternion;
  2393. /**
  2394. * Adds the given vector to the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the current updated Vector3
  2397. */
  2398. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Adds the given coordinates to the current Vector3
  2401. * @param x defines the x coordinate of the operand
  2402. * @param y defines the y coordinate of the operand
  2403. * @param z defines the z coordinate of the operand
  2404. * @returns the current updated Vector3
  2405. */
  2406. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2407. /**
  2408. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2409. * @param otherVector defines the second operand
  2410. * @returns the resulting Vector3
  2411. */
  2412. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2413. /**
  2414. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2415. * @param otherVector defines the second operand
  2416. * @param result defines the Vector3 object where to store the result
  2417. * @returns the current Vector3
  2418. */
  2419. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2420. /**
  2421. * Subtract the given vector from the current Vector3
  2422. * @param otherVector defines the second operand
  2423. * @returns the current updated Vector3
  2424. */
  2425. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2426. /**
  2427. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2428. * @param otherVector defines the second operand
  2429. * @returns the resulting Vector3
  2430. */
  2431. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2432. /**
  2433. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2434. * @param otherVector defines the second operand
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2439. /**
  2440. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2441. * @param x defines the x coordinate of the operand
  2442. * @param y defines the y coordinate of the operand
  2443. * @param z defines the z coordinate of the operand
  2444. * @returns the resulting Vector3
  2445. */
  2446. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2447. /**
  2448. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2449. * @param x defines the x coordinate of the operand
  2450. * @param y defines the y coordinate of the operand
  2451. * @param z defines the z coordinate of the operand
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2456. /**
  2457. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2458. * @returns a new Vector3
  2459. */
  2460. negate(): Vector3;
  2461. /**
  2462. * Negate this vector in place
  2463. * @returns this
  2464. */
  2465. negateInPlace(): Vector3;
  2466. /**
  2467. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2468. * @param result defines the Vector3 object where to store the result
  2469. * @returns the current Vector3
  2470. */
  2471. negateToRef(result: Vector3): Vector3;
  2472. /**
  2473. * Multiplies the Vector3 coordinates by the float "scale"
  2474. * @param scale defines the multiplier factor
  2475. * @returns the current updated Vector3
  2476. */
  2477. scaleInPlace(scale: number): Vector3;
  2478. /**
  2479. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2480. * @param scale defines the multiplier factor
  2481. * @returns a new Vector3
  2482. */
  2483. scale(scale: number): Vector3;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2486. * @param scale defines the multiplier factor
  2487. * @param result defines the Vector3 object where to store the result
  2488. * @returns the current Vector3
  2489. */
  2490. scaleToRef(scale: number, result: Vector3): Vector3;
  2491. /**
  2492. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2493. * @param scale defines the scale factor
  2494. * @param result defines the Vector3 object where to store the result
  2495. * @returns the unmodified current Vector3
  2496. */
  2497. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2498. /**
  2499. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2500. * @param otherVector defines the second operand
  2501. * @returns true if both vectors are equals
  2502. */
  2503. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2504. /**
  2505. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2506. * @param otherVector defines the second operand
  2507. * @param epsilon defines the minimal distance to define values as equals
  2508. * @returns true if both vectors are distant less than epsilon
  2509. */
  2510. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2511. /**
  2512. * Returns true if the current Vector3 coordinates equals the given floats
  2513. * @param x defines the x coordinate of the operand
  2514. * @param y defines the y coordinate of the operand
  2515. * @param z defines the z coordinate of the operand
  2516. * @returns true if both vectors are equals
  2517. */
  2518. equalsToFloats(x: number, y: number, z: number): boolean;
  2519. /**
  2520. * Multiplies the current Vector3 coordinates by the given ones
  2521. * @param otherVector defines the second operand
  2522. * @returns the current updated Vector3
  2523. */
  2524. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2525. /**
  2526. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2527. * @param otherVector defines the second operand
  2528. * @returns the new Vector3
  2529. */
  2530. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2531. /**
  2532. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2533. * @param otherVector defines the second operand
  2534. * @param result defines the Vector3 object where to store the result
  2535. * @returns the current Vector3
  2536. */
  2537. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2538. /**
  2539. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2540. * @param x defines the x coordinate of the operand
  2541. * @param y defines the y coordinate of the operand
  2542. * @param z defines the z coordinate of the operand
  2543. * @returns the new Vector3
  2544. */
  2545. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2546. /**
  2547. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2548. * @param otherVector defines the second operand
  2549. * @returns the new Vector3
  2550. */
  2551. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2552. /**
  2553. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2554. * @param otherVector defines the second operand
  2555. * @param result defines the Vector3 object where to store the result
  2556. * @returns the current Vector3
  2557. */
  2558. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2559. /**
  2560. * Divides the current Vector3 coordinates by the given ones.
  2561. * @param otherVector defines the second operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. divideInPlace(otherVector: Vector3): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2567. * @param other defines the second operand
  2568. * @returns the current updated Vector3
  2569. */
  2570. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2573. * @param other defines the second operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2579. * @param x defines the x coordinate of the operand
  2580. * @param y defines the y coordinate of the operand
  2581. * @param z defines the z coordinate of the operand
  2582. * @returns the current updated Vector3
  2583. */
  2584. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2585. /**
  2586. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2587. * @param x defines the x coordinate of the operand
  2588. * @param y defines the y coordinate of the operand
  2589. * @param z defines the z coordinate of the operand
  2590. * @returns the current updated Vector3
  2591. */
  2592. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2593. /**
  2594. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2595. * Check if is non uniform within a certain amount of decimal places to account for this
  2596. * @param epsilon the amount the values can differ
  2597. * @returns if the the vector is non uniform to a certain number of decimal places
  2598. */
  2599. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2600. /**
  2601. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2602. */
  2603. get isNonUniform(): boolean;
  2604. /**
  2605. * Gets a new Vector3 from current Vector3 floored values
  2606. * @returns a new Vector3
  2607. */
  2608. floor(): Vector3;
  2609. /**
  2610. * Gets a new Vector3 from current Vector3 floored values
  2611. * @returns a new Vector3
  2612. */
  2613. fract(): Vector3;
  2614. /**
  2615. * Gets the length of the Vector3
  2616. * @returns the length of the Vector3
  2617. */
  2618. length(): number;
  2619. /**
  2620. * Gets the squared length of the Vector3
  2621. * @returns squared length of the Vector3
  2622. */
  2623. lengthSquared(): number;
  2624. /**
  2625. * Normalize the current Vector3.
  2626. * Please note that this is an in place operation.
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalize(): Vector3;
  2630. /**
  2631. * Reorders the x y z properties of the vector in place
  2632. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2633. * @returns the current updated vector
  2634. */
  2635. reorderInPlace(order: string): this;
  2636. /**
  2637. * Rotates the vector around 0,0,0 by a quaternion
  2638. * @param quaternion the rotation quaternion
  2639. * @param result vector to store the result
  2640. * @returns the resulting vector
  2641. */
  2642. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2643. /**
  2644. * Rotates a vector around a given point
  2645. * @param quaternion the rotation quaternion
  2646. * @param point the point to rotate around
  2647. * @param result vector to store the result
  2648. * @returns the resulting vector
  2649. */
  2650. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2651. /**
  2652. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2653. * The cross product is then orthogonal to both current and "other"
  2654. * @param other defines the right operand
  2655. * @returns the cross product
  2656. */
  2657. cross(other: Vector3): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 with the given input length.
  2660. * Please note that this is an in place operation.
  2661. * @param len the length of the vector
  2662. * @returns the current updated Vector3
  2663. */
  2664. normalizeFromLength(len: number): Vector3;
  2665. /**
  2666. * Normalize the current Vector3 to a new vector
  2667. * @returns the new Vector3
  2668. */
  2669. normalizeToNew(): Vector3;
  2670. /**
  2671. * Normalize the current Vector3 to the reference
  2672. * @param reference define the Vector3 to update
  2673. * @returns the updated Vector3
  2674. */
  2675. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2676. /**
  2677. * Creates a new Vector3 copied from the current Vector3
  2678. * @returns the new Vector3
  2679. */
  2680. clone(): Vector3;
  2681. /**
  2682. * Copies the given vector coordinates to the current Vector3 ones
  2683. * @param source defines the source Vector3
  2684. * @returns the current updated Vector3
  2685. */
  2686. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2687. /**
  2688. * Copies the given floats to the current Vector3 coordinates
  2689. * @param x defines the x coordinate of the operand
  2690. * @param y defines the y coordinate of the operand
  2691. * @param z defines the z coordinate of the operand
  2692. * @returns the current updated Vector3
  2693. */
  2694. copyFromFloats(x: number, y: number, z: number): Vector3;
  2695. /**
  2696. * Copies the given floats to the current Vector3 coordinates
  2697. * @param x defines the x coordinate of the operand
  2698. * @param y defines the y coordinate of the operand
  2699. * @param z defines the z coordinate of the operand
  2700. * @returns the current updated Vector3
  2701. */
  2702. set(x: number, y: number, z: number): Vector3;
  2703. /**
  2704. * Copies the given float to the current Vector3 coordinates
  2705. * @param v defines the x, y and z coordinates of the operand
  2706. * @returns the current updated Vector3
  2707. */
  2708. setAll(v: number): Vector3;
  2709. /**
  2710. * Get the clip factor between two vectors
  2711. * @param vector0 defines the first operand
  2712. * @param vector1 defines the second operand
  2713. * @param axis defines the axis to use
  2714. * @param size defines the size along the axis
  2715. * @returns the clip factor
  2716. */
  2717. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2718. /**
  2719. * Get angle between two vectors
  2720. * @param vector0 angle between vector0 and vector1
  2721. * @param vector1 angle between vector0 and vector1
  2722. * @param normal direction of the normal
  2723. * @return the angle between vector0 and vector1
  2724. */
  2725. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2726. /**
  2727. * Returns a new Vector3 set from the index "offset" of the given array
  2728. * @param array defines the source array
  2729. * @param offset defines the offset in the source array
  2730. * @returns the new Vector3
  2731. */
  2732. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2735. * @param array defines the source array
  2736. * @param offset defines the offset in the source array
  2737. * @returns the new Vector3
  2738. * @deprecated Please use FromArray instead.
  2739. */
  2740. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2741. /**
  2742. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2743. * @param array defines the source array
  2744. * @param offset defines the offset in the source array
  2745. * @param result defines the Vector3 where to store the result
  2746. */
  2747. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2748. /**
  2749. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2750. * @param array defines the source array
  2751. * @param offset defines the offset in the source array
  2752. * @param result defines the Vector3 where to store the result
  2753. * @deprecated Please use FromArrayToRef instead.
  2754. */
  2755. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2756. /**
  2757. * Sets the given vector "result" with the given floats.
  2758. * @param x defines the x coordinate of the source
  2759. * @param y defines the y coordinate of the source
  2760. * @param z defines the z coordinate of the source
  2761. * @param result defines the Vector3 where to store the result
  2762. */
  2763. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2766. * @returns a new empty Vector3
  2767. */
  2768. static Zero(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2771. * @returns a new unit Vector3
  2772. */
  2773. static One(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2776. * @returns a new up Vector3
  2777. */
  2778. static Up(): Vector3;
  2779. /**
  2780. * Gets a up Vector3 that must not be updated
  2781. */
  2782. static get UpReadOnly(): DeepImmutable<Vector3>;
  2783. /**
  2784. * Gets a zero Vector3 that must not be updated
  2785. */
  2786. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2787. /**
  2788. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2789. * @returns a new down Vector3
  2790. */
  2791. static Down(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2794. * @returns a new forward Vector3
  2795. */
  2796. static Forward(): Vector3;
  2797. /**
  2798. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2799. * @returns a new forward Vector3
  2800. */
  2801. static Backward(): Vector3;
  2802. /**
  2803. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2804. * @returns a new right Vector3
  2805. */
  2806. static Right(): Vector3;
  2807. /**
  2808. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2809. * @returns a new left Vector3
  2810. */
  2811. static Left(): Vector3;
  2812. /**
  2813. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2814. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2815. * @param vector defines the Vector3 to transform
  2816. * @param transformation defines the transformation matrix
  2817. * @returns the transformed Vector3
  2818. */
  2819. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2820. /**
  2821. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2822. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2823. * @param vector defines the Vector3 to transform
  2824. * @param transformation defines the transformation matrix
  2825. * @param result defines the Vector3 where to store the result
  2826. */
  2827. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2828. /**
  2829. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2830. * This method computes tranformed coordinates only, not transformed direction vectors
  2831. * @param x define the x coordinate of the source vector
  2832. * @param y define the y coordinate of the source vector
  2833. * @param z define the z coordinate of the source vector
  2834. * @param transformation defines the transformation matrix
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2838. /**
  2839. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2840. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2841. * @param vector defines the Vector3 to transform
  2842. * @param transformation defines the transformation matrix
  2843. * @returns the new Vector3
  2844. */
  2845. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2846. /**
  2847. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2848. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2849. * @param vector defines the Vector3 to transform
  2850. * @param transformation defines the transformation matrix
  2851. * @param result defines the Vector3 where to store the result
  2852. */
  2853. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2854. /**
  2855. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2856. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2857. * @param x define the x coordinate of the source vector
  2858. * @param y define the y coordinate of the source vector
  2859. * @param z define the z coordinate of the source vector
  2860. * @param transformation defines the transformation matrix
  2861. * @param result defines the Vector3 where to store the result
  2862. */
  2863. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2864. /**
  2865. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2866. * @param value1 defines the first control point
  2867. * @param value2 defines the second control point
  2868. * @param value3 defines the third control point
  2869. * @param value4 defines the fourth control point
  2870. * @param amount defines the amount on the spline to use
  2871. * @returns the new Vector3
  2872. */
  2873. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2874. /**
  2875. * 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"
  2876. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2877. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2878. * @param value defines the current value
  2879. * @param min defines the lower range value
  2880. * @param max defines the upper range value
  2881. * @returns the new Vector3
  2882. */
  2883. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2884. /**
  2885. * 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"
  2886. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2887. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2888. * @param value defines the current value
  2889. * @param min defines the lower range value
  2890. * @param max defines the upper range value
  2891. * @param result defines the Vector3 where to store the result
  2892. */
  2893. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2894. /**
  2895. * Checks if a given vector is inside a specific range
  2896. * @param v defines the vector to test
  2897. * @param min defines the minimum range
  2898. * @param max defines the maximum range
  2899. */
  2900. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2901. /**
  2902. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2903. * @param value1 defines the first control point
  2904. * @param tangent1 defines the first tangent vector
  2905. * @param value2 defines the second control point
  2906. * @param tangent2 defines the second tangent vector
  2907. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2908. * @returns the new Vector3
  2909. */
  2910. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2911. /**
  2912. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2913. * @param start defines the start value
  2914. * @param end defines the end value
  2915. * @param amount max defines amount between both (between 0 and 1)
  2916. * @returns the new Vector3
  2917. */
  2918. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2919. /**
  2920. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2921. * @param start defines the start value
  2922. * @param end defines the end value
  2923. * @param amount max defines amount between both (between 0 and 1)
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2927. /**
  2928. * Returns the dot product (float) between the vectors "left" and "right"
  2929. * @param left defines the left operand
  2930. * @param right defines the right operand
  2931. * @returns the dot product
  2932. */
  2933. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2934. /**
  2935. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2936. * The cross product is then orthogonal to both "left" and "right"
  2937. * @param left defines the left operand
  2938. * @param right defines the right operand
  2939. * @returns the cross product
  2940. */
  2941. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2942. /**
  2943. * Sets the given vector "result" with the cross product of "left" and "right"
  2944. * The cross product is then orthogonal to both "left" and "right"
  2945. * @param left defines the left operand
  2946. * @param right defines the right operand
  2947. * @param result defines the Vector3 where to store the result
  2948. */
  2949. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2950. /**
  2951. * Returns a new Vector3 as the normalization of the given vector
  2952. * @param vector defines the Vector3 to normalize
  2953. * @returns the new Vector3
  2954. */
  2955. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2956. /**
  2957. * Sets the given vector "result" with the normalization of the given first vector
  2958. * @param vector defines the Vector3 to normalize
  2959. * @param result defines the Vector3 where to store the result
  2960. */
  2961. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2962. /**
  2963. * Project a Vector3 onto screen space
  2964. * @param vector defines the Vector3 to project
  2965. * @param world defines the world matrix to use
  2966. * @param transform defines the transform (view x projection) matrix to use
  2967. * @param viewport defines the screen viewport to use
  2968. * @returns the new Vector3
  2969. */
  2970. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2971. /** @hidden */
  2972. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Unproject from screen space to object space
  2975. * @param source defines the screen space Vector3 to use
  2976. * @param viewportWidth defines the current width of the viewport
  2977. * @param viewportHeight defines the current height of the viewport
  2978. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2979. * @param transform defines the transform (view x projection) matrix to use
  2980. * @returns the new Vector3
  2981. */
  2982. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2983. /**
  2984. * Unproject from screen space to object space
  2985. * @param source defines the screen space Vector3 to use
  2986. * @param viewportWidth defines the current width of the viewport
  2987. * @param viewportHeight defines the current height of the viewport
  2988. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2989. * @param view defines the view matrix to use
  2990. * @param projection defines the projection matrix to use
  2991. * @returns the new Vector3
  2992. */
  2993. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2994. /**
  2995. * Unproject from screen space to object space
  2996. * @param source defines the screen space Vector3 to use
  2997. * @param viewportWidth defines the current width of the viewport
  2998. * @param viewportHeight defines the current height of the viewport
  2999. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3000. * @param view defines the view matrix to use
  3001. * @param projection defines the projection matrix to use
  3002. * @param result defines the Vector3 where to store the result
  3003. */
  3004. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3005. /**
  3006. * Unproject from screen space to object space
  3007. * @param sourceX defines the screen space x coordinate to use
  3008. * @param sourceY defines the screen space y coordinate to use
  3009. * @param sourceZ defines the screen space z coordinate to use
  3010. * @param viewportWidth defines the current width of the viewport
  3011. * @param viewportHeight defines the current height of the viewport
  3012. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3013. * @param view defines the view matrix to use
  3014. * @param projection defines the projection matrix to use
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3018. /**
  3019. * Gets the minimal coordinate values between two Vector3
  3020. * @param left defines the first operand
  3021. * @param right defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Gets the maximal coordinate values between two Vector3
  3027. * @param left defines the first operand
  3028. * @param right defines the second operand
  3029. * @returns the new Vector3
  3030. */
  3031. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3032. /**
  3033. * Returns the distance between the vectors "value1" and "value2"
  3034. * @param value1 defines the first operand
  3035. * @param value2 defines the second operand
  3036. * @returns the distance
  3037. */
  3038. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3039. /**
  3040. * Returns the squared distance between the vectors "value1" and "value2"
  3041. * @param value1 defines the first operand
  3042. * @param value2 defines the second operand
  3043. * @returns the squared distance
  3044. */
  3045. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3046. /**
  3047. * Returns a new Vector3 located at the center between "value1" and "value2"
  3048. * @param value1 defines the first operand
  3049. * @param value2 defines the second operand
  3050. * @returns the new Vector3
  3051. */
  3052. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3053. /**
  3054. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3055. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3056. * to something in order to rotate it from its local system to the given target system
  3057. * Note: axis1, axis2 and axis3 are normalized during this operation
  3058. * @param axis1 defines the first axis
  3059. * @param axis2 defines the second axis
  3060. * @param axis3 defines the third axis
  3061. * @returns a new Vector3
  3062. */
  3063. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3064. /**
  3065. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3066. * @param axis1 defines the first axis
  3067. * @param axis2 defines the second axis
  3068. * @param axis3 defines the third axis
  3069. * @param ref defines the Vector3 where to store the result
  3070. */
  3071. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3072. }
  3073. /**
  3074. * Vector4 class created for EulerAngle class conversion to Quaternion
  3075. */
  3076. export class Vector4 {
  3077. /** x value of the vector */
  3078. x: number;
  3079. /** y value of the vector */
  3080. y: number;
  3081. /** z value of the vector */
  3082. z: number;
  3083. /** w value of the vector */
  3084. w: number;
  3085. /**
  3086. * Creates a Vector4 object from the given floats.
  3087. * @param x x value of the vector
  3088. * @param y y value of the vector
  3089. * @param z z value of the vector
  3090. * @param w w value of the vector
  3091. */
  3092. constructor(
  3093. /** x value of the vector */
  3094. x: number,
  3095. /** y value of the vector */
  3096. y: number,
  3097. /** z value of the vector */
  3098. z: number,
  3099. /** w value of the vector */
  3100. w: number);
  3101. /**
  3102. * Returns the string with the Vector4 coordinates.
  3103. * @returns a string containing all the vector values
  3104. */
  3105. toString(): string;
  3106. /**
  3107. * Returns the string "Vector4".
  3108. * @returns "Vector4"
  3109. */
  3110. getClassName(): string;
  3111. /**
  3112. * Returns the Vector4 hash code.
  3113. * @returns a unique hash code
  3114. */
  3115. getHashCode(): number;
  3116. /**
  3117. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3118. * @returns the resulting array
  3119. */
  3120. asArray(): number[];
  3121. /**
  3122. * Populates the given array from the given index with the Vector4 coordinates.
  3123. * @param array array to populate
  3124. * @param index index of the array to start at (default: 0)
  3125. * @returns the Vector4.
  3126. */
  3127. toArray(array: FloatArray, index?: number): Vector4;
  3128. /**
  3129. * Adds the given vector to the current Vector4.
  3130. * @param otherVector the vector to add
  3131. * @returns the updated Vector4.
  3132. */
  3133. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3134. /**
  3135. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3136. * @param otherVector the vector to add
  3137. * @returns the resulting vector
  3138. */
  3139. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3140. /**
  3141. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3142. * @param otherVector the vector to add
  3143. * @param result the vector to store the result
  3144. * @returns the current Vector4.
  3145. */
  3146. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3147. /**
  3148. * Subtract in place the given vector from the current Vector4.
  3149. * @param otherVector the vector to subtract
  3150. * @returns the updated Vector4.
  3151. */
  3152. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3153. /**
  3154. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3155. * @param otherVector the vector to add
  3156. * @returns the new vector with the result
  3157. */
  3158. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3159. /**
  3160. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3161. * @param otherVector the vector to subtract
  3162. * @param result the vector to store the result
  3163. * @returns the current Vector4.
  3164. */
  3165. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3166. /**
  3167. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3168. */
  3169. /**
  3170. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3171. * @param x value to subtract
  3172. * @param y value to subtract
  3173. * @param z value to subtract
  3174. * @param w value to subtract
  3175. * @returns new vector containing the result
  3176. */
  3177. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3178. /**
  3179. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3180. * @param x value to subtract
  3181. * @param y value to subtract
  3182. * @param z value to subtract
  3183. * @param w value to subtract
  3184. * @param result the vector to store the result in
  3185. * @returns the current Vector4.
  3186. */
  3187. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3188. /**
  3189. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3190. * @returns a new vector with the negated values
  3191. */
  3192. negate(): Vector4;
  3193. /**
  3194. * Negate this vector in place
  3195. * @returns this
  3196. */
  3197. negateInPlace(): Vector4;
  3198. /**
  3199. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3200. * @param result defines the Vector3 object where to store the result
  3201. * @returns the current Vector4
  3202. */
  3203. negateToRef(result: Vector4): Vector4;
  3204. /**
  3205. * Multiplies the current Vector4 coordinates by scale (float).
  3206. * @param scale the number to scale with
  3207. * @returns the updated Vector4.
  3208. */
  3209. scaleInPlace(scale: number): Vector4;
  3210. /**
  3211. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3212. * @param scale the number to scale with
  3213. * @returns a new vector with the result
  3214. */
  3215. scale(scale: number): Vector4;
  3216. /**
  3217. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3218. * @param scale the number to scale with
  3219. * @param result a vector to store the result in
  3220. * @returns the current Vector4.
  3221. */
  3222. scaleToRef(scale: number, result: Vector4): Vector4;
  3223. /**
  3224. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3225. * @param scale defines the scale factor
  3226. * @param result defines the Vector4 object where to store the result
  3227. * @returns the unmodified current Vector4
  3228. */
  3229. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3230. /**
  3231. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3232. * @param otherVector the vector to compare against
  3233. * @returns true if they are equal
  3234. */
  3235. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3236. /**
  3237. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3238. * @param otherVector vector to compare against
  3239. * @param epsilon (Default: very small number)
  3240. * @returns true if they are equal
  3241. */
  3242. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3243. /**
  3244. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3245. * @param x x value to compare against
  3246. * @param y y value to compare against
  3247. * @param z z value to compare against
  3248. * @param w w value to compare against
  3249. * @returns true if equal
  3250. */
  3251. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3252. /**
  3253. * Multiplies in place the current Vector4 by the given one.
  3254. * @param otherVector vector to multiple with
  3255. * @returns the updated Vector4.
  3256. */
  3257. multiplyInPlace(otherVector: Vector4): Vector4;
  3258. /**
  3259. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3260. * @param otherVector vector to multiple with
  3261. * @returns resulting new vector
  3262. */
  3263. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3266. * @param otherVector vector to multiple with
  3267. * @param result vector to store the result
  3268. * @returns the current Vector4.
  3269. */
  3270. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3271. /**
  3272. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3273. * @param x x value multiply with
  3274. * @param y y value multiply with
  3275. * @param z z value multiply with
  3276. * @param w w value multiply with
  3277. * @returns resulting new vector
  3278. */
  3279. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3280. /**
  3281. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3282. * @param otherVector vector to devide with
  3283. * @returns resulting new vector
  3284. */
  3285. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3286. /**
  3287. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3288. * @param otherVector vector to devide with
  3289. * @param result vector to store the result
  3290. * @returns the current Vector4.
  3291. */
  3292. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3293. /**
  3294. * Divides the current Vector3 coordinates by the given ones.
  3295. * @param otherVector vector to devide with
  3296. * @returns the updated Vector3.
  3297. */
  3298. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3299. /**
  3300. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3301. * @param other defines the second operand
  3302. * @returns the current updated Vector4
  3303. */
  3304. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3305. /**
  3306. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3307. * @param other defines the second operand
  3308. * @returns the current updated Vector4
  3309. */
  3310. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3311. /**
  3312. * Gets a new Vector4 from current Vector4 floored values
  3313. * @returns a new Vector4
  3314. */
  3315. floor(): Vector4;
  3316. /**
  3317. * Gets a new Vector4 from current Vector3 floored values
  3318. * @returns a new Vector4
  3319. */
  3320. fract(): Vector4;
  3321. /**
  3322. * Returns the Vector4 length (float).
  3323. * @returns the length
  3324. */
  3325. length(): number;
  3326. /**
  3327. * Returns the Vector4 squared length (float).
  3328. * @returns the length squared
  3329. */
  3330. lengthSquared(): number;
  3331. /**
  3332. * Normalizes in place the Vector4.
  3333. * @returns the updated Vector4.
  3334. */
  3335. normalize(): Vector4;
  3336. /**
  3337. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3338. * @returns this converted to a new vector3
  3339. */
  3340. toVector3(): Vector3;
  3341. /**
  3342. * Returns a new Vector4 copied from the current one.
  3343. * @returns the new cloned vector
  3344. */
  3345. clone(): Vector4;
  3346. /**
  3347. * Updates the current Vector4 with the given one coordinates.
  3348. * @param source the source vector to copy from
  3349. * @returns the updated Vector4.
  3350. */
  3351. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3352. /**
  3353. * Updates the current Vector4 coordinates with the given floats.
  3354. * @param x float to copy from
  3355. * @param y float to copy from
  3356. * @param z float to copy from
  3357. * @param w float to copy from
  3358. * @returns the updated Vector4.
  3359. */
  3360. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3361. /**
  3362. * Updates the current Vector4 coordinates with the given floats.
  3363. * @param x float to set from
  3364. * @param y float to set from
  3365. * @param z float to set from
  3366. * @param w float to set from
  3367. * @returns the updated Vector4.
  3368. */
  3369. set(x: number, y: number, z: number, w: number): Vector4;
  3370. /**
  3371. * Copies the given float to the current Vector3 coordinates
  3372. * @param v defines the x, y, z and w coordinates of the operand
  3373. * @returns the current updated Vector3
  3374. */
  3375. setAll(v: number): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set from the starting index of the given array.
  3378. * @param array the array to pull values from
  3379. * @param offset the offset into the array to start at
  3380. * @returns the new vector
  3381. */
  3382. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3383. /**
  3384. * Updates the given vector "result" from the starting index of the given array.
  3385. * @param array the array to pull values from
  3386. * @param offset the offset into the array to start at
  3387. * @param result the vector to store the result in
  3388. */
  3389. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3390. /**
  3391. * Updates the given vector "result" from the starting index of the given Float32Array.
  3392. * @param array the array to pull values from
  3393. * @param offset the offset into the array to start at
  3394. * @param result the vector to store the result in
  3395. */
  3396. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3397. /**
  3398. * Updates the given vector "result" coordinates from the given floats.
  3399. * @param x float to set from
  3400. * @param y float to set from
  3401. * @param z float to set from
  3402. * @param w float to set from
  3403. * @param result the vector to the floats in
  3404. */
  3405. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3406. /**
  3407. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3408. * @returns the new vector
  3409. */
  3410. static Zero(): Vector4;
  3411. /**
  3412. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3413. * @returns the new vector
  3414. */
  3415. static One(): Vector4;
  3416. /**
  3417. * Returns a new normalized Vector4 from the given one.
  3418. * @param vector the vector to normalize
  3419. * @returns the vector
  3420. */
  3421. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Updates the given vector "result" from the normalization of the given one.
  3424. * @param vector the vector to normalize
  3425. * @param result the vector to store the result in
  3426. */
  3427. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3428. /**
  3429. * Returns a vector with the minimum values from the left and right vectors
  3430. * @param left left vector to minimize
  3431. * @param right right vector to minimize
  3432. * @returns a new vector with the minimum of the left and right vector values
  3433. */
  3434. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3435. /**
  3436. * Returns a vector with the maximum values from the left and right vectors
  3437. * @param left left vector to maximize
  3438. * @param right right vector to maximize
  3439. * @returns a new vector with the maximum of the left and right vector values
  3440. */
  3441. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3442. /**
  3443. * Returns the distance (float) between the vectors "value1" and "value2".
  3444. * @param value1 value to calulate the distance between
  3445. * @param value2 value to calulate the distance between
  3446. * @return the distance between the two vectors
  3447. */
  3448. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3449. /**
  3450. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3451. * @param value1 value to calulate the distance between
  3452. * @param value2 value to calulate the distance between
  3453. * @return the distance between the two vectors squared
  3454. */
  3455. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3456. /**
  3457. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3458. * @param value1 value to calulate the center between
  3459. * @param value2 value to calulate the center between
  3460. * @return the center between the two vectors
  3461. */
  3462. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3463. /**
  3464. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3465. * This methods computes transformed normalized direction vectors only.
  3466. * @param vector the vector to transform
  3467. * @param transformation the transformation matrix to apply
  3468. * @returns the new vector
  3469. */
  3470. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3471. /**
  3472. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3473. * This methods computes transformed normalized direction vectors only.
  3474. * @param vector the vector to transform
  3475. * @param transformation the transformation matrix to apply
  3476. * @param result the vector to store the result in
  3477. */
  3478. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3479. /**
  3480. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3481. * This methods computes transformed normalized direction vectors only.
  3482. * @param x value to transform
  3483. * @param y value to transform
  3484. * @param z value to transform
  3485. * @param w value to transform
  3486. * @param transformation the transformation matrix to apply
  3487. * @param result the vector to store the results in
  3488. */
  3489. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3490. /**
  3491. * Creates a new Vector4 from a Vector3
  3492. * @param source defines the source data
  3493. * @param w defines the 4th component (default is 0)
  3494. * @returns a new Vector4
  3495. */
  3496. static FromVector3(source: Vector3, w?: number): Vector4;
  3497. }
  3498. /**
  3499. * Class used to store quaternion data
  3500. * @see https://en.wikipedia.org/wiki/Quaternion
  3501. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3502. */
  3503. export class Quaternion {
  3504. /** defines the first component (0 by default) */
  3505. x: number;
  3506. /** defines the second component (0 by default) */
  3507. y: number;
  3508. /** defines the third component (0 by default) */
  3509. z: number;
  3510. /** defines the fourth component (1.0 by default) */
  3511. w: number;
  3512. /**
  3513. * Creates a new Quaternion from the given floats
  3514. * @param x defines the first component (0 by default)
  3515. * @param y defines the second component (0 by default)
  3516. * @param z defines the third component (0 by default)
  3517. * @param w defines the fourth component (1.0 by default)
  3518. */
  3519. constructor(
  3520. /** defines the first component (0 by default) */
  3521. x?: number,
  3522. /** defines the second component (0 by default) */
  3523. y?: number,
  3524. /** defines the third component (0 by default) */
  3525. z?: number,
  3526. /** defines the fourth component (1.0 by default) */
  3527. w?: number);
  3528. /**
  3529. * Gets a string representation for the current quaternion
  3530. * @returns a string with the Quaternion coordinates
  3531. */
  3532. toString(): string;
  3533. /**
  3534. * Gets the class name of the quaternion
  3535. * @returns the string "Quaternion"
  3536. */
  3537. getClassName(): string;
  3538. /**
  3539. * Gets a hash code for this quaternion
  3540. * @returns the quaternion hash code
  3541. */
  3542. getHashCode(): number;
  3543. /**
  3544. * Copy the quaternion to an array
  3545. * @returns a new array populated with 4 elements from the quaternion coordinates
  3546. */
  3547. asArray(): number[];
  3548. /**
  3549. * Check if two quaternions are equals
  3550. * @param otherQuaternion defines the second operand
  3551. * @return true if the current quaternion and the given one coordinates are strictly equals
  3552. */
  3553. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3554. /**
  3555. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3556. * @param otherQuaternion defines the other quaternion
  3557. * @param epsilon defines the minimal distance to consider equality
  3558. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3559. */
  3560. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3561. /**
  3562. * Clone the current quaternion
  3563. * @returns a new quaternion copied from the current one
  3564. */
  3565. clone(): Quaternion;
  3566. /**
  3567. * Copy a quaternion to the current one
  3568. * @param other defines the other quaternion
  3569. * @returns the updated current quaternion
  3570. */
  3571. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3572. /**
  3573. * Updates the current quaternion with the given float coordinates
  3574. * @param x defines the x coordinate
  3575. * @param y defines the y coordinate
  3576. * @param z defines the z coordinate
  3577. * @param w defines the w coordinate
  3578. * @returns the updated current quaternion
  3579. */
  3580. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3581. /**
  3582. * Updates the current quaternion from the given float coordinates
  3583. * @param x defines the x coordinate
  3584. * @param y defines the y coordinate
  3585. * @param z defines the z coordinate
  3586. * @param w defines the w coordinate
  3587. * @returns the updated current quaternion
  3588. */
  3589. set(x: number, y: number, z: number, w: number): Quaternion;
  3590. /**
  3591. * Adds two quaternions
  3592. * @param other defines the second operand
  3593. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3594. */
  3595. add(other: DeepImmutable<Quaternion>): Quaternion;
  3596. /**
  3597. * Add a quaternion to the current one
  3598. * @param other defines the quaternion to add
  3599. * @returns the current quaternion
  3600. */
  3601. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3602. /**
  3603. * Subtract two quaternions
  3604. * @param other defines the second operand
  3605. * @returns a new quaternion as the subtraction result of the given one from the current one
  3606. */
  3607. subtract(other: Quaternion): Quaternion;
  3608. /**
  3609. * Multiplies the current quaternion by a scale factor
  3610. * @param value defines the scale factor
  3611. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3612. */
  3613. scale(value: number): Quaternion;
  3614. /**
  3615. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3616. * @param scale defines the scale factor
  3617. * @param result defines the Quaternion object where to store the result
  3618. * @returns the unmodified current quaternion
  3619. */
  3620. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3621. /**
  3622. * Multiplies in place the current quaternion by a scale factor
  3623. * @param value defines the scale factor
  3624. * @returns the current modified quaternion
  3625. */
  3626. scaleInPlace(value: number): Quaternion;
  3627. /**
  3628. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3629. * @param scale defines the scale factor
  3630. * @param result defines the Quaternion object where to store the result
  3631. * @returns the unmodified current quaternion
  3632. */
  3633. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3634. /**
  3635. * Multiplies two quaternions
  3636. * @param q1 defines the second operand
  3637. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3638. */
  3639. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3640. /**
  3641. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3642. * @param q1 defines the second operand
  3643. * @param result defines the target quaternion
  3644. * @returns the current quaternion
  3645. */
  3646. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3647. /**
  3648. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3649. * @param q1 defines the second operand
  3650. * @returns the currentupdated quaternion
  3651. */
  3652. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3653. /**
  3654. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3655. * @param ref defines the target quaternion
  3656. * @returns the current quaternion
  3657. */
  3658. conjugateToRef(ref: Quaternion): Quaternion;
  3659. /**
  3660. * Conjugates in place (1-q) the current quaternion
  3661. * @returns the current updated quaternion
  3662. */
  3663. conjugateInPlace(): Quaternion;
  3664. /**
  3665. * Conjugates in place (1-q) the current quaternion
  3666. * @returns a new quaternion
  3667. */
  3668. conjugate(): Quaternion;
  3669. /**
  3670. * Gets length of current quaternion
  3671. * @returns the quaternion length (float)
  3672. */
  3673. length(): number;
  3674. /**
  3675. * Normalize in place the current quaternion
  3676. * @returns the current updated quaternion
  3677. */
  3678. normalize(): Quaternion;
  3679. /**
  3680. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3681. * @param order is a reserved parameter and is ignore for now
  3682. * @returns a new Vector3 containing the Euler angles
  3683. */
  3684. toEulerAngles(order?: string): Vector3;
  3685. /**
  3686. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3687. * @param result defines the vector which will be filled with the Euler angles
  3688. * @param order is a reserved parameter and is ignore for now
  3689. * @returns the current unchanged quaternion
  3690. */
  3691. toEulerAnglesToRef(result: Vector3): Quaternion;
  3692. /**
  3693. * Updates the given rotation matrix with the current quaternion values
  3694. * @param result defines the target matrix
  3695. * @returns the current unchanged quaternion
  3696. */
  3697. toRotationMatrix(result: Matrix): Quaternion;
  3698. /**
  3699. * Updates the current quaternion from the given rotation matrix values
  3700. * @param matrix defines the source matrix
  3701. * @returns the current updated quaternion
  3702. */
  3703. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3704. /**
  3705. * Creates a new quaternion from a rotation matrix
  3706. * @param matrix defines the source matrix
  3707. * @returns a new quaternion created from the given rotation matrix values
  3708. */
  3709. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3710. /**
  3711. * Updates the given quaternion with the given rotation matrix values
  3712. * @param matrix defines the source matrix
  3713. * @param result defines the target quaternion
  3714. */
  3715. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3716. /**
  3717. * Returns the dot product (float) between the quaternions "left" and "right"
  3718. * @param left defines the left operand
  3719. * @param right defines the right operand
  3720. * @returns the dot product
  3721. */
  3722. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3723. /**
  3724. * Checks if the two quaternions are close to each other
  3725. * @param quat0 defines the first quaternion to check
  3726. * @param quat1 defines the second quaternion to check
  3727. * @returns true if the two quaternions are close to each other
  3728. */
  3729. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3730. /**
  3731. * Creates an empty quaternion
  3732. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3733. */
  3734. static Zero(): Quaternion;
  3735. /**
  3736. * Inverse a given quaternion
  3737. * @param q defines the source quaternion
  3738. * @returns a new quaternion as the inverted current quaternion
  3739. */
  3740. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3741. /**
  3742. * Inverse a given quaternion
  3743. * @param q defines the source quaternion
  3744. * @param result the quaternion the result will be stored in
  3745. * @returns the result quaternion
  3746. */
  3747. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3748. /**
  3749. * Creates an identity quaternion
  3750. * @returns the identity quaternion
  3751. */
  3752. static Identity(): Quaternion;
  3753. /**
  3754. * Gets a boolean indicating if the given quaternion is identity
  3755. * @param quaternion defines the quaternion to check
  3756. * @returns true if the quaternion is identity
  3757. */
  3758. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3759. /**
  3760. * Creates a quaternion from a rotation around an axis
  3761. * @param axis defines the axis to use
  3762. * @param angle defines the angle to use
  3763. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3764. */
  3765. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3766. /**
  3767. * Creates a rotation around an axis and stores it into the given quaternion
  3768. * @param axis defines the axis to use
  3769. * @param angle defines the angle to use
  3770. * @param result defines the target quaternion
  3771. * @returns the target quaternion
  3772. */
  3773. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3774. /**
  3775. * Creates a new quaternion from data stored into an array
  3776. * @param array defines the data source
  3777. * @param offset defines the offset in the source array where the data starts
  3778. * @returns a new quaternion
  3779. */
  3780. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3781. /**
  3782. * Updates the given quaternion "result" from the starting index of the given array.
  3783. * @param array the array to pull values from
  3784. * @param offset the offset into the array to start at
  3785. * @param result the quaternion to store the result in
  3786. */
  3787. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3788. /**
  3789. * Create a quaternion from Euler rotation angles
  3790. * @param x Pitch
  3791. * @param y Yaw
  3792. * @param z Roll
  3793. * @returns the new Quaternion
  3794. */
  3795. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3796. /**
  3797. * Updates a quaternion from Euler rotation angles
  3798. * @param x Pitch
  3799. * @param y Yaw
  3800. * @param z Roll
  3801. * @param result the quaternion to store the result
  3802. * @returns the updated quaternion
  3803. */
  3804. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3805. /**
  3806. * Create a quaternion from Euler rotation vector
  3807. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3808. * @returns the new Quaternion
  3809. */
  3810. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3811. /**
  3812. * Updates a quaternion from Euler rotation vector
  3813. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3814. * @param result the quaternion to store the result
  3815. * @returns the updated quaternion
  3816. */
  3817. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3818. /**
  3819. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3820. * @param yaw defines the rotation around Y axis
  3821. * @param pitch defines the rotation around X axis
  3822. * @param roll defines the rotation around Z axis
  3823. * @returns the new quaternion
  3824. */
  3825. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3826. /**
  3827. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3828. * @param yaw defines the rotation around Y axis
  3829. * @param pitch defines the rotation around X axis
  3830. * @param roll defines the rotation around Z axis
  3831. * @param result defines the target quaternion
  3832. */
  3833. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3834. /**
  3835. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3836. * @param alpha defines the rotation around first axis
  3837. * @param beta defines the rotation around second axis
  3838. * @param gamma defines the rotation around third axis
  3839. * @returns the new quaternion
  3840. */
  3841. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3842. /**
  3843. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3844. * @param alpha defines the rotation around first axis
  3845. * @param beta defines the rotation around second axis
  3846. * @param gamma defines the rotation around third axis
  3847. * @param result defines the target quaternion
  3848. */
  3849. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3850. /**
  3851. * 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)
  3852. * @param axis1 defines the first axis
  3853. * @param axis2 defines the second axis
  3854. * @param axis3 defines the third axis
  3855. * @returns the new quaternion
  3856. */
  3857. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3858. /**
  3859. * 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
  3860. * @param axis1 defines the first axis
  3861. * @param axis2 defines the second axis
  3862. * @param axis3 defines the third axis
  3863. * @param ref defines the target quaternion
  3864. */
  3865. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3866. /**
  3867. * Interpolates between two quaternions
  3868. * @param left defines first quaternion
  3869. * @param right defines second quaternion
  3870. * @param amount defines the gradient to use
  3871. * @returns the new interpolated quaternion
  3872. */
  3873. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3874. /**
  3875. * Interpolates between two quaternions and stores it into a target quaternion
  3876. * @param left defines first quaternion
  3877. * @param right defines second quaternion
  3878. * @param amount defines the gradient to use
  3879. * @param result defines the target quaternion
  3880. */
  3881. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3882. /**
  3883. * Interpolate between two quaternions using Hermite interpolation
  3884. * @param value1 defines first quaternion
  3885. * @param tangent1 defines the incoming tangent
  3886. * @param value2 defines second quaternion
  3887. * @param tangent2 defines the outgoing tangent
  3888. * @param amount defines the target quaternion
  3889. * @returns the new interpolated quaternion
  3890. */
  3891. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3892. }
  3893. /**
  3894. * Class used to store matrix data (4x4)
  3895. */
  3896. export class Matrix {
  3897. private static _updateFlagSeed;
  3898. private static _identityReadOnly;
  3899. private _isIdentity;
  3900. private _isIdentityDirty;
  3901. private _isIdentity3x2;
  3902. private _isIdentity3x2Dirty;
  3903. /**
  3904. * Gets the update flag of the matrix which is an unique number for the matrix.
  3905. * It will be incremented every time the matrix data change.
  3906. * You can use it to speed the comparison between two versions of the same matrix.
  3907. */
  3908. updateFlag: number;
  3909. private readonly _m;
  3910. /**
  3911. * Gets the internal data of the matrix
  3912. */
  3913. get m(): DeepImmutable<Float32Array>;
  3914. /** @hidden */
  3915. _markAsUpdated(): void;
  3916. /** @hidden */
  3917. private _updateIdentityStatus;
  3918. /**
  3919. * Creates an empty matrix (filled with zeros)
  3920. */
  3921. constructor();
  3922. /**
  3923. * Check if the current matrix is identity
  3924. * @returns true is the matrix is the identity matrix
  3925. */
  3926. isIdentity(): boolean;
  3927. /**
  3928. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3929. * @returns true is the matrix is the identity matrix
  3930. */
  3931. isIdentityAs3x2(): boolean;
  3932. /**
  3933. * Gets the determinant of the matrix
  3934. * @returns the matrix determinant
  3935. */
  3936. determinant(): number;
  3937. /**
  3938. * Returns the matrix as a Float32Array
  3939. * @returns the matrix underlying array
  3940. */
  3941. toArray(): DeepImmutable<Float32Array>;
  3942. /**
  3943. * Returns the matrix as a Float32Array
  3944. * @returns the matrix underlying array.
  3945. */
  3946. asArray(): DeepImmutable<Float32Array>;
  3947. /**
  3948. * Inverts the current matrix in place
  3949. * @returns the current inverted matrix
  3950. */
  3951. invert(): Matrix;
  3952. /**
  3953. * Sets all the matrix elements to zero
  3954. * @returns the current matrix
  3955. */
  3956. reset(): Matrix;
  3957. /**
  3958. * Adds the current matrix with a second one
  3959. * @param other defines the matrix to add
  3960. * @returns a new matrix as the addition of the current matrix and the given one
  3961. */
  3962. add(other: DeepImmutable<Matrix>): Matrix;
  3963. /**
  3964. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3965. * @param other defines the matrix to add
  3966. * @param result defines the target matrix
  3967. * @returns the current matrix
  3968. */
  3969. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3970. /**
  3971. * Adds in place the given matrix to the current matrix
  3972. * @param other defines the second operand
  3973. * @returns the current updated matrix
  3974. */
  3975. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3976. /**
  3977. * Sets the given matrix to the current inverted Matrix
  3978. * @param other defines the target matrix
  3979. * @returns the unmodified current matrix
  3980. */
  3981. invertToRef(other: Matrix): Matrix;
  3982. /**
  3983. * add a value at the specified position in the current Matrix
  3984. * @param index the index of the value within the matrix. between 0 and 15.
  3985. * @param value the value to be added
  3986. * @returns the current updated matrix
  3987. */
  3988. addAtIndex(index: number, value: number): Matrix;
  3989. /**
  3990. * mutiply the specified position in the current Matrix by a value
  3991. * @param index the index of the value within the matrix. between 0 and 15.
  3992. * @param value the value to be added
  3993. * @returns the current updated matrix
  3994. */
  3995. multiplyAtIndex(index: number, value: number): Matrix;
  3996. /**
  3997. * Inserts the translation vector (using 3 floats) in the current matrix
  3998. * @param x defines the 1st component of the translation
  3999. * @param y defines the 2nd component of the translation
  4000. * @param z defines the 3rd component of the translation
  4001. * @returns the current updated matrix
  4002. */
  4003. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4004. /**
  4005. * Adds the translation vector (using 3 floats) in the current matrix
  4006. * @param x defines the 1st component of the translation
  4007. * @param y defines the 2nd component of the translation
  4008. * @param z defines the 3rd component of the translation
  4009. * @returns the current updated matrix
  4010. */
  4011. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4012. /**
  4013. * Inserts the translation vector in the current matrix
  4014. * @param vector3 defines the translation to insert
  4015. * @returns the current updated matrix
  4016. */
  4017. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4018. /**
  4019. * Gets the translation value of the current matrix
  4020. * @returns a new Vector3 as the extracted translation from the matrix
  4021. */
  4022. getTranslation(): Vector3;
  4023. /**
  4024. * Fill a Vector3 with the extracted translation from the matrix
  4025. * @param result defines the Vector3 where to store the translation
  4026. * @returns the current matrix
  4027. */
  4028. getTranslationToRef(result: Vector3): Matrix;
  4029. /**
  4030. * Remove rotation and scaling part from the matrix
  4031. * @returns the updated matrix
  4032. */
  4033. removeRotationAndScaling(): Matrix;
  4034. /**
  4035. * Multiply two matrices
  4036. * @param other defines the second operand
  4037. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4038. */
  4039. multiply(other: DeepImmutable<Matrix>): Matrix;
  4040. /**
  4041. * Copy the current matrix from the given one
  4042. * @param other defines the source matrix
  4043. * @returns the current updated matrix
  4044. */
  4045. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4046. /**
  4047. * Populates the given array from the starting index with the current matrix values
  4048. * @param array defines the target array
  4049. * @param offset defines the offset in the target array where to start storing values
  4050. * @returns the current matrix
  4051. */
  4052. copyToArray(array: Float32Array, offset?: number): Matrix;
  4053. /**
  4054. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4055. * @param other defines the second operand
  4056. * @param result defines the matrix where to store the multiplication
  4057. * @returns the current matrix
  4058. */
  4059. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4060. /**
  4061. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4062. * @param other defines the second operand
  4063. * @param result defines the array where to store the multiplication
  4064. * @param offset defines the offset in the target array where to start storing values
  4065. * @returns the current matrix
  4066. */
  4067. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4068. /**
  4069. * Check equality between this matrix and a second one
  4070. * @param value defines the second matrix to compare
  4071. * @returns true is the current matrix and the given one values are strictly equal
  4072. */
  4073. equals(value: DeepImmutable<Matrix>): boolean;
  4074. /**
  4075. * Clone the current matrix
  4076. * @returns a new matrix from the current matrix
  4077. */
  4078. clone(): Matrix;
  4079. /**
  4080. * Returns the name of the current matrix class
  4081. * @returns the string "Matrix"
  4082. */
  4083. getClassName(): string;
  4084. /**
  4085. * Gets the hash code of the current matrix
  4086. * @returns the hash code
  4087. */
  4088. getHashCode(): number;
  4089. /**
  4090. * Decomposes the current Matrix into a translation, rotation and scaling components
  4091. * @param scale defines the scale vector3 given as a reference to update
  4092. * @param rotation defines the rotation quaternion given as a reference to update
  4093. * @param translation defines the translation vector3 given as a reference to update
  4094. * @returns true if operation was successful
  4095. */
  4096. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4097. /**
  4098. * Gets specific row of the matrix
  4099. * @param index defines the number of the row to get
  4100. * @returns the index-th row of the current matrix as a new Vector4
  4101. */
  4102. getRow(index: number): Nullable<Vector4>;
  4103. /**
  4104. * Sets the index-th row of the current matrix to the vector4 values
  4105. * @param index defines the number of the row to set
  4106. * @param row defines the target vector4
  4107. * @returns the updated current matrix
  4108. */
  4109. setRow(index: number, row: Vector4): Matrix;
  4110. /**
  4111. * Compute the transpose of the matrix
  4112. * @returns the new transposed matrix
  4113. */
  4114. transpose(): Matrix;
  4115. /**
  4116. * Compute the transpose of the matrix and store it in a given matrix
  4117. * @param result defines the target matrix
  4118. * @returns the current matrix
  4119. */
  4120. transposeToRef(result: Matrix): Matrix;
  4121. /**
  4122. * Sets the index-th row of the current matrix with the given 4 x float values
  4123. * @param index defines the row index
  4124. * @param x defines the x component to set
  4125. * @param y defines the y component to set
  4126. * @param z defines the z component to set
  4127. * @param w defines the w component to set
  4128. * @returns the updated current matrix
  4129. */
  4130. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4131. /**
  4132. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4133. * @param scale defines the scale factor
  4134. * @returns a new matrix
  4135. */
  4136. scale(scale: number): Matrix;
  4137. /**
  4138. * Scale the current matrix values by a factor to a given result matrix
  4139. * @param scale defines the scale factor
  4140. * @param result defines the matrix to store the result
  4141. * @returns the current matrix
  4142. */
  4143. scaleToRef(scale: number, result: Matrix): Matrix;
  4144. /**
  4145. * Scale the current matrix values by a factor and add the result to a given matrix
  4146. * @param scale defines the scale factor
  4147. * @param result defines the Matrix to store the result
  4148. * @returns the current matrix
  4149. */
  4150. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4151. /**
  4152. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4153. * @param ref matrix to store the result
  4154. */
  4155. toNormalMatrix(ref: Matrix): void;
  4156. /**
  4157. * Gets only rotation part of the current matrix
  4158. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4159. */
  4160. getRotationMatrix(): Matrix;
  4161. /**
  4162. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4163. * @param result defines the target matrix to store data to
  4164. * @returns the current matrix
  4165. */
  4166. getRotationMatrixToRef(result: Matrix): Matrix;
  4167. /**
  4168. * Toggles model matrix from being right handed to left handed in place and vice versa
  4169. */
  4170. toggleModelMatrixHandInPlace(): void;
  4171. /**
  4172. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4173. */
  4174. toggleProjectionMatrixHandInPlace(): void;
  4175. /**
  4176. * Creates a matrix from an array
  4177. * @param array defines the source array
  4178. * @param offset defines an offset in the source array
  4179. * @returns a new Matrix set from the starting index of the given array
  4180. */
  4181. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4182. /**
  4183. * Copy the content of an array into a given matrix
  4184. * @param array defines the source array
  4185. * @param offset defines an offset in the source array
  4186. * @param result defines the target matrix
  4187. */
  4188. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4189. /**
  4190. * Stores an array into a matrix after having multiplied each component by a given factor
  4191. * @param array defines the source array
  4192. * @param offset defines the offset in the source array
  4193. * @param scale defines the scaling factor
  4194. * @param result defines the target matrix
  4195. */
  4196. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4197. /**
  4198. * Gets an identity matrix that must not be updated
  4199. */
  4200. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4201. /**
  4202. * Stores a list of values (16) inside a given matrix
  4203. * @param initialM11 defines 1st value of 1st row
  4204. * @param initialM12 defines 2nd value of 1st row
  4205. * @param initialM13 defines 3rd value of 1st row
  4206. * @param initialM14 defines 4th value of 1st row
  4207. * @param initialM21 defines 1st value of 2nd row
  4208. * @param initialM22 defines 2nd value of 2nd row
  4209. * @param initialM23 defines 3rd value of 2nd row
  4210. * @param initialM24 defines 4th value of 2nd row
  4211. * @param initialM31 defines 1st value of 3rd row
  4212. * @param initialM32 defines 2nd value of 3rd row
  4213. * @param initialM33 defines 3rd value of 3rd row
  4214. * @param initialM34 defines 4th value of 3rd row
  4215. * @param initialM41 defines 1st value of 4th row
  4216. * @param initialM42 defines 2nd value of 4th row
  4217. * @param initialM43 defines 3rd value of 4th row
  4218. * @param initialM44 defines 4th value of 4th row
  4219. * @param result defines the target matrix
  4220. */
  4221. 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;
  4222. /**
  4223. * Creates new matrix from a list of values (16)
  4224. * @param initialM11 defines 1st value of 1st row
  4225. * @param initialM12 defines 2nd value of 1st row
  4226. * @param initialM13 defines 3rd value of 1st row
  4227. * @param initialM14 defines 4th value of 1st row
  4228. * @param initialM21 defines 1st value of 2nd row
  4229. * @param initialM22 defines 2nd value of 2nd row
  4230. * @param initialM23 defines 3rd value of 2nd row
  4231. * @param initialM24 defines 4th value of 2nd row
  4232. * @param initialM31 defines 1st value of 3rd row
  4233. * @param initialM32 defines 2nd value of 3rd row
  4234. * @param initialM33 defines 3rd value of 3rd row
  4235. * @param initialM34 defines 4th value of 3rd row
  4236. * @param initialM41 defines 1st value of 4th row
  4237. * @param initialM42 defines 2nd value of 4th row
  4238. * @param initialM43 defines 3rd value of 4th row
  4239. * @param initialM44 defines 4th value of 4th row
  4240. * @returns the new matrix
  4241. */
  4242. 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;
  4243. /**
  4244. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4245. * @param scale defines the scale vector3
  4246. * @param rotation defines the rotation quaternion
  4247. * @param translation defines the translation vector3
  4248. * @returns a new matrix
  4249. */
  4250. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4251. /**
  4252. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4253. * @param scale defines the scale vector3
  4254. * @param rotation defines the rotation quaternion
  4255. * @param translation defines the translation vector3
  4256. * @param result defines the target matrix
  4257. */
  4258. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4259. /**
  4260. * Creates a new identity matrix
  4261. * @returns a new identity matrix
  4262. */
  4263. static Identity(): Matrix;
  4264. /**
  4265. * Creates a new identity matrix and stores the result in a given matrix
  4266. * @param result defines the target matrix
  4267. */
  4268. static IdentityToRef(result: Matrix): void;
  4269. /**
  4270. * Creates a new zero matrix
  4271. * @returns a new zero matrix
  4272. */
  4273. static Zero(): Matrix;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the X axis
  4276. * @param angle defines the angle (in radians) to use
  4277. * @return the new matrix
  4278. */
  4279. static RotationX(angle: number): Matrix;
  4280. /**
  4281. * Creates a new matrix as the invert of a given matrix
  4282. * @param source defines the source matrix
  4283. * @returns the new matrix
  4284. */
  4285. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4286. /**
  4287. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4288. * @param angle defines the angle (in radians) to use
  4289. * @param result defines the target matrix
  4290. */
  4291. static RotationXToRef(angle: number, result: Matrix): void;
  4292. /**
  4293. * Creates a new rotation matrix for "angle" radians around the Y axis
  4294. * @param angle defines the angle (in radians) to use
  4295. * @return the new matrix
  4296. */
  4297. static RotationY(angle: number): Matrix;
  4298. /**
  4299. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4300. * @param angle defines the angle (in radians) to use
  4301. * @param result defines the target matrix
  4302. */
  4303. static RotationYToRef(angle: number, result: Matrix): void;
  4304. /**
  4305. * Creates a new rotation matrix for "angle" radians around the Z axis
  4306. * @param angle defines the angle (in radians) to use
  4307. * @return the new matrix
  4308. */
  4309. static RotationZ(angle: number): Matrix;
  4310. /**
  4311. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4312. * @param angle defines the angle (in radians) to use
  4313. * @param result defines the target matrix
  4314. */
  4315. static RotationZToRef(angle: number, result: Matrix): void;
  4316. /**
  4317. * Creates a new rotation matrix for "angle" radians around the given axis
  4318. * @param axis defines the axis to use
  4319. * @param angle defines the angle (in radians) to use
  4320. * @return the new matrix
  4321. */
  4322. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4323. /**
  4324. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4325. * @param axis defines the axis to use
  4326. * @param angle defines the angle (in radians) to use
  4327. * @param result defines the target matrix
  4328. */
  4329. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4330. /**
  4331. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4332. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4333. * @param from defines the vector to align
  4334. * @param to defines the vector to align to
  4335. * @param result defines the target matrix
  4336. */
  4337. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4338. /**
  4339. * Creates a rotation matrix
  4340. * @param yaw defines the yaw angle in radians (Y axis)
  4341. * @param pitch defines the pitch angle in radians (X axis)
  4342. * @param roll defines the roll angle in radians (X axis)
  4343. * @returns the new rotation matrix
  4344. */
  4345. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4346. /**
  4347. * Creates a rotation matrix and stores it in a given matrix
  4348. * @param yaw defines the yaw angle in radians (Y axis)
  4349. * @param pitch defines the pitch angle in radians (X axis)
  4350. * @param roll defines the roll angle in radians (X axis)
  4351. * @param result defines the target matrix
  4352. */
  4353. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4354. /**
  4355. * Creates a scaling matrix
  4356. * @param x defines the scale factor on X axis
  4357. * @param y defines the scale factor on Y axis
  4358. * @param z defines the scale factor on Z axis
  4359. * @returns the new matrix
  4360. */
  4361. static Scaling(x: number, y: number, z: number): Matrix;
  4362. /**
  4363. * Creates a scaling matrix and stores it in a given matrix
  4364. * @param x defines the scale factor on X axis
  4365. * @param y defines the scale factor on Y axis
  4366. * @param z defines the scale factor on Z axis
  4367. * @param result defines the target matrix
  4368. */
  4369. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4370. /**
  4371. * Creates a translation matrix
  4372. * @param x defines the translation on X axis
  4373. * @param y defines the translation on Y axis
  4374. * @param z defines the translationon Z axis
  4375. * @returns the new matrix
  4376. */
  4377. static Translation(x: number, y: number, z: number): Matrix;
  4378. /**
  4379. * Creates a translation matrix and stores it in a given matrix
  4380. * @param x defines the translation on X axis
  4381. * @param y defines the translation on Y axis
  4382. * @param z defines the translationon Z axis
  4383. * @param result defines the target matrix
  4384. */
  4385. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4386. /**
  4387. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4388. * @param startValue defines the start value
  4389. * @param endValue defines the end value
  4390. * @param gradient defines the gradient factor
  4391. * @returns the new matrix
  4392. */
  4393. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4394. /**
  4395. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4396. * @param startValue defines the start value
  4397. * @param endValue defines the end value
  4398. * @param gradient defines the gradient factor
  4399. * @param result defines the Matrix object where to store data
  4400. */
  4401. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4402. /**
  4403. * Builds a new matrix whose values are computed by:
  4404. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4405. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4406. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4407. * @param startValue defines the first matrix
  4408. * @param endValue defines the second matrix
  4409. * @param gradient defines the gradient between the two matrices
  4410. * @returns the new matrix
  4411. */
  4412. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4413. /**
  4414. * Update a matrix to values which are computed by:
  4415. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4416. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4417. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4418. * @param startValue defines the first matrix
  4419. * @param endValue defines the second matrix
  4420. * @param gradient defines the gradient between the two matrices
  4421. * @param result defines the target matrix
  4422. */
  4423. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4424. /**
  4425. * 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"
  4426. * This function works in left handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @returns the new matrix
  4431. */
  4432. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4433. /**
  4434. * 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".
  4435. * This function works in left handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @param result defines the target matrix
  4440. */
  4441. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4442. /**
  4443. * 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"
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @returns the new matrix
  4449. */
  4450. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4451. /**
  4452. * 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".
  4453. * This function works in right handed mode
  4454. * @param eye defines the final position of the entity
  4455. * @param target defines where the entity should look at
  4456. * @param up defines the up vector for the entity
  4457. * @param result defines the target matrix
  4458. */
  4459. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4460. /**
  4461. * Create a left-handed orthographic projection matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a left-handed orthographic projection matrix
  4467. */
  4468. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Store a left-handed orthographic projection to a given matrix
  4471. * @param width defines the viewport width
  4472. * @param height defines the viewport height
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @param result defines the target matrix
  4476. */
  4477. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4478. /**
  4479. * Create a left-handed orthographic projection matrix
  4480. * @param left defines the viewport left coordinate
  4481. * @param right defines the viewport right coordinate
  4482. * @param bottom defines the viewport bottom coordinate
  4483. * @param top defines the viewport top coordinate
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed orthographic projection matrix
  4487. */
  4488. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Stores a left-handed orthographic projection into a given matrix
  4491. * @param left defines the viewport left coordinate
  4492. * @param right defines the viewport right coordinate
  4493. * @param bottom defines the viewport bottom coordinate
  4494. * @param top defines the viewport top coordinate
  4495. * @param znear defines the near clip plane
  4496. * @param zfar defines the far clip plane
  4497. * @param result defines the target matrix
  4498. */
  4499. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4500. /**
  4501. * Creates a right-handed orthographic projection matrix
  4502. * @param left defines the viewport left coordinate
  4503. * @param right defines the viewport right coordinate
  4504. * @param bottom defines the viewport bottom coordinate
  4505. * @param top defines the viewport top coordinate
  4506. * @param znear defines the near clip plane
  4507. * @param zfar defines the far clip plane
  4508. * @returns a new matrix as a right-handed orthographic projection matrix
  4509. */
  4510. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4511. /**
  4512. * Stores a right-handed orthographic projection into a given matrix
  4513. * @param left defines the viewport left coordinate
  4514. * @param right defines the viewport right coordinate
  4515. * @param bottom defines the viewport bottom coordinate
  4516. * @param top defines the viewport top coordinate
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. */
  4521. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param width defines the viewport width
  4525. * @param height defines the viewport height
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Creates a left-handed perspective projection matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @returns a new matrix as a left-handed perspective projection matrix
  4538. */
  4539. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4540. /**
  4541. * Stores a left-handed perspective projection into a given matrix
  4542. * @param fov defines the horizontal field of view
  4543. * @param aspect defines the aspect ratio
  4544. * @param znear defines the near clip plane
  4545. * @param zfar defines the far clip plane
  4546. * @param result defines the target matrix
  4547. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4548. */
  4549. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4550. /**
  4551. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4552. * @param fov defines the horizontal field of view
  4553. * @param aspect defines the aspect ratio
  4554. * @param znear defines the near clip plane
  4555. * @param zfar not used as infinity is used as far clip
  4556. * @param result defines the target matrix
  4557. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4558. */
  4559. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4560. /**
  4561. * Creates a right-handed perspective projection matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @returns a new matrix as a right-handed perspective projection matrix
  4567. */
  4568. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4569. /**
  4570. * Stores a right-handed perspective projection into a given matrix
  4571. * @param fov defines the horizontal field of view
  4572. * @param aspect defines the aspect ratio
  4573. * @param znear defines the near clip plane
  4574. * @param zfar defines the far clip plane
  4575. * @param result defines the target matrix
  4576. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4577. */
  4578. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4579. /**
  4580. * Stores a right-handed perspective projection into a given matrix
  4581. * @param fov defines the horizontal field of view
  4582. * @param aspect defines the aspect ratio
  4583. * @param znear defines the near clip plane
  4584. * @param zfar not used as infinity is used as far clip
  4585. * @param result defines the target matrix
  4586. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4587. */
  4588. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4589. /**
  4590. * Stores a perspective projection for WebVR info a given matrix
  4591. * @param fov defines the field of view
  4592. * @param znear defines the near clip plane
  4593. * @param zfar defines the far clip plane
  4594. * @param result defines the target matrix
  4595. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4596. */
  4597. static PerspectiveFovWebVRToRef(fov: {
  4598. upDegrees: number;
  4599. downDegrees: number;
  4600. leftDegrees: number;
  4601. rightDegrees: number;
  4602. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4603. /**
  4604. * Computes a complete transformation matrix
  4605. * @param viewport defines the viewport to use
  4606. * @param world defines the world matrix
  4607. * @param view defines the view matrix
  4608. * @param projection defines the projection matrix
  4609. * @param zmin defines the near clip plane
  4610. * @param zmax defines the far clip plane
  4611. * @returns the transformation matrix
  4612. */
  4613. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4614. /**
  4615. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4616. * @param matrix defines the matrix to use
  4617. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4618. */
  4619. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4620. /**
  4621. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4622. * @param matrix defines the matrix to use
  4623. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4624. */
  4625. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4626. /**
  4627. * Compute the transpose of a given matrix
  4628. * @param matrix defines the matrix to transpose
  4629. * @returns the new matrix
  4630. */
  4631. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4632. /**
  4633. * Compute the transpose of a matrix and store it in a target matrix
  4634. * @param matrix defines the matrix to transpose
  4635. * @param result defines the target matrix
  4636. */
  4637. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4638. /**
  4639. * Computes a reflection matrix from a plane
  4640. * @param plane defines the reflection plane
  4641. * @returns a new matrix
  4642. */
  4643. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4644. /**
  4645. * Computes a reflection matrix from a plane
  4646. * @param plane defines the reflection plane
  4647. * @param result defines the target matrix
  4648. */
  4649. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4650. /**
  4651. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4652. * @param xaxis defines the value of the 1st axis
  4653. * @param yaxis defines the value of the 2nd axis
  4654. * @param zaxis defines the value of the 3rd axis
  4655. * @param result defines the target matrix
  4656. */
  4657. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4658. /**
  4659. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4660. * @param quat defines the quaternion to use
  4661. * @param result defines the target matrix
  4662. */
  4663. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4664. }
  4665. /**
  4666. * @hidden
  4667. */
  4668. export class TmpVectors {
  4669. static Vector2: Vector2[];
  4670. static Vector3: Vector3[];
  4671. static Vector4: Vector4[];
  4672. static Quaternion: Quaternion[];
  4673. static Matrix: Matrix[];
  4674. }
  4675. }
  4676. declare module "babylonjs/Maths/math.path" {
  4677. import { DeepImmutable, Nullable } from "babylonjs/types";
  4678. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4679. /**
  4680. * Defines potential orientation for back face culling
  4681. */
  4682. export enum Orientation {
  4683. /**
  4684. * Clockwise
  4685. */
  4686. CW = 0,
  4687. /** Counter clockwise */
  4688. CCW = 1
  4689. }
  4690. /** Class used to represent a Bezier curve */
  4691. export class BezierCurve {
  4692. /**
  4693. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4694. * @param t defines the time
  4695. * @param x1 defines the left coordinate on X axis
  4696. * @param y1 defines the left coordinate on Y axis
  4697. * @param x2 defines the right coordinate on X axis
  4698. * @param y2 defines the right coordinate on Y axis
  4699. * @returns the interpolated value
  4700. */
  4701. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4702. }
  4703. /**
  4704. * Defines angle representation
  4705. */
  4706. export class Angle {
  4707. private _radians;
  4708. /**
  4709. * Creates an Angle object of "radians" radians (float).
  4710. * @param radians the angle in radians
  4711. */
  4712. constructor(radians: number);
  4713. /**
  4714. * Get value in degrees
  4715. * @returns the Angle value in degrees (float)
  4716. */
  4717. degrees(): number;
  4718. /**
  4719. * Get value in radians
  4720. * @returns the Angle value in radians (float)
  4721. */
  4722. radians(): number;
  4723. /**
  4724. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4725. * @param a defines first vector
  4726. * @param b defines second vector
  4727. * @returns a new Angle
  4728. */
  4729. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4730. /**
  4731. * Gets a new Angle object from the given float in radians
  4732. * @param radians defines the angle value in radians
  4733. * @returns a new Angle
  4734. */
  4735. static FromRadians(radians: number): Angle;
  4736. /**
  4737. * Gets a new Angle object from the given float in degrees
  4738. * @param degrees defines the angle value in degrees
  4739. * @returns a new Angle
  4740. */
  4741. static FromDegrees(degrees: number): Angle;
  4742. }
  4743. /**
  4744. * This represents an arc in a 2d space.
  4745. */
  4746. export class Arc2 {
  4747. /** Defines the start point of the arc */
  4748. startPoint: Vector2;
  4749. /** Defines the mid point of the arc */
  4750. midPoint: Vector2;
  4751. /** Defines the end point of the arc */
  4752. endPoint: Vector2;
  4753. /**
  4754. * Defines the center point of the arc.
  4755. */
  4756. centerPoint: Vector2;
  4757. /**
  4758. * Defines the radius of the arc.
  4759. */
  4760. radius: number;
  4761. /**
  4762. * Defines the angle of the arc (from mid point to end point).
  4763. */
  4764. angle: Angle;
  4765. /**
  4766. * Defines the start angle of the arc (from start point to middle point).
  4767. */
  4768. startAngle: Angle;
  4769. /**
  4770. * Defines the orientation of the arc (clock wise/counter clock wise).
  4771. */
  4772. orientation: Orientation;
  4773. /**
  4774. * Creates an Arc object from the three given points : start, middle and end.
  4775. * @param startPoint Defines the start point of the arc
  4776. * @param midPoint Defines the midlle point of the arc
  4777. * @param endPoint Defines the end point of the arc
  4778. */
  4779. constructor(
  4780. /** Defines the start point of the arc */
  4781. startPoint: Vector2,
  4782. /** Defines the mid point of the arc */
  4783. midPoint: Vector2,
  4784. /** Defines the end point of the arc */
  4785. endPoint: Vector2);
  4786. }
  4787. /**
  4788. * Represents a 2D path made up of multiple 2D points
  4789. */
  4790. export class Path2 {
  4791. private _points;
  4792. private _length;
  4793. /**
  4794. * If the path start and end point are the same
  4795. */
  4796. closed: boolean;
  4797. /**
  4798. * Creates a Path2 object from the starting 2D coordinates x and y.
  4799. * @param x the starting points x value
  4800. * @param y the starting points y value
  4801. */
  4802. constructor(x: number, y: number);
  4803. /**
  4804. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4805. * @param x the added points x value
  4806. * @param y the added points y value
  4807. * @returns the updated Path2.
  4808. */
  4809. addLineTo(x: number, y: number): Path2;
  4810. /**
  4811. * 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.
  4812. * @param midX middle point x value
  4813. * @param midY middle point y value
  4814. * @param endX end point x value
  4815. * @param endY end point y value
  4816. * @param numberOfSegments (default: 36)
  4817. * @returns the updated Path2.
  4818. */
  4819. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4820. /**
  4821. * Closes the Path2.
  4822. * @returns the Path2.
  4823. */
  4824. close(): Path2;
  4825. /**
  4826. * Gets the sum of the distance between each sequential point in the path
  4827. * @returns the Path2 total length (float).
  4828. */
  4829. length(): number;
  4830. /**
  4831. * Gets the points which construct the path
  4832. * @returns the Path2 internal array of points.
  4833. */
  4834. getPoints(): Vector2[];
  4835. /**
  4836. * Retreives the point at the distance aways from the starting point
  4837. * @param normalizedLengthPosition the length along the path to retreive the point from
  4838. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4839. */
  4840. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4841. /**
  4842. * Creates a new path starting from an x and y position
  4843. * @param x starting x value
  4844. * @param y starting y value
  4845. * @returns a new Path2 starting at the coordinates (x, y).
  4846. */
  4847. static StartingAt(x: number, y: number): Path2;
  4848. }
  4849. /**
  4850. * Represents a 3D path made up of multiple 3D points
  4851. */
  4852. export class Path3D {
  4853. /**
  4854. * an array of Vector3, the curve axis of the Path3D
  4855. */
  4856. path: Vector3[];
  4857. private _curve;
  4858. private _distances;
  4859. private _tangents;
  4860. private _normals;
  4861. private _binormals;
  4862. private _raw;
  4863. private _alignTangentsWithPath;
  4864. private readonly _pointAtData;
  4865. /**
  4866. * new Path3D(path, normal, raw)
  4867. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4868. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4869. * @param path an array of Vector3, the curve axis of the Path3D
  4870. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4871. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4872. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4873. */
  4874. constructor(
  4875. /**
  4876. * an array of Vector3, the curve axis of the Path3D
  4877. */
  4878. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4879. /**
  4880. * Returns the Path3D array of successive Vector3 designing its curve.
  4881. * @returns the Path3D array of successive Vector3 designing its curve.
  4882. */
  4883. getCurve(): Vector3[];
  4884. /**
  4885. * Returns the Path3D array of successive Vector3 designing its curve.
  4886. * @returns the Path3D array of successive Vector3 designing its curve.
  4887. */
  4888. getPoints(): Vector3[];
  4889. /**
  4890. * @returns the computed length (float) of the path.
  4891. */
  4892. length(): number;
  4893. /**
  4894. * Returns an array populated with tangent vectors on each Path3D curve point.
  4895. * @returns an array populated with tangent vectors on each Path3D curve point.
  4896. */
  4897. getTangents(): Vector3[];
  4898. /**
  4899. * Returns an array populated with normal vectors on each Path3D curve point.
  4900. * @returns an array populated with normal vectors on each Path3D curve point.
  4901. */
  4902. getNormals(): Vector3[];
  4903. /**
  4904. * Returns an array populated with binormal vectors on each Path3D curve point.
  4905. * @returns an array populated with binormal vectors on each Path3D curve point.
  4906. */
  4907. getBinormals(): Vector3[];
  4908. /**
  4909. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4910. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4911. */
  4912. getDistances(): number[];
  4913. /**
  4914. * Returns an interpolated point along this path
  4915. * @param position the position of the point along this path, from 0.0 to 1.0
  4916. * @returns a new Vector3 as the point
  4917. */
  4918. getPointAt(position: number): Vector3;
  4919. /**
  4920. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4921. * @param position the position of the point along this path, from 0.0 to 1.0
  4922. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4923. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4924. */
  4925. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4926. /**
  4927. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4928. * @param position the position of the point along this path, from 0.0 to 1.0
  4929. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4930. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4931. */
  4932. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4933. /**
  4934. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4935. * @param position the position of the point along this path, from 0.0 to 1.0
  4936. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4937. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4938. */
  4939. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4940. /**
  4941. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4942. * @param position the position of the point along this path, from 0.0 to 1.0
  4943. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4944. */
  4945. getDistanceAt(position: number): number;
  4946. /**
  4947. * Returns the array index of the previous point of an interpolated point along this path
  4948. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4949. * @returns the array index
  4950. */
  4951. getPreviousPointIndexAt(position: number): number;
  4952. /**
  4953. * 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)
  4954. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4955. * @returns the sub position
  4956. */
  4957. getSubPositionAt(position: number): number;
  4958. /**
  4959. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4960. * @param target the vector of which to get the closest position to
  4961. * @returns the position of the closest virtual point on this path to the target vector
  4962. */
  4963. getClosestPositionTo(target: Vector3): number;
  4964. /**
  4965. * Returns a sub path (slice) of this path
  4966. * @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
  4967. * @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
  4968. * @returns a sub path (slice) of this path
  4969. */
  4970. slice(start?: number, end?: number): Path3D;
  4971. /**
  4972. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4973. * @param path path which all values are copied into the curves points
  4974. * @param firstNormal which should be projected onto the curve
  4975. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4976. * @returns the same object updated.
  4977. */
  4978. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4979. private _compute;
  4980. private _getFirstNonNullVector;
  4981. private _getLastNonNullVector;
  4982. private _normalVector;
  4983. /**
  4984. * Updates the point at data for an interpolated point along this curve
  4985. * @param position the position of the point along this curve, from 0.0 to 1.0
  4986. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4987. * @returns the (updated) point at data
  4988. */
  4989. private _updatePointAtData;
  4990. /**
  4991. * Updates the point at data from the specified parameters
  4992. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4993. * @param point the interpolated point
  4994. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4995. */
  4996. private _setPointAtData;
  4997. /**
  4998. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4999. */
  5000. private _updateInterpolationMatrix;
  5001. }
  5002. /**
  5003. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5004. * A Curve3 is designed from a series of successive Vector3.
  5005. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5006. */
  5007. export class Curve3 {
  5008. private _points;
  5009. private _length;
  5010. /**
  5011. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5013. * @param v1 (Vector3) the control point
  5014. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5015. * @param nbPoints (integer) the wanted number of points in the curve
  5016. * @returns the created Curve3
  5017. */
  5018. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5019. /**
  5020. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5021. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5022. * @param v1 (Vector3) the first control point
  5023. * @param v2 (Vector3) the second control point
  5024. * @param v3 (Vector3) the end point of the Cubic Bezier
  5025. * @param nbPoints (integer) the wanted number of points in the curve
  5026. * @returns the created Curve3
  5027. */
  5028. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5029. /**
  5030. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5031. * @param p1 (Vector3) the origin point of the Hermite Spline
  5032. * @param t1 (Vector3) the tangent vector at the origin point
  5033. * @param p2 (Vector3) the end point of the Hermite Spline
  5034. * @param t2 (Vector3) the tangent vector at the end point
  5035. * @param nbPoints (integer) the wanted number of points in the curve
  5036. * @returns the created Curve3
  5037. */
  5038. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5039. /**
  5040. * Returns a Curve3 object along a CatmullRom Spline curve :
  5041. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5042. * @param nbPoints (integer) the wanted number of points between each curve control points
  5043. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5044. * @returns the created Curve3
  5045. */
  5046. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5047. /**
  5048. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5049. * A Curve3 is designed from a series of successive Vector3.
  5050. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5051. * @param points points which make up the curve
  5052. */
  5053. constructor(points: Vector3[]);
  5054. /**
  5055. * @returns the Curve3 stored array of successive Vector3
  5056. */
  5057. getPoints(): Vector3[];
  5058. /**
  5059. * @returns the computed length (float) of the curve.
  5060. */
  5061. length(): number;
  5062. /**
  5063. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5064. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5065. * curveA and curveB keep unchanged.
  5066. * @param curve the curve to continue from this curve
  5067. * @returns the newly constructed curve
  5068. */
  5069. continue(curve: DeepImmutable<Curve3>): Curve3;
  5070. private _computeLength;
  5071. }
  5072. }
  5073. declare module "babylonjs/Animations/easing" {
  5074. /**
  5075. * This represents the main contract an easing function should follow.
  5076. * Easing functions are used throughout the animation system.
  5077. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5078. */
  5079. export interface IEasingFunction {
  5080. /**
  5081. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5082. * of the easing function.
  5083. * The link below provides some of the most common examples of easing functions.
  5084. * @see https://easings.net/
  5085. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5086. * @returns the corresponding value on the curve defined by the easing function
  5087. */
  5088. ease(gradient: number): number;
  5089. }
  5090. /**
  5091. * Base class used for every default easing function.
  5092. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5093. */
  5094. export class EasingFunction implements IEasingFunction {
  5095. /**
  5096. * Interpolation follows the mathematical formula associated with the easing function.
  5097. */
  5098. static readonly EASINGMODE_EASEIN: number;
  5099. /**
  5100. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5101. */
  5102. static readonly EASINGMODE_EASEOUT: number;
  5103. /**
  5104. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5105. */
  5106. static readonly EASINGMODE_EASEINOUT: number;
  5107. private _easingMode;
  5108. /**
  5109. * Sets the easing mode of the current function.
  5110. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5111. */
  5112. setEasingMode(easingMode: number): void;
  5113. /**
  5114. * Gets the current easing mode.
  5115. * @returns the easing mode
  5116. */
  5117. getEasingMode(): number;
  5118. /**
  5119. * @hidden
  5120. */
  5121. easeInCore(gradient: number): number;
  5122. /**
  5123. * Given an input gradient between 0 and 1, this returns the corresponding value
  5124. * of the easing function.
  5125. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5126. * @returns the corresponding value on the curve defined by the easing function
  5127. */
  5128. ease(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a circle shape (see link below).
  5132. * @see https://easings.net/#easeInCirc
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class CircleEase extends EasingFunction implements IEasingFunction {
  5136. /** @hidden */
  5137. easeInCore(gradient: number): number;
  5138. }
  5139. /**
  5140. * Easing function with a ease back shape (see link below).
  5141. * @see https://easings.net/#easeInBack
  5142. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5143. */
  5144. export class BackEase extends EasingFunction implements IEasingFunction {
  5145. /** Defines the amplitude of the function */
  5146. amplitude: number;
  5147. /**
  5148. * Instantiates a back ease easing
  5149. * @see https://easings.net/#easeInBack
  5150. * @param amplitude Defines the amplitude of the function
  5151. */
  5152. constructor(
  5153. /** Defines the amplitude of the function */
  5154. amplitude?: number);
  5155. /** @hidden */
  5156. easeInCore(gradient: number): number;
  5157. }
  5158. /**
  5159. * Easing function with a bouncing shape (see link below).
  5160. * @see https://easings.net/#easeInBounce
  5161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5162. */
  5163. export class BounceEase extends EasingFunction implements IEasingFunction {
  5164. /** Defines the number of bounces */
  5165. bounces: number;
  5166. /** Defines the amplitude of the bounce */
  5167. bounciness: number;
  5168. /**
  5169. * Instantiates a bounce easing
  5170. * @see https://easings.net/#easeInBounce
  5171. * @param bounces Defines the number of bounces
  5172. * @param bounciness Defines the amplitude of the bounce
  5173. */
  5174. constructor(
  5175. /** Defines the number of bounces */
  5176. bounces?: number,
  5177. /** Defines the amplitude of the bounce */
  5178. bounciness?: number);
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with a power of 3 shape (see link below).
  5184. * @see https://easings.net/#easeInCubic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class CubicEase extends EasingFunction implements IEasingFunction {
  5188. /** @hidden */
  5189. easeInCore(gradient: number): number;
  5190. }
  5191. /**
  5192. * Easing function with an elastic shape (see link below).
  5193. * @see https://easings.net/#easeInElastic
  5194. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5195. */
  5196. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5197. /** Defines the number of oscillations*/
  5198. oscillations: number;
  5199. /** Defines the amplitude of the oscillations*/
  5200. springiness: number;
  5201. /**
  5202. * Instantiates an elastic easing function
  5203. * @see https://easings.net/#easeInElastic
  5204. * @param oscillations Defines the number of oscillations
  5205. * @param springiness Defines the amplitude of the oscillations
  5206. */
  5207. constructor(
  5208. /** Defines the number of oscillations*/
  5209. oscillations?: number,
  5210. /** Defines the amplitude of the oscillations*/
  5211. springiness?: number);
  5212. /** @hidden */
  5213. easeInCore(gradient: number): number;
  5214. }
  5215. /**
  5216. * Easing function with an exponential shape (see link below).
  5217. * @see https://easings.net/#easeInExpo
  5218. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5219. */
  5220. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5221. /** Defines the exponent of the function */
  5222. exponent: number;
  5223. /**
  5224. * Instantiates an exponential easing function
  5225. * @see https://easings.net/#easeInExpo
  5226. * @param exponent Defines the exponent of the function
  5227. */
  5228. constructor(
  5229. /** Defines the exponent of the function */
  5230. exponent?: number);
  5231. /** @hidden */
  5232. easeInCore(gradient: number): number;
  5233. }
  5234. /**
  5235. * Easing function with a power shape (see link below).
  5236. * @see https://easings.net/#easeInQuad
  5237. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5238. */
  5239. export class PowerEase extends EasingFunction implements IEasingFunction {
  5240. /** Defines the power of the function */
  5241. power: number;
  5242. /**
  5243. * Instantiates an power base easing function
  5244. * @see https://easings.net/#easeInQuad
  5245. * @param power Defines the power of the function
  5246. */
  5247. constructor(
  5248. /** Defines the power of the function */
  5249. power?: number);
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 2 shape (see link below).
  5255. * @see https://easings.net/#easeInQuad
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 4 shape (see link below).
  5264. * @see https://easings.net/#easeInQuart
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a power of 5 shape (see link below).
  5273. * @see https://easings.net/#easeInQuint
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a sin shape (see link below).
  5282. * @see https://easings.net/#easeInSine
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class SineEase extends EasingFunction implements IEasingFunction {
  5286. /** @hidden */
  5287. easeInCore(gradient: number): number;
  5288. }
  5289. /**
  5290. * Easing function with a bezier shape (see link below).
  5291. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5292. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5293. */
  5294. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5295. /** Defines the x component of the start tangent in the bezier curve */
  5296. x1: number;
  5297. /** Defines the y component of the start tangent in the bezier curve */
  5298. y1: number;
  5299. /** Defines the x component of the end tangent in the bezier curve */
  5300. x2: number;
  5301. /** Defines the y component of the end tangent in the bezier curve */
  5302. y2: number;
  5303. /**
  5304. * Instantiates a bezier function
  5305. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5306. * @param x1 Defines the x component of the start tangent in the bezier curve
  5307. * @param y1 Defines the y component of the start tangent in the bezier curve
  5308. * @param x2 Defines the x component of the end tangent in the bezier curve
  5309. * @param y2 Defines the y component of the end tangent in the bezier curve
  5310. */
  5311. constructor(
  5312. /** Defines the x component of the start tangent in the bezier curve */
  5313. x1?: number,
  5314. /** Defines the y component of the start tangent in the bezier curve */
  5315. y1?: number,
  5316. /** Defines the x component of the end tangent in the bezier curve */
  5317. x2?: number,
  5318. /** Defines the y component of the end tangent in the bezier curve */
  5319. y2?: number);
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. }
  5324. declare module "babylonjs/Maths/math.color" {
  5325. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5326. /**
  5327. * Class used to hold a RBG color
  5328. */
  5329. export class Color3 {
  5330. /**
  5331. * Defines the red component (between 0 and 1, default is 0)
  5332. */
  5333. r: number;
  5334. /**
  5335. * Defines the green component (between 0 and 1, default is 0)
  5336. */
  5337. g: number;
  5338. /**
  5339. * Defines the blue component (between 0 and 1, default is 0)
  5340. */
  5341. b: number;
  5342. /**
  5343. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5344. * @param r defines the red component (between 0 and 1, default is 0)
  5345. * @param g defines the green component (between 0 and 1, default is 0)
  5346. * @param b defines the blue component (between 0 and 1, default is 0)
  5347. */
  5348. constructor(
  5349. /**
  5350. * Defines the red component (between 0 and 1, default is 0)
  5351. */
  5352. r?: number,
  5353. /**
  5354. * Defines the green component (between 0 and 1, default is 0)
  5355. */
  5356. g?: number,
  5357. /**
  5358. * Defines the blue component (between 0 and 1, default is 0)
  5359. */
  5360. b?: number);
  5361. /**
  5362. * Creates a string with the Color3 current values
  5363. * @returns the string representation of the Color3 object
  5364. */
  5365. toString(): string;
  5366. /**
  5367. * Returns the string "Color3"
  5368. * @returns "Color3"
  5369. */
  5370. getClassName(): string;
  5371. /**
  5372. * Compute the Color3 hash code
  5373. * @returns an unique number that can be used to hash Color3 objects
  5374. */
  5375. getHashCode(): number;
  5376. /**
  5377. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5378. * @param array defines the array where to store the r,g,b components
  5379. * @param index defines an optional index in the target array to define where to start storing values
  5380. * @returns the current Color3 object
  5381. */
  5382. toArray(array: FloatArray, index?: number): Color3;
  5383. /**
  5384. * Returns a new Color4 object from the current Color3 and the given alpha
  5385. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5386. * @returns a new Color4 object
  5387. */
  5388. toColor4(alpha?: number): Color4;
  5389. /**
  5390. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5391. * @returns the new array
  5392. */
  5393. asArray(): number[];
  5394. /**
  5395. * Returns the luminance value
  5396. * @returns a float value
  5397. */
  5398. toLuminance(): number;
  5399. /**
  5400. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5401. * @param otherColor defines the second operand
  5402. * @returns the new Color3 object
  5403. */
  5404. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5405. /**
  5406. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5407. * @param otherColor defines the second operand
  5408. * @param result defines the Color3 object where to store the result
  5409. * @returns the current Color3
  5410. */
  5411. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5412. /**
  5413. * Determines equality between Color3 objects
  5414. * @param otherColor defines the second operand
  5415. * @returns true if the rgb values are equal to the given ones
  5416. */
  5417. equals(otherColor: DeepImmutable<Color3>): boolean;
  5418. /**
  5419. * Determines equality between the current Color3 object and a set of r,b,g values
  5420. * @param r defines the red component to check
  5421. * @param g defines the green component to check
  5422. * @param b defines the blue component to check
  5423. * @returns true if the rgb values are equal to the given ones
  5424. */
  5425. equalsFloats(r: number, g: number, b: number): boolean;
  5426. /**
  5427. * Multiplies in place each rgb value by scale
  5428. * @param scale defines the scaling factor
  5429. * @returns the updated Color3
  5430. */
  5431. scale(scale: number): Color3;
  5432. /**
  5433. * Multiplies the rgb values by scale and stores the result into "result"
  5434. * @param scale defines the scaling factor
  5435. * @param result defines the Color3 object where to store the result
  5436. * @returns the unmodified current Color3
  5437. */
  5438. scaleToRef(scale: number, result: Color3): Color3;
  5439. /**
  5440. * Scale the current Color3 values by a factor and add the result to a given Color3
  5441. * @param scale defines the scale factor
  5442. * @param result defines color to store the result into
  5443. * @returns the unmodified current Color3
  5444. */
  5445. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5446. /**
  5447. * Clamps the rgb values by the min and max values and stores the result into "result"
  5448. * @param min defines minimum clamping value (default is 0)
  5449. * @param max defines maximum clamping value (default is 1)
  5450. * @param result defines color to store the result into
  5451. * @returns the original Color3
  5452. */
  5453. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5454. /**
  5455. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5456. * @param otherColor defines the second operand
  5457. * @returns the new Color3
  5458. */
  5459. add(otherColor: DeepImmutable<Color3>): Color3;
  5460. /**
  5461. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5462. * @param otherColor defines the second operand
  5463. * @param result defines Color3 object to store the result into
  5464. * @returns the unmodified current Color3
  5465. */
  5466. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5467. /**
  5468. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5469. * @param otherColor defines the second operand
  5470. * @returns the new Color3
  5471. */
  5472. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5473. /**
  5474. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5475. * @param otherColor defines the second operand
  5476. * @param result defines Color3 object to store the result into
  5477. * @returns the unmodified current Color3
  5478. */
  5479. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5480. /**
  5481. * Copy the current object
  5482. * @returns a new Color3 copied the current one
  5483. */
  5484. clone(): Color3;
  5485. /**
  5486. * Copies the rgb values from the source in the current Color3
  5487. * @param source defines the source Color3 object
  5488. * @returns the updated Color3 object
  5489. */
  5490. copyFrom(source: DeepImmutable<Color3>): Color3;
  5491. /**
  5492. * Updates the Color3 rgb values from the given floats
  5493. * @param r defines the red component to read from
  5494. * @param g defines the green component to read from
  5495. * @param b defines the blue component to read from
  5496. * @returns the current Color3 object
  5497. */
  5498. copyFromFloats(r: number, g: number, b: number): Color3;
  5499. /**
  5500. * Updates the Color3 rgb values from the given floats
  5501. * @param r defines the red component to read from
  5502. * @param g defines the green component to read from
  5503. * @param b defines the blue component to read from
  5504. * @returns the current Color3 object
  5505. */
  5506. set(r: number, g: number, b: number): Color3;
  5507. /**
  5508. * Compute the Color3 hexadecimal code as a string
  5509. * @returns a string containing the hexadecimal representation of the Color3 object
  5510. */
  5511. toHexString(): string;
  5512. /**
  5513. * Computes a new Color3 converted from the current one to linear space
  5514. * @returns a new Color3 object
  5515. */
  5516. toLinearSpace(): Color3;
  5517. /**
  5518. * Converts current color in rgb space to HSV values
  5519. * @returns a new color3 representing the HSV values
  5520. */
  5521. toHSV(): Color3;
  5522. /**
  5523. * Converts current color in rgb space to HSV values
  5524. * @param result defines the Color3 where to store the HSV values
  5525. */
  5526. toHSVToRef(result: Color3): void;
  5527. /**
  5528. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5529. * @param convertedColor defines the Color3 object where to store the linear space version
  5530. * @returns the unmodified Color3
  5531. */
  5532. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5533. /**
  5534. * Computes a new Color3 converted from the current one to gamma space
  5535. * @returns a new Color3 object
  5536. */
  5537. toGammaSpace(): Color3;
  5538. /**
  5539. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5540. * @param convertedColor defines the Color3 object where to store the gamma space version
  5541. * @returns the unmodified Color3
  5542. */
  5543. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5544. private static _BlackReadOnly;
  5545. /**
  5546. * Convert Hue, saturation and value to a Color3 (RGB)
  5547. * @param hue defines the hue
  5548. * @param saturation defines the saturation
  5549. * @param value defines the value
  5550. * @param result defines the Color3 where to store the RGB values
  5551. */
  5552. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5553. /**
  5554. * Creates a new Color3 from the string containing valid hexadecimal values
  5555. * @param hex defines a string containing valid hexadecimal values
  5556. * @returns a new Color3 object
  5557. */
  5558. static FromHexString(hex: string): Color3;
  5559. /**
  5560. * Creates a new Color3 from the starting index of the given array
  5561. * @param array defines the source array
  5562. * @param offset defines an offset in the source array
  5563. * @returns a new Color3 object
  5564. */
  5565. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5566. /**
  5567. * Creates a new Color3 from integer values (< 256)
  5568. * @param r defines the red component to read from (value between 0 and 255)
  5569. * @param g defines the green component to read from (value between 0 and 255)
  5570. * @param b defines the blue component to read from (value between 0 and 255)
  5571. * @returns a new Color3 object
  5572. */
  5573. static FromInts(r: number, g: number, b: number): Color3;
  5574. /**
  5575. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5576. * @param start defines the start Color3 value
  5577. * @param end defines the end Color3 value
  5578. * @param amount defines the gradient value between start and end
  5579. * @returns a new Color3 object
  5580. */
  5581. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5582. /**
  5583. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5584. * @param left defines the start value
  5585. * @param right defines the end value
  5586. * @param amount defines the gradient factor
  5587. * @param result defines the Color3 object where to store the result
  5588. */
  5589. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5590. /**
  5591. * Returns a Color3 value containing a red color
  5592. * @returns a new Color3 object
  5593. */
  5594. static Red(): Color3;
  5595. /**
  5596. * Returns a Color3 value containing a green color
  5597. * @returns a new Color3 object
  5598. */
  5599. static Green(): Color3;
  5600. /**
  5601. * Returns a Color3 value containing a blue color
  5602. * @returns a new Color3 object
  5603. */
  5604. static Blue(): Color3;
  5605. /**
  5606. * Returns a Color3 value containing a black color
  5607. * @returns a new Color3 object
  5608. */
  5609. static Black(): Color3;
  5610. /**
  5611. * Gets a Color3 value containing a black color that must not be updated
  5612. */
  5613. static get BlackReadOnly(): DeepImmutable<Color3>;
  5614. /**
  5615. * Returns a Color3 value containing a white color
  5616. * @returns a new Color3 object
  5617. */
  5618. static White(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a purple color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Purple(): Color3;
  5624. /**
  5625. * Returns a Color3 value containing a magenta color
  5626. * @returns a new Color3 object
  5627. */
  5628. static Magenta(): Color3;
  5629. /**
  5630. * Returns a Color3 value containing a yellow color
  5631. * @returns a new Color3 object
  5632. */
  5633. static Yellow(): Color3;
  5634. /**
  5635. * Returns a Color3 value containing a gray color
  5636. * @returns a new Color3 object
  5637. */
  5638. static Gray(): Color3;
  5639. /**
  5640. * Returns a Color3 value containing a teal color
  5641. * @returns a new Color3 object
  5642. */
  5643. static Teal(): Color3;
  5644. /**
  5645. * Returns a Color3 value containing a random color
  5646. * @returns a new Color3 object
  5647. */
  5648. static Random(): Color3;
  5649. }
  5650. /**
  5651. * Class used to hold a RBGA color
  5652. */
  5653. export class Color4 {
  5654. /**
  5655. * Defines the red component (between 0 and 1, default is 0)
  5656. */
  5657. r: number;
  5658. /**
  5659. * Defines the green component (between 0 and 1, default is 0)
  5660. */
  5661. g: number;
  5662. /**
  5663. * Defines the blue component (between 0 and 1, default is 0)
  5664. */
  5665. b: number;
  5666. /**
  5667. * Defines the alpha component (between 0 and 1, default is 1)
  5668. */
  5669. a: number;
  5670. /**
  5671. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5672. * @param r defines the red component (between 0 and 1, default is 0)
  5673. * @param g defines the green component (between 0 and 1, default is 0)
  5674. * @param b defines the blue component (between 0 and 1, default is 0)
  5675. * @param a defines the alpha component (between 0 and 1, default is 1)
  5676. */
  5677. constructor(
  5678. /**
  5679. * Defines the red component (between 0 and 1, default is 0)
  5680. */
  5681. r?: number,
  5682. /**
  5683. * Defines the green component (between 0 and 1, default is 0)
  5684. */
  5685. g?: number,
  5686. /**
  5687. * Defines the blue component (between 0 and 1, default is 0)
  5688. */
  5689. b?: number,
  5690. /**
  5691. * Defines the alpha component (between 0 and 1, default is 1)
  5692. */
  5693. a?: number);
  5694. /**
  5695. * Adds in place the given Color4 values to the current Color4 object
  5696. * @param right defines the second operand
  5697. * @returns the current updated Color4 object
  5698. */
  5699. addInPlace(right: DeepImmutable<Color4>): Color4;
  5700. /**
  5701. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5702. * @returns the new array
  5703. */
  5704. asArray(): number[];
  5705. /**
  5706. * Stores from the starting index in the given array the Color4 successive values
  5707. * @param array defines the array where to store the r,g,b components
  5708. * @param index defines an optional index in the target array to define where to start storing values
  5709. * @returns the current Color4 object
  5710. */
  5711. toArray(array: number[], index?: number): Color4;
  5712. /**
  5713. * Determines equality between Color4 objects
  5714. * @param otherColor defines the second operand
  5715. * @returns true if the rgba values are equal to the given ones
  5716. */
  5717. equals(otherColor: DeepImmutable<Color4>): boolean;
  5718. /**
  5719. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5720. * @param right defines the second operand
  5721. * @returns a new Color4 object
  5722. */
  5723. add(right: DeepImmutable<Color4>): Color4;
  5724. /**
  5725. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5726. * @param right defines the second operand
  5727. * @returns a new Color4 object
  5728. */
  5729. subtract(right: DeepImmutable<Color4>): Color4;
  5730. /**
  5731. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5732. * @param right defines the second operand
  5733. * @param result defines the Color4 object where to store the result
  5734. * @returns the current Color4 object
  5735. */
  5736. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5737. /**
  5738. * Creates a new Color4 with the current Color4 values multiplied by scale
  5739. * @param scale defines the scaling factor to apply
  5740. * @returns a new Color4 object
  5741. */
  5742. scale(scale: number): Color4;
  5743. /**
  5744. * Multiplies the current Color4 values by scale and stores the result in "result"
  5745. * @param scale defines the scaling factor to apply
  5746. * @param result defines the Color4 object where to store the result
  5747. * @returns the current unmodified Color4
  5748. */
  5749. scaleToRef(scale: number, result: Color4): Color4;
  5750. /**
  5751. * Scale the current Color4 values by a factor and add the result to a given Color4
  5752. * @param scale defines the scale factor
  5753. * @param result defines the Color4 object where to store the result
  5754. * @returns the unmodified current Color4
  5755. */
  5756. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5757. /**
  5758. * Clamps the rgb values by the min and max values and stores the result into "result"
  5759. * @param min defines minimum clamping value (default is 0)
  5760. * @param max defines maximum clamping value (default is 1)
  5761. * @param result defines color to store the result into.
  5762. * @returns the cuurent Color4
  5763. */
  5764. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5765. /**
  5766. * Multipy an Color4 value by another and return a new Color4 object
  5767. * @param color defines the Color4 value to multiply by
  5768. * @returns a new Color4 object
  5769. */
  5770. multiply(color: Color4): Color4;
  5771. /**
  5772. * Multipy a Color4 value by another and push the result in a reference value
  5773. * @param color defines the Color4 value to multiply by
  5774. * @param result defines the Color4 to fill the result in
  5775. * @returns the result Color4
  5776. */
  5777. multiplyToRef(color: Color4, result: Color4): Color4;
  5778. /**
  5779. * Creates a string with the Color4 current values
  5780. * @returns the string representation of the Color4 object
  5781. */
  5782. toString(): string;
  5783. /**
  5784. * Returns the string "Color4"
  5785. * @returns "Color4"
  5786. */
  5787. getClassName(): string;
  5788. /**
  5789. * Compute the Color4 hash code
  5790. * @returns an unique number that can be used to hash Color4 objects
  5791. */
  5792. getHashCode(): number;
  5793. /**
  5794. * Creates a new Color4 copied from the current one
  5795. * @returns a new Color4 object
  5796. */
  5797. clone(): Color4;
  5798. /**
  5799. * Copies the given Color4 values into the current one
  5800. * @param source defines the source Color4 object
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFrom(source: Color4): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Copies the given float values into the current one
  5815. * @param r defines the red component to read from
  5816. * @param g defines the green component to read from
  5817. * @param b defines the blue component to read from
  5818. * @param a defines the alpha component to read from
  5819. * @returns the current updated Color4 object
  5820. */
  5821. set(r: number, g: number, b: number, a: number): Color4;
  5822. /**
  5823. * Compute the Color4 hexadecimal code as a string
  5824. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5825. * @returns a string containing the hexadecimal representation of the Color4 object
  5826. */
  5827. toHexString(returnAsColor3?: boolean): string;
  5828. /**
  5829. * Computes a new Color4 converted from the current one to linear space
  5830. * @returns a new Color4 object
  5831. */
  5832. toLinearSpace(): Color4;
  5833. /**
  5834. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5835. * @param convertedColor defines the Color4 object where to store the linear space version
  5836. * @returns the unmodified Color4
  5837. */
  5838. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5839. /**
  5840. * Computes a new Color4 converted from the current one to gamma space
  5841. * @returns a new Color4 object
  5842. */
  5843. toGammaSpace(): Color4;
  5844. /**
  5845. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5846. * @param convertedColor defines the Color4 object where to store the gamma space version
  5847. * @returns the unmodified Color4
  5848. */
  5849. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5850. /**
  5851. * Creates a new Color4 from the string containing valid hexadecimal values
  5852. * @param hex defines a string containing valid hexadecimal values
  5853. * @returns a new Color4 object
  5854. */
  5855. static FromHexString(hex: string): Color4;
  5856. /**
  5857. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5858. * @param left defines the start value
  5859. * @param right defines the end value
  5860. * @param amount defines the gradient factor
  5861. * @returns a new Color4 object
  5862. */
  5863. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5864. /**
  5865. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5866. * @param left defines the start value
  5867. * @param right defines the end value
  5868. * @param amount defines the gradient factor
  5869. * @param result defines the Color4 object where to store data
  5870. */
  5871. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5872. /**
  5873. * Creates a new Color4 from a Color3 and an alpha value
  5874. * @param color3 defines the source Color3 to read from
  5875. * @param alpha defines the alpha component (1.0 by default)
  5876. * @returns a new Color4 object
  5877. */
  5878. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5879. /**
  5880. * Creates a new Color4 from the starting index element of the given array
  5881. * @param array defines the source array to read from
  5882. * @param offset defines the offset in the source array
  5883. * @returns a new Color4 object
  5884. */
  5885. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5886. /**
  5887. * Creates a new Color3 from integer values (< 256)
  5888. * @param r defines the red component to read from (value between 0 and 255)
  5889. * @param g defines the green component to read from (value between 0 and 255)
  5890. * @param b defines the blue component to read from (value between 0 and 255)
  5891. * @param a defines the alpha component to read from (value between 0 and 255)
  5892. * @returns a new Color3 object
  5893. */
  5894. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5895. /**
  5896. * Check the content of a given array and convert it to an array containing RGBA data
  5897. * If the original array was already containing count * 4 values then it is returned directly
  5898. * @param colors defines the array to check
  5899. * @param count defines the number of RGBA data to expect
  5900. * @returns an array containing count * 4 values (RGBA)
  5901. */
  5902. static CheckColors4(colors: number[], count: number): number[];
  5903. }
  5904. /**
  5905. * @hidden
  5906. */
  5907. export class TmpColors {
  5908. static Color3: Color3[];
  5909. static Color4: Color4[];
  5910. }
  5911. }
  5912. declare module "babylonjs/Animations/animationKey" {
  5913. /**
  5914. * Defines an interface which represents an animation key frame
  5915. */
  5916. export interface IAnimationKey {
  5917. /**
  5918. * Frame of the key frame
  5919. */
  5920. frame: number;
  5921. /**
  5922. * Value at the specifies key frame
  5923. */
  5924. value: any;
  5925. /**
  5926. * The input tangent for the cubic hermite spline
  5927. */
  5928. inTangent?: any;
  5929. /**
  5930. * The output tangent for the cubic hermite spline
  5931. */
  5932. outTangent?: any;
  5933. /**
  5934. * The animation interpolation type
  5935. */
  5936. interpolation?: AnimationKeyInterpolation;
  5937. }
  5938. /**
  5939. * Enum for the animation key frame interpolation type
  5940. */
  5941. export enum AnimationKeyInterpolation {
  5942. /**
  5943. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5944. */
  5945. STEP = 1
  5946. }
  5947. }
  5948. declare module "babylonjs/Animations/animationRange" {
  5949. /**
  5950. * Represents the range of an animation
  5951. */
  5952. export class AnimationRange {
  5953. /**The name of the animation range**/
  5954. name: string;
  5955. /**The starting frame of the animation */
  5956. from: number;
  5957. /**The ending frame of the animation*/
  5958. to: number;
  5959. /**
  5960. * Initializes the range of an animation
  5961. * @param name The name of the animation range
  5962. * @param from The starting frame of the animation
  5963. * @param to The ending frame of the animation
  5964. */
  5965. constructor(
  5966. /**The name of the animation range**/
  5967. name: string,
  5968. /**The starting frame of the animation */
  5969. from: number,
  5970. /**The ending frame of the animation*/
  5971. to: number);
  5972. /**
  5973. * Makes a copy of the animation range
  5974. * @returns A copy of the animation range
  5975. */
  5976. clone(): AnimationRange;
  5977. }
  5978. }
  5979. declare module "babylonjs/Animations/animationEvent" {
  5980. /**
  5981. * Composed of a frame, and an action function
  5982. */
  5983. export class AnimationEvent {
  5984. /** The frame for which the event is triggered **/
  5985. frame: number;
  5986. /** The event to perform when triggered **/
  5987. action: (currentFrame: number) => void;
  5988. /** Specifies if the event should be triggered only once**/
  5989. onlyOnce?: boolean | undefined;
  5990. /**
  5991. * Specifies if the animation event is done
  5992. */
  5993. isDone: boolean;
  5994. /**
  5995. * Initializes the animation event
  5996. * @param frame The frame for which the event is triggered
  5997. * @param action The event to perform when triggered
  5998. * @param onlyOnce Specifies if the event should be triggered only once
  5999. */
  6000. constructor(
  6001. /** The frame for which the event is triggered **/
  6002. frame: number,
  6003. /** The event to perform when triggered **/
  6004. action: (currentFrame: number) => void,
  6005. /** Specifies if the event should be triggered only once**/
  6006. onlyOnce?: boolean | undefined);
  6007. /** @hidden */
  6008. _clone(): AnimationEvent;
  6009. }
  6010. }
  6011. declare module "babylonjs/Behaviors/behavior" {
  6012. import { Nullable } from "babylonjs/types";
  6013. /**
  6014. * Interface used to define a behavior
  6015. */
  6016. export interface Behavior<T> {
  6017. /** gets or sets behavior's name */
  6018. name: string;
  6019. /**
  6020. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6021. */
  6022. init(): void;
  6023. /**
  6024. * Called when the behavior is attached to a target
  6025. * @param target defines the target where the behavior is attached to
  6026. */
  6027. attach(target: T): void;
  6028. /**
  6029. * Called when the behavior is detached from its target
  6030. */
  6031. detach(): void;
  6032. }
  6033. /**
  6034. * Interface implemented by classes supporting behaviors
  6035. */
  6036. export interface IBehaviorAware<T> {
  6037. /**
  6038. * Attach a behavior
  6039. * @param behavior defines the behavior to attach
  6040. * @returns the current host
  6041. */
  6042. addBehavior(behavior: Behavior<T>): T;
  6043. /**
  6044. * Remove a behavior from the current object
  6045. * @param behavior defines the behavior to detach
  6046. * @returns the current host
  6047. */
  6048. removeBehavior(behavior: Behavior<T>): T;
  6049. /**
  6050. * Gets a behavior using its name to search
  6051. * @param name defines the name to search
  6052. * @returns the behavior or null if not found
  6053. */
  6054. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6055. }
  6056. }
  6057. declare module "babylonjs/Misc/smartArray" {
  6058. /**
  6059. * Defines an array and its length.
  6060. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6061. */
  6062. export interface ISmartArrayLike<T> {
  6063. /**
  6064. * The data of the array.
  6065. */
  6066. data: Array<T>;
  6067. /**
  6068. * The active length of the array.
  6069. */
  6070. length: number;
  6071. }
  6072. /**
  6073. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6074. */
  6075. export class SmartArray<T> implements ISmartArrayLike<T> {
  6076. /**
  6077. * The full set of data from the array.
  6078. */
  6079. data: Array<T>;
  6080. /**
  6081. * The active length of the array.
  6082. */
  6083. length: number;
  6084. protected _id: number;
  6085. /**
  6086. * Instantiates a Smart Array.
  6087. * @param capacity defines the default capacity of the array.
  6088. */
  6089. constructor(capacity: number);
  6090. /**
  6091. * Pushes a value at the end of the active data.
  6092. * @param value defines the object to push in the array.
  6093. */
  6094. push(value: T): void;
  6095. /**
  6096. * Iterates over the active data and apply the lambda to them.
  6097. * @param func defines the action to apply on each value.
  6098. */
  6099. forEach(func: (content: T) => void): void;
  6100. /**
  6101. * Sorts the full sets of data.
  6102. * @param compareFn defines the comparison function to apply.
  6103. */
  6104. sort(compareFn: (a: T, b: T) => number): void;
  6105. /**
  6106. * Resets the active data to an empty array.
  6107. */
  6108. reset(): void;
  6109. /**
  6110. * Releases all the data from the array as well as the array.
  6111. */
  6112. dispose(): void;
  6113. /**
  6114. * Concats the active data with a given array.
  6115. * @param array defines the data to concatenate with.
  6116. */
  6117. concat(array: any): void;
  6118. /**
  6119. * Returns the position of a value in the active data.
  6120. * @param value defines the value to find the index for
  6121. * @returns the index if found in the active data otherwise -1
  6122. */
  6123. indexOf(value: T): number;
  6124. /**
  6125. * Returns whether an element is part of the active data.
  6126. * @param value defines the value to look for
  6127. * @returns true if found in the active data otherwise false
  6128. */
  6129. contains(value: T): boolean;
  6130. private static _GlobalId;
  6131. }
  6132. /**
  6133. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6134. * The data in this array can only be present once
  6135. */
  6136. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6137. private _duplicateId;
  6138. /**
  6139. * Pushes a value at the end of the active data.
  6140. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6141. * @param value defines the object to push in the array.
  6142. */
  6143. push(value: T): void;
  6144. /**
  6145. * Pushes a value at the end of the active data.
  6146. * If the data is already present, it won t be added again
  6147. * @param value defines the object to push in the array.
  6148. * @returns true if added false if it was already present
  6149. */
  6150. pushNoDuplicate(value: T): boolean;
  6151. /**
  6152. * Resets the active data to an empty array.
  6153. */
  6154. reset(): void;
  6155. /**
  6156. * Concats the active data with a given array.
  6157. * This ensures no dupplicate will be present in the result.
  6158. * @param array defines the data to concatenate with.
  6159. */
  6160. concatWithNoDuplicate(array: any): void;
  6161. }
  6162. }
  6163. declare module "babylonjs/Cameras/cameraInputsManager" {
  6164. import { Nullable } from "babylonjs/types";
  6165. import { Camera } from "babylonjs/Cameras/camera";
  6166. /**
  6167. * @ignore
  6168. * This is a list of all the different input types that are available in the application.
  6169. * Fo instance: ArcRotateCameraGamepadInput...
  6170. */
  6171. export var CameraInputTypes: {};
  6172. /**
  6173. * This is the contract to implement in order to create a new input class.
  6174. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6175. */
  6176. export interface ICameraInput<TCamera extends Camera> {
  6177. /**
  6178. * Defines the camera the input is attached to.
  6179. */
  6180. camera: Nullable<TCamera>;
  6181. /**
  6182. * Gets the class name of the current intput.
  6183. * @returns the class name
  6184. */
  6185. getClassName(): string;
  6186. /**
  6187. * Get the friendly name associated with the input class.
  6188. * @returns the input friendly name
  6189. */
  6190. getSimpleName(): string;
  6191. /**
  6192. * Attach the input controls to a specific dom element to get the input from.
  6193. * @param element Defines the element the controls should be listened from
  6194. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6195. */
  6196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6197. /**
  6198. * Detach the current controls from the specified dom element.
  6199. * @param element Defines the element to stop listening the inputs from
  6200. */
  6201. detachControl(element: Nullable<HTMLElement>): void;
  6202. /**
  6203. * Update the current camera state depending on the inputs that have been used this frame.
  6204. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6205. */
  6206. checkInputs?: () => void;
  6207. }
  6208. /**
  6209. * Represents a map of input types to input instance or input index to input instance.
  6210. */
  6211. export interface CameraInputsMap<TCamera extends Camera> {
  6212. /**
  6213. * Accessor to the input by input type.
  6214. */
  6215. [name: string]: ICameraInput<TCamera>;
  6216. /**
  6217. * Accessor to the input by input index.
  6218. */
  6219. [idx: number]: ICameraInput<TCamera>;
  6220. }
  6221. /**
  6222. * This represents the input manager used within a camera.
  6223. * It helps dealing with all the different kind of input attached to a camera.
  6224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6225. */
  6226. export class CameraInputsManager<TCamera extends Camera> {
  6227. /**
  6228. * Defines the list of inputs attahed to the camera.
  6229. */
  6230. attached: CameraInputsMap<TCamera>;
  6231. /**
  6232. * Defines the dom element the camera is collecting inputs from.
  6233. * This is null if the controls have not been attached.
  6234. */
  6235. attachedElement: Nullable<HTMLElement>;
  6236. /**
  6237. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6238. */
  6239. noPreventDefault: boolean;
  6240. /**
  6241. * Defined the camera the input manager belongs to.
  6242. */
  6243. camera: TCamera;
  6244. /**
  6245. * Update the current camera state depending on the inputs that have been used this frame.
  6246. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6247. */
  6248. checkInputs: () => void;
  6249. /**
  6250. * Instantiate a new Camera Input Manager.
  6251. * @param camera Defines the camera the input manager blongs to
  6252. */
  6253. constructor(camera: TCamera);
  6254. /**
  6255. * Add an input method to a camera
  6256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6257. * @param input camera input method
  6258. */
  6259. add(input: ICameraInput<TCamera>): void;
  6260. /**
  6261. * Remove a specific input method from a camera
  6262. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6263. * @param inputToRemove camera input method
  6264. */
  6265. remove(inputToRemove: ICameraInput<TCamera>): void;
  6266. /**
  6267. * Remove a specific input type from a camera
  6268. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6269. * @param inputType the type of the input to remove
  6270. */
  6271. removeByType(inputType: string): void;
  6272. private _addCheckInputs;
  6273. /**
  6274. * Attach the input controls to the currently attached dom element to listen the events from.
  6275. * @param input Defines the input to attach
  6276. */
  6277. attachInput(input: ICameraInput<TCamera>): void;
  6278. /**
  6279. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6280. * @param element Defines the dom element to collect the events from
  6281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6282. */
  6283. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6284. /**
  6285. * Detach the current manager inputs controls from a specific dom element.
  6286. * @param element Defines the dom element to collect the events from
  6287. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6288. */
  6289. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6290. /**
  6291. * Rebuild the dynamic inputCheck function from the current list of
  6292. * defined inputs in the manager.
  6293. */
  6294. rebuildInputCheck(): void;
  6295. /**
  6296. * Remove all attached input methods from a camera
  6297. */
  6298. clear(): void;
  6299. /**
  6300. * Serialize the current input manager attached to a camera.
  6301. * This ensures than once parsed,
  6302. * the input associated to the camera will be identical to the current ones
  6303. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6304. */
  6305. serialize(serializedCamera: any): void;
  6306. /**
  6307. * Parses an input manager serialized JSON to restore the previous list of inputs
  6308. * and states associated to a camera.
  6309. * @param parsedCamera Defines the JSON to parse
  6310. */
  6311. parse(parsedCamera: any): void;
  6312. }
  6313. }
  6314. declare module "babylonjs/Meshes/buffer" {
  6315. import { Nullable, DataArray } from "babylonjs/types";
  6316. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6317. /**
  6318. * Class used to store data that will be store in GPU memory
  6319. */
  6320. export class Buffer {
  6321. private _engine;
  6322. private _buffer;
  6323. /** @hidden */
  6324. _data: Nullable<DataArray>;
  6325. private _updatable;
  6326. private _instanced;
  6327. private _divisor;
  6328. /**
  6329. * Gets the byte stride.
  6330. */
  6331. readonly byteStride: number;
  6332. /**
  6333. * Constructor
  6334. * @param engine the engine
  6335. * @param data the data to use for this buffer
  6336. * @param updatable whether the data is updatable
  6337. * @param stride the stride (optional)
  6338. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6339. * @param instanced whether the buffer is instanced (optional)
  6340. * @param useBytes set to true if the stride in in bytes (optional)
  6341. * @param divisor sets an optional divisor for instances (1 by default)
  6342. */
  6343. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6344. /**
  6345. * Create a new VertexBuffer based on the current buffer
  6346. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6347. * @param offset defines offset in the buffer (0 by default)
  6348. * @param size defines the size in floats of attributes (position is 3 for instance)
  6349. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6350. * @param instanced defines if the vertex buffer contains indexed data
  6351. * @param useBytes defines if the offset and stride are in bytes *
  6352. * @param divisor sets an optional divisor for instances (1 by default)
  6353. * @returns the new vertex buffer
  6354. */
  6355. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6356. /**
  6357. * Gets a boolean indicating if the Buffer is updatable?
  6358. * @returns true if the buffer is updatable
  6359. */
  6360. isUpdatable(): boolean;
  6361. /**
  6362. * Gets current buffer's data
  6363. * @returns a DataArray or null
  6364. */
  6365. getData(): Nullable<DataArray>;
  6366. /**
  6367. * Gets underlying native buffer
  6368. * @returns underlying native buffer
  6369. */
  6370. getBuffer(): Nullable<DataBuffer>;
  6371. /**
  6372. * Gets the stride in float32 units (i.e. byte stride / 4).
  6373. * May not be an integer if the byte stride is not divisible by 4.
  6374. * @returns the stride in float32 units
  6375. * @deprecated Please use byteStride instead.
  6376. */
  6377. getStrideSize(): number;
  6378. /**
  6379. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6380. * @param data defines the data to store
  6381. */
  6382. create(data?: Nullable<DataArray>): void;
  6383. /** @hidden */
  6384. _rebuild(): void;
  6385. /**
  6386. * Update current buffer data
  6387. * @param data defines the data to store
  6388. */
  6389. update(data: DataArray): void;
  6390. /**
  6391. * Updates the data directly.
  6392. * @param data the new data
  6393. * @param offset the new offset
  6394. * @param vertexCount the vertex count (optional)
  6395. * @param useBytes set to true if the offset is in bytes
  6396. */
  6397. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6398. /**
  6399. * Release all resources
  6400. */
  6401. dispose(): void;
  6402. }
  6403. /**
  6404. * Specialized buffer used to store vertex data
  6405. */
  6406. export class VertexBuffer {
  6407. /** @hidden */
  6408. _buffer: Buffer;
  6409. private _kind;
  6410. private _size;
  6411. private _ownsBuffer;
  6412. private _instanced;
  6413. private _instanceDivisor;
  6414. /**
  6415. * The byte type.
  6416. */
  6417. static readonly BYTE: number;
  6418. /**
  6419. * The unsigned byte type.
  6420. */
  6421. static readonly UNSIGNED_BYTE: number;
  6422. /**
  6423. * The short type.
  6424. */
  6425. static readonly SHORT: number;
  6426. /**
  6427. * The unsigned short type.
  6428. */
  6429. static readonly UNSIGNED_SHORT: number;
  6430. /**
  6431. * The integer type.
  6432. */
  6433. static readonly INT: number;
  6434. /**
  6435. * The unsigned integer type.
  6436. */
  6437. static readonly UNSIGNED_INT: number;
  6438. /**
  6439. * The float type.
  6440. */
  6441. static readonly FLOAT: number;
  6442. /**
  6443. * Gets or sets the instance divisor when in instanced mode
  6444. */
  6445. get instanceDivisor(): number;
  6446. set instanceDivisor(value: number);
  6447. /**
  6448. * Gets the byte stride.
  6449. */
  6450. readonly byteStride: number;
  6451. /**
  6452. * Gets the byte offset.
  6453. */
  6454. readonly byteOffset: number;
  6455. /**
  6456. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6457. */
  6458. readonly normalized: boolean;
  6459. /**
  6460. * Gets the data type of each component in the array.
  6461. */
  6462. readonly type: number;
  6463. /**
  6464. * Constructor
  6465. * @param engine the engine
  6466. * @param data the data to use for this vertex buffer
  6467. * @param kind the vertex buffer kind
  6468. * @param updatable whether the data is updatable
  6469. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6470. * @param stride the stride (optional)
  6471. * @param instanced whether the buffer is instanced (optional)
  6472. * @param offset the offset of the data (optional)
  6473. * @param size the number of components (optional)
  6474. * @param type the type of the component (optional)
  6475. * @param normalized whether the data contains normalized data (optional)
  6476. * @param useBytes set to true if stride and offset are in bytes (optional)
  6477. * @param divisor defines the instance divisor to use (1 by default)
  6478. */
  6479. 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);
  6480. /** @hidden */
  6481. _rebuild(): void;
  6482. /**
  6483. * Returns the kind of the VertexBuffer (string)
  6484. * @returns a string
  6485. */
  6486. getKind(): string;
  6487. /**
  6488. * Gets a boolean indicating if the VertexBuffer is updatable?
  6489. * @returns true if the buffer is updatable
  6490. */
  6491. isUpdatable(): boolean;
  6492. /**
  6493. * Gets current buffer's data
  6494. * @returns a DataArray or null
  6495. */
  6496. getData(): Nullable<DataArray>;
  6497. /**
  6498. * Gets underlying native buffer
  6499. * @returns underlying native buffer
  6500. */
  6501. getBuffer(): Nullable<DataBuffer>;
  6502. /**
  6503. * Gets the stride in float32 units (i.e. byte stride / 4).
  6504. * May not be an integer if the byte stride is not divisible by 4.
  6505. * @returns the stride in float32 units
  6506. * @deprecated Please use byteStride instead.
  6507. */
  6508. getStrideSize(): number;
  6509. /**
  6510. * Returns the offset as a multiple of the type byte length.
  6511. * @returns the offset in bytes
  6512. * @deprecated Please use byteOffset instead.
  6513. */
  6514. getOffset(): number;
  6515. /**
  6516. * Returns the number of components per vertex attribute (integer)
  6517. * @returns the size in float
  6518. */
  6519. getSize(): number;
  6520. /**
  6521. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6522. * @returns true if this buffer is instanced
  6523. */
  6524. getIsInstanced(): boolean;
  6525. /**
  6526. * Returns the instancing divisor, zero for non-instanced (integer).
  6527. * @returns a number
  6528. */
  6529. getInstanceDivisor(): number;
  6530. /**
  6531. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6532. * @param data defines the data to store
  6533. */
  6534. create(data?: DataArray): void;
  6535. /**
  6536. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6537. * This function will create a new buffer if the current one is not updatable
  6538. * @param data defines the data to store
  6539. */
  6540. update(data: DataArray): void;
  6541. /**
  6542. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6543. * Returns the directly updated WebGLBuffer.
  6544. * @param data the new data
  6545. * @param offset the new offset
  6546. * @param useBytes set to true if the offset is in bytes
  6547. */
  6548. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6549. /**
  6550. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6551. */
  6552. dispose(): void;
  6553. /**
  6554. * Enumerates each value of this vertex buffer as numbers.
  6555. * @param count the number of values to enumerate
  6556. * @param callback the callback function called for each value
  6557. */
  6558. forEach(count: number, callback: (value: number, index: number) => void): void;
  6559. /**
  6560. * Positions
  6561. */
  6562. static readonly PositionKind: string;
  6563. /**
  6564. * Normals
  6565. */
  6566. static readonly NormalKind: string;
  6567. /**
  6568. * Tangents
  6569. */
  6570. static readonly TangentKind: string;
  6571. /**
  6572. * Texture coordinates
  6573. */
  6574. static readonly UVKind: string;
  6575. /**
  6576. * Texture coordinates 2
  6577. */
  6578. static readonly UV2Kind: string;
  6579. /**
  6580. * Texture coordinates 3
  6581. */
  6582. static readonly UV3Kind: string;
  6583. /**
  6584. * Texture coordinates 4
  6585. */
  6586. static readonly UV4Kind: string;
  6587. /**
  6588. * Texture coordinates 5
  6589. */
  6590. static readonly UV5Kind: string;
  6591. /**
  6592. * Texture coordinates 6
  6593. */
  6594. static readonly UV6Kind: string;
  6595. /**
  6596. * Colors
  6597. */
  6598. static readonly ColorKind: string;
  6599. /**
  6600. * Matrix indices (for bones)
  6601. */
  6602. static readonly MatricesIndicesKind: string;
  6603. /**
  6604. * Matrix weights (for bones)
  6605. */
  6606. static readonly MatricesWeightsKind: string;
  6607. /**
  6608. * Additional matrix indices (for bones)
  6609. */
  6610. static readonly MatricesIndicesExtraKind: string;
  6611. /**
  6612. * Additional matrix weights (for bones)
  6613. */
  6614. static readonly MatricesWeightsExtraKind: string;
  6615. /**
  6616. * Deduces the stride given a kind.
  6617. * @param kind The kind string to deduce
  6618. * @returns The deduced stride
  6619. */
  6620. static DeduceStride(kind: string): number;
  6621. /**
  6622. * Gets the byte length of the given type.
  6623. * @param type the type
  6624. * @returns the number of bytes
  6625. */
  6626. static GetTypeByteLength(type: number): number;
  6627. /**
  6628. * Enumerates each value of the given parameters as numbers.
  6629. * @param data the data to enumerate
  6630. * @param byteOffset the byte offset of the data
  6631. * @param byteStride the byte stride of the data
  6632. * @param componentCount the number of components per element
  6633. * @param componentType the type of the component
  6634. * @param count the number of values to enumerate
  6635. * @param normalized whether the data is normalized
  6636. * @param callback the callback function called for each value
  6637. */
  6638. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6639. private static _GetFloatValue;
  6640. }
  6641. }
  6642. declare module "babylonjs/Collisions/intersectionInfo" {
  6643. import { Nullable } from "babylonjs/types";
  6644. /**
  6645. * @hidden
  6646. */
  6647. export class IntersectionInfo {
  6648. bu: Nullable<number>;
  6649. bv: Nullable<number>;
  6650. distance: number;
  6651. faceId: number;
  6652. subMeshId: number;
  6653. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6654. }
  6655. }
  6656. declare module "babylonjs/Maths/math.plane" {
  6657. import { DeepImmutable } from "babylonjs/types";
  6658. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6659. /**
  6660. * Represens a plane by the equation ax + by + cz + d = 0
  6661. */
  6662. export class Plane {
  6663. private static _TmpMatrix;
  6664. /**
  6665. * Normal of the plane (a,b,c)
  6666. */
  6667. normal: Vector3;
  6668. /**
  6669. * d component of the plane
  6670. */
  6671. d: number;
  6672. /**
  6673. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6674. * @param a a component of the plane
  6675. * @param b b component of the plane
  6676. * @param c c component of the plane
  6677. * @param d d component of the plane
  6678. */
  6679. constructor(a: number, b: number, c: number, d: number);
  6680. /**
  6681. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6682. */
  6683. asArray(): number[];
  6684. /**
  6685. * @returns a new plane copied from the current Plane.
  6686. */
  6687. clone(): Plane;
  6688. /**
  6689. * @returns the string "Plane".
  6690. */
  6691. getClassName(): string;
  6692. /**
  6693. * @returns the Plane hash code.
  6694. */
  6695. getHashCode(): number;
  6696. /**
  6697. * Normalize the current Plane in place.
  6698. * @returns the updated Plane.
  6699. */
  6700. normalize(): Plane;
  6701. /**
  6702. * Applies a transformation the plane and returns the result
  6703. * @param transformation the transformation matrix to be applied to the plane
  6704. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6705. */
  6706. transform(transformation: DeepImmutable<Matrix>): Plane;
  6707. /**
  6708. * Calcualtte the dot product between the point and the plane normal
  6709. * @param point point to calculate the dot product with
  6710. * @returns the dot product (float) of the point coordinates and the plane normal.
  6711. */
  6712. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6713. /**
  6714. * Updates the current Plane from the plane defined by the three given points.
  6715. * @param point1 one of the points used to contruct the plane
  6716. * @param point2 one of the points used to contruct the plane
  6717. * @param point3 one of the points used to contruct the plane
  6718. * @returns the updated Plane.
  6719. */
  6720. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6721. /**
  6722. * Checks if the plane is facing a given direction
  6723. * @param direction the direction to check if the plane is facing
  6724. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6725. * @returns True is the vector "direction" is the same side than the plane normal.
  6726. */
  6727. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6728. /**
  6729. * Calculates the distance to a point
  6730. * @param point point to calculate distance to
  6731. * @returns the signed distance (float) from the given point to the Plane.
  6732. */
  6733. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6734. /**
  6735. * Creates a plane from an array
  6736. * @param array the array to create a plane from
  6737. * @returns a new Plane from the given array.
  6738. */
  6739. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6740. /**
  6741. * Creates a plane from three points
  6742. * @param point1 point used to create the plane
  6743. * @param point2 point used to create the plane
  6744. * @param point3 point used to create the plane
  6745. * @returns a new Plane defined by the three given points.
  6746. */
  6747. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6748. /**
  6749. * Creates a plane from an origin point and a normal
  6750. * @param origin origin of the plane to be constructed
  6751. * @param normal normal of the plane to be constructed
  6752. * @returns a new Plane the normal vector to this plane at the given origin point.
  6753. * Note : the vector "normal" is updated because normalized.
  6754. */
  6755. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6756. /**
  6757. * Calculates the distance from a plane and a point
  6758. * @param origin origin of the plane to be constructed
  6759. * @param normal normal of the plane to be constructed
  6760. * @param point point to calculate distance to
  6761. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6762. */
  6763. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6764. }
  6765. }
  6766. declare module "babylonjs/Culling/boundingSphere" {
  6767. import { DeepImmutable } from "babylonjs/types";
  6768. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6769. import { Plane } from "babylonjs/Maths/math.plane";
  6770. /**
  6771. * Class used to store bounding sphere information
  6772. */
  6773. export class BoundingSphere {
  6774. /**
  6775. * Gets the center of the bounding sphere in local space
  6776. */
  6777. readonly center: Vector3;
  6778. /**
  6779. * Radius of the bounding sphere in local space
  6780. */
  6781. radius: number;
  6782. /**
  6783. * Gets the center of the bounding sphere in world space
  6784. */
  6785. readonly centerWorld: Vector3;
  6786. /**
  6787. * Radius of the bounding sphere in world space
  6788. */
  6789. radiusWorld: number;
  6790. /**
  6791. * Gets the minimum vector in local space
  6792. */
  6793. readonly minimum: Vector3;
  6794. /**
  6795. * Gets the maximum vector in local space
  6796. */
  6797. readonly maximum: Vector3;
  6798. private _worldMatrix;
  6799. private static readonly TmpVector3;
  6800. /**
  6801. * Creates a new bounding sphere
  6802. * @param min defines the minimum vector (in local space)
  6803. * @param max defines the maximum vector (in local space)
  6804. * @param worldMatrix defines the new world matrix
  6805. */
  6806. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6807. /**
  6808. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6809. * @param min defines the new minimum vector (in local space)
  6810. * @param max defines the new maximum vector (in local space)
  6811. * @param worldMatrix defines the new world matrix
  6812. */
  6813. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6814. /**
  6815. * Scale the current bounding sphere by applying a scale factor
  6816. * @param factor defines the scale factor to apply
  6817. * @returns the current bounding box
  6818. */
  6819. scale(factor: number): BoundingSphere;
  6820. /**
  6821. * Gets the world matrix of the bounding box
  6822. * @returns a matrix
  6823. */
  6824. getWorldMatrix(): DeepImmutable<Matrix>;
  6825. /** @hidden */
  6826. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6827. /**
  6828. * Tests if the bounding sphere is intersecting the frustum planes
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if there is an intersection
  6831. */
  6832. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if the bounding sphere center is in between the frustum planes.
  6835. * Used for optimistic fast inclusion.
  6836. * @param frustumPlanes defines the frustum planes to test
  6837. * @returns true if the sphere center is in between the frustum planes
  6838. */
  6839. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6840. /**
  6841. * Tests if a point is inside the bounding sphere
  6842. * @param point defines the point to test
  6843. * @returns true if the point is inside the bounding sphere
  6844. */
  6845. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6846. /**
  6847. * Checks if two sphere intersct
  6848. * @param sphere0 sphere 0
  6849. * @param sphere1 sphere 1
  6850. * @returns true if the speres intersect
  6851. */
  6852. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6853. }
  6854. }
  6855. declare module "babylonjs/Culling/boundingBox" {
  6856. import { DeepImmutable } from "babylonjs/types";
  6857. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6858. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6859. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6860. import { Plane } from "babylonjs/Maths/math.plane";
  6861. /**
  6862. * Class used to store bounding box information
  6863. */
  6864. export class BoundingBox implements ICullable {
  6865. /**
  6866. * Gets the 8 vectors representing the bounding box in local space
  6867. */
  6868. readonly vectors: Vector3[];
  6869. /**
  6870. * Gets the center of the bounding box in local space
  6871. */
  6872. readonly center: Vector3;
  6873. /**
  6874. * Gets the center of the bounding box in world space
  6875. */
  6876. readonly centerWorld: Vector3;
  6877. /**
  6878. * Gets the extend size in local space
  6879. */
  6880. readonly extendSize: Vector3;
  6881. /**
  6882. * Gets the extend size in world space
  6883. */
  6884. readonly extendSizeWorld: Vector3;
  6885. /**
  6886. * Gets the OBB (object bounding box) directions
  6887. */
  6888. readonly directions: Vector3[];
  6889. /**
  6890. * Gets the 8 vectors representing the bounding box in world space
  6891. */
  6892. readonly vectorsWorld: Vector3[];
  6893. /**
  6894. * Gets the minimum vector in world space
  6895. */
  6896. readonly minimumWorld: Vector3;
  6897. /**
  6898. * Gets the maximum vector in world space
  6899. */
  6900. readonly maximumWorld: Vector3;
  6901. /**
  6902. * Gets the minimum vector in local space
  6903. */
  6904. readonly minimum: Vector3;
  6905. /**
  6906. * Gets the maximum vector in local space
  6907. */
  6908. readonly maximum: Vector3;
  6909. private _worldMatrix;
  6910. private static readonly TmpVector3;
  6911. /**
  6912. * @hidden
  6913. */
  6914. _tag: number;
  6915. /**
  6916. * Creates a new bounding box
  6917. * @param min defines the minimum vector (in local space)
  6918. * @param max defines the maximum vector (in local space)
  6919. * @param worldMatrix defines the new world matrix
  6920. */
  6921. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6922. /**
  6923. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6924. * @param min defines the new minimum vector (in local space)
  6925. * @param max defines the new maximum vector (in local space)
  6926. * @param worldMatrix defines the new world matrix
  6927. */
  6928. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6929. /**
  6930. * Scale the current bounding box by applying a scale factor
  6931. * @param factor defines the scale factor to apply
  6932. * @returns the current bounding box
  6933. */
  6934. scale(factor: number): BoundingBox;
  6935. /**
  6936. * Gets the world matrix of the bounding box
  6937. * @returns a matrix
  6938. */
  6939. getWorldMatrix(): DeepImmutable<Matrix>;
  6940. /** @hidden */
  6941. _update(world: DeepImmutable<Matrix>): void;
  6942. /**
  6943. * Tests if the bounding box is intersecting the frustum planes
  6944. * @param frustumPlanes defines the frustum planes to test
  6945. * @returns true if there is an intersection
  6946. */
  6947. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6948. /**
  6949. * Tests if the bounding box is entirely inside the frustum planes
  6950. * @param frustumPlanes defines the frustum planes to test
  6951. * @returns true if there is an inclusion
  6952. */
  6953. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6954. /**
  6955. * Tests if a point is inside the bounding box
  6956. * @param point defines the point to test
  6957. * @returns true if the point is inside the bounding box
  6958. */
  6959. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6960. /**
  6961. * Tests if the bounding box intersects with a bounding sphere
  6962. * @param sphere defines the sphere to test
  6963. * @returns true if there is an intersection
  6964. */
  6965. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6966. /**
  6967. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6968. * @param min defines the min vector to use
  6969. * @param max defines the max vector to use
  6970. * @returns true if there is an intersection
  6971. */
  6972. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6973. /**
  6974. * Tests if two bounding boxes are intersections
  6975. * @param box0 defines the first box to test
  6976. * @param box1 defines the second box to test
  6977. * @returns true if there is an intersection
  6978. */
  6979. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6980. /**
  6981. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6982. * @param minPoint defines the minimum vector of the bounding box
  6983. * @param maxPoint defines the maximum vector of the bounding box
  6984. * @param sphereCenter defines the sphere center
  6985. * @param sphereRadius defines the sphere radius
  6986. * @returns true if there is an intersection
  6987. */
  6988. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6989. /**
  6990. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6991. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6992. * @param frustumPlanes defines the frustum planes to test
  6993. * @return true if there is an inclusion
  6994. */
  6995. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6996. /**
  6997. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6998. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @return true if there is an intersection
  7001. */
  7002. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. }
  7004. }
  7005. declare module "babylonjs/Collisions/collider" {
  7006. import { Nullable, IndicesArray } from "babylonjs/types";
  7007. import { Vector3 } from "babylonjs/Maths/math.vector";
  7008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7009. import { Plane } from "babylonjs/Maths/math.plane";
  7010. /** @hidden */
  7011. export class Collider {
  7012. /** Define if a collision was found */
  7013. collisionFound: boolean;
  7014. /**
  7015. * Define last intersection point in local space
  7016. */
  7017. intersectionPoint: Vector3;
  7018. /**
  7019. * Define last collided mesh
  7020. */
  7021. collidedMesh: Nullable<AbstractMesh>;
  7022. private _collisionPoint;
  7023. private _planeIntersectionPoint;
  7024. private _tempVector;
  7025. private _tempVector2;
  7026. private _tempVector3;
  7027. private _tempVector4;
  7028. private _edge;
  7029. private _baseToVertex;
  7030. private _destinationPoint;
  7031. private _slidePlaneNormal;
  7032. private _displacementVector;
  7033. /** @hidden */
  7034. _radius: Vector3;
  7035. /** @hidden */
  7036. _retry: number;
  7037. private _velocity;
  7038. private _basePoint;
  7039. private _epsilon;
  7040. /** @hidden */
  7041. _velocityWorldLength: number;
  7042. /** @hidden */
  7043. _basePointWorld: Vector3;
  7044. private _velocityWorld;
  7045. private _normalizedVelocity;
  7046. /** @hidden */
  7047. _initialVelocity: Vector3;
  7048. /** @hidden */
  7049. _initialPosition: Vector3;
  7050. private _nearestDistance;
  7051. private _collisionMask;
  7052. get collisionMask(): number;
  7053. set collisionMask(mask: number);
  7054. /**
  7055. * Gets the plane normal used to compute the sliding response (in local space)
  7056. */
  7057. get slidePlaneNormal(): Vector3;
  7058. /** @hidden */
  7059. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7060. /** @hidden */
  7061. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7062. /** @hidden */
  7063. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7064. /** @hidden */
  7065. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7066. /** @hidden */
  7067. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7068. /** @hidden */
  7069. _getResponse(pos: Vector3, vel: Vector3): void;
  7070. }
  7071. }
  7072. declare module "babylonjs/Culling/boundingInfo" {
  7073. import { DeepImmutable } from "babylonjs/types";
  7074. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7075. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7076. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7077. import { Plane } from "babylonjs/Maths/math.plane";
  7078. import { Collider } from "babylonjs/Collisions/collider";
  7079. /**
  7080. * Interface for cullable objects
  7081. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7082. */
  7083. export interface ICullable {
  7084. /**
  7085. * Checks if the object or part of the object is in the frustum
  7086. * @param frustumPlanes Camera near/planes
  7087. * @returns true if the object is in frustum otherwise false
  7088. */
  7089. isInFrustum(frustumPlanes: Plane[]): boolean;
  7090. /**
  7091. * Checks if a cullable object (mesh...) is in the camera frustum
  7092. * Unlike isInFrustum this cheks the full bounding box
  7093. * @param frustumPlanes Camera near/planes
  7094. * @returns true if the object is in frustum otherwise false
  7095. */
  7096. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7097. }
  7098. /**
  7099. * Info for a bounding data of a mesh
  7100. */
  7101. export class BoundingInfo implements ICullable {
  7102. /**
  7103. * Bounding box for the mesh
  7104. */
  7105. readonly boundingBox: BoundingBox;
  7106. /**
  7107. * Bounding sphere for the mesh
  7108. */
  7109. readonly boundingSphere: BoundingSphere;
  7110. private _isLocked;
  7111. private static readonly TmpVector3;
  7112. /**
  7113. * Constructs bounding info
  7114. * @param minimum min vector of the bounding box/sphere
  7115. * @param maximum max vector of the bounding box/sphere
  7116. * @param worldMatrix defines the new world matrix
  7117. */
  7118. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7119. /**
  7120. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7121. * @param min defines the new minimum vector (in local space)
  7122. * @param max defines the new maximum vector (in local space)
  7123. * @param worldMatrix defines the new world matrix
  7124. */
  7125. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7126. /**
  7127. * min vector of the bounding box/sphere
  7128. */
  7129. get minimum(): Vector3;
  7130. /**
  7131. * max vector of the bounding box/sphere
  7132. */
  7133. get maximum(): Vector3;
  7134. /**
  7135. * If the info is locked and won't be updated to avoid perf overhead
  7136. */
  7137. get isLocked(): boolean;
  7138. set isLocked(value: boolean);
  7139. /**
  7140. * Updates the bounding sphere and box
  7141. * @param world world matrix to be used to update
  7142. */
  7143. update(world: DeepImmutable<Matrix>): void;
  7144. /**
  7145. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7146. * @param center New center of the bounding info
  7147. * @param extend New extend of the bounding info
  7148. * @returns the current bounding info
  7149. */
  7150. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7151. /**
  7152. * Scale the current bounding info by applying a scale factor
  7153. * @param factor defines the scale factor to apply
  7154. * @returns the current bounding info
  7155. */
  7156. scale(factor: number): BoundingInfo;
  7157. /**
  7158. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7159. * @param frustumPlanes defines the frustum to test
  7160. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7161. * @returns true if the bounding info is in the frustum planes
  7162. */
  7163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7164. /**
  7165. * Gets the world distance between the min and max points of the bounding box
  7166. */
  7167. get diagonalLength(): number;
  7168. /**
  7169. * Checks if a cullable object (mesh...) is in the camera frustum
  7170. * Unlike isInFrustum this cheks the full bounding box
  7171. * @param frustumPlanes Camera near/planes
  7172. * @returns true if the object is in frustum otherwise false
  7173. */
  7174. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7175. /** @hidden */
  7176. _checkCollision(collider: Collider): boolean;
  7177. /**
  7178. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7179. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7180. * @param point the point to check intersection with
  7181. * @returns if the point intersects
  7182. */
  7183. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7184. /**
  7185. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7186. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7187. * @param boundingInfo the bounding info to check intersection with
  7188. * @param precise if the intersection should be done using OBB
  7189. * @returns if the bounding info intersects
  7190. */
  7191. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7192. }
  7193. }
  7194. declare module "babylonjs/Maths/math.functions" {
  7195. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7196. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7197. /**
  7198. * Extracts minimum and maximum values from a list of indexed positions
  7199. * @param positions defines the positions to use
  7200. * @param indices defines the indices to the positions
  7201. * @param indexStart defines the start index
  7202. * @param indexCount defines the end index
  7203. * @param bias defines bias value to add to the result
  7204. * @return minimum and maximum values
  7205. */
  7206. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7207. minimum: Vector3;
  7208. maximum: Vector3;
  7209. };
  7210. /**
  7211. * Extracts minimum and maximum values from a list of positions
  7212. * @param positions defines the positions to use
  7213. * @param start defines the start index in the positions array
  7214. * @param count defines the number of positions to handle
  7215. * @param bias defines bias value to add to the result
  7216. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7217. * @return minimum and maximum values
  7218. */
  7219. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7220. minimum: Vector3;
  7221. maximum: Vector3;
  7222. };
  7223. }
  7224. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7225. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7226. /** @hidden */
  7227. export class WebGLDataBuffer extends DataBuffer {
  7228. private _buffer;
  7229. constructor(resource: WebGLBuffer);
  7230. get underlyingResource(): any;
  7231. }
  7232. }
  7233. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7234. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7235. import { Nullable } from "babylonjs/types";
  7236. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7237. /** @hidden */
  7238. export class WebGLPipelineContext implements IPipelineContext {
  7239. engine: ThinEngine;
  7240. program: Nullable<WebGLProgram>;
  7241. context?: WebGLRenderingContext;
  7242. vertexShader?: WebGLShader;
  7243. fragmentShader?: WebGLShader;
  7244. isParallelCompiled: boolean;
  7245. onCompiled?: () => void;
  7246. transformFeedback?: WebGLTransformFeedback | null;
  7247. vertexCompilationError: Nullable<string>;
  7248. fragmentCompilationError: Nullable<string>;
  7249. programLinkError: Nullable<string>;
  7250. programValidationError: Nullable<string>;
  7251. get isAsync(): boolean;
  7252. get isReady(): boolean;
  7253. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7254. _getVertexShaderCode(): string | null;
  7255. _getFragmentShaderCode(): string | null;
  7256. }
  7257. }
  7258. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7259. import { FloatArray, Nullable } from "babylonjs/types";
  7260. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7261. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7262. module "babylonjs/Engines/thinEngine" {
  7263. interface ThinEngine {
  7264. /**
  7265. * Create an uniform buffer
  7266. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7267. * @param elements defines the content of the uniform buffer
  7268. * @returns the webGL uniform buffer
  7269. */
  7270. createUniformBuffer(elements: FloatArray): DataBuffer;
  7271. /**
  7272. * Create a dynamic uniform buffer
  7273. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7274. * @param elements defines the content of the uniform buffer
  7275. * @returns the webGL uniform buffer
  7276. */
  7277. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7278. /**
  7279. * Update an existing uniform buffer
  7280. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7281. * @param uniformBuffer defines the target uniform buffer
  7282. * @param elements defines the content to update
  7283. * @param offset defines the offset in the uniform buffer where update should start
  7284. * @param count defines the size of the data to update
  7285. */
  7286. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7287. /**
  7288. * Bind an uniform buffer to the current webGL context
  7289. * @param buffer defines the buffer to bind
  7290. */
  7291. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7292. /**
  7293. * Bind a buffer to the current webGL context at a given location
  7294. * @param buffer defines the buffer to bind
  7295. * @param location defines the index where to bind the buffer
  7296. */
  7297. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7298. /**
  7299. * Bind a specific block at a given index in a specific shader program
  7300. * @param pipelineContext defines the pipeline context to use
  7301. * @param blockName defines the block name
  7302. * @param index defines the index where to bind the block
  7303. */
  7304. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7305. }
  7306. }
  7307. }
  7308. declare module "babylonjs/Materials/uniformBuffer" {
  7309. import { Nullable, FloatArray } from "babylonjs/types";
  7310. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7311. import { Engine } from "babylonjs/Engines/engine";
  7312. import { Effect } from "babylonjs/Materials/effect";
  7313. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7315. import { Color3 } from "babylonjs/Maths/math.color";
  7316. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7317. /**
  7318. * Uniform buffer objects.
  7319. *
  7320. * Handles blocks of uniform on the GPU.
  7321. *
  7322. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7323. *
  7324. * For more information, please refer to :
  7325. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7326. */
  7327. export class UniformBuffer {
  7328. private _engine;
  7329. private _buffer;
  7330. private _data;
  7331. private _bufferData;
  7332. private _dynamic?;
  7333. private _uniformLocations;
  7334. private _uniformSizes;
  7335. private _uniformLocationPointer;
  7336. private _needSync;
  7337. private _noUBO;
  7338. private _currentEffect;
  7339. /** @hidden */
  7340. _alreadyBound: boolean;
  7341. private static _MAX_UNIFORM_SIZE;
  7342. private static _tempBuffer;
  7343. /**
  7344. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7349. /**
  7350. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7355. /**
  7356. * Lambda to Update a single float in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateFloat: (name: string, x: number) => void;
  7361. /**
  7362. * Lambda to Update a vec2 of float in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7367. /**
  7368. * Lambda to Update a vec3 of float in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update a vec4 of float in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7379. /**
  7380. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateMatrix: (name: string, mat: Matrix) => void;
  7385. /**
  7386. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateVector3: (name: string, vector: Vector3) => void;
  7391. /**
  7392. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateVector4: (name: string, vector: Vector4) => void;
  7397. /**
  7398. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7399. * This is dynamic to allow compat with webgl 1 and 2.
  7400. * You will need to pass the name of the uniform as well as the value.
  7401. */
  7402. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7403. /**
  7404. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7405. * This is dynamic to allow compat with webgl 1 and 2.
  7406. * You will need to pass the name of the uniform as well as the value.
  7407. */
  7408. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7409. /**
  7410. * Instantiates a new Uniform buffer objects.
  7411. *
  7412. * Handles blocks of uniform on the GPU.
  7413. *
  7414. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7415. *
  7416. * For more information, please refer to :
  7417. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7418. * @param engine Define the engine the buffer is associated with
  7419. * @param data Define the data contained in the buffer
  7420. * @param dynamic Define if the buffer is updatable
  7421. */
  7422. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7423. /**
  7424. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7425. * or just falling back on setUniformXXX calls.
  7426. */
  7427. get useUbo(): boolean;
  7428. /**
  7429. * Indicates if the WebGL underlying uniform buffer is in sync
  7430. * with the javascript cache data.
  7431. */
  7432. get isSync(): boolean;
  7433. /**
  7434. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7435. * Also, a dynamic UniformBuffer will disable cache verification and always
  7436. * update the underlying WebGL uniform buffer to the GPU.
  7437. * @returns if Dynamic, otherwise false
  7438. */
  7439. isDynamic(): boolean;
  7440. /**
  7441. * The data cache on JS side.
  7442. * @returns the underlying data as a float array
  7443. */
  7444. getData(): Float32Array;
  7445. /**
  7446. * The underlying WebGL Uniform buffer.
  7447. * @returns the webgl buffer
  7448. */
  7449. getBuffer(): Nullable<DataBuffer>;
  7450. /**
  7451. * std140 layout specifies how to align data within an UBO structure.
  7452. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7453. * for specs.
  7454. */
  7455. private _fillAlignment;
  7456. /**
  7457. * Adds an uniform in the buffer.
  7458. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7459. * for the layout to be correct !
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param size Data size, or data directly.
  7462. */
  7463. addUniform(name: string, size: number | number[]): void;
  7464. /**
  7465. * Adds a Matrix 4x4 to the uniform buffer.
  7466. * @param name Name of the uniform, as used in the uniform block in the shader.
  7467. * @param mat A 4x4 matrix.
  7468. */
  7469. addMatrix(name: string, mat: Matrix): void;
  7470. /**
  7471. * Adds a vec2 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param x Define the x component value of the vec2
  7474. * @param y Define the y component value of the vec2
  7475. */
  7476. addFloat2(name: string, x: number, y: number): void;
  7477. /**
  7478. * Adds a vec3 to the uniform buffer.
  7479. * @param name Name of the uniform, as used in the uniform block in the shader.
  7480. * @param x Define the x component value of the vec3
  7481. * @param y Define the y component value of the vec3
  7482. * @param z Define the z component value of the vec3
  7483. */
  7484. addFloat3(name: string, x: number, y: number, z: number): void;
  7485. /**
  7486. * Adds a vec3 to the uniform buffer.
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param color Define the vec3 from a Color
  7489. */
  7490. addColor3(name: string, color: Color3): void;
  7491. /**
  7492. * Adds a vec4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param color Define the rgb components from a Color
  7495. * @param alpha Define the a component of the vec4
  7496. */
  7497. addColor4(name: string, color: Color3, alpha: number): void;
  7498. /**
  7499. * Adds a vec3 to the uniform buffer.
  7500. * @param name Name of the uniform, as used in the uniform block in the shader.
  7501. * @param vector Define the vec3 components from a Vector
  7502. */
  7503. addVector3(name: string, vector: Vector3): void;
  7504. /**
  7505. * Adds a Matrix 3x3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. */
  7508. addMatrix3x3(name: string): void;
  7509. /**
  7510. * Adds a Matrix 2x2 to the uniform buffer.
  7511. * @param name Name of the uniform, as used in the uniform block in the shader.
  7512. */
  7513. addMatrix2x2(name: string): void;
  7514. /**
  7515. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7516. */
  7517. create(): void;
  7518. /** @hidden */
  7519. _rebuild(): void;
  7520. /**
  7521. * Updates the WebGL Uniform Buffer on the GPU.
  7522. * If the `dynamic` flag is set to true, no cache comparison is done.
  7523. * Otherwise, the buffer will be updated only if the cache differs.
  7524. */
  7525. update(): void;
  7526. /**
  7527. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7528. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7529. * @param data Define the flattened data
  7530. * @param size Define the size of the data.
  7531. */
  7532. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7533. private _valueCache;
  7534. private _cacheMatrix;
  7535. private _updateMatrix3x3ForUniform;
  7536. private _updateMatrix3x3ForEffect;
  7537. private _updateMatrix2x2ForEffect;
  7538. private _updateMatrix2x2ForUniform;
  7539. private _updateFloatForEffect;
  7540. private _updateFloatForUniform;
  7541. private _updateFloat2ForEffect;
  7542. private _updateFloat2ForUniform;
  7543. private _updateFloat3ForEffect;
  7544. private _updateFloat3ForUniform;
  7545. private _updateFloat4ForEffect;
  7546. private _updateFloat4ForUniform;
  7547. private _updateMatrixForEffect;
  7548. private _updateMatrixForUniform;
  7549. private _updateVector3ForEffect;
  7550. private _updateVector3ForUniform;
  7551. private _updateVector4ForEffect;
  7552. private _updateVector4ForUniform;
  7553. private _updateColor3ForEffect;
  7554. private _updateColor3ForUniform;
  7555. private _updateColor4ForEffect;
  7556. private _updateColor4ForUniform;
  7557. /**
  7558. * Sets a sampler uniform on the effect.
  7559. * @param name Define the name of the sampler.
  7560. * @param texture Define the texture to set in the sampler
  7561. */
  7562. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7563. /**
  7564. * Directly updates the value of the uniform in the cache AND on the GPU.
  7565. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7566. * @param data Define the flattened data
  7567. */
  7568. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7569. /**
  7570. * Binds this uniform buffer to an effect.
  7571. * @param effect Define the effect to bind the buffer to
  7572. * @param name Name of the uniform block in the shader.
  7573. */
  7574. bindToEffect(effect: Effect, name: string): void;
  7575. /**
  7576. * Disposes the uniform buffer.
  7577. */
  7578. dispose(): void;
  7579. }
  7580. }
  7581. declare module "babylonjs/Misc/iInspectable" {
  7582. /**
  7583. * Enum that determines the text-wrapping mode to use.
  7584. */
  7585. export enum InspectableType {
  7586. /**
  7587. * Checkbox for booleans
  7588. */
  7589. Checkbox = 0,
  7590. /**
  7591. * Sliders for numbers
  7592. */
  7593. Slider = 1,
  7594. /**
  7595. * Vector3
  7596. */
  7597. Vector3 = 2,
  7598. /**
  7599. * Quaternions
  7600. */
  7601. Quaternion = 3,
  7602. /**
  7603. * Color3
  7604. */
  7605. Color3 = 4,
  7606. /**
  7607. * String
  7608. */
  7609. String = 5
  7610. }
  7611. /**
  7612. * Interface used to define custom inspectable properties.
  7613. * This interface is used by the inspector to display custom property grids
  7614. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7615. */
  7616. export interface IInspectable {
  7617. /**
  7618. * Gets the label to display
  7619. */
  7620. label: string;
  7621. /**
  7622. * Gets the name of the property to edit
  7623. */
  7624. propertyName: string;
  7625. /**
  7626. * Gets the type of the editor to use
  7627. */
  7628. type: InspectableType;
  7629. /**
  7630. * Gets the minimum value of the property when using in "slider" mode
  7631. */
  7632. min?: number;
  7633. /**
  7634. * Gets the maximum value of the property when using in "slider" mode
  7635. */
  7636. max?: number;
  7637. /**
  7638. * Gets the setp to use when using in "slider" mode
  7639. */
  7640. step?: number;
  7641. }
  7642. }
  7643. declare module "babylonjs/Misc/timingTools" {
  7644. /**
  7645. * Class used to provide helper for timing
  7646. */
  7647. export class TimingTools {
  7648. /**
  7649. * Polyfill for setImmediate
  7650. * @param action defines the action to execute after the current execution block
  7651. */
  7652. static SetImmediate(action: () => void): void;
  7653. }
  7654. }
  7655. declare module "babylonjs/Misc/instantiationTools" {
  7656. /**
  7657. * Class used to enable instatition of objects by class name
  7658. */
  7659. export class InstantiationTools {
  7660. /**
  7661. * Use this object to register external classes like custom textures or material
  7662. * to allow the laoders to instantiate them
  7663. */
  7664. static RegisteredExternalClasses: {
  7665. [key: string]: Object;
  7666. };
  7667. /**
  7668. * Tries to instantiate a new object from a given class name
  7669. * @param className defines the class name to instantiate
  7670. * @returns the new object or null if the system was not able to do the instantiation
  7671. */
  7672. static Instantiate(className: string): any;
  7673. }
  7674. }
  7675. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7676. /**
  7677. * Define options used to create a depth texture
  7678. */
  7679. export class DepthTextureCreationOptions {
  7680. /** Specifies whether or not a stencil should be allocated in the texture */
  7681. generateStencil?: boolean;
  7682. /** Specifies whether or not bilinear filtering is enable on the texture */
  7683. bilinearFiltering?: boolean;
  7684. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7685. comparisonFunction?: number;
  7686. /** Specifies if the created texture is a cube texture */
  7687. isCube?: boolean;
  7688. }
  7689. }
  7690. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7692. import { Nullable } from "babylonjs/types";
  7693. import { Scene } from "babylonjs/scene";
  7694. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7695. module "babylonjs/Engines/thinEngine" {
  7696. interface ThinEngine {
  7697. /**
  7698. * Creates a depth stencil cube texture.
  7699. * This is only available in WebGL 2.
  7700. * @param size The size of face edge in the cube texture.
  7701. * @param options The options defining the cube texture.
  7702. * @returns The cube texture
  7703. */
  7704. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7705. /**
  7706. * Creates a cube texture
  7707. * @param rootUrl defines the url where the files to load is located
  7708. * @param scene defines the current scene
  7709. * @param files defines the list of files to load (1 per face)
  7710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7711. * @param onLoad defines an optional callback raised when the texture is loaded
  7712. * @param onError defines an optional callback raised if there is an issue to load the texture
  7713. * @param format defines the format of the data
  7714. * @param forcedExtension defines the extension to use to pick the right loader
  7715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7718. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7719. * @returns the cube texture as an InternalTexture
  7720. */
  7721. 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;
  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. * @returns the cube texture as an InternalTexture
  7733. */
  7734. 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;
  7735. /**
  7736. * Creates a cube texture
  7737. * @param rootUrl defines the url where the files to load is located
  7738. * @param scene defines the current scene
  7739. * @param files defines the list of files to load (1 per face)
  7740. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7741. * @param onLoad defines an optional callback raised when the texture is loaded
  7742. * @param onError defines an optional callback raised if there is an issue to load the texture
  7743. * @param format defines the format of the data
  7744. * @param forcedExtension defines the extension to use to pick the right loader
  7745. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7746. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7747. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7748. * @returns the cube texture as an InternalTexture
  7749. */
  7750. 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;
  7751. /** @hidden */
  7752. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7753. /** @hidden */
  7754. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7755. /** @hidden */
  7756. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7757. /** @hidden */
  7758. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7759. /**
  7760. * @hidden
  7761. */
  7762. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7763. }
  7764. }
  7765. }
  7766. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7767. import { Nullable } from "babylonjs/types";
  7768. import { Scene } from "babylonjs/scene";
  7769. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7770. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7771. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7772. import { Observable } from "babylonjs/Misc/observable";
  7773. /**
  7774. * Class for creating a cube texture
  7775. */
  7776. export class CubeTexture extends BaseTexture {
  7777. private _delayedOnLoad;
  7778. /**
  7779. * Observable triggered once the texture has been loaded.
  7780. */
  7781. onLoadObservable: Observable<CubeTexture>;
  7782. /**
  7783. * The url of the texture
  7784. */
  7785. url: string;
  7786. /**
  7787. * Gets or sets the center of the bounding box associated with the cube texture.
  7788. * It must define where the camera used to render the texture was set
  7789. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7790. */
  7791. boundingBoxPosition: Vector3;
  7792. private _boundingBoxSize;
  7793. /**
  7794. * Gets or sets the size of the bounding box associated with the cube texture
  7795. * When defined, the cubemap will switch to local mode
  7796. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7797. * @example https://www.babylonjs-playground.com/#RNASML
  7798. */
  7799. set boundingBoxSize(value: Vector3);
  7800. /**
  7801. * Returns the bounding box size
  7802. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7803. */
  7804. get boundingBoxSize(): Vector3;
  7805. protected _rotationY: number;
  7806. /**
  7807. * Sets texture matrix rotation angle around Y axis in radians.
  7808. */
  7809. set rotationY(value: number);
  7810. /**
  7811. * Gets texture matrix rotation angle around Y axis radians.
  7812. */
  7813. get rotationY(): number;
  7814. /**
  7815. * Are mip maps generated for this texture or not.
  7816. */
  7817. get noMipmap(): boolean;
  7818. private _noMipmap;
  7819. private _files;
  7820. protected _forcedExtension: Nullable<string>;
  7821. private _extensions;
  7822. private _textureMatrix;
  7823. private _format;
  7824. private _createPolynomials;
  7825. /** @hidden */
  7826. _prefiltered: boolean;
  7827. /**
  7828. * Creates a cube texture from an array of image urls
  7829. * @param files defines an array of image urls
  7830. * @param scene defines the hosting scene
  7831. * @param noMipmap specifies if mip maps are not used
  7832. * @returns a cube texture
  7833. */
  7834. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7835. /**
  7836. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7837. * @param url defines the url of the prefiltered texture
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param forcedExtension defines the extension of the file if different from the url
  7840. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7841. * @return the prefiltered texture
  7842. */
  7843. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7844. /**
  7845. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7846. * as prefiltered data.
  7847. * @param rootUrl defines the url of the texture or the root name of the six images
  7848. * @param scene defines the scene the texture is attached to
  7849. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7850. * @param noMipmap defines if mipmaps should be created or not
  7851. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7852. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7853. * @param onError defines a callback triggered in case of error during load
  7854. * @param format defines the internal format to use for the texture once loaded
  7855. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7856. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7857. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7858. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7859. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7860. * @return the cube texture
  7861. */
  7862. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7863. /**
  7864. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7865. */
  7866. get isPrefiltered(): boolean;
  7867. /**
  7868. * Get the current class name of the texture useful for serialization or dynamic coding.
  7869. * @returns "CubeTexture"
  7870. */
  7871. getClassName(): string;
  7872. /**
  7873. * Update the url (and optional buffer) of this texture if url was null during construction.
  7874. * @param url the url of the texture
  7875. * @param forcedExtension defines the extension to use
  7876. * @param onLoad callback called when the texture is loaded (defaults to null)
  7877. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7878. */
  7879. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7880. /**
  7881. * Delays loading of the cube texture
  7882. * @param forcedExtension defines the extension to use
  7883. */
  7884. delayLoad(forcedExtension?: string): void;
  7885. /**
  7886. * Returns the reflection texture matrix
  7887. * @returns the reflection texture matrix
  7888. */
  7889. getReflectionTextureMatrix(): Matrix;
  7890. /**
  7891. * Sets the reflection texture matrix
  7892. * @param value Reflection texture matrix
  7893. */
  7894. setReflectionTextureMatrix(value: Matrix): void;
  7895. /**
  7896. * Parses text to create a cube texture
  7897. * @param parsedTexture define the serialized text to read from
  7898. * @param scene defines the hosting scene
  7899. * @param rootUrl defines the root url of the cube texture
  7900. * @returns a cube texture
  7901. */
  7902. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7903. /**
  7904. * Makes a clone, or deep copy, of the cube texture
  7905. * @returns a new cube texture
  7906. */
  7907. clone(): CubeTexture;
  7908. }
  7909. }
  7910. declare module "babylonjs/Materials/materialDefines" {
  7911. /**
  7912. * Manages the defines for the Material
  7913. */
  7914. export class MaterialDefines {
  7915. /** @hidden */
  7916. protected _keys: string[];
  7917. private _isDirty;
  7918. /** @hidden */
  7919. _renderId: number;
  7920. /** @hidden */
  7921. _areLightsDirty: boolean;
  7922. /** @hidden */
  7923. _areLightsDisposed: boolean;
  7924. /** @hidden */
  7925. _areAttributesDirty: boolean;
  7926. /** @hidden */
  7927. _areTexturesDirty: boolean;
  7928. /** @hidden */
  7929. _areFresnelDirty: boolean;
  7930. /** @hidden */
  7931. _areMiscDirty: boolean;
  7932. /** @hidden */
  7933. _areImageProcessingDirty: boolean;
  7934. /** @hidden */
  7935. _normals: boolean;
  7936. /** @hidden */
  7937. _uvs: boolean;
  7938. /** @hidden */
  7939. _needNormals: boolean;
  7940. /** @hidden */
  7941. _needUVs: boolean;
  7942. [id: string]: any;
  7943. /**
  7944. * Specifies if the material needs to be re-calculated
  7945. */
  7946. get isDirty(): boolean;
  7947. /**
  7948. * Marks the material to indicate that it has been re-calculated
  7949. */
  7950. markAsProcessed(): void;
  7951. /**
  7952. * Marks the material to indicate that it needs to be re-calculated
  7953. */
  7954. markAsUnprocessed(): void;
  7955. /**
  7956. * Marks the material to indicate all of its defines need to be re-calculated
  7957. */
  7958. markAllAsDirty(): void;
  7959. /**
  7960. * Marks the material to indicate that image processing needs to be re-calculated
  7961. */
  7962. markAsImageProcessingDirty(): void;
  7963. /**
  7964. * Marks the material to indicate the lights need to be re-calculated
  7965. * @param disposed Defines whether the light is dirty due to dispose or not
  7966. */
  7967. markAsLightDirty(disposed?: boolean): void;
  7968. /**
  7969. * Marks the attribute state as changed
  7970. */
  7971. markAsAttributesDirty(): void;
  7972. /**
  7973. * Marks the texture state as changed
  7974. */
  7975. markAsTexturesDirty(): void;
  7976. /**
  7977. * Marks the fresnel state as changed
  7978. */
  7979. markAsFresnelDirty(): void;
  7980. /**
  7981. * Marks the misc state as changed
  7982. */
  7983. markAsMiscDirty(): void;
  7984. /**
  7985. * Rebuilds the material defines
  7986. */
  7987. rebuild(): void;
  7988. /**
  7989. * Specifies if two material defines are equal
  7990. * @param other - A material define instance to compare to
  7991. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7992. */
  7993. isEqual(other: MaterialDefines): boolean;
  7994. /**
  7995. * Clones this instance's defines to another instance
  7996. * @param other - material defines to clone values to
  7997. */
  7998. cloneTo(other: MaterialDefines): void;
  7999. /**
  8000. * Resets the material define values
  8001. */
  8002. reset(): void;
  8003. /**
  8004. * Converts the material define values to a string
  8005. * @returns - String of material define information
  8006. */
  8007. toString(): string;
  8008. }
  8009. }
  8010. declare module "babylonjs/Materials/colorCurves" {
  8011. import { Effect } from "babylonjs/Materials/effect";
  8012. /**
  8013. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8014. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8015. * 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;
  8016. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8017. */
  8018. export class ColorCurves {
  8019. private _dirty;
  8020. private _tempColor;
  8021. private _globalCurve;
  8022. private _highlightsCurve;
  8023. private _midtonesCurve;
  8024. private _shadowsCurve;
  8025. private _positiveCurve;
  8026. private _negativeCurve;
  8027. private _globalHue;
  8028. private _globalDensity;
  8029. private _globalSaturation;
  8030. private _globalExposure;
  8031. /**
  8032. * Gets the global Hue value.
  8033. * 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).
  8034. */
  8035. get globalHue(): number;
  8036. /**
  8037. * Sets the global Hue value.
  8038. * 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).
  8039. */
  8040. set globalHue(value: number);
  8041. /**
  8042. * Gets the global Density value.
  8043. * 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.
  8044. * Values less than zero provide a filter of opposite hue.
  8045. */
  8046. get globalDensity(): number;
  8047. /**
  8048. * Sets the global Density value.
  8049. * 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.
  8050. * Values less than zero provide a filter of opposite hue.
  8051. */
  8052. set globalDensity(value: number);
  8053. /**
  8054. * Gets the global Saturation value.
  8055. * 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.
  8056. */
  8057. get globalSaturation(): number;
  8058. /**
  8059. * Sets the global Saturation value.
  8060. * 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.
  8061. */
  8062. set globalSaturation(value: number);
  8063. /**
  8064. * Gets the global Exposure value.
  8065. * 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.
  8066. */
  8067. get globalExposure(): number;
  8068. /**
  8069. * Sets the global Exposure value.
  8070. * 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.
  8071. */
  8072. set globalExposure(value: number);
  8073. private _highlightsHue;
  8074. private _highlightsDensity;
  8075. private _highlightsSaturation;
  8076. private _highlightsExposure;
  8077. /**
  8078. * Gets the highlights Hue value.
  8079. * 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).
  8080. */
  8081. get highlightsHue(): number;
  8082. /**
  8083. * Sets the highlights Hue value.
  8084. * 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).
  8085. */
  8086. set highlightsHue(value: number);
  8087. /**
  8088. * Gets the highlights Density value.
  8089. * 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.
  8090. * Values less than zero provide a filter of opposite hue.
  8091. */
  8092. get highlightsDensity(): number;
  8093. /**
  8094. * Sets the highlights Density value.
  8095. * 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.
  8096. * Values less than zero provide a filter of opposite hue.
  8097. */
  8098. set highlightsDensity(value: number);
  8099. /**
  8100. * Gets the highlights Saturation value.
  8101. * 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.
  8102. */
  8103. get highlightsSaturation(): number;
  8104. /**
  8105. * Sets the highlights Saturation value.
  8106. * 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.
  8107. */
  8108. set highlightsSaturation(value: number);
  8109. /**
  8110. * Gets the highlights Exposure value.
  8111. * 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.
  8112. */
  8113. get highlightsExposure(): number;
  8114. /**
  8115. * Sets the highlights Exposure value.
  8116. * 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.
  8117. */
  8118. set highlightsExposure(value: number);
  8119. private _midtonesHue;
  8120. private _midtonesDensity;
  8121. private _midtonesSaturation;
  8122. private _midtonesExposure;
  8123. /**
  8124. * Gets the midtones Hue value.
  8125. * 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).
  8126. */
  8127. get midtonesHue(): number;
  8128. /**
  8129. * Sets the midtones Hue value.
  8130. * 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).
  8131. */
  8132. set midtonesHue(value: number);
  8133. /**
  8134. * Gets the midtones Density value.
  8135. * 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.
  8136. * Values less than zero provide a filter of opposite hue.
  8137. */
  8138. get midtonesDensity(): number;
  8139. /**
  8140. * Sets the midtones Density value.
  8141. * 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.
  8142. * Values less than zero provide a filter of opposite hue.
  8143. */
  8144. set midtonesDensity(value: number);
  8145. /**
  8146. * Gets the midtones Saturation value.
  8147. * 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.
  8148. */
  8149. get midtonesSaturation(): number;
  8150. /**
  8151. * Sets the midtones Saturation value.
  8152. * 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.
  8153. */
  8154. set midtonesSaturation(value: number);
  8155. /**
  8156. * Gets the midtones Exposure value.
  8157. * 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.
  8158. */
  8159. get midtonesExposure(): number;
  8160. /**
  8161. * Sets the midtones Exposure value.
  8162. * 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.
  8163. */
  8164. set midtonesExposure(value: number);
  8165. private _shadowsHue;
  8166. private _shadowsDensity;
  8167. private _shadowsSaturation;
  8168. private _shadowsExposure;
  8169. /**
  8170. * Gets the shadows Hue value.
  8171. * 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).
  8172. */
  8173. get shadowsHue(): number;
  8174. /**
  8175. * Sets the shadows Hue value.
  8176. * 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).
  8177. */
  8178. set shadowsHue(value: number);
  8179. /**
  8180. * Gets the shadows Density value.
  8181. * 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.
  8182. * Values less than zero provide a filter of opposite hue.
  8183. */
  8184. get shadowsDensity(): number;
  8185. /**
  8186. * Sets the shadows Density value.
  8187. * 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.
  8188. * Values less than zero provide a filter of opposite hue.
  8189. */
  8190. set shadowsDensity(value: number);
  8191. /**
  8192. * Gets the shadows Saturation value.
  8193. * 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.
  8194. */
  8195. get shadowsSaturation(): number;
  8196. /**
  8197. * Sets the shadows Saturation value.
  8198. * 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.
  8199. */
  8200. set shadowsSaturation(value: number);
  8201. /**
  8202. * Gets the shadows Exposure value.
  8203. * 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.
  8204. */
  8205. get shadowsExposure(): number;
  8206. /**
  8207. * Sets the shadows Exposure value.
  8208. * 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.
  8209. */
  8210. set shadowsExposure(value: number);
  8211. /**
  8212. * Returns the class name
  8213. * @returns The class name
  8214. */
  8215. getClassName(): string;
  8216. /**
  8217. * Binds the color curves to the shader.
  8218. * @param colorCurves The color curve to bind
  8219. * @param effect The effect to bind to
  8220. * @param positiveUniform The positive uniform shader parameter
  8221. * @param neutralUniform The neutral uniform shader parameter
  8222. * @param negativeUniform The negative uniform shader parameter
  8223. */
  8224. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8225. /**
  8226. * Prepare the list of uniforms associated with the ColorCurves effects.
  8227. * @param uniformsList The list of uniforms used in the effect
  8228. */
  8229. static PrepareUniforms(uniformsList: string[]): void;
  8230. /**
  8231. * Returns color grading data based on a hue, density, saturation and exposure value.
  8232. * @param filterHue The hue of the color filter.
  8233. * @param filterDensity The density of the color filter.
  8234. * @param saturation The saturation.
  8235. * @param exposure The exposure.
  8236. * @param result The result data container.
  8237. */
  8238. private getColorGradingDataToRef;
  8239. /**
  8240. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8241. * @param value The input slider value in range [-100,100].
  8242. * @returns Adjusted value.
  8243. */
  8244. private static applyColorGradingSliderNonlinear;
  8245. /**
  8246. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8247. * @param hue The hue (H) input.
  8248. * @param saturation The saturation (S) input.
  8249. * @param brightness The brightness (B) input.
  8250. * @result An RGBA color represented as Vector4.
  8251. */
  8252. private static fromHSBToRef;
  8253. /**
  8254. * Returns a value clamped between min and max
  8255. * @param value The value to clamp
  8256. * @param min The minimum of value
  8257. * @param max The maximum of value
  8258. * @returns The clamped value.
  8259. */
  8260. private static clamp;
  8261. /**
  8262. * Clones the current color curve instance.
  8263. * @return The cloned curves
  8264. */
  8265. clone(): ColorCurves;
  8266. /**
  8267. * Serializes the current color curve instance to a json representation.
  8268. * @return a JSON representation
  8269. */
  8270. serialize(): any;
  8271. /**
  8272. * Parses the color curve from a json representation.
  8273. * @param source the JSON source to parse
  8274. * @return The parsed curves
  8275. */
  8276. static Parse(source: any): ColorCurves;
  8277. }
  8278. }
  8279. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8280. import { Observable } from "babylonjs/Misc/observable";
  8281. import { Nullable } from "babylonjs/types";
  8282. import { Color4 } from "babylonjs/Maths/math.color";
  8283. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8284. import { Effect } from "babylonjs/Materials/effect";
  8285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8286. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8287. /**
  8288. * Interface to follow in your material defines to integrate easily the
  8289. * Image proccessing functions.
  8290. * @hidden
  8291. */
  8292. export interface IImageProcessingConfigurationDefines {
  8293. IMAGEPROCESSING: boolean;
  8294. VIGNETTE: boolean;
  8295. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8296. VIGNETTEBLENDMODEOPAQUE: boolean;
  8297. TONEMAPPING: boolean;
  8298. TONEMAPPING_ACES: boolean;
  8299. CONTRAST: boolean;
  8300. EXPOSURE: boolean;
  8301. COLORCURVES: boolean;
  8302. COLORGRADING: boolean;
  8303. COLORGRADING3D: boolean;
  8304. SAMPLER3DGREENDEPTH: boolean;
  8305. SAMPLER3DBGRMAP: boolean;
  8306. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8307. }
  8308. /**
  8309. * @hidden
  8310. */
  8311. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8312. IMAGEPROCESSING: boolean;
  8313. VIGNETTE: boolean;
  8314. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8315. VIGNETTEBLENDMODEOPAQUE: boolean;
  8316. TONEMAPPING: boolean;
  8317. TONEMAPPING_ACES: boolean;
  8318. CONTRAST: boolean;
  8319. COLORCURVES: boolean;
  8320. COLORGRADING: boolean;
  8321. COLORGRADING3D: boolean;
  8322. SAMPLER3DGREENDEPTH: boolean;
  8323. SAMPLER3DBGRMAP: boolean;
  8324. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8325. EXPOSURE: boolean;
  8326. constructor();
  8327. }
  8328. /**
  8329. * This groups together the common properties used for image processing either in direct forward pass
  8330. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8331. * or not.
  8332. */
  8333. export class ImageProcessingConfiguration {
  8334. /**
  8335. * Default tone mapping applied in BabylonJS.
  8336. */
  8337. static readonly TONEMAPPING_STANDARD: number;
  8338. /**
  8339. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8340. * to other engines rendering to increase portability.
  8341. */
  8342. static readonly TONEMAPPING_ACES: number;
  8343. /**
  8344. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8345. */
  8346. colorCurves: Nullable<ColorCurves>;
  8347. private _colorCurvesEnabled;
  8348. /**
  8349. * Gets wether the color curves effect is enabled.
  8350. */
  8351. get colorCurvesEnabled(): boolean;
  8352. /**
  8353. * Sets wether the color curves effect is enabled.
  8354. */
  8355. set colorCurvesEnabled(value: boolean);
  8356. private _colorGradingTexture;
  8357. /**
  8358. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8359. */
  8360. get colorGradingTexture(): Nullable<BaseTexture>;
  8361. /**
  8362. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8363. */
  8364. set colorGradingTexture(value: Nullable<BaseTexture>);
  8365. private _colorGradingEnabled;
  8366. /**
  8367. * Gets wether the color grading effect is enabled.
  8368. */
  8369. get colorGradingEnabled(): boolean;
  8370. /**
  8371. * Sets wether the color grading effect is enabled.
  8372. */
  8373. set colorGradingEnabled(value: boolean);
  8374. private _colorGradingWithGreenDepth;
  8375. /**
  8376. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8377. */
  8378. get colorGradingWithGreenDepth(): boolean;
  8379. /**
  8380. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8381. */
  8382. set colorGradingWithGreenDepth(value: boolean);
  8383. private _colorGradingBGR;
  8384. /**
  8385. * Gets wether the color grading texture contains BGR values.
  8386. */
  8387. get colorGradingBGR(): boolean;
  8388. /**
  8389. * Sets wether the color grading texture contains BGR values.
  8390. */
  8391. set colorGradingBGR(value: boolean);
  8392. /** @hidden */
  8393. _exposure: number;
  8394. /**
  8395. * Gets the Exposure used in the effect.
  8396. */
  8397. get exposure(): number;
  8398. /**
  8399. * Sets the Exposure used in the effect.
  8400. */
  8401. set exposure(value: number);
  8402. private _toneMappingEnabled;
  8403. /**
  8404. * Gets wether the tone mapping effect is enabled.
  8405. */
  8406. get toneMappingEnabled(): boolean;
  8407. /**
  8408. * Sets wether the tone mapping effect is enabled.
  8409. */
  8410. set toneMappingEnabled(value: boolean);
  8411. private _toneMappingType;
  8412. /**
  8413. * Gets the type of tone mapping effect.
  8414. */
  8415. get toneMappingType(): number;
  8416. /**
  8417. * Sets the type of tone mapping effect used in BabylonJS.
  8418. */
  8419. set toneMappingType(value: number);
  8420. protected _contrast: number;
  8421. /**
  8422. * Gets the contrast used in the effect.
  8423. */
  8424. get contrast(): number;
  8425. /**
  8426. * Sets the contrast used in the effect.
  8427. */
  8428. set contrast(value: number);
  8429. /**
  8430. * Vignette stretch size.
  8431. */
  8432. vignetteStretch: number;
  8433. /**
  8434. * Vignette centre X Offset.
  8435. */
  8436. vignetteCentreX: number;
  8437. /**
  8438. * Vignette centre Y Offset.
  8439. */
  8440. vignetteCentreY: number;
  8441. /**
  8442. * Vignette weight or intensity of the vignette effect.
  8443. */
  8444. vignetteWeight: number;
  8445. /**
  8446. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8447. * if vignetteEnabled is set to true.
  8448. */
  8449. vignetteColor: Color4;
  8450. /**
  8451. * Camera field of view used by the Vignette effect.
  8452. */
  8453. vignetteCameraFov: number;
  8454. private _vignetteBlendMode;
  8455. /**
  8456. * Gets the vignette blend mode allowing different kind of effect.
  8457. */
  8458. get vignetteBlendMode(): number;
  8459. /**
  8460. * Sets the vignette blend mode allowing different kind of effect.
  8461. */
  8462. set vignetteBlendMode(value: number);
  8463. private _vignetteEnabled;
  8464. /**
  8465. * Gets wether the vignette effect is enabled.
  8466. */
  8467. get vignetteEnabled(): boolean;
  8468. /**
  8469. * Sets wether the vignette effect is enabled.
  8470. */
  8471. set vignetteEnabled(value: boolean);
  8472. private _applyByPostProcess;
  8473. /**
  8474. * Gets wether the image processing is applied through a post process or not.
  8475. */
  8476. get applyByPostProcess(): boolean;
  8477. /**
  8478. * Sets wether the image processing is applied through a post process or not.
  8479. */
  8480. set applyByPostProcess(value: boolean);
  8481. private _isEnabled;
  8482. /**
  8483. * Gets wether the image processing is enabled or not.
  8484. */
  8485. get isEnabled(): boolean;
  8486. /**
  8487. * Sets wether the image processing is enabled or not.
  8488. */
  8489. set isEnabled(value: boolean);
  8490. /**
  8491. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8492. */
  8493. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8494. /**
  8495. * Method called each time the image processing information changes requires to recompile the effect.
  8496. */
  8497. protected _updateParameters(): void;
  8498. /**
  8499. * Gets the current class name.
  8500. * @return "ImageProcessingConfiguration"
  8501. */
  8502. getClassName(): string;
  8503. /**
  8504. * Prepare the list of uniforms associated with the Image Processing effects.
  8505. * @param uniforms The list of uniforms used in the effect
  8506. * @param defines the list of defines currently in use
  8507. */
  8508. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8509. /**
  8510. * Prepare the list of samplers associated with the Image Processing effects.
  8511. * @param samplersList The list of uniforms used in the effect
  8512. * @param defines the list of defines currently in use
  8513. */
  8514. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8515. /**
  8516. * Prepare the list of defines associated to the shader.
  8517. * @param defines the list of defines to complete
  8518. * @param forPostProcess Define if we are currently in post process mode or not
  8519. */
  8520. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8521. /**
  8522. * Returns true if all the image processing information are ready.
  8523. * @returns True if ready, otherwise, false
  8524. */
  8525. isReady(): boolean;
  8526. /**
  8527. * Binds the image processing to the shader.
  8528. * @param effect The effect to bind to
  8529. * @param overrideAspectRatio Override the aspect ratio of the effect
  8530. */
  8531. bind(effect: Effect, overrideAspectRatio?: number): void;
  8532. /**
  8533. * Clones the current image processing instance.
  8534. * @return The cloned image processing
  8535. */
  8536. clone(): ImageProcessingConfiguration;
  8537. /**
  8538. * Serializes the current image processing instance to a json representation.
  8539. * @return a JSON representation
  8540. */
  8541. serialize(): any;
  8542. /**
  8543. * Parses the image processing from a json representation.
  8544. * @param source the JSON source to parse
  8545. * @return The parsed image processing
  8546. */
  8547. static Parse(source: any): ImageProcessingConfiguration;
  8548. private static _VIGNETTEMODE_MULTIPLY;
  8549. private static _VIGNETTEMODE_OPAQUE;
  8550. /**
  8551. * Used to apply the vignette as a mix with the pixel color.
  8552. */
  8553. static get VIGNETTEMODE_MULTIPLY(): number;
  8554. /**
  8555. * Used to apply the vignette as a replacement of the pixel color.
  8556. */
  8557. static get VIGNETTEMODE_OPAQUE(): number;
  8558. }
  8559. }
  8560. declare module "babylonjs/Shaders/postprocess.vertex" {
  8561. /** @hidden */
  8562. export var postprocessVertexShader: {
  8563. name: string;
  8564. shader: string;
  8565. };
  8566. }
  8567. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8568. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8569. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8570. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8571. module "babylonjs/Engines/thinEngine" {
  8572. interface ThinEngine {
  8573. /**
  8574. * Creates a new render target texture
  8575. * @param size defines the size of the texture
  8576. * @param options defines the options used to create the texture
  8577. * @returns a new render target texture stored in an InternalTexture
  8578. */
  8579. createRenderTargetTexture(size: number | {
  8580. width: number;
  8581. height: number;
  8582. layers?: number;
  8583. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8584. /**
  8585. * Creates a depth stencil texture.
  8586. * This is only available in WebGL 2 or with the depth texture extension available.
  8587. * @param size The size of face edge in the texture.
  8588. * @param options The options defining the texture.
  8589. * @returns The texture
  8590. */
  8591. createDepthStencilTexture(size: number | {
  8592. width: number;
  8593. height: number;
  8594. layers?: number;
  8595. }, options: DepthTextureCreationOptions): InternalTexture;
  8596. /** @hidden */
  8597. _createDepthStencilTexture(size: number | {
  8598. width: number;
  8599. height: number;
  8600. layers?: number;
  8601. }, options: DepthTextureCreationOptions): InternalTexture;
  8602. }
  8603. }
  8604. }
  8605. declare module "babylonjs/Maths/math.axis" {
  8606. import { Vector3 } from "babylonjs/Maths/math.vector";
  8607. /** Defines supported spaces */
  8608. export enum Space {
  8609. /** Local (object) space */
  8610. LOCAL = 0,
  8611. /** World space */
  8612. WORLD = 1,
  8613. /** Bone space */
  8614. BONE = 2
  8615. }
  8616. /** Defines the 3 main axes */
  8617. export class Axis {
  8618. /** X axis */
  8619. static X: Vector3;
  8620. /** Y axis */
  8621. static Y: Vector3;
  8622. /** Z axis */
  8623. static Z: Vector3;
  8624. }
  8625. }
  8626. declare module "babylonjs/Cameras/targetCamera" {
  8627. import { Nullable } from "babylonjs/types";
  8628. import { Camera } from "babylonjs/Cameras/camera";
  8629. import { Scene } from "babylonjs/scene";
  8630. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8631. /**
  8632. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8633. * This is the base of the follow, arc rotate cameras and Free camera
  8634. * @see http://doc.babylonjs.com/features/cameras
  8635. */
  8636. export class TargetCamera extends Camera {
  8637. private static _RigCamTransformMatrix;
  8638. private static _TargetTransformMatrix;
  8639. private static _TargetFocalPoint;
  8640. /**
  8641. * Define the current direction the camera is moving to
  8642. */
  8643. cameraDirection: Vector3;
  8644. /**
  8645. * Define the current rotation the camera is rotating to
  8646. */
  8647. cameraRotation: Vector2;
  8648. /**
  8649. * When set, the up vector of the camera will be updated by the rotation of the camera
  8650. */
  8651. updateUpVectorFromRotation: boolean;
  8652. private _tmpQuaternion;
  8653. /**
  8654. * Define the current rotation of the camera
  8655. */
  8656. rotation: Vector3;
  8657. /**
  8658. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8659. */
  8660. rotationQuaternion: Quaternion;
  8661. /**
  8662. * Define the current speed of the camera
  8663. */
  8664. speed: number;
  8665. /**
  8666. * Add constraint to the camera to prevent it to move freely in all directions and
  8667. * around all axis.
  8668. */
  8669. noRotationConstraint: boolean;
  8670. /**
  8671. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8672. * panning
  8673. */
  8674. invertRotation: boolean;
  8675. /**
  8676. * Speed multiplier for inverse camera panning
  8677. */
  8678. inverseRotationSpeed: number;
  8679. /**
  8680. * Define the current target of the camera as an object or a position.
  8681. */
  8682. lockedTarget: any;
  8683. /** @hidden */
  8684. _currentTarget: Vector3;
  8685. /** @hidden */
  8686. _initialFocalDistance: number;
  8687. /** @hidden */
  8688. _viewMatrix: Matrix;
  8689. /** @hidden */
  8690. _camMatrix: Matrix;
  8691. /** @hidden */
  8692. _cameraTransformMatrix: Matrix;
  8693. /** @hidden */
  8694. _cameraRotationMatrix: Matrix;
  8695. /** @hidden */
  8696. _referencePoint: Vector3;
  8697. /** @hidden */
  8698. _transformedReferencePoint: Vector3;
  8699. protected _globalCurrentTarget: Vector3;
  8700. protected _globalCurrentUpVector: Vector3;
  8701. /** @hidden */
  8702. _reset: () => void;
  8703. private _defaultUp;
  8704. /**
  8705. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8706. * This is the base of the follow, arc rotate cameras and Free camera
  8707. * @see http://doc.babylonjs.com/features/cameras
  8708. * @param name Defines the name of the camera in the scene
  8709. * @param position Defines the start position of the camera in the scene
  8710. * @param scene Defines the scene the camera belongs to
  8711. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8712. */
  8713. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8714. /**
  8715. * Gets the position in front of the camera at a given distance.
  8716. * @param distance The distance from the camera we want the position to be
  8717. * @returns the position
  8718. */
  8719. getFrontPosition(distance: number): Vector3;
  8720. /** @hidden */
  8721. _getLockedTargetPosition(): Nullable<Vector3>;
  8722. private _storedPosition;
  8723. private _storedRotation;
  8724. private _storedRotationQuaternion;
  8725. /**
  8726. * Store current camera state of the camera (fov, position, rotation, etc..)
  8727. * @returns the camera
  8728. */
  8729. storeState(): Camera;
  8730. /**
  8731. * Restored camera state. You must call storeState() first
  8732. * @returns whether it was successful or not
  8733. * @hidden
  8734. */
  8735. _restoreStateValues(): boolean;
  8736. /** @hidden */
  8737. _initCache(): void;
  8738. /** @hidden */
  8739. _updateCache(ignoreParentClass?: boolean): void;
  8740. /** @hidden */
  8741. _isSynchronizedViewMatrix(): boolean;
  8742. /** @hidden */
  8743. _computeLocalCameraSpeed(): number;
  8744. /**
  8745. * Defines the target the camera should look at.
  8746. * @param target Defines the new target as a Vector or a mesh
  8747. */
  8748. setTarget(target: Vector3): void;
  8749. /**
  8750. * Return the current target position of the camera. This value is expressed in local space.
  8751. * @returns the target position
  8752. */
  8753. getTarget(): Vector3;
  8754. /** @hidden */
  8755. _decideIfNeedsToMove(): boolean;
  8756. /** @hidden */
  8757. _updatePosition(): void;
  8758. /** @hidden */
  8759. _checkInputs(): void;
  8760. protected _updateCameraRotationMatrix(): void;
  8761. /**
  8762. * 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)
  8763. * @returns the current camera
  8764. */
  8765. private _rotateUpVectorWithCameraRotationMatrix;
  8766. private _cachedRotationZ;
  8767. private _cachedQuaternionRotationZ;
  8768. /** @hidden */
  8769. _getViewMatrix(): Matrix;
  8770. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8771. /**
  8772. * @hidden
  8773. */
  8774. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8775. /**
  8776. * @hidden
  8777. */
  8778. _updateRigCameras(): void;
  8779. private _getRigCamPositionAndTarget;
  8780. /**
  8781. * Gets the current object class name.
  8782. * @return the class name
  8783. */
  8784. getClassName(): string;
  8785. }
  8786. }
  8787. declare module "babylonjs/Events/keyboardEvents" {
  8788. /**
  8789. * Gather the list of keyboard event types as constants.
  8790. */
  8791. export class KeyboardEventTypes {
  8792. /**
  8793. * The keydown event is fired when a key becomes active (pressed).
  8794. */
  8795. static readonly KEYDOWN: number;
  8796. /**
  8797. * The keyup event is fired when a key has been released.
  8798. */
  8799. static readonly KEYUP: number;
  8800. }
  8801. /**
  8802. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8803. */
  8804. export class KeyboardInfo {
  8805. /**
  8806. * Defines the type of event (KeyboardEventTypes)
  8807. */
  8808. type: number;
  8809. /**
  8810. * Defines the related dom event
  8811. */
  8812. event: KeyboardEvent;
  8813. /**
  8814. * Instantiates a new keyboard info.
  8815. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8816. * @param type Defines the type of event (KeyboardEventTypes)
  8817. * @param event Defines the related dom event
  8818. */
  8819. constructor(
  8820. /**
  8821. * Defines the type of event (KeyboardEventTypes)
  8822. */
  8823. type: number,
  8824. /**
  8825. * Defines the related dom event
  8826. */
  8827. event: KeyboardEvent);
  8828. }
  8829. /**
  8830. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8831. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8832. */
  8833. export class KeyboardInfoPre extends KeyboardInfo {
  8834. /**
  8835. * Defines the type of event (KeyboardEventTypes)
  8836. */
  8837. type: number;
  8838. /**
  8839. * Defines the related dom event
  8840. */
  8841. event: KeyboardEvent;
  8842. /**
  8843. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8844. */
  8845. skipOnPointerObservable: boolean;
  8846. /**
  8847. * Instantiates a new keyboard pre info.
  8848. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8849. * @param type Defines the type of event (KeyboardEventTypes)
  8850. * @param event Defines the related dom event
  8851. */
  8852. constructor(
  8853. /**
  8854. * Defines the type of event (KeyboardEventTypes)
  8855. */
  8856. type: number,
  8857. /**
  8858. * Defines the related dom event
  8859. */
  8860. event: KeyboardEvent);
  8861. }
  8862. }
  8863. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8864. import { Nullable } from "babylonjs/types";
  8865. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8866. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8867. /**
  8868. * Manage the keyboard inputs to control the movement of a free camera.
  8869. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8870. */
  8871. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8872. /**
  8873. * Defines the camera the input is attached to.
  8874. */
  8875. camera: FreeCamera;
  8876. /**
  8877. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8878. */
  8879. keysUp: number[];
  8880. /**
  8881. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8882. */
  8883. keysUpward: number[];
  8884. /**
  8885. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8886. */
  8887. keysDown: number[];
  8888. /**
  8889. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8890. */
  8891. keysDownward: number[];
  8892. /**
  8893. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8894. */
  8895. keysLeft: number[];
  8896. /**
  8897. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8898. */
  8899. keysRight: number[];
  8900. private _keys;
  8901. private _onCanvasBlurObserver;
  8902. private _onKeyboardObserver;
  8903. private _engine;
  8904. private _scene;
  8905. /**
  8906. * Attach the input controls to a specific dom element to get the input from.
  8907. * @param element Defines the element the controls should be listened from
  8908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8909. */
  8910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8911. /**
  8912. * Detach the current controls from the specified dom element.
  8913. * @param element Defines the element to stop listening the inputs from
  8914. */
  8915. detachControl(element: Nullable<HTMLElement>): void;
  8916. /**
  8917. * Update the current camera state depending on the inputs that have been used this frame.
  8918. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8919. */
  8920. checkInputs(): void;
  8921. /**
  8922. * Gets the class name of the current intput.
  8923. * @returns the class name
  8924. */
  8925. getClassName(): string;
  8926. /** @hidden */
  8927. _onLostFocus(): void;
  8928. /**
  8929. * Get the friendly name associated with the input class.
  8930. * @returns the input friendly name
  8931. */
  8932. getSimpleName(): string;
  8933. }
  8934. }
  8935. declare module "babylonjs/Lights/shadowLight" {
  8936. import { Camera } from "babylonjs/Cameras/camera";
  8937. import { Scene } from "babylonjs/scene";
  8938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8940. import { Light } from "babylonjs/Lights/light";
  8941. /**
  8942. * Interface describing all the common properties and methods a shadow light needs to implement.
  8943. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8944. * as well as binding the different shadow properties to the effects.
  8945. */
  8946. export interface IShadowLight extends Light {
  8947. /**
  8948. * The light id in the scene (used in scene.findLighById for instance)
  8949. */
  8950. id: string;
  8951. /**
  8952. * The position the shdow will be casted from.
  8953. */
  8954. position: Vector3;
  8955. /**
  8956. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8957. */
  8958. direction: Vector3;
  8959. /**
  8960. * The transformed position. Position of the light in world space taking parenting in account.
  8961. */
  8962. transformedPosition: Vector3;
  8963. /**
  8964. * The transformed direction. Direction of the light in world space taking parenting in account.
  8965. */
  8966. transformedDirection: Vector3;
  8967. /**
  8968. * The friendly name of the light in the scene.
  8969. */
  8970. name: string;
  8971. /**
  8972. * Defines the shadow projection clipping minimum z value.
  8973. */
  8974. shadowMinZ: number;
  8975. /**
  8976. * Defines the shadow projection clipping maximum z value.
  8977. */
  8978. shadowMaxZ: number;
  8979. /**
  8980. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8981. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8982. */
  8983. computeTransformedInformation(): boolean;
  8984. /**
  8985. * Gets the scene the light belongs to.
  8986. * @returns The scene
  8987. */
  8988. getScene(): Scene;
  8989. /**
  8990. * Callback defining a custom Projection Matrix Builder.
  8991. * This can be used to override the default projection matrix computation.
  8992. */
  8993. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8994. /**
  8995. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8996. * @param matrix The materix to updated with the projection information
  8997. * @param viewMatrix The transform matrix of the light
  8998. * @param renderList The list of mesh to render in the map
  8999. * @returns The current light
  9000. */
  9001. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9002. /**
  9003. * Gets the current depth scale used in ESM.
  9004. * @returns The scale
  9005. */
  9006. getDepthScale(): number;
  9007. /**
  9008. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9009. * @returns true if a cube texture needs to be use
  9010. */
  9011. needCube(): boolean;
  9012. /**
  9013. * Detects if the projection matrix requires to be recomputed this frame.
  9014. * @returns true if it requires to be recomputed otherwise, false.
  9015. */
  9016. needProjectionMatrixCompute(): boolean;
  9017. /**
  9018. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9019. */
  9020. forceProjectionMatrixCompute(): void;
  9021. /**
  9022. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9023. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9024. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9025. */
  9026. getShadowDirection(faceIndex?: number): Vector3;
  9027. /**
  9028. * Gets the minZ used for shadow according to both the scene and the light.
  9029. * @param activeCamera The camera we are returning the min for
  9030. * @returns the depth min z
  9031. */
  9032. getDepthMinZ(activeCamera: Camera): number;
  9033. /**
  9034. * Gets the maxZ used for shadow according to both the scene and the light.
  9035. * @param activeCamera The camera we are returning the max for
  9036. * @returns the depth max z
  9037. */
  9038. getDepthMaxZ(activeCamera: Camera): number;
  9039. }
  9040. /**
  9041. * Base implementation IShadowLight
  9042. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9043. */
  9044. export abstract class ShadowLight extends Light implements IShadowLight {
  9045. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9046. protected _position: Vector3;
  9047. protected _setPosition(value: Vector3): void;
  9048. /**
  9049. * Sets the position the shadow will be casted from. Also use as the light position for both
  9050. * point and spot lights.
  9051. */
  9052. get position(): Vector3;
  9053. /**
  9054. * Sets the position the shadow will be casted from. Also use as the light position for both
  9055. * point and spot lights.
  9056. */
  9057. set position(value: Vector3);
  9058. protected _direction: Vector3;
  9059. protected _setDirection(value: Vector3): void;
  9060. /**
  9061. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9062. * Also use as the light direction on spot and directional lights.
  9063. */
  9064. get direction(): Vector3;
  9065. /**
  9066. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9067. * Also use as the light direction on spot and directional lights.
  9068. */
  9069. set direction(value: Vector3);
  9070. protected _shadowMinZ: number;
  9071. /**
  9072. * Gets the shadow projection clipping minimum z value.
  9073. */
  9074. get shadowMinZ(): number;
  9075. /**
  9076. * Sets the shadow projection clipping minimum z value.
  9077. */
  9078. set shadowMinZ(value: number);
  9079. protected _shadowMaxZ: number;
  9080. /**
  9081. * Sets the shadow projection clipping maximum z value.
  9082. */
  9083. get shadowMaxZ(): number;
  9084. /**
  9085. * Gets the shadow projection clipping maximum z value.
  9086. */
  9087. set shadowMaxZ(value: number);
  9088. /**
  9089. * Callback defining a custom Projection Matrix Builder.
  9090. * This can be used to override the default projection matrix computation.
  9091. */
  9092. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9093. /**
  9094. * The transformed position. Position of the light in world space taking parenting in account.
  9095. */
  9096. transformedPosition: Vector3;
  9097. /**
  9098. * The transformed direction. Direction of the light in world space taking parenting in account.
  9099. */
  9100. transformedDirection: Vector3;
  9101. private _needProjectionMatrixCompute;
  9102. /**
  9103. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9104. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9105. */
  9106. computeTransformedInformation(): boolean;
  9107. /**
  9108. * Return the depth scale used for the shadow map.
  9109. * @returns the depth scale.
  9110. */
  9111. getDepthScale(): number;
  9112. /**
  9113. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9114. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9115. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9116. */
  9117. getShadowDirection(faceIndex?: number): Vector3;
  9118. /**
  9119. * Returns the ShadowLight absolute position in the World.
  9120. * @returns the position vector in world space
  9121. */
  9122. getAbsolutePosition(): Vector3;
  9123. /**
  9124. * Sets the ShadowLight direction toward the passed target.
  9125. * @param target The point to target in local space
  9126. * @returns the updated ShadowLight direction
  9127. */
  9128. setDirectionToTarget(target: Vector3): Vector3;
  9129. /**
  9130. * Returns the light rotation in euler definition.
  9131. * @returns the x y z rotation in local space.
  9132. */
  9133. getRotation(): Vector3;
  9134. /**
  9135. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9136. * @returns true if a cube texture needs to be use
  9137. */
  9138. needCube(): boolean;
  9139. /**
  9140. * Detects if the projection matrix requires to be recomputed this frame.
  9141. * @returns true if it requires to be recomputed otherwise, false.
  9142. */
  9143. needProjectionMatrixCompute(): boolean;
  9144. /**
  9145. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9146. */
  9147. forceProjectionMatrixCompute(): void;
  9148. /** @hidden */
  9149. _initCache(): void;
  9150. /** @hidden */
  9151. _isSynchronized(): boolean;
  9152. /**
  9153. * Computes the world matrix of the node
  9154. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9155. * @returns the world matrix
  9156. */
  9157. computeWorldMatrix(force?: boolean): Matrix;
  9158. /**
  9159. * Gets the minZ used for shadow according to both the scene and the light.
  9160. * @param activeCamera The camera we are returning the min for
  9161. * @returns the depth min z
  9162. */
  9163. getDepthMinZ(activeCamera: Camera): number;
  9164. /**
  9165. * Gets the maxZ used for shadow according to both the scene and the light.
  9166. * @param activeCamera The camera we are returning the max for
  9167. * @returns the depth max z
  9168. */
  9169. getDepthMaxZ(activeCamera: Camera): number;
  9170. /**
  9171. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9172. * @param matrix The materix to updated with the projection information
  9173. * @param viewMatrix The transform matrix of the light
  9174. * @param renderList The list of mesh to render in the map
  9175. * @returns The current light
  9176. */
  9177. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9178. }
  9179. }
  9180. declare module "babylonjs/Materials/effectFallbacks" {
  9181. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9182. import { Effect } from "babylonjs/Materials/effect";
  9183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9184. /**
  9185. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9186. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9187. */
  9188. export class EffectFallbacks implements IEffectFallbacks {
  9189. private _defines;
  9190. private _currentRank;
  9191. private _maxRank;
  9192. private _mesh;
  9193. /**
  9194. * Removes the fallback from the bound mesh.
  9195. */
  9196. unBindMesh(): void;
  9197. /**
  9198. * Adds a fallback on the specified property.
  9199. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9200. * @param define The name of the define in the shader
  9201. */
  9202. addFallback(rank: number, define: string): void;
  9203. /**
  9204. * Sets the mesh to use CPU skinning when needing to fallback.
  9205. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9206. * @param mesh The mesh to use the fallbacks.
  9207. */
  9208. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9209. /**
  9210. * Checks to see if more fallbacks are still availible.
  9211. */
  9212. get hasMoreFallbacks(): boolean;
  9213. /**
  9214. * Removes the defines that should be removed when falling back.
  9215. * @param currentDefines defines the current define statements for the shader.
  9216. * @param effect defines the current effect we try to compile
  9217. * @returns The resulting defines with defines of the current rank removed.
  9218. */
  9219. reduce(currentDefines: string, effect: Effect): string;
  9220. }
  9221. }
  9222. declare module "babylonjs/Materials/materialHelper" {
  9223. import { Nullable } from "babylonjs/types";
  9224. import { Scene } from "babylonjs/scene";
  9225. import { Engine } from "babylonjs/Engines/engine";
  9226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9227. import { Light } from "babylonjs/Lights/light";
  9228. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9229. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9230. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9231. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9232. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9233. /**
  9234. * "Static Class" containing the most commonly used helper while dealing with material for
  9235. * rendering purpose.
  9236. *
  9237. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9238. *
  9239. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9240. */
  9241. export class MaterialHelper {
  9242. /**
  9243. * Bind the current view position to an effect.
  9244. * @param effect The effect to be bound
  9245. * @param scene The scene the eyes position is used from
  9246. */
  9247. static BindEyePosition(effect: Effect, scene: Scene): void;
  9248. /**
  9249. * Helps preparing the defines values about the UVs in used in the effect.
  9250. * UVs are shared as much as we can accross channels in the shaders.
  9251. * @param texture The texture we are preparing the UVs for
  9252. * @param defines The defines to update
  9253. * @param key The channel key "diffuse", "specular"... used in the shader
  9254. */
  9255. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9256. /**
  9257. * Binds a texture matrix value to its corrsponding uniform
  9258. * @param texture The texture to bind the matrix for
  9259. * @param uniformBuffer The uniform buffer receivin the data
  9260. * @param key The channel key "diffuse", "specular"... used in the shader
  9261. */
  9262. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9263. /**
  9264. * Gets the current status of the fog (should it be enabled?)
  9265. * @param mesh defines the mesh to evaluate for fog support
  9266. * @param scene defines the hosting scene
  9267. * @returns true if fog must be enabled
  9268. */
  9269. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9270. /**
  9271. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9272. * @param mesh defines the current mesh
  9273. * @param scene defines the current scene
  9274. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9275. * @param pointsCloud defines if point cloud rendering has to be turned on
  9276. * @param fogEnabled defines if fog has to be turned on
  9277. * @param alphaTest defines if alpha testing has to be turned on
  9278. * @param defines defines the current list of defines
  9279. */
  9280. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9281. /**
  9282. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9283. * @param scene defines the current scene
  9284. * @param engine defines the current engine
  9285. * @param defines specifies the list of active defines
  9286. * @param useInstances defines if instances have to be turned on
  9287. * @param useClipPlane defines if clip plane have to be turned on
  9288. */
  9289. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9290. /**
  9291. * Prepares the defines for bones
  9292. * @param mesh The mesh containing the geometry data we will draw
  9293. * @param defines The defines to update
  9294. */
  9295. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9296. /**
  9297. * Prepares the defines for morph targets
  9298. * @param mesh The mesh containing the geometry data we will draw
  9299. * @param defines The defines to update
  9300. */
  9301. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9302. /**
  9303. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9304. * @param mesh The mesh containing the geometry data we will draw
  9305. * @param defines The defines to update
  9306. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9307. * @param useBones Precise whether bones should be used or not (override mesh info)
  9308. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9309. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9310. * @returns false if defines are considered not dirty and have not been checked
  9311. */
  9312. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9313. /**
  9314. * Prepares the defines related to multiview
  9315. * @param scene The scene we are intending to draw
  9316. * @param defines The defines to update
  9317. */
  9318. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9319. /**
  9320. * Prepares the defines related to the light information passed in parameter
  9321. * @param scene The scene we are intending to draw
  9322. * @param mesh The mesh the effect is compiling for
  9323. * @param light The light the effect is compiling for
  9324. * @param lightIndex The index of the light
  9325. * @param defines The defines to update
  9326. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9327. * @param state Defines the current state regarding what is needed (normals, etc...)
  9328. */
  9329. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9330. needNormals: boolean;
  9331. needRebuild: boolean;
  9332. shadowEnabled: boolean;
  9333. specularEnabled: boolean;
  9334. lightmapMode: boolean;
  9335. }): void;
  9336. /**
  9337. * Prepares the defines related to the light information passed in parameter
  9338. * @param scene The scene we are intending to draw
  9339. * @param mesh The mesh the effect is compiling for
  9340. * @param defines The defines to update
  9341. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9342. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9343. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9344. * @returns true if normals will be required for the rest of the effect
  9345. */
  9346. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9347. /**
  9348. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9349. * @param lightIndex defines the light index
  9350. * @param uniformsList The uniform list
  9351. * @param samplersList The sampler list
  9352. * @param projectedLightTexture defines if projected texture must be used
  9353. * @param uniformBuffersList defines an optional list of uniform buffers
  9354. */
  9355. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9356. /**
  9357. * Prepares the uniforms and samplers list to be used in the effect
  9358. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9359. * @param samplersList The sampler list
  9360. * @param defines The defines helping in the list generation
  9361. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9362. */
  9363. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9364. /**
  9365. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9366. * @param defines The defines to update while falling back
  9367. * @param fallbacks The authorized effect fallbacks
  9368. * @param maxSimultaneousLights The maximum number of lights allowed
  9369. * @param rank the current rank of the Effect
  9370. * @returns The newly affected rank
  9371. */
  9372. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9373. private static _TmpMorphInfluencers;
  9374. /**
  9375. * Prepares the list of attributes required for morph targets according to the effect defines.
  9376. * @param attribs The current list of supported attribs
  9377. * @param mesh The mesh to prepare the morph targets attributes for
  9378. * @param influencers The number of influencers
  9379. */
  9380. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9381. /**
  9382. * Prepares the list of attributes required for morph targets according to the effect defines.
  9383. * @param attribs The current list of supported attribs
  9384. * @param mesh The mesh to prepare the morph targets attributes for
  9385. * @param defines The current Defines of the effect
  9386. */
  9387. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9388. /**
  9389. * Prepares the list of attributes required for bones according to the effect defines.
  9390. * @param attribs The current list of supported attribs
  9391. * @param mesh The mesh to prepare the bones attributes for
  9392. * @param defines The current Defines of the effect
  9393. * @param fallbacks The current efffect fallback strategy
  9394. */
  9395. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9396. /**
  9397. * Check and prepare the list of attributes required for instances according to the effect defines.
  9398. * @param attribs The current list of supported attribs
  9399. * @param defines The current MaterialDefines of the effect
  9400. */
  9401. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9402. /**
  9403. * Add the list of attributes required for instances to the attribs array.
  9404. * @param attribs The current list of supported attribs
  9405. */
  9406. static PushAttributesForInstances(attribs: string[]): void;
  9407. /**
  9408. * Binds the light information to the effect.
  9409. * @param light The light containing the generator
  9410. * @param effect The effect we are binding the data to
  9411. * @param lightIndex The light index in the effect used to render
  9412. */
  9413. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9414. /**
  9415. * Binds the lights information from the scene to the effect for the given mesh.
  9416. * @param light Light to bind
  9417. * @param lightIndex Light index
  9418. * @param scene The scene where the light belongs to
  9419. * @param effect The effect we are binding the data to
  9420. * @param useSpecular Defines if specular is supported
  9421. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9422. */
  9423. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9424. /**
  9425. * Binds the lights information from the scene to the effect for the given mesh.
  9426. * @param scene The scene the lights belongs to
  9427. * @param mesh The mesh we are binding the information to render
  9428. * @param effect The effect we are binding the data to
  9429. * @param defines The generated defines for the effect
  9430. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9431. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9432. */
  9433. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9434. private static _tempFogColor;
  9435. /**
  9436. * Binds the fog information from the scene to the effect for the given mesh.
  9437. * @param scene The scene the lights belongs to
  9438. * @param mesh The mesh we are binding the information to render
  9439. * @param effect The effect we are binding the data to
  9440. * @param linearSpace Defines if the fog effect is applied in linear space
  9441. */
  9442. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9443. /**
  9444. * Binds the bones information from the mesh to the effect.
  9445. * @param mesh The mesh we are binding the information to render
  9446. * @param effect The effect we are binding the data to
  9447. */
  9448. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9449. /**
  9450. * Binds the morph targets information from the mesh to the effect.
  9451. * @param abstractMesh The mesh we are binding the information to render
  9452. * @param effect The effect we are binding the data to
  9453. */
  9454. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9455. /**
  9456. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9457. * @param defines The generated defines used in the effect
  9458. * @param effect The effect we are binding the data to
  9459. * @param scene The scene we are willing to render with logarithmic scale for
  9460. */
  9461. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9462. /**
  9463. * Binds the clip plane information from the scene to the effect.
  9464. * @param scene The scene the clip plane information are extracted from
  9465. * @param effect The effect we are binding the data to
  9466. */
  9467. static BindClipPlane(effect: Effect, scene: Scene): void;
  9468. }
  9469. }
  9470. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9471. /** @hidden */
  9472. export var packingFunctions: {
  9473. name: string;
  9474. shader: string;
  9475. };
  9476. }
  9477. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9478. /** @hidden */
  9479. export var clipPlaneFragmentDeclaration: {
  9480. name: string;
  9481. shader: string;
  9482. };
  9483. }
  9484. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9485. /** @hidden */
  9486. export var clipPlaneFragment: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9492. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9493. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9494. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9495. /** @hidden */
  9496. export var shadowMapPixelShader: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9502. /** @hidden */
  9503. export var bonesDeclaration: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9509. /** @hidden */
  9510. export var morphTargetsVertexGlobalDeclaration: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9516. /** @hidden */
  9517. export var morphTargetsVertexDeclaration: {
  9518. name: string;
  9519. shader: string;
  9520. };
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9523. /** @hidden */
  9524. export var instancesDeclaration: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9530. /** @hidden */
  9531. export var helperFunctions: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9537. /** @hidden */
  9538. export var clipPlaneVertexDeclaration: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9544. /** @hidden */
  9545. export var morphTargetsVertex: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9551. /** @hidden */
  9552. export var instancesVertex: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9558. /** @hidden */
  9559. export var bonesVertex: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9565. /** @hidden */
  9566. export var clipPlaneVertex: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9572. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9573. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9575. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9576. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9577. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9579. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9580. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9581. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9582. /** @hidden */
  9583. export var shadowMapVertexShader: {
  9584. name: string;
  9585. shader: string;
  9586. };
  9587. }
  9588. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9589. /** @hidden */
  9590. export var depthBoxBlurPixelShader: {
  9591. name: string;
  9592. shader: string;
  9593. };
  9594. }
  9595. declare module "babylonjs/Culling/ray" {
  9596. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9599. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9600. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9601. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9602. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9603. import { Plane } from "babylonjs/Maths/math.plane";
  9604. /**
  9605. * Class representing a ray with position and direction
  9606. */
  9607. export class Ray {
  9608. /** origin point */
  9609. origin: Vector3;
  9610. /** direction */
  9611. direction: Vector3;
  9612. /** length of the ray */
  9613. length: number;
  9614. private static readonly TmpVector3;
  9615. private _tmpRay;
  9616. /**
  9617. * Creates a new ray
  9618. * @param origin origin point
  9619. * @param direction direction
  9620. * @param length length of the ray
  9621. */
  9622. constructor(
  9623. /** origin point */
  9624. origin: Vector3,
  9625. /** direction */
  9626. direction: Vector3,
  9627. /** length of the ray */
  9628. length?: number);
  9629. /**
  9630. * Checks if the ray intersects a box
  9631. * @param minimum bound of the box
  9632. * @param maximum bound of the box
  9633. * @param intersectionTreshold extra extend to be added to the box in all direction
  9634. * @returns if the box was hit
  9635. */
  9636. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9637. /**
  9638. * Checks if the ray intersects a box
  9639. * @param box the bounding box to check
  9640. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9641. * @returns if the box was hit
  9642. */
  9643. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9644. /**
  9645. * If the ray hits a sphere
  9646. * @param sphere the bounding sphere to check
  9647. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9648. * @returns true if it hits the sphere
  9649. */
  9650. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9651. /**
  9652. * If the ray hits a triange
  9653. * @param vertex0 triangle vertex
  9654. * @param vertex1 triangle vertex
  9655. * @param vertex2 triangle vertex
  9656. * @returns intersection information if hit
  9657. */
  9658. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9659. /**
  9660. * Checks if ray intersects a plane
  9661. * @param plane the plane to check
  9662. * @returns the distance away it was hit
  9663. */
  9664. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9665. /**
  9666. * Calculate the intercept of a ray on a given axis
  9667. * @param axis to check 'x' | 'y' | 'z'
  9668. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9669. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9670. */
  9671. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9672. /**
  9673. * Checks if ray intersects a mesh
  9674. * @param mesh the mesh to check
  9675. * @param fastCheck if only the bounding box should checked
  9676. * @returns picking info of the intersecton
  9677. */
  9678. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9679. /**
  9680. * Checks if ray intersects a mesh
  9681. * @param meshes the meshes to check
  9682. * @param fastCheck if only the bounding box should checked
  9683. * @param results array to store result in
  9684. * @returns Array of picking infos
  9685. */
  9686. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9687. private _comparePickingInfo;
  9688. private static smallnum;
  9689. private static rayl;
  9690. /**
  9691. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9692. * @param sega the first point of the segment to test the intersection against
  9693. * @param segb the second point of the segment to test the intersection against
  9694. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9695. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9696. */
  9697. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9698. /**
  9699. * Update the ray from viewport position
  9700. * @param x position
  9701. * @param y y position
  9702. * @param viewportWidth viewport width
  9703. * @param viewportHeight viewport height
  9704. * @param world world matrix
  9705. * @param view view matrix
  9706. * @param projection projection matrix
  9707. * @returns this ray updated
  9708. */
  9709. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9710. /**
  9711. * Creates a ray with origin and direction of 0,0,0
  9712. * @returns the new ray
  9713. */
  9714. static Zero(): Ray;
  9715. /**
  9716. * Creates a new ray from screen space and viewport
  9717. * @param x position
  9718. * @param y y position
  9719. * @param viewportWidth viewport width
  9720. * @param viewportHeight viewport height
  9721. * @param world world matrix
  9722. * @param view view matrix
  9723. * @param projection projection matrix
  9724. * @returns new ray
  9725. */
  9726. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9727. /**
  9728. * 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
  9729. * transformed to the given world matrix.
  9730. * @param origin The origin point
  9731. * @param end The end point
  9732. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9733. * @returns the new ray
  9734. */
  9735. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9736. /**
  9737. * Transforms a ray by a matrix
  9738. * @param ray ray to transform
  9739. * @param matrix matrix to apply
  9740. * @returns the resulting new ray
  9741. */
  9742. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9743. /**
  9744. * Transforms a ray by a matrix
  9745. * @param ray ray to transform
  9746. * @param matrix matrix to apply
  9747. * @param result ray to store result in
  9748. */
  9749. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9750. /**
  9751. * Unproject a ray from screen space to object space
  9752. * @param sourceX defines the screen space x coordinate to use
  9753. * @param sourceY defines the screen space y coordinate to use
  9754. * @param viewportWidth defines the current width of the viewport
  9755. * @param viewportHeight defines the current height of the viewport
  9756. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9757. * @param view defines the view matrix to use
  9758. * @param projection defines the projection matrix to use
  9759. */
  9760. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9761. }
  9762. /**
  9763. * Type used to define predicate used to select faces when a mesh intersection is detected
  9764. */
  9765. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9766. module "babylonjs/scene" {
  9767. interface Scene {
  9768. /** @hidden */
  9769. _tempPickingRay: Nullable<Ray>;
  9770. /** @hidden */
  9771. _cachedRayForTransform: Ray;
  9772. /** @hidden */
  9773. _pickWithRayInverseMatrix: Matrix;
  9774. /** @hidden */
  9775. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9776. /** @hidden */
  9777. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9778. }
  9779. }
  9780. }
  9781. declare module "babylonjs/sceneComponent" {
  9782. import { Scene } from "babylonjs/scene";
  9783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9784. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9785. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9786. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9787. import { Nullable } from "babylonjs/types";
  9788. import { Camera } from "babylonjs/Cameras/camera";
  9789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9790. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9791. import { AbstractScene } from "babylonjs/abstractScene";
  9792. import { Mesh } from "babylonjs/Meshes/mesh";
  9793. /**
  9794. * Groups all the scene component constants in one place to ease maintenance.
  9795. * @hidden
  9796. */
  9797. export class SceneComponentConstants {
  9798. static readonly NAME_EFFECTLAYER: string;
  9799. static readonly NAME_LAYER: string;
  9800. static readonly NAME_LENSFLARESYSTEM: string;
  9801. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9802. static readonly NAME_PARTICLESYSTEM: string;
  9803. static readonly NAME_GAMEPAD: string;
  9804. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9805. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9806. static readonly NAME_DEPTHRENDERER: string;
  9807. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9808. static readonly NAME_SPRITE: string;
  9809. static readonly NAME_OUTLINERENDERER: string;
  9810. static readonly NAME_PROCEDURALTEXTURE: string;
  9811. static readonly NAME_SHADOWGENERATOR: string;
  9812. static readonly NAME_OCTREE: string;
  9813. static readonly NAME_PHYSICSENGINE: string;
  9814. static readonly NAME_AUDIO: string;
  9815. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9816. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9817. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9818. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9819. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9820. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9821. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9822. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9823. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9824. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9825. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9826. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9827. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9828. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9829. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9830. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9831. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9832. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9833. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9834. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9835. static readonly STEP_AFTERRENDER_AUDIO: number;
  9836. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9837. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9838. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9839. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9840. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9841. static readonly STEP_POINTERMOVE_SPRITE: number;
  9842. static readonly STEP_POINTERDOWN_SPRITE: number;
  9843. static readonly STEP_POINTERUP_SPRITE: number;
  9844. }
  9845. /**
  9846. * This represents a scene component.
  9847. *
  9848. * This is used to decouple the dependency the scene is having on the different workloads like
  9849. * layers, post processes...
  9850. */
  9851. export interface ISceneComponent {
  9852. /**
  9853. * The name of the component. Each component must have a unique name.
  9854. */
  9855. name: string;
  9856. /**
  9857. * The scene the component belongs to.
  9858. */
  9859. scene: Scene;
  9860. /**
  9861. * Register the component to one instance of a scene.
  9862. */
  9863. register(): void;
  9864. /**
  9865. * Rebuilds the elements related to this component in case of
  9866. * context lost for instance.
  9867. */
  9868. rebuild(): void;
  9869. /**
  9870. * Disposes the component and the associated ressources.
  9871. */
  9872. dispose(): void;
  9873. }
  9874. /**
  9875. * This represents a SERIALIZABLE scene component.
  9876. *
  9877. * This extends Scene Component to add Serialization methods on top.
  9878. */
  9879. export interface ISceneSerializableComponent extends ISceneComponent {
  9880. /**
  9881. * Adds all the elements from the container to the scene
  9882. * @param container the container holding the elements
  9883. */
  9884. addFromContainer(container: AbstractScene): void;
  9885. /**
  9886. * Removes all the elements in the container from the scene
  9887. * @param container contains the elements to remove
  9888. * @param dispose if the removed element should be disposed (default: false)
  9889. */
  9890. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9891. /**
  9892. * Serializes the component data to the specified json object
  9893. * @param serializationObject The object to serialize to
  9894. */
  9895. serialize(serializationObject: any): void;
  9896. }
  9897. /**
  9898. * Strong typing of a Mesh related stage step action
  9899. */
  9900. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9901. /**
  9902. * Strong typing of a Evaluate Sub Mesh related stage step action
  9903. */
  9904. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9905. /**
  9906. * Strong typing of a Active Mesh related stage step action
  9907. */
  9908. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9909. /**
  9910. * Strong typing of a Camera related stage step action
  9911. */
  9912. export type CameraStageAction = (camera: Camera) => void;
  9913. /**
  9914. * Strong typing of a Camera Frame buffer related stage step action
  9915. */
  9916. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9917. /**
  9918. * Strong typing of a Render Target related stage step action
  9919. */
  9920. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9921. /**
  9922. * Strong typing of a RenderingGroup related stage step action
  9923. */
  9924. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9925. /**
  9926. * Strong typing of a Mesh Render related stage step action
  9927. */
  9928. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9929. /**
  9930. * Strong typing of a simple stage step action
  9931. */
  9932. export type SimpleStageAction = () => void;
  9933. /**
  9934. * Strong typing of a render target action.
  9935. */
  9936. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9937. /**
  9938. * Strong typing of a pointer move action.
  9939. */
  9940. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9941. /**
  9942. * Strong typing of a pointer up/down action.
  9943. */
  9944. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9945. /**
  9946. * Representation of a stage in the scene (Basically a list of ordered steps)
  9947. * @hidden
  9948. */
  9949. export class Stage<T extends Function> extends Array<{
  9950. index: number;
  9951. component: ISceneComponent;
  9952. action: T;
  9953. }> {
  9954. /**
  9955. * Hide ctor from the rest of the world.
  9956. * @param items The items to add.
  9957. */
  9958. private constructor();
  9959. /**
  9960. * Creates a new Stage.
  9961. * @returns A new instance of a Stage
  9962. */
  9963. static Create<T extends Function>(): Stage<T>;
  9964. /**
  9965. * Registers a step in an ordered way in the targeted stage.
  9966. * @param index Defines the position to register the step in
  9967. * @param component Defines the component attached to the step
  9968. * @param action Defines the action to launch during the step
  9969. */
  9970. registerStep(index: number, component: ISceneComponent, action: T): void;
  9971. /**
  9972. * Clears all the steps from the stage.
  9973. */
  9974. clear(): void;
  9975. }
  9976. }
  9977. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9978. import { Nullable } from "babylonjs/types";
  9979. import { Observable } from "babylonjs/Misc/observable";
  9980. import { Scene } from "babylonjs/scene";
  9981. import { Sprite } from "babylonjs/Sprites/sprite";
  9982. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9983. import { Ray } from "babylonjs/Culling/ray";
  9984. import { Camera } from "babylonjs/Cameras/camera";
  9985. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9986. import { ISceneComponent } from "babylonjs/sceneComponent";
  9987. module "babylonjs/scene" {
  9988. interface Scene {
  9989. /** @hidden */
  9990. _pointerOverSprite: Nullable<Sprite>;
  9991. /** @hidden */
  9992. _pickedDownSprite: Nullable<Sprite>;
  9993. /** @hidden */
  9994. _tempSpritePickingRay: Nullable<Ray>;
  9995. /**
  9996. * All of the sprite managers added to this scene
  9997. * @see http://doc.babylonjs.com/babylon101/sprites
  9998. */
  9999. spriteManagers: Array<ISpriteManager>;
  10000. /**
  10001. * An event triggered when sprites rendering is about to start
  10002. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10003. */
  10004. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10005. /**
  10006. * An event triggered when sprites rendering is done
  10007. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10008. */
  10009. onAfterSpritesRenderingObservable: Observable<Scene>;
  10010. /** @hidden */
  10011. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10012. /** Launch a ray to try to pick a sprite in the scene
  10013. * @param x position on screen
  10014. * @param y position on screen
  10015. * @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
  10016. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10017. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10018. * @returns a PickingInfo
  10019. */
  10020. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10021. /** Use the given ray to pick a sprite in the scene
  10022. * @param ray The ray (in world space) to use to pick meshes
  10023. * @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
  10024. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  10025. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10026. * @returns a PickingInfo
  10027. */
  10028. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10029. /** @hidden */
  10030. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10031. /** Launch a ray to try to pick sprites in the scene
  10032. * @param x position on screen
  10033. * @param y position on screen
  10034. * @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
  10035. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10036. * @returns a PickingInfo array
  10037. */
  10038. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10039. /** Use the given ray to pick sprites in the scene
  10040. * @param ray The ray (in world space) to use to pick meshes
  10041. * @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
  10042. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10043. * @returns a PickingInfo array
  10044. */
  10045. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10046. /**
  10047. * Force the sprite under the pointer
  10048. * @param sprite defines the sprite to use
  10049. */
  10050. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10051. /**
  10052. * Gets the sprite under the pointer
  10053. * @returns a Sprite or null if no sprite is under the pointer
  10054. */
  10055. getPointerOverSprite(): Nullable<Sprite>;
  10056. }
  10057. }
  10058. /**
  10059. * Defines the sprite scene component responsible to manage sprites
  10060. * in a given scene.
  10061. */
  10062. export class SpriteSceneComponent implements ISceneComponent {
  10063. /**
  10064. * The component name helpfull to identify the component in the list of scene components.
  10065. */
  10066. readonly name: string;
  10067. /**
  10068. * The scene the component belongs to.
  10069. */
  10070. scene: Scene;
  10071. /** @hidden */
  10072. private _spritePredicate;
  10073. /**
  10074. * Creates a new instance of the component for the given scene
  10075. * @param scene Defines the scene to register the component in
  10076. */
  10077. constructor(scene: Scene);
  10078. /**
  10079. * Registers the component in a given scene
  10080. */
  10081. register(): void;
  10082. /**
  10083. * Rebuilds the elements related to this component in case of
  10084. * context lost for instance.
  10085. */
  10086. rebuild(): void;
  10087. /**
  10088. * Disposes the component and the associated ressources.
  10089. */
  10090. dispose(): void;
  10091. private _pickSpriteButKeepRay;
  10092. private _pointerMove;
  10093. private _pointerDown;
  10094. private _pointerUp;
  10095. }
  10096. }
  10097. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10098. /** @hidden */
  10099. export var fogFragmentDeclaration: {
  10100. name: string;
  10101. shader: string;
  10102. };
  10103. }
  10104. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10105. /** @hidden */
  10106. export var fogFragment: {
  10107. name: string;
  10108. shader: string;
  10109. };
  10110. }
  10111. declare module "babylonjs/Shaders/sprites.fragment" {
  10112. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10113. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10114. /** @hidden */
  10115. export var spritesPixelShader: {
  10116. name: string;
  10117. shader: string;
  10118. };
  10119. }
  10120. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10121. /** @hidden */
  10122. export var fogVertexDeclaration: {
  10123. name: string;
  10124. shader: string;
  10125. };
  10126. }
  10127. declare module "babylonjs/Shaders/sprites.vertex" {
  10128. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10129. /** @hidden */
  10130. export var spritesVertexShader: {
  10131. name: string;
  10132. shader: string;
  10133. };
  10134. }
  10135. declare module "babylonjs/Sprites/spriteManager" {
  10136. import { IDisposable, Scene } from "babylonjs/scene";
  10137. import { Nullable } from "babylonjs/types";
  10138. import { Observable } from "babylonjs/Misc/observable";
  10139. import { Sprite } from "babylonjs/Sprites/sprite";
  10140. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10141. import { Camera } from "babylonjs/Cameras/camera";
  10142. import { Texture } from "babylonjs/Materials/Textures/texture";
  10143. import "babylonjs/Shaders/sprites.fragment";
  10144. import "babylonjs/Shaders/sprites.vertex";
  10145. import { Ray } from "babylonjs/Culling/ray";
  10146. /**
  10147. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10148. */
  10149. export interface ISpriteManager extends IDisposable {
  10150. /**
  10151. * Restricts the camera to viewing objects with the same layerMask.
  10152. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10153. */
  10154. layerMask: number;
  10155. /**
  10156. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10157. */
  10158. isPickable: boolean;
  10159. /**
  10160. * Specifies the rendering group id for this mesh (0 by default)
  10161. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10162. */
  10163. renderingGroupId: number;
  10164. /**
  10165. * Defines the list of sprites managed by the manager.
  10166. */
  10167. sprites: Array<Sprite>;
  10168. /**
  10169. * Tests the intersection of a sprite with a specific ray.
  10170. * @param ray The ray we are sending to test the collision
  10171. * @param camera The camera space we are sending rays in
  10172. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10173. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10174. * @returns picking info or null.
  10175. */
  10176. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10177. /**
  10178. * Intersects the sprites with a ray
  10179. * @param ray defines the ray to intersect with
  10180. * @param camera defines the current active camera
  10181. * @param predicate defines a predicate used to select candidate sprites
  10182. * @returns null if no hit or a PickingInfo array
  10183. */
  10184. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10185. /**
  10186. * Renders the list of sprites on screen.
  10187. */
  10188. render(): void;
  10189. }
  10190. /**
  10191. * Class used to manage multiple sprites on the same spritesheet
  10192. * @see http://doc.babylonjs.com/babylon101/sprites
  10193. */
  10194. export class SpriteManager implements ISpriteManager {
  10195. /** defines the manager's name */
  10196. name: string;
  10197. /** Gets the list of sprites */
  10198. sprites: Sprite[];
  10199. /** Gets or sets the rendering group id (0 by default) */
  10200. renderingGroupId: number;
  10201. /** Gets or sets camera layer mask */
  10202. layerMask: number;
  10203. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10204. fogEnabled: boolean;
  10205. /** Gets or sets a boolean indicating if the sprites are pickable */
  10206. isPickable: boolean;
  10207. /** Defines the default width of a cell in the spritesheet */
  10208. cellWidth: number;
  10209. /** Defines the default height of a cell in the spritesheet */
  10210. cellHeight: number;
  10211. /** Associative array from JSON sprite data file */
  10212. private _cellData;
  10213. /** Array of sprite names from JSON sprite data file */
  10214. private _spriteMap;
  10215. /** True when packed cell data from JSON file is ready*/
  10216. private _packedAndReady;
  10217. /**
  10218. * An event triggered when the manager is disposed.
  10219. */
  10220. onDisposeObservable: Observable<SpriteManager>;
  10221. private _onDisposeObserver;
  10222. /**
  10223. * Callback called when the manager is disposed
  10224. */
  10225. set onDispose(callback: () => void);
  10226. private _capacity;
  10227. private _fromPacked;
  10228. private _spriteTexture;
  10229. private _epsilon;
  10230. private _scene;
  10231. private _vertexData;
  10232. private _buffer;
  10233. private _vertexBuffers;
  10234. private _indexBuffer;
  10235. private _effectBase;
  10236. private _effectFog;
  10237. /**
  10238. * Gets or sets the spritesheet texture
  10239. */
  10240. get texture(): Texture;
  10241. set texture(value: Texture);
  10242. private _blendMode;
  10243. /**
  10244. * Blend mode use to render the particle, it can be any of
  10245. * the static Constants.ALPHA_x properties provided in this class.
  10246. * Default value is Constants.ALPHA_COMBINE
  10247. */
  10248. get blendMode(): number;
  10249. set blendMode(blendMode: number);
  10250. /** Disables writing to the depth buffer when rendering the sprites.
  10251. * It can be handy to disable depth writing when using textures without alpha channel
  10252. * and setting some specific blend modes.
  10253. */
  10254. disableDepthWrite: boolean;
  10255. /**
  10256. * Creates a new sprite manager
  10257. * @param name defines the manager's name
  10258. * @param imgUrl defines the sprite sheet url
  10259. * @param capacity defines the maximum allowed number of sprites
  10260. * @param cellSize defines the size of a sprite cell
  10261. * @param scene defines the hosting scene
  10262. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10263. * @param samplingMode defines the smapling mode to use with spritesheet
  10264. * @param fromPacked set to false; do not alter
  10265. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10266. */
  10267. constructor(
  10268. /** defines the manager's name */
  10269. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10270. private _makePacked;
  10271. private _appendSpriteVertex;
  10272. /**
  10273. * Intersects the sprites with a ray
  10274. * @param ray defines the ray to intersect with
  10275. * @param camera defines the current active camera
  10276. * @param predicate defines a predicate used to select candidate sprites
  10277. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10278. * @returns null if no hit or a PickingInfo
  10279. */
  10280. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10281. /**
  10282. * Intersects the sprites with a ray
  10283. * @param ray defines the ray to intersect with
  10284. * @param camera defines the current active camera
  10285. * @param predicate defines a predicate used to select candidate sprites
  10286. * @returns null if no hit or a PickingInfo array
  10287. */
  10288. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10289. /**
  10290. * Render all child sprites
  10291. */
  10292. render(): void;
  10293. /**
  10294. * Release associated resources
  10295. */
  10296. dispose(): void;
  10297. }
  10298. }
  10299. declare module "babylonjs/Misc/gradients" {
  10300. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10301. /** Interface used by value gradients (color, factor, ...) */
  10302. export interface IValueGradient {
  10303. /**
  10304. * Gets or sets the gradient value (between 0 and 1)
  10305. */
  10306. gradient: number;
  10307. }
  10308. /** Class used to store color4 gradient */
  10309. export class ColorGradient implements IValueGradient {
  10310. /**
  10311. * Gets or sets the gradient value (between 0 and 1)
  10312. */
  10313. gradient: number;
  10314. /**
  10315. * Gets or sets first associated color
  10316. */
  10317. color1: Color4;
  10318. /**
  10319. * Gets or sets second associated color
  10320. */
  10321. color2?: Color4 | undefined;
  10322. /**
  10323. * Creates a new color4 gradient
  10324. * @param gradient gets or sets the gradient value (between 0 and 1)
  10325. * @param color1 gets or sets first associated color
  10326. * @param color2 gets or sets first second color
  10327. */
  10328. constructor(
  10329. /**
  10330. * Gets or sets the gradient value (between 0 and 1)
  10331. */
  10332. gradient: number,
  10333. /**
  10334. * Gets or sets first associated color
  10335. */
  10336. color1: Color4,
  10337. /**
  10338. * Gets or sets second associated color
  10339. */
  10340. color2?: Color4 | undefined);
  10341. /**
  10342. * Will get a color picked randomly between color1 and color2.
  10343. * If color2 is undefined then color1 will be used
  10344. * @param result defines the target Color4 to store the result in
  10345. */
  10346. getColorToRef(result: Color4): void;
  10347. }
  10348. /** Class used to store color 3 gradient */
  10349. export class Color3Gradient implements IValueGradient {
  10350. /**
  10351. * Gets or sets the gradient value (between 0 and 1)
  10352. */
  10353. gradient: number;
  10354. /**
  10355. * Gets or sets the associated color
  10356. */
  10357. color: Color3;
  10358. /**
  10359. * Creates a new color3 gradient
  10360. * @param gradient gets or sets the gradient value (between 0 and 1)
  10361. * @param color gets or sets associated color
  10362. */
  10363. constructor(
  10364. /**
  10365. * Gets or sets the gradient value (between 0 and 1)
  10366. */
  10367. gradient: number,
  10368. /**
  10369. * Gets or sets the associated color
  10370. */
  10371. color: Color3);
  10372. }
  10373. /** Class used to store factor gradient */
  10374. export class FactorGradient implements IValueGradient {
  10375. /**
  10376. * Gets or sets the gradient value (between 0 and 1)
  10377. */
  10378. gradient: number;
  10379. /**
  10380. * Gets or sets first associated factor
  10381. */
  10382. factor1: number;
  10383. /**
  10384. * Gets or sets second associated factor
  10385. */
  10386. factor2?: number | undefined;
  10387. /**
  10388. * Creates a new factor gradient
  10389. * @param gradient gets or sets the gradient value (between 0 and 1)
  10390. * @param factor1 gets or sets first associated factor
  10391. * @param factor2 gets or sets second associated factor
  10392. */
  10393. constructor(
  10394. /**
  10395. * Gets or sets the gradient value (between 0 and 1)
  10396. */
  10397. gradient: number,
  10398. /**
  10399. * Gets or sets first associated factor
  10400. */
  10401. factor1: number,
  10402. /**
  10403. * Gets or sets second associated factor
  10404. */
  10405. factor2?: number | undefined);
  10406. /**
  10407. * Will get a number picked randomly between factor1 and factor2.
  10408. * If factor2 is undefined then factor1 will be used
  10409. * @returns the picked number
  10410. */
  10411. getFactor(): number;
  10412. }
  10413. /**
  10414. * Helper used to simplify some generic gradient tasks
  10415. */
  10416. export class GradientHelper {
  10417. /**
  10418. * Gets the current gradient from an array of IValueGradient
  10419. * @param ratio defines the current ratio to get
  10420. * @param gradients defines the array of IValueGradient
  10421. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10422. */
  10423. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10424. }
  10425. }
  10426. declare module "babylonjs/Maths/math.size" {
  10427. /**
  10428. * Interface for the size containing width and height
  10429. */
  10430. export interface ISize {
  10431. /**
  10432. * Width
  10433. */
  10434. width: number;
  10435. /**
  10436. * Heighht
  10437. */
  10438. height: number;
  10439. }
  10440. /**
  10441. * Size containing widht and height
  10442. */
  10443. export class Size implements ISize {
  10444. /**
  10445. * Width
  10446. */
  10447. width: number;
  10448. /**
  10449. * Height
  10450. */
  10451. height: number;
  10452. /**
  10453. * Creates a Size object from the given width and height (floats).
  10454. * @param width width of the new size
  10455. * @param height height of the new size
  10456. */
  10457. constructor(width: number, height: number);
  10458. /**
  10459. * Returns a string with the Size width and height
  10460. * @returns a string with the Size width and height
  10461. */
  10462. toString(): string;
  10463. /**
  10464. * "Size"
  10465. * @returns the string "Size"
  10466. */
  10467. getClassName(): string;
  10468. /**
  10469. * Returns the Size hash code.
  10470. * @returns a hash code for a unique width and height
  10471. */
  10472. getHashCode(): number;
  10473. /**
  10474. * Updates the current size from the given one.
  10475. * @param src the given size
  10476. */
  10477. copyFrom(src: Size): void;
  10478. /**
  10479. * Updates in place the current Size from the given floats.
  10480. * @param width width of the new size
  10481. * @param height height of the new size
  10482. * @returns the updated Size.
  10483. */
  10484. copyFromFloats(width: number, height: number): Size;
  10485. /**
  10486. * Updates in place the current Size from the given floats.
  10487. * @param width width to set
  10488. * @param height height to set
  10489. * @returns the updated Size.
  10490. */
  10491. set(width: number, height: number): Size;
  10492. /**
  10493. * Multiplies the width and height by numbers
  10494. * @param w factor to multiple the width by
  10495. * @param h factor to multiple the height by
  10496. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10497. */
  10498. multiplyByFloats(w: number, h: number): Size;
  10499. /**
  10500. * Clones the size
  10501. * @returns a new Size copied from the given one.
  10502. */
  10503. clone(): Size;
  10504. /**
  10505. * True if the current Size and the given one width and height are strictly equal.
  10506. * @param other the other size to compare against
  10507. * @returns True if the current Size and the given one width and height are strictly equal.
  10508. */
  10509. equals(other: Size): boolean;
  10510. /**
  10511. * The surface of the Size : width * height (float).
  10512. */
  10513. get surface(): number;
  10514. /**
  10515. * Create a new size of zero
  10516. * @returns a new Size set to (0.0, 0.0)
  10517. */
  10518. static Zero(): Size;
  10519. /**
  10520. * Sums the width and height of two sizes
  10521. * @param otherSize size to add to this size
  10522. * @returns a new Size set as the addition result of the current Size and the given one.
  10523. */
  10524. add(otherSize: Size): Size;
  10525. /**
  10526. * Subtracts the width and height of two
  10527. * @param otherSize size to subtract to this size
  10528. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10529. */
  10530. subtract(otherSize: Size): Size;
  10531. /**
  10532. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10533. * @param start starting size to lerp between
  10534. * @param end end size to lerp between
  10535. * @param amount amount to lerp between the start and end values
  10536. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10537. */
  10538. static Lerp(start: Size, end: Size, amount: number): Size;
  10539. }
  10540. }
  10541. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10543. import { Nullable } from "babylonjs/types";
  10544. module "babylonjs/Engines/thinEngine" {
  10545. interface ThinEngine {
  10546. /**
  10547. * Creates a dynamic texture
  10548. * @param width defines the width of the texture
  10549. * @param height defines the height of the texture
  10550. * @param generateMipMaps defines if the engine should generate the mip levels
  10551. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10552. * @returns the dynamic texture inside an InternalTexture
  10553. */
  10554. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10555. /**
  10556. * Update the content of a dynamic texture
  10557. * @param texture defines the texture to update
  10558. * @param canvas defines the canvas containing the source
  10559. * @param invertY defines if data must be stored with Y axis inverted
  10560. * @param premulAlpha defines if alpha is stored as premultiplied
  10561. * @param format defines the format of the data
  10562. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10563. */
  10564. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10565. }
  10566. }
  10567. }
  10568. declare module "babylonjs/Misc/canvasGenerator" {
  10569. /**
  10570. * Helper class used to generate a canvas to manipulate images
  10571. */
  10572. export class CanvasGenerator {
  10573. /**
  10574. * Create a new canvas (or offscreen canvas depending on the context)
  10575. * @param width defines the expected width
  10576. * @param height defines the expected height
  10577. * @return a new canvas or offscreen canvas
  10578. */
  10579. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10580. }
  10581. }
  10582. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10583. import { Scene } from "babylonjs/scene";
  10584. import { Texture } from "babylonjs/Materials/Textures/texture";
  10585. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10586. /**
  10587. * A class extending Texture allowing drawing on a texture
  10588. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10589. */
  10590. export class DynamicTexture extends Texture {
  10591. private _generateMipMaps;
  10592. private _canvas;
  10593. private _context;
  10594. private _engine;
  10595. /**
  10596. * Creates a DynamicTexture
  10597. * @param name defines the name of the texture
  10598. * @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
  10599. * @param scene defines the scene where you want the texture
  10600. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10601. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10602. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10603. */
  10604. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10605. /**
  10606. * Get the current class name of the texture useful for serialization or dynamic coding.
  10607. * @returns "DynamicTexture"
  10608. */
  10609. getClassName(): string;
  10610. /**
  10611. * Gets the current state of canRescale
  10612. */
  10613. get canRescale(): boolean;
  10614. private _recreate;
  10615. /**
  10616. * Scales the texture
  10617. * @param ratio the scale factor to apply to both width and height
  10618. */
  10619. scale(ratio: number): void;
  10620. /**
  10621. * Resizes the texture
  10622. * @param width the new width
  10623. * @param height the new height
  10624. */
  10625. scaleTo(width: number, height: number): void;
  10626. /**
  10627. * Gets the context of the canvas used by the texture
  10628. * @returns the canvas context of the dynamic texture
  10629. */
  10630. getContext(): CanvasRenderingContext2D;
  10631. /**
  10632. * Clears the texture
  10633. */
  10634. clear(): void;
  10635. /**
  10636. * Updates the texture
  10637. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10638. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10639. */
  10640. update(invertY?: boolean, premulAlpha?: boolean): void;
  10641. /**
  10642. * Draws text onto the texture
  10643. * @param text defines the text to be drawn
  10644. * @param x defines the placement of the text from the left
  10645. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10646. * @param font defines the font to be used with font-style, font-size, font-name
  10647. * @param color defines the color used for the text
  10648. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10649. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10650. * @param update defines whether texture is immediately update (default is true)
  10651. */
  10652. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10653. /**
  10654. * Clones the texture
  10655. * @returns the clone of the texture.
  10656. */
  10657. clone(): DynamicTexture;
  10658. /**
  10659. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10660. * @returns a serialized dynamic texture object
  10661. */
  10662. serialize(): any;
  10663. /** @hidden */
  10664. _rebuild(): void;
  10665. }
  10666. }
  10667. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10668. import { Nullable } from "babylonjs/types";
  10669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10670. import { Scene } from "babylonjs/scene";
  10671. module "babylonjs/Engines/engine" {
  10672. interface Engine {
  10673. /**
  10674. * Creates a raw texture
  10675. * @param data defines the data to store in the texture
  10676. * @param width defines the width of the texture
  10677. * @param height defines the height of the texture
  10678. * @param format defines the format of the data
  10679. * @param generateMipMaps defines if the engine should generate the mip levels
  10680. * @param invertY defines if data must be stored with Y axis inverted
  10681. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10682. * @param compression defines the compression used (null by default)
  10683. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10684. * @returns the raw texture inside an InternalTexture
  10685. */
  10686. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10687. /**
  10688. * Update a raw texture
  10689. * @param texture defines the texture to update
  10690. * @param data defines the data to store in the texture
  10691. * @param format defines the format of the data
  10692. * @param invertY defines if data must be stored with Y axis inverted
  10693. */
  10694. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10695. /**
  10696. * Update a raw texture
  10697. * @param texture defines the texture to update
  10698. * @param data defines the data to store in the texture
  10699. * @param format defines the format of the data
  10700. * @param invertY defines if data must be stored with Y axis inverted
  10701. * @param compression defines the compression used (null by default)
  10702. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10703. */
  10704. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10705. /**
  10706. * Creates a new raw cube texture
  10707. * @param data defines the array of data to use to create each face
  10708. * @param size defines the size of the textures
  10709. * @param format defines the format of the data
  10710. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10711. * @param generateMipMaps defines if the engine should generate the mip levels
  10712. * @param invertY defines if data must be stored with Y axis inverted
  10713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10714. * @param compression defines the compression used (null by default)
  10715. * @returns the cube texture as an InternalTexture
  10716. */
  10717. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10718. /**
  10719. * Update a raw cube texture
  10720. * @param texture defines the texture to udpdate
  10721. * @param data defines the data to store
  10722. * @param format defines the data format
  10723. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10724. * @param invertY defines if data must be stored with Y axis inverted
  10725. */
  10726. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10727. /**
  10728. * Update a raw cube texture
  10729. * @param texture defines the texture to udpdate
  10730. * @param data defines the data to store
  10731. * @param format defines the data format
  10732. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10733. * @param invertY defines if data must be stored with Y axis inverted
  10734. * @param compression defines the compression used (null by default)
  10735. */
  10736. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10737. /**
  10738. * Update a raw cube texture
  10739. * @param texture defines the texture to udpdate
  10740. * @param data defines the data to store
  10741. * @param format defines the data format
  10742. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10743. * @param invertY defines if data must be stored with Y axis inverted
  10744. * @param compression defines the compression used (null by default)
  10745. * @param level defines which level of the texture to update
  10746. */
  10747. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10748. /**
  10749. * Creates a new raw cube texture from a specified url
  10750. * @param url defines the url where the data is located
  10751. * @param scene defines the current scene
  10752. * @param size defines the size of the textures
  10753. * @param format defines the format of the data
  10754. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10755. * @param noMipmap defines if the engine should avoid generating the mip levels
  10756. * @param callback defines a callback used to extract texture data from loaded data
  10757. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10758. * @param onLoad defines a callback called when texture is loaded
  10759. * @param onError defines a callback called if there is an error
  10760. * @returns the cube texture as an InternalTexture
  10761. */
  10762. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10763. /**
  10764. * Creates a new raw cube texture from a specified url
  10765. * @param url defines the url where the data is located
  10766. * @param scene defines the current scene
  10767. * @param size defines the size of the textures
  10768. * @param format defines the format of the data
  10769. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10770. * @param noMipmap defines if the engine should avoid generating the mip levels
  10771. * @param callback defines a callback used to extract texture data from loaded data
  10772. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10773. * @param onLoad defines a callback called when texture is loaded
  10774. * @param onError defines a callback called if there is an error
  10775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10776. * @param invertY defines if data must be stored with Y axis inverted
  10777. * @returns the cube texture as an InternalTexture
  10778. */
  10779. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10780. /**
  10781. * Creates a new raw 3D texture
  10782. * @param data defines the data used to create the texture
  10783. * @param width defines the width of the texture
  10784. * @param height defines the height of the texture
  10785. * @param depth defines the depth of the texture
  10786. * @param format defines the format of the texture
  10787. * @param generateMipMaps defines if the engine must generate mip levels
  10788. * @param invertY defines if data must be stored with Y axis inverted
  10789. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10790. * @param compression defines the compressed used (can be null)
  10791. * @param textureType defines the compressed used (can be null)
  10792. * @returns a new raw 3D texture (stored in an InternalTexture)
  10793. */
  10794. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10795. /**
  10796. * Update a raw 3D texture
  10797. * @param texture defines the texture to update
  10798. * @param data defines the data to store
  10799. * @param format defines the data format
  10800. * @param invertY defines if data must be stored with Y axis inverted
  10801. */
  10802. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10803. /**
  10804. * Update a raw 3D texture
  10805. * @param texture defines the texture to update
  10806. * @param data defines the data to store
  10807. * @param format defines the data format
  10808. * @param invertY defines if data must be stored with Y axis inverted
  10809. * @param compression defines the used compression (can be null)
  10810. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10811. */
  10812. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10813. /**
  10814. * Creates a new raw 2D array texture
  10815. * @param data defines the data used to create the texture
  10816. * @param width defines the width of the texture
  10817. * @param height defines the height of the texture
  10818. * @param depth defines the number of layers of the texture
  10819. * @param format defines the format of the texture
  10820. * @param generateMipMaps defines if the engine must generate mip levels
  10821. * @param invertY defines if data must be stored with Y axis inverted
  10822. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10823. * @param compression defines the compressed used (can be null)
  10824. * @param textureType defines the compressed used (can be null)
  10825. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10826. */
  10827. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10828. /**
  10829. * Update a raw 2D array texture
  10830. * @param texture defines the texture to update
  10831. * @param data defines the data to store
  10832. * @param format defines the data format
  10833. * @param invertY defines if data must be stored with Y axis inverted
  10834. */
  10835. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10836. /**
  10837. * Update a raw 2D array texture
  10838. * @param texture defines the texture to update
  10839. * @param data defines the data to store
  10840. * @param format defines the data format
  10841. * @param invertY defines if data must be stored with Y axis inverted
  10842. * @param compression defines the used compression (can be null)
  10843. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10844. */
  10845. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10846. }
  10847. }
  10848. }
  10849. declare module "babylonjs/Materials/Textures/rawTexture" {
  10850. import { Scene } from "babylonjs/scene";
  10851. import { Texture } from "babylonjs/Materials/Textures/texture";
  10852. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10853. /**
  10854. * Raw texture can help creating a texture directly from an array of data.
  10855. * This can be super useful if you either get the data from an uncompressed source or
  10856. * if you wish to create your texture pixel by pixel.
  10857. */
  10858. export class RawTexture extends Texture {
  10859. /**
  10860. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10861. */
  10862. format: number;
  10863. private _engine;
  10864. /**
  10865. * Instantiates a new RawTexture.
  10866. * Raw texture can help creating a texture directly from an array of data.
  10867. * This can be super useful if you either get the data from an uncompressed source or
  10868. * if you wish to create your texture pixel by pixel.
  10869. * @param data define the array of data to use to create the texture
  10870. * @param width define the width of the texture
  10871. * @param height define the height of the texture
  10872. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10873. * @param scene define the scene the texture belongs to
  10874. * @param generateMipMaps define whether mip maps should be generated or not
  10875. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10876. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10877. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10878. */
  10879. constructor(data: ArrayBufferView, width: number, height: number,
  10880. /**
  10881. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10882. */
  10883. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10884. /**
  10885. * Updates the texture underlying data.
  10886. * @param data Define the new data of the texture
  10887. */
  10888. update(data: ArrayBufferView): void;
  10889. /**
  10890. * Creates a luminance texture from some data.
  10891. * @param data Define the texture data
  10892. * @param width Define the width of the texture
  10893. * @param height Define the height of the texture
  10894. * @param scene Define the scene the texture belongs to
  10895. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10896. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10897. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10898. * @returns the luminance texture
  10899. */
  10900. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10901. /**
  10902. * Creates a luminance alpha texture from some data.
  10903. * @param data Define the texture data
  10904. * @param width Define the width of the texture
  10905. * @param height Define the height of the texture
  10906. * @param scene Define the scene the texture belongs to
  10907. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10908. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10909. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10910. * @returns the luminance alpha texture
  10911. */
  10912. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10913. /**
  10914. * Creates an alpha texture from some data.
  10915. * @param data Define the texture data
  10916. * @param width Define the width of the texture
  10917. * @param height Define the height of the texture
  10918. * @param scene Define the scene the texture belongs to
  10919. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10922. * @returns the alpha texture
  10923. */
  10924. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10925. /**
  10926. * Creates a RGB texture from some data.
  10927. * @param data Define the texture data
  10928. * @param width Define the width of the texture
  10929. * @param height Define the height of the texture
  10930. * @param scene Define the scene the texture belongs to
  10931. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10932. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10933. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10934. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10935. * @returns the RGB alpha texture
  10936. */
  10937. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10938. /**
  10939. * Creates a RGBA texture from some data.
  10940. * @param data Define the texture data
  10941. * @param width Define the width of the texture
  10942. * @param height Define the height of the texture
  10943. * @param scene Define the scene the texture belongs to
  10944. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10945. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10946. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10947. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10948. * @returns the RGBA texture
  10949. */
  10950. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10951. /**
  10952. * Creates a R texture from some data.
  10953. * @param data Define the texture data
  10954. * @param width Define the width of the texture
  10955. * @param height Define the height of the texture
  10956. * @param scene Define the scene the texture belongs to
  10957. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10958. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10959. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10960. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10961. * @returns the R texture
  10962. */
  10963. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10964. }
  10965. }
  10966. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10967. import { Scene } from "babylonjs/scene";
  10968. import { ISceneComponent } from "babylonjs/sceneComponent";
  10969. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10970. module "babylonjs/abstractScene" {
  10971. interface AbstractScene {
  10972. /**
  10973. * The list of procedural textures added to the scene
  10974. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10975. */
  10976. proceduralTextures: Array<ProceduralTexture>;
  10977. }
  10978. }
  10979. /**
  10980. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10981. * in a given scene.
  10982. */
  10983. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10984. /**
  10985. * The component name helpfull to identify the component in the list of scene components.
  10986. */
  10987. readonly name: string;
  10988. /**
  10989. * The scene the component belongs to.
  10990. */
  10991. scene: Scene;
  10992. /**
  10993. * Creates a new instance of the component for the given scene
  10994. * @param scene Defines the scene to register the component in
  10995. */
  10996. constructor(scene: Scene);
  10997. /**
  10998. * Registers the component in a given scene
  10999. */
  11000. register(): void;
  11001. /**
  11002. * Rebuilds the elements related to this component in case of
  11003. * context lost for instance.
  11004. */
  11005. rebuild(): void;
  11006. /**
  11007. * Disposes the component and the associated ressources.
  11008. */
  11009. dispose(): void;
  11010. private _beforeClear;
  11011. }
  11012. }
  11013. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11014. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11015. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11016. module "babylonjs/Engines/thinEngine" {
  11017. interface ThinEngine {
  11018. /**
  11019. * Creates a new render target cube texture
  11020. * @param size defines the size of the texture
  11021. * @param options defines the options used to create the texture
  11022. * @returns a new render target cube texture stored in an InternalTexture
  11023. */
  11024. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11025. }
  11026. }
  11027. }
  11028. declare module "babylonjs/Shaders/procedural.vertex" {
  11029. /** @hidden */
  11030. export var proceduralVertexShader: {
  11031. name: string;
  11032. shader: string;
  11033. };
  11034. }
  11035. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11036. import { Observable } from "babylonjs/Misc/observable";
  11037. import { Nullable } from "babylonjs/types";
  11038. import { Scene } from "babylonjs/scene";
  11039. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11040. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11041. import { Effect } from "babylonjs/Materials/effect";
  11042. import { Texture } from "babylonjs/Materials/Textures/texture";
  11043. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11044. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11045. import "babylonjs/Shaders/procedural.vertex";
  11046. /**
  11047. * 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.
  11048. * This is the base class of any Procedural texture and contains most of the shareable code.
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11050. */
  11051. export class ProceduralTexture extends Texture {
  11052. isCube: boolean;
  11053. /**
  11054. * Define if the texture is enabled or not (disabled texture will not render)
  11055. */
  11056. isEnabled: boolean;
  11057. /**
  11058. * Define if the texture must be cleared before rendering (default is true)
  11059. */
  11060. autoClear: boolean;
  11061. /**
  11062. * Callback called when the texture is generated
  11063. */
  11064. onGenerated: () => void;
  11065. /**
  11066. * Event raised when the texture is generated
  11067. */
  11068. onGeneratedObservable: Observable<ProceduralTexture>;
  11069. /** @hidden */
  11070. _generateMipMaps: boolean;
  11071. /** @hidden **/
  11072. _effect: Effect;
  11073. /** @hidden */
  11074. _textures: {
  11075. [key: string]: Texture;
  11076. };
  11077. /** @hidden */
  11078. protected _fallbackTexture: Nullable<Texture>;
  11079. private _size;
  11080. private _currentRefreshId;
  11081. private _frameId;
  11082. private _refreshRate;
  11083. private _vertexBuffers;
  11084. private _indexBuffer;
  11085. private _uniforms;
  11086. private _samplers;
  11087. private _fragment;
  11088. private _floats;
  11089. private _ints;
  11090. private _floatsArrays;
  11091. private _colors3;
  11092. private _colors4;
  11093. private _vectors2;
  11094. private _vectors3;
  11095. private _matrices;
  11096. private _fallbackTextureUsed;
  11097. private _engine;
  11098. private _cachedDefines;
  11099. private _contentUpdateId;
  11100. private _contentData;
  11101. /**
  11102. * Instantiates a new procedural texture.
  11103. * 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.
  11104. * This is the base class of any Procedural texture and contains most of the shareable code.
  11105. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11106. * @param name Define the name of the texture
  11107. * @param size Define the size of the texture to create
  11108. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11109. * @param scene Define the scene the texture belongs to
  11110. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11111. * @param generateMipMaps Define if the texture should creates mip maps or not
  11112. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11113. */
  11114. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11115. /**
  11116. * The effect that is created when initializing the post process.
  11117. * @returns The created effect corresponding the the postprocess.
  11118. */
  11119. getEffect(): Effect;
  11120. /**
  11121. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11122. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11123. */
  11124. getContent(): Nullable<ArrayBufferView>;
  11125. private _createIndexBuffer;
  11126. /** @hidden */
  11127. _rebuild(): void;
  11128. /**
  11129. * Resets the texture in order to recreate its associated resources.
  11130. * This can be called in case of context loss
  11131. */
  11132. reset(): void;
  11133. protected _getDefines(): string;
  11134. /**
  11135. * Is the texture ready to be used ? (rendered at least once)
  11136. * @returns true if ready, otherwise, false.
  11137. */
  11138. isReady(): boolean;
  11139. /**
  11140. * Resets the refresh counter of the texture and start bak from scratch.
  11141. * Could be useful to regenerate the texture if it is setup to render only once.
  11142. */
  11143. resetRefreshCounter(): void;
  11144. /**
  11145. * Set the fragment shader to use in order to render the texture.
  11146. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11147. */
  11148. setFragment(fragment: any): void;
  11149. /**
  11150. * Define the refresh rate of the texture or the rendering frequency.
  11151. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11152. */
  11153. get refreshRate(): number;
  11154. set refreshRate(value: number);
  11155. /** @hidden */
  11156. _shouldRender(): boolean;
  11157. /**
  11158. * Get the size the texture is rendering at.
  11159. * @returns the size (texture is always squared)
  11160. */
  11161. getRenderSize(): number;
  11162. /**
  11163. * Resize the texture to new value.
  11164. * @param size Define the new size the texture should have
  11165. * @param generateMipMaps Define whether the new texture should create mip maps
  11166. */
  11167. resize(size: number, generateMipMaps: boolean): void;
  11168. private _checkUniform;
  11169. /**
  11170. * Set a texture in the shader program used to render.
  11171. * @param name Define the name of the uniform samplers as defined in the shader
  11172. * @param texture Define the texture to bind to this sampler
  11173. * @return the texture itself allowing "fluent" like uniform updates
  11174. */
  11175. setTexture(name: string, texture: Texture): ProceduralTexture;
  11176. /**
  11177. * Set a float in the shader.
  11178. * @param name Define the name of the uniform as defined in the shader
  11179. * @param value Define the value to give to the uniform
  11180. * @return the texture itself allowing "fluent" like uniform updates
  11181. */
  11182. setFloat(name: string, value: number): ProceduralTexture;
  11183. /**
  11184. * Set a int in the shader.
  11185. * @param name Define the name of the uniform as defined in the shader
  11186. * @param value Define the value to give to the uniform
  11187. * @return the texture itself allowing "fluent" like uniform updates
  11188. */
  11189. setInt(name: string, value: number): ProceduralTexture;
  11190. /**
  11191. * Set an array of floats in the shader.
  11192. * @param name Define the name of the uniform as defined in the shader
  11193. * @param value Define the value to give to the uniform
  11194. * @return the texture itself allowing "fluent" like uniform updates
  11195. */
  11196. setFloats(name: string, value: number[]): ProceduralTexture;
  11197. /**
  11198. * Set a vec3 in the shader from a Color3.
  11199. * @param name Define the name of the uniform as defined in the shader
  11200. * @param value Define the value to give to the uniform
  11201. * @return the texture itself allowing "fluent" like uniform updates
  11202. */
  11203. setColor3(name: string, value: Color3): ProceduralTexture;
  11204. /**
  11205. * Set a vec4 in the shader from a Color4.
  11206. * @param name Define the name of the uniform as defined in the shader
  11207. * @param value Define the value to give to the uniform
  11208. * @return the texture itself allowing "fluent" like uniform updates
  11209. */
  11210. setColor4(name: string, value: Color4): ProceduralTexture;
  11211. /**
  11212. * Set a vec2 in the shader from a Vector2.
  11213. * @param name Define the name of the uniform as defined in the shader
  11214. * @param value Define the value to give to the uniform
  11215. * @return the texture itself allowing "fluent" like uniform updates
  11216. */
  11217. setVector2(name: string, value: Vector2): ProceduralTexture;
  11218. /**
  11219. * Set a vec3 in the shader from a Vector3.
  11220. * @param name Define the name of the uniform as defined in the shader
  11221. * @param value Define the value to give to the uniform
  11222. * @return the texture itself allowing "fluent" like uniform updates
  11223. */
  11224. setVector3(name: string, value: Vector3): ProceduralTexture;
  11225. /**
  11226. * Set a mat4 in the shader from a MAtrix.
  11227. * @param name Define the name of the uniform as defined in the shader
  11228. * @param value Define the value to give to the uniform
  11229. * @return the texture itself allowing "fluent" like uniform updates
  11230. */
  11231. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11232. /**
  11233. * Render the texture to its associated render target.
  11234. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11235. */
  11236. render(useCameraPostProcess?: boolean): void;
  11237. /**
  11238. * Clone the texture.
  11239. * @returns the cloned texture
  11240. */
  11241. clone(): ProceduralTexture;
  11242. /**
  11243. * Dispose the texture and release its asoociated resources.
  11244. */
  11245. dispose(): void;
  11246. }
  11247. }
  11248. declare module "babylonjs/Particles/baseParticleSystem" {
  11249. import { Nullable } from "babylonjs/types";
  11250. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11252. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11253. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11254. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11255. import { Scene } from "babylonjs/scene";
  11256. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11257. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11258. import { Texture } from "babylonjs/Materials/Textures/texture";
  11259. import { Color4 } from "babylonjs/Maths/math.color";
  11260. import { Animation } from "babylonjs/Animations/animation";
  11261. /**
  11262. * This represents the base class for particle system in Babylon.
  11263. * 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.
  11264. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11265. * @example https://doc.babylonjs.com/babylon101/particles
  11266. */
  11267. export class BaseParticleSystem {
  11268. /**
  11269. * Source color is added to the destination color without alpha affecting the result
  11270. */
  11271. static BLENDMODE_ONEONE: number;
  11272. /**
  11273. * Blend current color and particle color using particle’s alpha
  11274. */
  11275. static BLENDMODE_STANDARD: number;
  11276. /**
  11277. * Add current color and particle color multiplied by particle’s alpha
  11278. */
  11279. static BLENDMODE_ADD: number;
  11280. /**
  11281. * Multiply current color with particle color
  11282. */
  11283. static BLENDMODE_MULTIPLY: number;
  11284. /**
  11285. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11286. */
  11287. static BLENDMODE_MULTIPLYADD: number;
  11288. /**
  11289. * List of animations used by the particle system.
  11290. */
  11291. animations: Animation[];
  11292. /**
  11293. * Gets or sets the unique id of the particle system
  11294. */
  11295. uniqueId: number;
  11296. /**
  11297. * The id of the Particle system.
  11298. */
  11299. id: string;
  11300. /**
  11301. * The friendly name of the Particle system.
  11302. */
  11303. name: string;
  11304. /**
  11305. * Snippet ID if the particle system was created from the snippet server
  11306. */
  11307. snippetId: string;
  11308. /**
  11309. * The rendering group used by the Particle system to chose when to render.
  11310. */
  11311. renderingGroupId: number;
  11312. /**
  11313. * The emitter represents the Mesh or position we are attaching the particle system to.
  11314. */
  11315. emitter: Nullable<AbstractMesh | Vector3>;
  11316. /**
  11317. * The maximum number of particles to emit per frame
  11318. */
  11319. emitRate: number;
  11320. /**
  11321. * If you want to launch only a few particles at once, that can be done, as well.
  11322. */
  11323. manualEmitCount: number;
  11324. /**
  11325. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11326. */
  11327. updateSpeed: number;
  11328. /**
  11329. * The amount of time the particle system is running (depends of the overall update speed).
  11330. */
  11331. targetStopDuration: number;
  11332. /**
  11333. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11334. */
  11335. disposeOnStop: boolean;
  11336. /**
  11337. * Minimum power of emitting particles.
  11338. */
  11339. minEmitPower: number;
  11340. /**
  11341. * Maximum power of emitting particles.
  11342. */
  11343. maxEmitPower: number;
  11344. /**
  11345. * Minimum life time of emitting particles.
  11346. */
  11347. minLifeTime: number;
  11348. /**
  11349. * Maximum life time of emitting particles.
  11350. */
  11351. maxLifeTime: number;
  11352. /**
  11353. * Minimum Size of emitting particles.
  11354. */
  11355. minSize: number;
  11356. /**
  11357. * Maximum Size of emitting particles.
  11358. */
  11359. maxSize: number;
  11360. /**
  11361. * Minimum scale of emitting particles on X axis.
  11362. */
  11363. minScaleX: number;
  11364. /**
  11365. * Maximum scale of emitting particles on X axis.
  11366. */
  11367. maxScaleX: number;
  11368. /**
  11369. * Minimum scale of emitting particles on Y axis.
  11370. */
  11371. minScaleY: number;
  11372. /**
  11373. * Maximum scale of emitting particles on Y axis.
  11374. */
  11375. maxScaleY: number;
  11376. /**
  11377. * Gets or sets the minimal initial rotation in radians.
  11378. */
  11379. minInitialRotation: number;
  11380. /**
  11381. * Gets or sets the maximal initial rotation in radians.
  11382. */
  11383. maxInitialRotation: number;
  11384. /**
  11385. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11386. */
  11387. minAngularSpeed: number;
  11388. /**
  11389. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11390. */
  11391. maxAngularSpeed: number;
  11392. /**
  11393. * The texture used to render each particle. (this can be a spritesheet)
  11394. */
  11395. particleTexture: Nullable<Texture>;
  11396. /**
  11397. * The layer mask we are rendering the particles through.
  11398. */
  11399. layerMask: number;
  11400. /**
  11401. * This can help using your own shader to render the particle system.
  11402. * The according effect will be created
  11403. */
  11404. customShader: any;
  11405. /**
  11406. * By default particle system starts as soon as they are created. This prevents the
  11407. * automatic start to happen and let you decide when to start emitting particles.
  11408. */
  11409. preventAutoStart: boolean;
  11410. private _noiseTexture;
  11411. /**
  11412. * Gets or sets a texture used to add random noise to particle positions
  11413. */
  11414. get noiseTexture(): Nullable<ProceduralTexture>;
  11415. set noiseTexture(value: Nullable<ProceduralTexture>);
  11416. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11417. noiseStrength: Vector3;
  11418. /**
  11419. * Callback triggered when the particle animation is ending.
  11420. */
  11421. onAnimationEnd: Nullable<() => void>;
  11422. /**
  11423. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11424. */
  11425. blendMode: number;
  11426. /**
  11427. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11428. * to override the particles.
  11429. */
  11430. forceDepthWrite: boolean;
  11431. /** 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 */
  11432. preWarmCycles: number;
  11433. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11434. preWarmStepOffset: number;
  11435. /**
  11436. * 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)
  11437. */
  11438. spriteCellChangeSpeed: number;
  11439. /**
  11440. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11441. */
  11442. startSpriteCellID: number;
  11443. /**
  11444. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11445. */
  11446. endSpriteCellID: number;
  11447. /**
  11448. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11449. */
  11450. spriteCellWidth: number;
  11451. /**
  11452. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11453. */
  11454. spriteCellHeight: number;
  11455. /**
  11456. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11457. */
  11458. spriteRandomStartCell: boolean;
  11459. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11460. translationPivot: Vector2;
  11461. /** @hidden */
  11462. protected _isAnimationSheetEnabled: boolean;
  11463. /**
  11464. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11465. */
  11466. beginAnimationOnStart: boolean;
  11467. /**
  11468. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11469. */
  11470. beginAnimationFrom: number;
  11471. /**
  11472. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11473. */
  11474. beginAnimationTo: number;
  11475. /**
  11476. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11477. */
  11478. beginAnimationLoop: boolean;
  11479. /**
  11480. * Gets or sets a world offset applied to all particles
  11481. */
  11482. worldOffset: Vector3;
  11483. /**
  11484. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11485. */
  11486. get isAnimationSheetEnabled(): boolean;
  11487. set isAnimationSheetEnabled(value: boolean);
  11488. /**
  11489. * Get hosting scene
  11490. * @returns the scene
  11491. */
  11492. getScene(): Scene;
  11493. /**
  11494. * You can use gravity if you want to give an orientation to your particles.
  11495. */
  11496. gravity: Vector3;
  11497. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11498. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11499. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11500. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11501. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11502. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11503. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11504. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11505. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11506. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11507. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11508. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11509. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11510. /**
  11511. * Defines the delay in milliseconds before starting the system (0 by default)
  11512. */
  11513. startDelay: number;
  11514. /**
  11515. * Gets the current list of drag gradients.
  11516. * You must use addDragGradient and removeDragGradient to udpate this list
  11517. * @returns the list of drag gradients
  11518. */
  11519. getDragGradients(): Nullable<Array<FactorGradient>>;
  11520. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11521. limitVelocityDamping: number;
  11522. /**
  11523. * Gets the current list of limit velocity gradients.
  11524. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11525. * @returns the list of limit velocity gradients
  11526. */
  11527. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11528. /**
  11529. * Gets the current list of color gradients.
  11530. * You must use addColorGradient and removeColorGradient to udpate this list
  11531. * @returns the list of color gradients
  11532. */
  11533. getColorGradients(): Nullable<Array<ColorGradient>>;
  11534. /**
  11535. * Gets the current list of size gradients.
  11536. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11537. * @returns the list of size gradients
  11538. */
  11539. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11540. /**
  11541. * Gets the current list of color remap gradients.
  11542. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11543. * @returns the list of color remap gradients
  11544. */
  11545. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11546. /**
  11547. * Gets the current list of alpha remap gradients.
  11548. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11549. * @returns the list of alpha remap gradients
  11550. */
  11551. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11552. /**
  11553. * Gets the current list of life time gradients.
  11554. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11555. * @returns the list of life time gradients
  11556. */
  11557. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11558. /**
  11559. * Gets the current list of angular speed gradients.
  11560. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11561. * @returns the list of angular speed gradients
  11562. */
  11563. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11564. /**
  11565. * Gets the current list of velocity gradients.
  11566. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11567. * @returns the list of velocity gradients
  11568. */
  11569. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11570. /**
  11571. * Gets the current list of start size gradients.
  11572. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11573. * @returns the list of start size gradients
  11574. */
  11575. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11576. /**
  11577. * Gets the current list of emit rate gradients.
  11578. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11579. * @returns the list of emit rate gradients
  11580. */
  11581. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11582. /**
  11583. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11584. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11585. */
  11586. get direction1(): Vector3;
  11587. set direction1(value: Vector3);
  11588. /**
  11589. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11590. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11591. */
  11592. get direction2(): Vector3;
  11593. set direction2(value: Vector3);
  11594. /**
  11595. * 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.
  11596. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11597. */
  11598. get minEmitBox(): Vector3;
  11599. set minEmitBox(value: Vector3);
  11600. /**
  11601. * 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.
  11602. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11603. */
  11604. get maxEmitBox(): Vector3;
  11605. set maxEmitBox(value: Vector3);
  11606. /**
  11607. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11608. */
  11609. color1: Color4;
  11610. /**
  11611. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11612. */
  11613. color2: Color4;
  11614. /**
  11615. * Color the particle will have at the end of its lifetime
  11616. */
  11617. colorDead: Color4;
  11618. /**
  11619. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11620. */
  11621. textureMask: Color4;
  11622. /**
  11623. * The particle emitter type defines the emitter used by the particle system.
  11624. * It can be for example box, sphere, or cone...
  11625. */
  11626. particleEmitterType: IParticleEmitterType;
  11627. /** @hidden */
  11628. _isSubEmitter: boolean;
  11629. /**
  11630. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11631. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11632. */
  11633. billboardMode: number;
  11634. protected _isBillboardBased: boolean;
  11635. /**
  11636. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11637. */
  11638. get isBillboardBased(): boolean;
  11639. set isBillboardBased(value: boolean);
  11640. /**
  11641. * The scene the particle system belongs to.
  11642. */
  11643. protected _scene: Scene;
  11644. /**
  11645. * Local cache of defines for image processing.
  11646. */
  11647. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11648. /**
  11649. * Default configuration related to image processing available in the standard Material.
  11650. */
  11651. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11652. /**
  11653. * Gets the image processing configuration used either in this material.
  11654. */
  11655. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11656. /**
  11657. * Sets the Default image processing configuration used either in the this material.
  11658. *
  11659. * If sets to null, the scene one is in use.
  11660. */
  11661. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11662. /**
  11663. * Attaches a new image processing configuration to the Standard Material.
  11664. * @param configuration
  11665. */
  11666. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11667. /** @hidden */
  11668. protected _reset(): void;
  11669. /** @hidden */
  11670. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11671. /**
  11672. * Instantiates a particle system.
  11673. * 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.
  11674. * @param name The name of the particle system
  11675. */
  11676. constructor(name: string);
  11677. /**
  11678. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11679. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11680. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11681. * @returns the emitter
  11682. */
  11683. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11684. /**
  11685. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11686. * @param radius The radius of the hemisphere to emit from
  11687. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11688. * @returns the emitter
  11689. */
  11690. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11691. /**
  11692. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11693. * @param radius The radius of the sphere to emit from
  11694. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11695. * @returns the emitter
  11696. */
  11697. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11698. /**
  11699. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11700. * @param radius The radius of the sphere to emit from
  11701. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11702. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11703. * @returns the emitter
  11704. */
  11705. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11706. /**
  11707. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11708. * @param radius The radius of the emission cylinder
  11709. * @param height The height of the emission cylinder
  11710. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11711. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11712. * @returns the emitter
  11713. */
  11714. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11715. /**
  11716. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11717. * @param radius The radius of the cylinder to emit from
  11718. * @param height The height of the emission cylinder
  11719. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11720. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11721. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11722. * @returns the emitter
  11723. */
  11724. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11725. /**
  11726. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11727. * @param radius The radius of the cone to emit from
  11728. * @param angle The base angle of the cone
  11729. * @returns the emitter
  11730. */
  11731. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11732. /**
  11733. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11734. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11735. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11736. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11737. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11738. * @returns the emitter
  11739. */
  11740. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11741. }
  11742. }
  11743. declare module "babylonjs/Particles/subEmitter" {
  11744. import { Scene } from "babylonjs/scene";
  11745. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11746. /**
  11747. * Type of sub emitter
  11748. */
  11749. export enum SubEmitterType {
  11750. /**
  11751. * Attached to the particle over it's lifetime
  11752. */
  11753. ATTACHED = 0,
  11754. /**
  11755. * Created when the particle dies
  11756. */
  11757. END = 1
  11758. }
  11759. /**
  11760. * Sub emitter class used to emit particles from an existing particle
  11761. */
  11762. export class SubEmitter {
  11763. /**
  11764. * the particle system to be used by the sub emitter
  11765. */
  11766. particleSystem: ParticleSystem;
  11767. /**
  11768. * Type of the submitter (Default: END)
  11769. */
  11770. type: SubEmitterType;
  11771. /**
  11772. * 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)
  11773. * Note: This only is supported when using an emitter of type Mesh
  11774. */
  11775. inheritDirection: boolean;
  11776. /**
  11777. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11778. */
  11779. inheritedVelocityAmount: number;
  11780. /**
  11781. * Creates a sub emitter
  11782. * @param particleSystem the particle system to be used by the sub emitter
  11783. */
  11784. constructor(
  11785. /**
  11786. * the particle system to be used by the sub emitter
  11787. */
  11788. particleSystem: ParticleSystem);
  11789. /**
  11790. * Clones the sub emitter
  11791. * @returns the cloned sub emitter
  11792. */
  11793. clone(): SubEmitter;
  11794. /**
  11795. * Serialize current object to a JSON object
  11796. * @returns the serialized object
  11797. */
  11798. serialize(): any;
  11799. /** @hidden */
  11800. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11801. /**
  11802. * Creates a new SubEmitter from a serialized JSON version
  11803. * @param serializationObject defines the JSON object to read from
  11804. * @param scene defines the hosting scene
  11805. * @param rootUrl defines the rootUrl for data loading
  11806. * @returns a new SubEmitter
  11807. */
  11808. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11809. /** Release associated resources */
  11810. dispose(): void;
  11811. }
  11812. }
  11813. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11814. /** @hidden */
  11815. export var imageProcessingDeclaration: {
  11816. name: string;
  11817. shader: string;
  11818. };
  11819. }
  11820. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11821. /** @hidden */
  11822. export var imageProcessingFunctions: {
  11823. name: string;
  11824. shader: string;
  11825. };
  11826. }
  11827. declare module "babylonjs/Shaders/particles.fragment" {
  11828. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11829. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11831. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11832. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11833. /** @hidden */
  11834. export var particlesPixelShader: {
  11835. name: string;
  11836. shader: string;
  11837. };
  11838. }
  11839. declare module "babylonjs/Shaders/particles.vertex" {
  11840. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11841. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11842. /** @hidden */
  11843. export var particlesVertexShader: {
  11844. name: string;
  11845. shader: string;
  11846. };
  11847. }
  11848. declare module "babylonjs/Particles/particleSystem" {
  11849. import { Nullable } from "babylonjs/types";
  11850. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11851. import { Observable } from "babylonjs/Misc/observable";
  11852. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11853. import { Effect } from "babylonjs/Materials/effect";
  11854. import { Scene, IDisposable } from "babylonjs/scene";
  11855. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11856. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11857. import { Particle } from "babylonjs/Particles/particle";
  11858. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11859. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11860. import "babylonjs/Shaders/particles.fragment";
  11861. import "babylonjs/Shaders/particles.vertex";
  11862. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11863. /**
  11864. * This represents a particle system in Babylon.
  11865. * 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.
  11866. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11867. * @example https://doc.babylonjs.com/babylon101/particles
  11868. */
  11869. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11870. /**
  11871. * Billboard mode will only apply to Y axis
  11872. */
  11873. static readonly BILLBOARDMODE_Y: number;
  11874. /**
  11875. * Billboard mode will apply to all axes
  11876. */
  11877. static readonly BILLBOARDMODE_ALL: number;
  11878. /**
  11879. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11880. */
  11881. static readonly BILLBOARDMODE_STRETCHED: number;
  11882. /**
  11883. * This function can be defined to provide custom update for active particles.
  11884. * This function will be called instead of regular update (age, position, color, etc.).
  11885. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11886. */
  11887. updateFunction: (particles: Particle[]) => void;
  11888. private _emitterWorldMatrix;
  11889. /**
  11890. * This function can be defined to specify initial direction for every new particle.
  11891. * It by default use the emitterType defined function
  11892. */
  11893. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11894. /**
  11895. * This function can be defined to specify initial position for every new particle.
  11896. * It by default use the emitterType defined function
  11897. */
  11898. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11899. /**
  11900. * @hidden
  11901. */
  11902. _inheritedVelocityOffset: Vector3;
  11903. /**
  11904. * An event triggered when the system is disposed
  11905. */
  11906. onDisposeObservable: Observable<ParticleSystem>;
  11907. private _onDisposeObserver;
  11908. /**
  11909. * Sets a callback that will be triggered when the system is disposed
  11910. */
  11911. set onDispose(callback: () => void);
  11912. private _particles;
  11913. private _epsilon;
  11914. private _capacity;
  11915. private _stockParticles;
  11916. private _newPartsExcess;
  11917. private _vertexData;
  11918. private _vertexBuffer;
  11919. private _vertexBuffers;
  11920. private _spriteBuffer;
  11921. private _indexBuffer;
  11922. private _effect;
  11923. private _customEffect;
  11924. private _cachedDefines;
  11925. private _scaledColorStep;
  11926. private _colorDiff;
  11927. private _scaledDirection;
  11928. private _scaledGravity;
  11929. private _currentRenderId;
  11930. private _alive;
  11931. private _useInstancing;
  11932. private _started;
  11933. private _stopped;
  11934. private _actualFrame;
  11935. private _scaledUpdateSpeed;
  11936. private _vertexBufferSize;
  11937. /** @hidden */
  11938. _currentEmitRateGradient: Nullable<FactorGradient>;
  11939. /** @hidden */
  11940. _currentEmitRate1: number;
  11941. /** @hidden */
  11942. _currentEmitRate2: number;
  11943. /** @hidden */
  11944. _currentStartSizeGradient: Nullable<FactorGradient>;
  11945. /** @hidden */
  11946. _currentStartSize1: number;
  11947. /** @hidden */
  11948. _currentStartSize2: number;
  11949. private readonly _rawTextureWidth;
  11950. private _rampGradientsTexture;
  11951. private _useRampGradients;
  11952. /** Gets or sets a boolean indicating that ramp gradients must be used
  11953. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11954. */
  11955. get useRampGradients(): boolean;
  11956. set useRampGradients(value: boolean);
  11957. /**
  11958. * 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.
  11959. * 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: [])
  11960. */
  11961. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11962. private _subEmitters;
  11963. /**
  11964. * @hidden
  11965. * If the particle systems emitter should be disposed when the particle system is disposed
  11966. */
  11967. _disposeEmitterOnDispose: boolean;
  11968. /**
  11969. * The current active Sub-systems, this property is used by the root particle system only.
  11970. */
  11971. activeSubSystems: Array<ParticleSystem>;
  11972. /**
  11973. * Specifies if the particles are updated in emitter local space or world space
  11974. */
  11975. isLocal: boolean;
  11976. private _rootParticleSystem;
  11977. /**
  11978. * Gets the current list of active particles
  11979. */
  11980. get particles(): Particle[];
  11981. /**
  11982. * Gets the number of particles active at the same time.
  11983. * @returns The number of active particles.
  11984. */
  11985. getActiveCount(): number;
  11986. /**
  11987. * Returns the string "ParticleSystem"
  11988. * @returns a string containing the class name
  11989. */
  11990. getClassName(): string;
  11991. /**
  11992. * Gets a boolean indicating that the system is stopping
  11993. * @returns true if the system is currently stopping
  11994. */
  11995. isStopping(): boolean;
  11996. /**
  11997. * Instantiates a particle system.
  11998. * 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.
  11999. * @param name The name of the particle system
  12000. * @param capacity The max number of particles alive at the same time
  12001. * @param scene The scene the particle system belongs to
  12002. * @param customEffect a custom effect used to change the way particles are rendered by default
  12003. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12004. * @param epsilon Offset used to render the particles
  12005. */
  12006. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12007. private _addFactorGradient;
  12008. private _removeFactorGradient;
  12009. /**
  12010. * Adds a new life time gradient
  12011. * @param gradient defines the gradient to use (between 0 and 1)
  12012. * @param factor defines the life time factor to affect to the specified gradient
  12013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12014. * @returns the current particle system
  12015. */
  12016. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12017. /**
  12018. * Remove a specific life time gradient
  12019. * @param gradient defines the gradient to remove
  12020. * @returns the current particle system
  12021. */
  12022. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12023. /**
  12024. * Adds a new size gradient
  12025. * @param gradient defines the gradient to use (between 0 and 1)
  12026. * @param factor defines the size factor to affect to the specified gradient
  12027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12028. * @returns the current particle system
  12029. */
  12030. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12031. /**
  12032. * Remove a specific size gradient
  12033. * @param gradient defines the gradient to remove
  12034. * @returns the current particle system
  12035. */
  12036. removeSizeGradient(gradient: number): IParticleSystem;
  12037. /**
  12038. * Adds a new color remap gradient
  12039. * @param gradient defines the gradient to use (between 0 and 1)
  12040. * @param min defines the color remap minimal range
  12041. * @param max defines the color remap maximal range
  12042. * @returns the current particle system
  12043. */
  12044. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12045. /**
  12046. * Remove a specific color remap gradient
  12047. * @param gradient defines the gradient to remove
  12048. * @returns the current particle system
  12049. */
  12050. removeColorRemapGradient(gradient: number): IParticleSystem;
  12051. /**
  12052. * Adds a new alpha remap gradient
  12053. * @param gradient defines the gradient to use (between 0 and 1)
  12054. * @param min defines the alpha remap minimal range
  12055. * @param max defines the alpha remap maximal range
  12056. * @returns the current particle system
  12057. */
  12058. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12059. /**
  12060. * Remove a specific alpha remap gradient
  12061. * @param gradient defines the gradient to remove
  12062. * @returns the current particle system
  12063. */
  12064. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12065. /**
  12066. * Adds a new angular speed gradient
  12067. * @param gradient defines the gradient to use (between 0 and 1)
  12068. * @param factor defines the angular speed to affect to the specified gradient
  12069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12070. * @returns the current particle system
  12071. */
  12072. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12073. /**
  12074. * Remove a specific angular speed gradient
  12075. * @param gradient defines the gradient to remove
  12076. * @returns the current particle system
  12077. */
  12078. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12079. /**
  12080. * Adds a new velocity gradient
  12081. * @param gradient defines the gradient to use (between 0 and 1)
  12082. * @param factor defines the velocity to affect to the specified gradient
  12083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12084. * @returns the current particle system
  12085. */
  12086. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12087. /**
  12088. * Remove a specific velocity gradient
  12089. * @param gradient defines the gradient to remove
  12090. * @returns the current particle system
  12091. */
  12092. removeVelocityGradient(gradient: number): IParticleSystem;
  12093. /**
  12094. * Adds a new limit velocity gradient
  12095. * @param gradient defines the gradient to use (between 0 and 1)
  12096. * @param factor defines the limit velocity value to affect to the specified gradient
  12097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12098. * @returns the current particle system
  12099. */
  12100. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12101. /**
  12102. * Remove a specific limit velocity gradient
  12103. * @param gradient defines the gradient to remove
  12104. * @returns the current particle system
  12105. */
  12106. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12107. /**
  12108. * Adds a new drag gradient
  12109. * @param gradient defines the gradient to use (between 0 and 1)
  12110. * @param factor defines the drag value to affect to the specified gradient
  12111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12112. * @returns the current particle system
  12113. */
  12114. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12115. /**
  12116. * Remove a specific drag gradient
  12117. * @param gradient defines the gradient to remove
  12118. * @returns the current particle system
  12119. */
  12120. removeDragGradient(gradient: number): IParticleSystem;
  12121. /**
  12122. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12123. * @param gradient defines the gradient to use (between 0 and 1)
  12124. * @param factor defines the emit rate value to affect to the specified gradient
  12125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12126. * @returns the current particle system
  12127. */
  12128. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12129. /**
  12130. * Remove a specific emit rate gradient
  12131. * @param gradient defines the gradient to remove
  12132. * @returns the current particle system
  12133. */
  12134. removeEmitRateGradient(gradient: number): IParticleSystem;
  12135. /**
  12136. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12137. * @param gradient defines the gradient to use (between 0 and 1)
  12138. * @param factor defines the start size value to affect to the specified gradient
  12139. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12140. * @returns the current particle system
  12141. */
  12142. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12143. /**
  12144. * Remove a specific start size gradient
  12145. * @param gradient defines the gradient to remove
  12146. * @returns the current particle system
  12147. */
  12148. removeStartSizeGradient(gradient: number): IParticleSystem;
  12149. private _createRampGradientTexture;
  12150. /**
  12151. * Gets the current list of ramp gradients.
  12152. * You must use addRampGradient and removeRampGradient to udpate this list
  12153. * @returns the list of ramp gradients
  12154. */
  12155. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12156. /** Force the system to rebuild all gradients that need to be resync */
  12157. forceRefreshGradients(): void;
  12158. private _syncRampGradientTexture;
  12159. /**
  12160. * Adds a new ramp gradient used to remap particle colors
  12161. * @param gradient defines the gradient to use (between 0 and 1)
  12162. * @param color defines the color to affect to the specified gradient
  12163. * @returns the current particle system
  12164. */
  12165. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12166. /**
  12167. * Remove a specific ramp gradient
  12168. * @param gradient defines the gradient to remove
  12169. * @returns the current particle system
  12170. */
  12171. removeRampGradient(gradient: number): ParticleSystem;
  12172. /**
  12173. * Adds a new color gradient
  12174. * @param gradient defines the gradient to use (between 0 and 1)
  12175. * @param color1 defines the color to affect to the specified gradient
  12176. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12177. * @returns this particle system
  12178. */
  12179. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12180. /**
  12181. * Remove a specific color gradient
  12182. * @param gradient defines the gradient to remove
  12183. * @returns this particle system
  12184. */
  12185. removeColorGradient(gradient: number): IParticleSystem;
  12186. private _fetchR;
  12187. protected _reset(): void;
  12188. private _resetEffect;
  12189. private _createVertexBuffers;
  12190. private _createIndexBuffer;
  12191. /**
  12192. * Gets the maximum number of particles active at the same time.
  12193. * @returns The max number of active particles.
  12194. */
  12195. getCapacity(): number;
  12196. /**
  12197. * Gets whether there are still active particles in the system.
  12198. * @returns True if it is alive, otherwise false.
  12199. */
  12200. isAlive(): boolean;
  12201. /**
  12202. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12203. * @returns True if it has been started, otherwise false.
  12204. */
  12205. isStarted(): boolean;
  12206. private _prepareSubEmitterInternalArray;
  12207. /**
  12208. * Starts the particle system and begins to emit
  12209. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12210. */
  12211. start(delay?: number): void;
  12212. /**
  12213. * Stops the particle system.
  12214. * @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.
  12215. */
  12216. stop(stopSubEmitters?: boolean): void;
  12217. /**
  12218. * Remove all active particles
  12219. */
  12220. reset(): void;
  12221. /**
  12222. * @hidden (for internal use only)
  12223. */
  12224. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12225. /**
  12226. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12227. * Its lifetime will start back at 0.
  12228. */
  12229. recycleParticle: (particle: Particle) => void;
  12230. private _stopSubEmitters;
  12231. private _createParticle;
  12232. private _removeFromRoot;
  12233. private _emitFromParticle;
  12234. private _update;
  12235. /** @hidden */
  12236. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12237. /** @hidden */
  12238. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12239. /** @hidden */
  12240. private _getEffect;
  12241. /**
  12242. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12243. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12244. */
  12245. animate(preWarmOnly?: boolean): void;
  12246. private _appendParticleVertices;
  12247. /**
  12248. * Rebuilds the particle system.
  12249. */
  12250. rebuild(): void;
  12251. /**
  12252. * Is this system ready to be used/rendered
  12253. * @return true if the system is ready
  12254. */
  12255. isReady(): boolean;
  12256. private _render;
  12257. /**
  12258. * Renders the particle system in its current state.
  12259. * @returns the current number of particles
  12260. */
  12261. render(): number;
  12262. /**
  12263. * Disposes the particle system and free the associated resources
  12264. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12265. */
  12266. dispose(disposeTexture?: boolean): void;
  12267. /**
  12268. * Clones the particle system.
  12269. * @param name The name of the cloned object
  12270. * @param newEmitter The new emitter to use
  12271. * @returns the cloned particle system
  12272. */
  12273. clone(name: string, newEmitter: any): ParticleSystem;
  12274. /**
  12275. * Serializes the particle system to a JSON object
  12276. * @param serializeTexture defines if the texture must be serialized as well
  12277. * @returns the JSON object
  12278. */
  12279. serialize(serializeTexture?: boolean): any;
  12280. /** @hidden */
  12281. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12282. /** @hidden */
  12283. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12284. /**
  12285. * Parses a JSON object to create a particle system.
  12286. * @param parsedParticleSystem The JSON object to parse
  12287. * @param scene The scene to create the particle system in
  12288. * @param rootUrl The root url to use to load external dependencies like texture
  12289. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12290. * @returns the Parsed particle system
  12291. */
  12292. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12293. }
  12294. }
  12295. declare module "babylonjs/Particles/particle" {
  12296. import { Nullable } from "babylonjs/types";
  12297. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12298. import { Color4 } from "babylonjs/Maths/math.color";
  12299. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12300. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12301. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12302. /**
  12303. * A particle represents one of the element emitted by a particle system.
  12304. * This is mainly define by its coordinates, direction, velocity and age.
  12305. */
  12306. export class Particle {
  12307. /**
  12308. * The particle system the particle belongs to.
  12309. */
  12310. particleSystem: ParticleSystem;
  12311. private static _Count;
  12312. /**
  12313. * Unique ID of the particle
  12314. */
  12315. id: number;
  12316. /**
  12317. * The world position of the particle in the scene.
  12318. */
  12319. position: Vector3;
  12320. /**
  12321. * The world direction of the particle in the scene.
  12322. */
  12323. direction: Vector3;
  12324. /**
  12325. * The color of the particle.
  12326. */
  12327. color: Color4;
  12328. /**
  12329. * The color change of the particle per step.
  12330. */
  12331. colorStep: Color4;
  12332. /**
  12333. * Defines how long will the life of the particle be.
  12334. */
  12335. lifeTime: number;
  12336. /**
  12337. * The current age of the particle.
  12338. */
  12339. age: number;
  12340. /**
  12341. * The current size of the particle.
  12342. */
  12343. size: number;
  12344. /**
  12345. * The current scale of the particle.
  12346. */
  12347. scale: Vector2;
  12348. /**
  12349. * The current angle of the particle.
  12350. */
  12351. angle: number;
  12352. /**
  12353. * Defines how fast is the angle changing.
  12354. */
  12355. angularSpeed: number;
  12356. /**
  12357. * Defines the cell index used by the particle to be rendered from a sprite.
  12358. */
  12359. cellIndex: number;
  12360. /**
  12361. * The information required to support color remapping
  12362. */
  12363. remapData: Vector4;
  12364. /** @hidden */
  12365. _randomCellOffset?: number;
  12366. /** @hidden */
  12367. _initialDirection: Nullable<Vector3>;
  12368. /** @hidden */
  12369. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12370. /** @hidden */
  12371. _initialStartSpriteCellID: number;
  12372. /** @hidden */
  12373. _initialEndSpriteCellID: number;
  12374. /** @hidden */
  12375. _currentColorGradient: Nullable<ColorGradient>;
  12376. /** @hidden */
  12377. _currentColor1: Color4;
  12378. /** @hidden */
  12379. _currentColor2: Color4;
  12380. /** @hidden */
  12381. _currentSizeGradient: Nullable<FactorGradient>;
  12382. /** @hidden */
  12383. _currentSize1: number;
  12384. /** @hidden */
  12385. _currentSize2: number;
  12386. /** @hidden */
  12387. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12388. /** @hidden */
  12389. _currentAngularSpeed1: number;
  12390. /** @hidden */
  12391. _currentAngularSpeed2: number;
  12392. /** @hidden */
  12393. _currentVelocityGradient: Nullable<FactorGradient>;
  12394. /** @hidden */
  12395. _currentVelocity1: number;
  12396. /** @hidden */
  12397. _currentVelocity2: number;
  12398. /** @hidden */
  12399. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12400. /** @hidden */
  12401. _currentLimitVelocity1: number;
  12402. /** @hidden */
  12403. _currentLimitVelocity2: number;
  12404. /** @hidden */
  12405. _currentDragGradient: Nullable<FactorGradient>;
  12406. /** @hidden */
  12407. _currentDrag1: number;
  12408. /** @hidden */
  12409. _currentDrag2: number;
  12410. /** @hidden */
  12411. _randomNoiseCoordinates1: Vector3;
  12412. /** @hidden */
  12413. _randomNoiseCoordinates2: Vector3;
  12414. /** @hidden */
  12415. _localPosition?: Vector3;
  12416. /**
  12417. * Creates a new instance Particle
  12418. * @param particleSystem the particle system the particle belongs to
  12419. */
  12420. constructor(
  12421. /**
  12422. * The particle system the particle belongs to.
  12423. */
  12424. particleSystem: ParticleSystem);
  12425. private updateCellInfoFromSystem;
  12426. /**
  12427. * Defines how the sprite cell index is updated for the particle
  12428. */
  12429. updateCellIndex(): void;
  12430. /** @hidden */
  12431. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12432. /** @hidden */
  12433. _inheritParticleInfoToSubEmitters(): void;
  12434. /** @hidden */
  12435. _reset(): void;
  12436. /**
  12437. * Copy the properties of particle to another one.
  12438. * @param other the particle to copy the information to.
  12439. */
  12440. copyTo(other: Particle): void;
  12441. }
  12442. }
  12443. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12444. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12445. import { Effect } from "babylonjs/Materials/effect";
  12446. import { Particle } from "babylonjs/Particles/particle";
  12447. import { Scene } from "babylonjs/scene";
  12448. /**
  12449. * Particle emitter represents a volume emitting particles.
  12450. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12451. */
  12452. export interface IParticleEmitterType {
  12453. /**
  12454. * Called by the particle System when the direction is computed for the created particle.
  12455. * @param worldMatrix is the world matrix of the particle system
  12456. * @param directionToUpdate is the direction vector to update with the result
  12457. * @param particle is the particle we are computed the direction for
  12458. * @param isLocal defines if the direction should be set in local space
  12459. */
  12460. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12461. /**
  12462. * Called by the particle System when the position is computed for the created particle.
  12463. * @param worldMatrix is the world matrix of the particle system
  12464. * @param positionToUpdate is the position vector to update with the result
  12465. * @param particle is the particle we are computed the position for
  12466. * @param isLocal defines if the position should be set in local space
  12467. */
  12468. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12469. /**
  12470. * Clones the current emitter and returns a copy of it
  12471. * @returns the new emitter
  12472. */
  12473. clone(): IParticleEmitterType;
  12474. /**
  12475. * Called by the GPUParticleSystem to setup the update shader
  12476. * @param effect defines the update shader
  12477. */
  12478. applyToShader(effect: Effect): void;
  12479. /**
  12480. * Returns a string to use to update the GPU particles update shader
  12481. * @returns the effect defines string
  12482. */
  12483. getEffectDefines(): string;
  12484. /**
  12485. * Returns a string representing the class name
  12486. * @returns a string containing the class name
  12487. */
  12488. getClassName(): string;
  12489. /**
  12490. * Serializes the particle system to a JSON object.
  12491. * @returns the JSON object
  12492. */
  12493. serialize(): any;
  12494. /**
  12495. * Parse properties from a JSON object
  12496. * @param serializationObject defines the JSON object
  12497. * @param scene defines the hosting scene
  12498. */
  12499. parse(serializationObject: any, scene: Scene): void;
  12500. }
  12501. }
  12502. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12503. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12504. import { Effect } from "babylonjs/Materials/effect";
  12505. import { Particle } from "babylonjs/Particles/particle";
  12506. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12507. /**
  12508. * Particle emitter emitting particles from the inside of a box.
  12509. * It emits the particles randomly between 2 given directions.
  12510. */
  12511. export class BoxParticleEmitter implements IParticleEmitterType {
  12512. /**
  12513. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12514. */
  12515. direction1: Vector3;
  12516. /**
  12517. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12518. */
  12519. direction2: Vector3;
  12520. /**
  12521. * 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.
  12522. */
  12523. minEmitBox: Vector3;
  12524. /**
  12525. * 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.
  12526. */
  12527. maxEmitBox: Vector3;
  12528. /**
  12529. * Creates a new instance BoxParticleEmitter
  12530. */
  12531. constructor();
  12532. /**
  12533. * Called by the particle System when the direction is computed for the created particle.
  12534. * @param worldMatrix is the world matrix of the particle system
  12535. * @param directionToUpdate is the direction vector to update with the result
  12536. * @param particle is the particle we are computed the direction for
  12537. * @param isLocal defines if the direction should be set in local space
  12538. */
  12539. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12540. /**
  12541. * Called by the particle System when the position is computed for the created particle.
  12542. * @param worldMatrix is the world matrix of the particle system
  12543. * @param positionToUpdate is the position vector to update with the result
  12544. * @param particle is the particle we are computed the position for
  12545. * @param isLocal defines if the position should be set in local space
  12546. */
  12547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12548. /**
  12549. * Clones the current emitter and returns a copy of it
  12550. * @returns the new emitter
  12551. */
  12552. clone(): BoxParticleEmitter;
  12553. /**
  12554. * Called by the GPUParticleSystem to setup the update shader
  12555. * @param effect defines the update shader
  12556. */
  12557. applyToShader(effect: Effect): void;
  12558. /**
  12559. * Returns a string to use to update the GPU particles update shader
  12560. * @returns a string containng the defines string
  12561. */
  12562. getEffectDefines(): string;
  12563. /**
  12564. * Returns the string "BoxParticleEmitter"
  12565. * @returns a string containing the class name
  12566. */
  12567. getClassName(): string;
  12568. /**
  12569. * Serializes the particle system to a JSON object.
  12570. * @returns the JSON object
  12571. */
  12572. serialize(): any;
  12573. /**
  12574. * Parse properties from a JSON object
  12575. * @param serializationObject defines the JSON object
  12576. */
  12577. parse(serializationObject: any): void;
  12578. }
  12579. }
  12580. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12581. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12582. import { Effect } from "babylonjs/Materials/effect";
  12583. import { Particle } from "babylonjs/Particles/particle";
  12584. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12585. /**
  12586. * Particle emitter emitting particles from the inside of a cone.
  12587. * It emits the particles alongside the cone volume from the base to the particle.
  12588. * The emission direction might be randomized.
  12589. */
  12590. export class ConeParticleEmitter implements IParticleEmitterType {
  12591. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12592. directionRandomizer: number;
  12593. private _radius;
  12594. private _angle;
  12595. private _height;
  12596. /**
  12597. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12598. */
  12599. radiusRange: number;
  12600. /**
  12601. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12602. */
  12603. heightRange: number;
  12604. /**
  12605. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12606. */
  12607. emitFromSpawnPointOnly: boolean;
  12608. /**
  12609. * Gets or sets the radius of the emission cone
  12610. */
  12611. get radius(): number;
  12612. set radius(value: number);
  12613. /**
  12614. * Gets or sets the angle of the emission cone
  12615. */
  12616. get angle(): number;
  12617. set angle(value: number);
  12618. private _buildHeight;
  12619. /**
  12620. * Creates a new instance ConeParticleEmitter
  12621. * @param radius the radius of the emission cone (1 by default)
  12622. * @param angle the cone base angle (PI by default)
  12623. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12624. */
  12625. constructor(radius?: number, angle?: number,
  12626. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12627. directionRandomizer?: number);
  12628. /**
  12629. * Called by the particle System when the direction is computed for the created particle.
  12630. * @param worldMatrix is the world matrix of the particle system
  12631. * @param directionToUpdate is the direction vector to update with the result
  12632. * @param particle is the particle we are computed the direction for
  12633. * @param isLocal defines if the direction should be set in local space
  12634. */
  12635. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12636. /**
  12637. * Called by the particle System when the position is computed for the created particle.
  12638. * @param worldMatrix is the world matrix of the particle system
  12639. * @param positionToUpdate is the position vector to update with the result
  12640. * @param particle is the particle we are computed the position for
  12641. * @param isLocal defines if the position should be set in local space
  12642. */
  12643. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12644. /**
  12645. * Clones the current emitter and returns a copy of it
  12646. * @returns the new emitter
  12647. */
  12648. clone(): ConeParticleEmitter;
  12649. /**
  12650. * Called by the GPUParticleSystem to setup the update shader
  12651. * @param effect defines the update shader
  12652. */
  12653. applyToShader(effect: Effect): void;
  12654. /**
  12655. * Returns a string to use to update the GPU particles update shader
  12656. * @returns a string containng the defines string
  12657. */
  12658. getEffectDefines(): string;
  12659. /**
  12660. * Returns the string "ConeParticleEmitter"
  12661. * @returns a string containing the class name
  12662. */
  12663. getClassName(): string;
  12664. /**
  12665. * Serializes the particle system to a JSON object.
  12666. * @returns the JSON object
  12667. */
  12668. serialize(): any;
  12669. /**
  12670. * Parse properties from a JSON object
  12671. * @param serializationObject defines the JSON object
  12672. */
  12673. parse(serializationObject: any): void;
  12674. }
  12675. }
  12676. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12677. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12678. import { Effect } from "babylonjs/Materials/effect";
  12679. import { Particle } from "babylonjs/Particles/particle";
  12680. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12681. /**
  12682. * Particle emitter emitting particles from the inside of a cylinder.
  12683. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12684. */
  12685. export class CylinderParticleEmitter implements IParticleEmitterType {
  12686. /**
  12687. * The radius of the emission cylinder.
  12688. */
  12689. radius: number;
  12690. /**
  12691. * The height of the emission cylinder.
  12692. */
  12693. height: number;
  12694. /**
  12695. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12696. */
  12697. radiusRange: number;
  12698. /**
  12699. * How much to randomize the particle direction [0-1].
  12700. */
  12701. directionRandomizer: number;
  12702. /**
  12703. * Creates a new instance CylinderParticleEmitter
  12704. * @param radius the radius of the emission cylinder (1 by default)
  12705. * @param height the height of the emission cylinder (1 by default)
  12706. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12707. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12708. */
  12709. constructor(
  12710. /**
  12711. * The radius of the emission cylinder.
  12712. */
  12713. radius?: number,
  12714. /**
  12715. * The height of the emission cylinder.
  12716. */
  12717. height?: number,
  12718. /**
  12719. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12720. */
  12721. radiusRange?: number,
  12722. /**
  12723. * How much to randomize the particle direction [0-1].
  12724. */
  12725. directionRandomizer?: number);
  12726. /**
  12727. * Called by the particle System when the direction is computed for the created particle.
  12728. * @param worldMatrix is the world matrix of the particle system
  12729. * @param directionToUpdate is the direction vector to update with the result
  12730. * @param particle is the particle we are computed the direction for
  12731. * @param isLocal defines if the direction should be set in local space
  12732. */
  12733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12734. /**
  12735. * Called by the particle System when the position is computed for the created particle.
  12736. * @param worldMatrix is the world matrix of the particle system
  12737. * @param positionToUpdate is the position vector to update with the result
  12738. * @param particle is the particle we are computed the position for
  12739. * @param isLocal defines if the position should be set in local space
  12740. */
  12741. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12742. /**
  12743. * Clones the current emitter and returns a copy of it
  12744. * @returns the new emitter
  12745. */
  12746. clone(): CylinderParticleEmitter;
  12747. /**
  12748. * Called by the GPUParticleSystem to setup the update shader
  12749. * @param effect defines the update shader
  12750. */
  12751. applyToShader(effect: Effect): void;
  12752. /**
  12753. * Returns a string to use to update the GPU particles update shader
  12754. * @returns a string containng the defines string
  12755. */
  12756. getEffectDefines(): string;
  12757. /**
  12758. * Returns the string "CylinderParticleEmitter"
  12759. * @returns a string containing the class name
  12760. */
  12761. getClassName(): string;
  12762. /**
  12763. * Serializes the particle system to a JSON object.
  12764. * @returns the JSON object
  12765. */
  12766. serialize(): any;
  12767. /**
  12768. * Parse properties from a JSON object
  12769. * @param serializationObject defines the JSON object
  12770. */
  12771. parse(serializationObject: any): void;
  12772. }
  12773. /**
  12774. * Particle emitter emitting particles from the inside of a cylinder.
  12775. * It emits the particles randomly between two vectors.
  12776. */
  12777. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12778. /**
  12779. * The min limit of the emission direction.
  12780. */
  12781. direction1: Vector3;
  12782. /**
  12783. * The max limit of the emission direction.
  12784. */
  12785. direction2: Vector3;
  12786. /**
  12787. * Creates a new instance CylinderDirectedParticleEmitter
  12788. * @param radius the radius of the emission cylinder (1 by default)
  12789. * @param height the height of the emission cylinder (1 by default)
  12790. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12791. * @param direction1 the min limit of the emission direction (up vector by default)
  12792. * @param direction2 the max limit of the emission direction (up vector by default)
  12793. */
  12794. constructor(radius?: number, height?: number, radiusRange?: number,
  12795. /**
  12796. * The min limit of the emission direction.
  12797. */
  12798. direction1?: Vector3,
  12799. /**
  12800. * The max limit of the emission direction.
  12801. */
  12802. direction2?: Vector3);
  12803. /**
  12804. * Called by the particle System when the direction is computed for the created particle.
  12805. * @param worldMatrix is the world matrix of the particle system
  12806. * @param directionToUpdate is the direction vector to update with the result
  12807. * @param particle is the particle we are computed the direction for
  12808. */
  12809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12810. /**
  12811. * Clones the current emitter and returns a copy of it
  12812. * @returns the new emitter
  12813. */
  12814. clone(): CylinderDirectedParticleEmitter;
  12815. /**
  12816. * Called by the GPUParticleSystem to setup the update shader
  12817. * @param effect defines the update shader
  12818. */
  12819. applyToShader(effect: Effect): void;
  12820. /**
  12821. * Returns a string to use to update the GPU particles update shader
  12822. * @returns a string containng the defines string
  12823. */
  12824. getEffectDefines(): string;
  12825. /**
  12826. * Returns the string "CylinderDirectedParticleEmitter"
  12827. * @returns a string containing the class name
  12828. */
  12829. getClassName(): string;
  12830. /**
  12831. * Serializes the particle system to a JSON object.
  12832. * @returns the JSON object
  12833. */
  12834. serialize(): any;
  12835. /**
  12836. * Parse properties from a JSON object
  12837. * @param serializationObject defines the JSON object
  12838. */
  12839. parse(serializationObject: any): void;
  12840. }
  12841. }
  12842. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12843. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12844. import { Effect } from "babylonjs/Materials/effect";
  12845. import { Particle } from "babylonjs/Particles/particle";
  12846. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12847. /**
  12848. * Particle emitter emitting particles from the inside of a hemisphere.
  12849. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12850. */
  12851. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12852. /**
  12853. * The radius of the emission hemisphere.
  12854. */
  12855. radius: number;
  12856. /**
  12857. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12858. */
  12859. radiusRange: number;
  12860. /**
  12861. * How much to randomize the particle direction [0-1].
  12862. */
  12863. directionRandomizer: number;
  12864. /**
  12865. * Creates a new instance HemisphericParticleEmitter
  12866. * @param radius the radius of the emission hemisphere (1 by default)
  12867. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12868. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12869. */
  12870. constructor(
  12871. /**
  12872. * The radius of the emission hemisphere.
  12873. */
  12874. radius?: number,
  12875. /**
  12876. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12877. */
  12878. radiusRange?: number,
  12879. /**
  12880. * How much to randomize the particle direction [0-1].
  12881. */
  12882. directionRandomizer?: number);
  12883. /**
  12884. * Called by the particle System when the direction is computed for the created particle.
  12885. * @param worldMatrix is the world matrix of the particle system
  12886. * @param directionToUpdate is the direction vector to update with the result
  12887. * @param particle is the particle we are computed the direction for
  12888. * @param isLocal defines if the direction should be set in local space
  12889. */
  12890. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12891. /**
  12892. * Called by the particle System when the position is computed for the created particle.
  12893. * @param worldMatrix is the world matrix of the particle system
  12894. * @param positionToUpdate is the position vector to update with the result
  12895. * @param particle is the particle we are computed the position for
  12896. * @param isLocal defines if the position should be set in local space
  12897. */
  12898. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12899. /**
  12900. * Clones the current emitter and returns a copy of it
  12901. * @returns the new emitter
  12902. */
  12903. clone(): HemisphericParticleEmitter;
  12904. /**
  12905. * Called by the GPUParticleSystem to setup the update shader
  12906. * @param effect defines the update shader
  12907. */
  12908. applyToShader(effect: Effect): void;
  12909. /**
  12910. * Returns a string to use to update the GPU particles update shader
  12911. * @returns a string containng the defines string
  12912. */
  12913. getEffectDefines(): string;
  12914. /**
  12915. * Returns the string "HemisphericParticleEmitter"
  12916. * @returns a string containing the class name
  12917. */
  12918. getClassName(): string;
  12919. /**
  12920. * Serializes the particle system to a JSON object.
  12921. * @returns the JSON object
  12922. */
  12923. serialize(): any;
  12924. /**
  12925. * Parse properties from a JSON object
  12926. * @param serializationObject defines the JSON object
  12927. */
  12928. parse(serializationObject: any): void;
  12929. }
  12930. }
  12931. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12932. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12933. import { Effect } from "babylonjs/Materials/effect";
  12934. import { Particle } from "babylonjs/Particles/particle";
  12935. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12936. /**
  12937. * Particle emitter emitting particles from a point.
  12938. * It emits the particles randomly between 2 given directions.
  12939. */
  12940. export class PointParticleEmitter implements IParticleEmitterType {
  12941. /**
  12942. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12943. */
  12944. direction1: Vector3;
  12945. /**
  12946. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12947. */
  12948. direction2: Vector3;
  12949. /**
  12950. * Creates a new instance PointParticleEmitter
  12951. */
  12952. constructor();
  12953. /**
  12954. * Called by the particle System when the direction is computed for the created particle.
  12955. * @param worldMatrix is the world matrix of the particle system
  12956. * @param directionToUpdate is the direction vector to update with the result
  12957. * @param particle is the particle we are computed the direction for
  12958. * @param isLocal defines if the direction should be set in local space
  12959. */
  12960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12961. /**
  12962. * Called by the particle System when the position is computed for the created particle.
  12963. * @param worldMatrix is the world matrix of the particle system
  12964. * @param positionToUpdate is the position vector to update with the result
  12965. * @param particle is the particle we are computed the position for
  12966. * @param isLocal defines if the position should be set in local space
  12967. */
  12968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12969. /**
  12970. * Clones the current emitter and returns a copy of it
  12971. * @returns the new emitter
  12972. */
  12973. clone(): PointParticleEmitter;
  12974. /**
  12975. * Called by the GPUParticleSystem to setup the update shader
  12976. * @param effect defines the update shader
  12977. */
  12978. applyToShader(effect: Effect): void;
  12979. /**
  12980. * Returns a string to use to update the GPU particles update shader
  12981. * @returns a string containng the defines string
  12982. */
  12983. getEffectDefines(): string;
  12984. /**
  12985. * Returns the string "PointParticleEmitter"
  12986. * @returns a string containing the class name
  12987. */
  12988. getClassName(): string;
  12989. /**
  12990. * Serializes the particle system to a JSON object.
  12991. * @returns the JSON object
  12992. */
  12993. serialize(): any;
  12994. /**
  12995. * Parse properties from a JSON object
  12996. * @param serializationObject defines the JSON object
  12997. */
  12998. parse(serializationObject: any): void;
  12999. }
  13000. }
  13001. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13002. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13003. import { Effect } from "babylonjs/Materials/effect";
  13004. import { Particle } from "babylonjs/Particles/particle";
  13005. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13006. /**
  13007. * Particle emitter emitting particles from the inside of a sphere.
  13008. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13009. */
  13010. export class SphereParticleEmitter implements IParticleEmitterType {
  13011. /**
  13012. * The radius of the emission sphere.
  13013. */
  13014. radius: number;
  13015. /**
  13016. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13017. */
  13018. radiusRange: number;
  13019. /**
  13020. * How much to randomize the particle direction [0-1].
  13021. */
  13022. directionRandomizer: number;
  13023. /**
  13024. * Creates a new instance SphereParticleEmitter
  13025. * @param radius the radius of the emission sphere (1 by default)
  13026. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13027. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13028. */
  13029. constructor(
  13030. /**
  13031. * The radius of the emission sphere.
  13032. */
  13033. radius?: number,
  13034. /**
  13035. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13036. */
  13037. radiusRange?: number,
  13038. /**
  13039. * How much to randomize the particle direction [0-1].
  13040. */
  13041. directionRandomizer?: number);
  13042. /**
  13043. * Called by the particle System when the direction is computed for the created particle.
  13044. * @param worldMatrix is the world matrix of the particle system
  13045. * @param directionToUpdate is the direction vector to update with the result
  13046. * @param particle is the particle we are computed the direction for
  13047. * @param isLocal defines if the direction should be set in local space
  13048. */
  13049. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13050. /**
  13051. * Called by the particle System when the position is computed for the created particle.
  13052. * @param worldMatrix is the world matrix of the particle system
  13053. * @param positionToUpdate is the position vector to update with the result
  13054. * @param particle is the particle we are computed the position for
  13055. * @param isLocal defines if the position should be set in local space
  13056. */
  13057. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13058. /**
  13059. * Clones the current emitter and returns a copy of it
  13060. * @returns the new emitter
  13061. */
  13062. clone(): SphereParticleEmitter;
  13063. /**
  13064. * Called by the GPUParticleSystem to setup the update shader
  13065. * @param effect defines the update shader
  13066. */
  13067. applyToShader(effect: Effect): void;
  13068. /**
  13069. * Returns a string to use to update the GPU particles update shader
  13070. * @returns a string containng the defines string
  13071. */
  13072. getEffectDefines(): string;
  13073. /**
  13074. * Returns the string "SphereParticleEmitter"
  13075. * @returns a string containing the class name
  13076. */
  13077. getClassName(): string;
  13078. /**
  13079. * Serializes the particle system to a JSON object.
  13080. * @returns the JSON object
  13081. */
  13082. serialize(): any;
  13083. /**
  13084. * Parse properties from a JSON object
  13085. * @param serializationObject defines the JSON object
  13086. */
  13087. parse(serializationObject: any): void;
  13088. }
  13089. /**
  13090. * Particle emitter emitting particles from the inside of a sphere.
  13091. * It emits the particles randomly between two vectors.
  13092. */
  13093. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13094. /**
  13095. * The min limit of the emission direction.
  13096. */
  13097. direction1: Vector3;
  13098. /**
  13099. * The max limit of the emission direction.
  13100. */
  13101. direction2: Vector3;
  13102. /**
  13103. * Creates a new instance SphereDirectedParticleEmitter
  13104. * @param radius the radius of the emission sphere (1 by default)
  13105. * @param direction1 the min limit of the emission direction (up vector by default)
  13106. * @param direction2 the max limit of the emission direction (up vector by default)
  13107. */
  13108. constructor(radius?: number,
  13109. /**
  13110. * The min limit of the emission direction.
  13111. */
  13112. direction1?: Vector3,
  13113. /**
  13114. * The max limit of the emission direction.
  13115. */
  13116. direction2?: Vector3);
  13117. /**
  13118. * Called by the particle System when the direction is computed for the created particle.
  13119. * @param worldMatrix is the world matrix of the particle system
  13120. * @param directionToUpdate is the direction vector to update with the result
  13121. * @param particle is the particle we are computed the direction for
  13122. */
  13123. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13124. /**
  13125. * Clones the current emitter and returns a copy of it
  13126. * @returns the new emitter
  13127. */
  13128. clone(): SphereDirectedParticleEmitter;
  13129. /**
  13130. * Called by the GPUParticleSystem to setup the update shader
  13131. * @param effect defines the update shader
  13132. */
  13133. applyToShader(effect: Effect): void;
  13134. /**
  13135. * Returns a string to use to update the GPU particles update shader
  13136. * @returns a string containng the defines string
  13137. */
  13138. getEffectDefines(): string;
  13139. /**
  13140. * Returns the string "SphereDirectedParticleEmitter"
  13141. * @returns a string containing the class name
  13142. */
  13143. getClassName(): string;
  13144. /**
  13145. * Serializes the particle system to a JSON object.
  13146. * @returns the JSON object
  13147. */
  13148. serialize(): any;
  13149. /**
  13150. * Parse properties from a JSON object
  13151. * @param serializationObject defines the JSON object
  13152. */
  13153. parse(serializationObject: any): void;
  13154. }
  13155. }
  13156. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13157. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13158. import { Effect } from "babylonjs/Materials/effect";
  13159. import { Particle } from "babylonjs/Particles/particle";
  13160. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13161. import { Nullable } from "babylonjs/types";
  13162. /**
  13163. * Particle emitter emitting particles from a custom list of positions.
  13164. */
  13165. export class CustomParticleEmitter implements IParticleEmitterType {
  13166. /**
  13167. * Gets or sets the position generator that will create the inital position of each particle.
  13168. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13169. */
  13170. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13171. /**
  13172. * Gets or sets the destination generator that will create the final destination of each particle.
  13173. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13174. */
  13175. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13176. /**
  13177. * Creates a new instance CustomParticleEmitter
  13178. */
  13179. constructor();
  13180. /**
  13181. * Called by the particle System when the direction is computed for the created particle.
  13182. * @param worldMatrix is the world matrix of the particle system
  13183. * @param directionToUpdate is the direction vector to update with the result
  13184. * @param particle is the particle we are computed the direction for
  13185. * @param isLocal defines if the direction should be set in local space
  13186. */
  13187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13188. /**
  13189. * Called by the particle System when the position is computed for the created particle.
  13190. * @param worldMatrix is the world matrix of the particle system
  13191. * @param positionToUpdate is the position vector to update with the result
  13192. * @param particle is the particle we are computed the position for
  13193. * @param isLocal defines if the position should be set in local space
  13194. */
  13195. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13196. /**
  13197. * Clones the current emitter and returns a copy of it
  13198. * @returns the new emitter
  13199. */
  13200. clone(): CustomParticleEmitter;
  13201. /**
  13202. * Called by the GPUParticleSystem to setup the update shader
  13203. * @param effect defines the update shader
  13204. */
  13205. applyToShader(effect: Effect): void;
  13206. /**
  13207. * Returns a string to use to update the GPU particles update shader
  13208. * @returns a string containng the defines string
  13209. */
  13210. getEffectDefines(): string;
  13211. /**
  13212. * Returns the string "PointParticleEmitter"
  13213. * @returns a string containing the class name
  13214. */
  13215. getClassName(): string;
  13216. /**
  13217. * Serializes the particle system to a JSON object.
  13218. * @returns the JSON object
  13219. */
  13220. serialize(): any;
  13221. /**
  13222. * Parse properties from a JSON object
  13223. * @param serializationObject defines the JSON object
  13224. */
  13225. parse(serializationObject: any): void;
  13226. }
  13227. }
  13228. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13229. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13230. import { Effect } from "babylonjs/Materials/effect";
  13231. import { Particle } from "babylonjs/Particles/particle";
  13232. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13233. import { Nullable } from "babylonjs/types";
  13234. import { Scene } from "babylonjs/scene";
  13235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13236. /**
  13237. * Particle emitter emitting particles from the inside of a box.
  13238. * It emits the particles randomly between 2 given directions.
  13239. */
  13240. export class MeshParticleEmitter implements IParticleEmitterType {
  13241. private _indices;
  13242. private _positions;
  13243. private _normals;
  13244. private _storedNormal;
  13245. private _mesh;
  13246. /**
  13247. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13248. */
  13249. direction1: Vector3;
  13250. /**
  13251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13252. */
  13253. direction2: Vector3;
  13254. /**
  13255. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13256. */
  13257. useMeshNormalsForDirection: boolean;
  13258. /** Defines the mesh to use as source */
  13259. get mesh(): Nullable<AbstractMesh>;
  13260. set mesh(value: Nullable<AbstractMesh>);
  13261. /**
  13262. * Creates a new instance MeshParticleEmitter
  13263. * @param mesh defines the mesh to use as source
  13264. */
  13265. constructor(mesh?: Nullable<AbstractMesh>);
  13266. /**
  13267. * Called by the particle System when the direction is computed for the created particle.
  13268. * @param worldMatrix is the world matrix of the particle system
  13269. * @param directionToUpdate is the direction vector to update with the result
  13270. * @param particle is the particle we are computed the direction for
  13271. * @param isLocal defines if the direction should be set in local space
  13272. */
  13273. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13274. /**
  13275. * Called by the particle System when the position is computed for the created particle.
  13276. * @param worldMatrix is the world matrix of the particle system
  13277. * @param positionToUpdate is the position vector to update with the result
  13278. * @param particle is the particle we are computed the position for
  13279. * @param isLocal defines if the position should be set in local space
  13280. */
  13281. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13282. /**
  13283. * Clones the current emitter and returns a copy of it
  13284. * @returns the new emitter
  13285. */
  13286. clone(): MeshParticleEmitter;
  13287. /**
  13288. * Called by the GPUParticleSystem to setup the update shader
  13289. * @param effect defines the update shader
  13290. */
  13291. applyToShader(effect: Effect): void;
  13292. /**
  13293. * Returns a string to use to update the GPU particles update shader
  13294. * @returns a string containng the defines string
  13295. */
  13296. getEffectDefines(): string;
  13297. /**
  13298. * Returns the string "BoxParticleEmitter"
  13299. * @returns a string containing the class name
  13300. */
  13301. getClassName(): string;
  13302. /**
  13303. * Serializes the particle system to a JSON object.
  13304. * @returns the JSON object
  13305. */
  13306. serialize(): any;
  13307. /**
  13308. * Parse properties from a JSON object
  13309. * @param serializationObject defines the JSON object
  13310. * @param scene defines the hosting scene
  13311. */
  13312. parse(serializationObject: any, scene: Scene): void;
  13313. }
  13314. }
  13315. declare module "babylonjs/Particles/EmitterTypes/index" {
  13316. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13317. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13318. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13319. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13320. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13321. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13322. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13323. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13324. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13325. }
  13326. declare module "babylonjs/Particles/IParticleSystem" {
  13327. import { Nullable } from "babylonjs/types";
  13328. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13329. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13331. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13332. import { Texture } from "babylonjs/Materials/Textures/texture";
  13333. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13334. import { Scene } from "babylonjs/scene";
  13335. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13336. import { Animation } from "babylonjs/Animations/animation";
  13337. /**
  13338. * Interface representing a particle system in Babylon.js.
  13339. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13340. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13341. */
  13342. export interface IParticleSystem {
  13343. /**
  13344. * List of animations used by the particle system.
  13345. */
  13346. animations: Animation[];
  13347. /**
  13348. * The id of the Particle system.
  13349. */
  13350. id: string;
  13351. /**
  13352. * The name of the Particle system.
  13353. */
  13354. name: string;
  13355. /**
  13356. * The emitter represents the Mesh or position we are attaching the particle system to.
  13357. */
  13358. emitter: Nullable<AbstractMesh | Vector3>;
  13359. /**
  13360. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13361. */
  13362. isBillboardBased: boolean;
  13363. /**
  13364. * The rendering group used by the Particle system to chose when to render.
  13365. */
  13366. renderingGroupId: number;
  13367. /**
  13368. * The layer mask we are rendering the particles through.
  13369. */
  13370. layerMask: number;
  13371. /**
  13372. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13373. */
  13374. updateSpeed: number;
  13375. /**
  13376. * The amount of time the particle system is running (depends of the overall update speed).
  13377. */
  13378. targetStopDuration: number;
  13379. /**
  13380. * The texture used to render each particle. (this can be a spritesheet)
  13381. */
  13382. particleTexture: Nullable<Texture>;
  13383. /**
  13384. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13385. */
  13386. blendMode: number;
  13387. /**
  13388. * Minimum life time of emitting particles.
  13389. */
  13390. minLifeTime: number;
  13391. /**
  13392. * Maximum life time of emitting particles.
  13393. */
  13394. maxLifeTime: number;
  13395. /**
  13396. * Minimum Size of emitting particles.
  13397. */
  13398. minSize: number;
  13399. /**
  13400. * Maximum Size of emitting particles.
  13401. */
  13402. maxSize: number;
  13403. /**
  13404. * Minimum scale of emitting particles on X axis.
  13405. */
  13406. minScaleX: number;
  13407. /**
  13408. * Maximum scale of emitting particles on X axis.
  13409. */
  13410. maxScaleX: number;
  13411. /**
  13412. * Minimum scale of emitting particles on Y axis.
  13413. */
  13414. minScaleY: number;
  13415. /**
  13416. * Maximum scale of emitting particles on Y axis.
  13417. */
  13418. maxScaleY: number;
  13419. /**
  13420. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13421. */
  13422. color1: Color4;
  13423. /**
  13424. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13425. */
  13426. color2: Color4;
  13427. /**
  13428. * Color the particle will have at the end of its lifetime.
  13429. */
  13430. colorDead: Color4;
  13431. /**
  13432. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13433. */
  13434. emitRate: number;
  13435. /**
  13436. * You can use gravity if you want to give an orientation to your particles.
  13437. */
  13438. gravity: Vector3;
  13439. /**
  13440. * Minimum power of emitting particles.
  13441. */
  13442. minEmitPower: number;
  13443. /**
  13444. * Maximum power of emitting particles.
  13445. */
  13446. maxEmitPower: number;
  13447. /**
  13448. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13449. */
  13450. minAngularSpeed: number;
  13451. /**
  13452. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13453. */
  13454. maxAngularSpeed: number;
  13455. /**
  13456. * Gets or sets the minimal initial rotation in radians.
  13457. */
  13458. minInitialRotation: number;
  13459. /**
  13460. * Gets or sets the maximal initial rotation in radians.
  13461. */
  13462. maxInitialRotation: number;
  13463. /**
  13464. * The particle emitter type defines the emitter used by the particle system.
  13465. * It can be for example box, sphere, or cone...
  13466. */
  13467. particleEmitterType: Nullable<IParticleEmitterType>;
  13468. /**
  13469. * Defines the delay in milliseconds before starting the system (0 by default)
  13470. */
  13471. startDelay: number;
  13472. /**
  13473. * 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
  13474. */
  13475. preWarmCycles: number;
  13476. /**
  13477. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13478. */
  13479. preWarmStepOffset: number;
  13480. /**
  13481. * 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)
  13482. */
  13483. spriteCellChangeSpeed: number;
  13484. /**
  13485. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13486. */
  13487. startSpriteCellID: number;
  13488. /**
  13489. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13490. */
  13491. endSpriteCellID: number;
  13492. /**
  13493. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13494. */
  13495. spriteCellWidth: number;
  13496. /**
  13497. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13498. */
  13499. spriteCellHeight: number;
  13500. /**
  13501. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13502. */
  13503. spriteRandomStartCell: boolean;
  13504. /**
  13505. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13506. */
  13507. isAnimationSheetEnabled: boolean;
  13508. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13509. translationPivot: Vector2;
  13510. /**
  13511. * Gets or sets a texture used to add random noise to particle positions
  13512. */
  13513. noiseTexture: Nullable<BaseTexture>;
  13514. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13515. noiseStrength: Vector3;
  13516. /**
  13517. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13518. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13519. */
  13520. billboardMode: number;
  13521. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13522. limitVelocityDamping: number;
  13523. /**
  13524. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13525. */
  13526. beginAnimationOnStart: boolean;
  13527. /**
  13528. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13529. */
  13530. beginAnimationFrom: number;
  13531. /**
  13532. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13533. */
  13534. beginAnimationTo: number;
  13535. /**
  13536. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13537. */
  13538. beginAnimationLoop: boolean;
  13539. /**
  13540. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13541. */
  13542. disposeOnStop: boolean;
  13543. /**
  13544. * Specifies if the particles are updated in emitter local space or world space
  13545. */
  13546. isLocal: boolean;
  13547. /** Snippet ID if the particle system was created from the snippet server */
  13548. snippetId: string;
  13549. /**
  13550. * Gets the maximum number of particles active at the same time.
  13551. * @returns The max number of active particles.
  13552. */
  13553. getCapacity(): number;
  13554. /**
  13555. * Gets the number of particles active at the same time.
  13556. * @returns The number of active particles.
  13557. */
  13558. getActiveCount(): number;
  13559. /**
  13560. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13561. * @returns True if it has been started, otherwise false.
  13562. */
  13563. isStarted(): boolean;
  13564. /**
  13565. * Animates the particle system for this frame.
  13566. */
  13567. animate(): void;
  13568. /**
  13569. * Renders the particle system in its current state.
  13570. * @returns the current number of particles
  13571. */
  13572. render(): number;
  13573. /**
  13574. * Dispose the particle system and frees its associated resources.
  13575. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13576. */
  13577. dispose(disposeTexture?: boolean): void;
  13578. /**
  13579. * Clones the particle system.
  13580. * @param name The name of the cloned object
  13581. * @param newEmitter The new emitter to use
  13582. * @returns the cloned particle system
  13583. */
  13584. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13585. /**
  13586. * Serializes the particle system to a JSON object
  13587. * @param serializeTexture defines if the texture must be serialized as well
  13588. * @returns the JSON object
  13589. */
  13590. serialize(serializeTexture: boolean): any;
  13591. /**
  13592. * Rebuild the particle system
  13593. */
  13594. rebuild(): void;
  13595. /** Force the system to rebuild all gradients that need to be resync */
  13596. forceRefreshGradients(): void;
  13597. /**
  13598. * Starts the particle system and begins to emit
  13599. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13600. */
  13601. start(delay?: number): void;
  13602. /**
  13603. * Stops the particle system.
  13604. */
  13605. stop(): void;
  13606. /**
  13607. * Remove all active particles
  13608. */
  13609. reset(): void;
  13610. /**
  13611. * Gets a boolean indicating that the system is stopping
  13612. * @returns true if the system is currently stopping
  13613. */
  13614. isStopping(): boolean;
  13615. /**
  13616. * Is this system ready to be used/rendered
  13617. * @return true if the system is ready
  13618. */
  13619. isReady(): boolean;
  13620. /**
  13621. * Returns the string "ParticleSystem"
  13622. * @returns a string containing the class name
  13623. */
  13624. getClassName(): string;
  13625. /**
  13626. * Adds a new color gradient
  13627. * @param gradient defines the gradient to use (between 0 and 1)
  13628. * @param color1 defines the color to affect to the specified gradient
  13629. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13630. * @returns the current particle system
  13631. */
  13632. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13633. /**
  13634. * Remove a specific color gradient
  13635. * @param gradient defines the gradient to remove
  13636. * @returns the current particle system
  13637. */
  13638. removeColorGradient(gradient: number): IParticleSystem;
  13639. /**
  13640. * Adds a new size gradient
  13641. * @param gradient defines the gradient to use (between 0 and 1)
  13642. * @param factor defines the size factor to affect to the specified gradient
  13643. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13644. * @returns the current particle system
  13645. */
  13646. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13647. /**
  13648. * Remove a specific size gradient
  13649. * @param gradient defines the gradient to remove
  13650. * @returns the current particle system
  13651. */
  13652. removeSizeGradient(gradient: number): IParticleSystem;
  13653. /**
  13654. * Gets the current list of color gradients.
  13655. * You must use addColorGradient and removeColorGradient to udpate this list
  13656. * @returns the list of color gradients
  13657. */
  13658. getColorGradients(): Nullable<Array<ColorGradient>>;
  13659. /**
  13660. * Gets the current list of size gradients.
  13661. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13662. * @returns the list of size gradients
  13663. */
  13664. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13665. /**
  13666. * Gets the current list of angular speed gradients.
  13667. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13668. * @returns the list of angular speed gradients
  13669. */
  13670. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13671. /**
  13672. * Adds a new angular speed gradient
  13673. * @param gradient defines the gradient to use (between 0 and 1)
  13674. * @param factor defines the angular speed to affect to the specified gradient
  13675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13676. * @returns the current particle system
  13677. */
  13678. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13679. /**
  13680. * Remove a specific angular speed gradient
  13681. * @param gradient defines the gradient to remove
  13682. * @returns the current particle system
  13683. */
  13684. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13685. /**
  13686. * Gets the current list of velocity gradients.
  13687. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13688. * @returns the list of velocity gradients
  13689. */
  13690. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13691. /**
  13692. * Adds a new velocity gradient
  13693. * @param gradient defines the gradient to use (between 0 and 1)
  13694. * @param factor defines the velocity to affect to the specified gradient
  13695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13696. * @returns the current particle system
  13697. */
  13698. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13699. /**
  13700. * Remove a specific velocity gradient
  13701. * @param gradient defines the gradient to remove
  13702. * @returns the current particle system
  13703. */
  13704. removeVelocityGradient(gradient: number): IParticleSystem;
  13705. /**
  13706. * Gets the current list of limit velocity gradients.
  13707. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13708. * @returns the list of limit velocity gradients
  13709. */
  13710. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13711. /**
  13712. * Adds a new limit velocity gradient
  13713. * @param gradient defines the gradient to use (between 0 and 1)
  13714. * @param factor defines the limit velocity to affect to the specified gradient
  13715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13716. * @returns the current particle system
  13717. */
  13718. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13719. /**
  13720. * Remove a specific limit velocity gradient
  13721. * @param gradient defines the gradient to remove
  13722. * @returns the current particle system
  13723. */
  13724. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13725. /**
  13726. * Adds a new drag gradient
  13727. * @param gradient defines the gradient to use (between 0 and 1)
  13728. * @param factor defines the drag to affect to the specified gradient
  13729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13730. * @returns the current particle system
  13731. */
  13732. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13733. /**
  13734. * Remove a specific drag gradient
  13735. * @param gradient defines the gradient to remove
  13736. * @returns the current particle system
  13737. */
  13738. removeDragGradient(gradient: number): IParticleSystem;
  13739. /**
  13740. * Gets the current list of drag gradients.
  13741. * You must use addDragGradient and removeDragGradient to udpate this list
  13742. * @returns the list of drag gradients
  13743. */
  13744. getDragGradients(): Nullable<Array<FactorGradient>>;
  13745. /**
  13746. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13747. * @param gradient defines the gradient to use (between 0 and 1)
  13748. * @param factor defines the emit rate to affect to the specified gradient
  13749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13750. * @returns the current particle system
  13751. */
  13752. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13753. /**
  13754. * Remove a specific emit rate gradient
  13755. * @param gradient defines the gradient to remove
  13756. * @returns the current particle system
  13757. */
  13758. removeEmitRateGradient(gradient: number): IParticleSystem;
  13759. /**
  13760. * Gets the current list of emit rate gradients.
  13761. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13762. * @returns the list of emit rate gradients
  13763. */
  13764. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13765. /**
  13766. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13767. * @param gradient defines the gradient to use (between 0 and 1)
  13768. * @param factor defines the start size to affect to the specified gradient
  13769. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13770. * @returns the current particle system
  13771. */
  13772. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13773. /**
  13774. * Remove a specific start size gradient
  13775. * @param gradient defines the gradient to remove
  13776. * @returns the current particle system
  13777. */
  13778. removeStartSizeGradient(gradient: number): IParticleSystem;
  13779. /**
  13780. * Gets the current list of start size gradients.
  13781. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13782. * @returns the list of start size gradients
  13783. */
  13784. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13785. /**
  13786. * Adds a new life time gradient
  13787. * @param gradient defines the gradient to use (between 0 and 1)
  13788. * @param factor defines the life time factor to affect to the specified gradient
  13789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13790. * @returns the current particle system
  13791. */
  13792. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13793. /**
  13794. * Remove a specific life time gradient
  13795. * @param gradient defines the gradient to remove
  13796. * @returns the current particle system
  13797. */
  13798. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13799. /**
  13800. * Gets the current list of life time gradients.
  13801. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13802. * @returns the list of life time gradients
  13803. */
  13804. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13805. /**
  13806. * Gets the current list of color gradients.
  13807. * You must use addColorGradient and removeColorGradient to udpate this list
  13808. * @returns the list of color gradients
  13809. */
  13810. getColorGradients(): Nullable<Array<ColorGradient>>;
  13811. /**
  13812. * Adds a new ramp gradient used to remap particle colors
  13813. * @param gradient defines the gradient to use (between 0 and 1)
  13814. * @param color defines the color to affect to the specified gradient
  13815. * @returns the current particle system
  13816. */
  13817. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13818. /**
  13819. * Gets the current list of ramp gradients.
  13820. * You must use addRampGradient and removeRampGradient to udpate this list
  13821. * @returns the list of ramp gradients
  13822. */
  13823. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13824. /** Gets or sets a boolean indicating that ramp gradients must be used
  13825. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13826. */
  13827. useRampGradients: boolean;
  13828. /**
  13829. * Adds a new color remap gradient
  13830. * @param gradient defines the gradient to use (between 0 and 1)
  13831. * @param min defines the color remap minimal range
  13832. * @param max defines the color remap maximal range
  13833. * @returns the current particle system
  13834. */
  13835. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13836. /**
  13837. * Gets the current list of color remap gradients.
  13838. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13839. * @returns the list of color remap gradients
  13840. */
  13841. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13842. /**
  13843. * Adds a new alpha remap gradient
  13844. * @param gradient defines the gradient to use (between 0 and 1)
  13845. * @param min defines the alpha remap minimal range
  13846. * @param max defines the alpha remap maximal range
  13847. * @returns the current particle system
  13848. */
  13849. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13850. /**
  13851. * Gets the current list of alpha remap gradients.
  13852. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13853. * @returns the list of alpha remap gradients
  13854. */
  13855. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13856. /**
  13857. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13858. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13859. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13860. * @returns the emitter
  13861. */
  13862. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13863. /**
  13864. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13865. * @param radius The radius of the hemisphere to emit from
  13866. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13867. * @returns the emitter
  13868. */
  13869. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13870. /**
  13871. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13872. * @param radius The radius of the sphere to emit from
  13873. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13874. * @returns the emitter
  13875. */
  13876. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13877. /**
  13878. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13879. * @param radius The radius of the sphere to emit from
  13880. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13881. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13882. * @returns the emitter
  13883. */
  13884. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13885. /**
  13886. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13887. * @param radius The radius of the emission cylinder
  13888. * @param height The height of the emission cylinder
  13889. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13890. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13891. * @returns the emitter
  13892. */
  13893. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13894. /**
  13895. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13896. * @param radius The radius of the cylinder to emit from
  13897. * @param height The height of the emission cylinder
  13898. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13899. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13900. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13901. * @returns the emitter
  13902. */
  13903. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13904. /**
  13905. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13906. * @param radius The radius of the cone to emit from
  13907. * @param angle The base angle of the cone
  13908. * @returns the emitter
  13909. */
  13910. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13911. /**
  13912. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13913. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13914. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13915. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13916. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13917. * @returns the emitter
  13918. */
  13919. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13920. /**
  13921. * Get hosting scene
  13922. * @returns the scene
  13923. */
  13924. getScene(): Scene;
  13925. }
  13926. }
  13927. declare module "babylonjs/Meshes/transformNode" {
  13928. import { DeepImmutable } from "babylonjs/types";
  13929. import { Observable } from "babylonjs/Misc/observable";
  13930. import { Nullable } from "babylonjs/types";
  13931. import { Camera } from "babylonjs/Cameras/camera";
  13932. import { Scene } from "babylonjs/scene";
  13933. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13934. import { Node } from "babylonjs/node";
  13935. import { Bone } from "babylonjs/Bones/bone";
  13936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13937. import { Space } from "babylonjs/Maths/math.axis";
  13938. /**
  13939. * 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.
  13940. * @see https://doc.babylonjs.com/how_to/transformnode
  13941. */
  13942. export class TransformNode extends Node {
  13943. /**
  13944. * Object will not rotate to face the camera
  13945. */
  13946. static BILLBOARDMODE_NONE: number;
  13947. /**
  13948. * Object will rotate to face the camera but only on the x axis
  13949. */
  13950. static BILLBOARDMODE_X: number;
  13951. /**
  13952. * Object will rotate to face the camera but only on the y axis
  13953. */
  13954. static BILLBOARDMODE_Y: number;
  13955. /**
  13956. * Object will rotate to face the camera but only on the z axis
  13957. */
  13958. static BILLBOARDMODE_Z: number;
  13959. /**
  13960. * Object will rotate to face the camera
  13961. */
  13962. static BILLBOARDMODE_ALL: number;
  13963. /**
  13964. * Object will rotate to face the camera's position instead of orientation
  13965. */
  13966. static BILLBOARDMODE_USE_POSITION: number;
  13967. private _forward;
  13968. private _forwardInverted;
  13969. private _up;
  13970. private _right;
  13971. private _rightInverted;
  13972. private _position;
  13973. private _rotation;
  13974. private _rotationQuaternion;
  13975. protected _scaling: Vector3;
  13976. protected _isDirty: boolean;
  13977. private _transformToBoneReferal;
  13978. private _isAbsoluteSynced;
  13979. private _billboardMode;
  13980. /**
  13981. * Gets or sets the billboard mode. Default is 0.
  13982. *
  13983. * | Value | Type | Description |
  13984. * | --- | --- | --- |
  13985. * | 0 | BILLBOARDMODE_NONE | |
  13986. * | 1 | BILLBOARDMODE_X | |
  13987. * | 2 | BILLBOARDMODE_Y | |
  13988. * | 4 | BILLBOARDMODE_Z | |
  13989. * | 7 | BILLBOARDMODE_ALL | |
  13990. *
  13991. */
  13992. get billboardMode(): number;
  13993. set billboardMode(value: number);
  13994. private _preserveParentRotationForBillboard;
  13995. /**
  13996. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13997. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13998. */
  13999. get preserveParentRotationForBillboard(): boolean;
  14000. set preserveParentRotationForBillboard(value: boolean);
  14001. /**
  14002. * 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
  14003. */
  14004. scalingDeterminant: number;
  14005. private _infiniteDistance;
  14006. /**
  14007. * Gets or sets the distance of the object to max, often used by skybox
  14008. */
  14009. get infiniteDistance(): boolean;
  14010. set infiniteDistance(value: boolean);
  14011. /**
  14012. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14013. * By default the system will update normals to compensate
  14014. */
  14015. ignoreNonUniformScaling: boolean;
  14016. /**
  14017. * 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
  14018. */
  14019. reIntegrateRotationIntoRotationQuaternion: boolean;
  14020. /** @hidden */
  14021. _poseMatrix: Nullable<Matrix>;
  14022. /** @hidden */
  14023. _localMatrix: Matrix;
  14024. private _usePivotMatrix;
  14025. private _absolutePosition;
  14026. private _absoluteScaling;
  14027. private _absoluteRotationQuaternion;
  14028. private _pivotMatrix;
  14029. private _pivotMatrixInverse;
  14030. protected _postMultiplyPivotMatrix: boolean;
  14031. protected _isWorldMatrixFrozen: boolean;
  14032. /** @hidden */
  14033. _indexInSceneTransformNodesArray: number;
  14034. /**
  14035. * An event triggered after the world matrix is updated
  14036. */
  14037. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14038. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14039. /**
  14040. * Gets a string identifying the name of the class
  14041. * @returns "TransformNode" string
  14042. */
  14043. getClassName(): string;
  14044. /**
  14045. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14046. */
  14047. get position(): Vector3;
  14048. set position(newPosition: Vector3);
  14049. /**
  14050. * 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)).
  14051. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14052. */
  14053. get rotation(): Vector3;
  14054. set rotation(newRotation: Vector3);
  14055. /**
  14056. * 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)).
  14057. */
  14058. get scaling(): Vector3;
  14059. set scaling(newScaling: Vector3);
  14060. /**
  14061. * 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).
  14062. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14063. */
  14064. get rotationQuaternion(): Nullable<Quaternion>;
  14065. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14066. /**
  14067. * The forward direction of that transform in world space.
  14068. */
  14069. get forward(): Vector3;
  14070. /**
  14071. * The up direction of that transform in world space.
  14072. */
  14073. get up(): Vector3;
  14074. /**
  14075. * The right direction of that transform in world space.
  14076. */
  14077. get right(): Vector3;
  14078. /**
  14079. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14080. * @param matrix the matrix to copy the pose from
  14081. * @returns this TransformNode.
  14082. */
  14083. updatePoseMatrix(matrix: Matrix): TransformNode;
  14084. /**
  14085. * Returns the mesh Pose matrix.
  14086. * @returns the pose matrix
  14087. */
  14088. getPoseMatrix(): Matrix;
  14089. /** @hidden */
  14090. _isSynchronized(): boolean;
  14091. /** @hidden */
  14092. _initCache(): void;
  14093. /**
  14094. * Flag the transform node as dirty (Forcing it to update everything)
  14095. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14096. * @returns this transform node
  14097. */
  14098. markAsDirty(property: string): TransformNode;
  14099. /**
  14100. * Returns the current mesh absolute position.
  14101. * Returns a Vector3.
  14102. */
  14103. get absolutePosition(): Vector3;
  14104. /**
  14105. * Returns the current mesh absolute scaling.
  14106. * Returns a Vector3.
  14107. */
  14108. get absoluteScaling(): Vector3;
  14109. /**
  14110. * Returns the current mesh absolute rotation.
  14111. * Returns a Quaternion.
  14112. */
  14113. get absoluteRotationQuaternion(): Quaternion;
  14114. /**
  14115. * Sets a new matrix to apply before all other transformation
  14116. * @param matrix defines the transform matrix
  14117. * @returns the current TransformNode
  14118. */
  14119. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14120. /**
  14121. * Sets a new pivot matrix to the current node
  14122. * @param matrix defines the new pivot matrix to use
  14123. * @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
  14124. * @returns the current TransformNode
  14125. */
  14126. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14127. /**
  14128. * Returns the mesh pivot matrix.
  14129. * Default : Identity.
  14130. * @returns the matrix
  14131. */
  14132. getPivotMatrix(): Matrix;
  14133. /**
  14134. * Instantiate (when possible) or clone that node with its hierarchy
  14135. * @param newParent defines the new parent to use for the instance (or clone)
  14136. * @param options defines options to configure how copy is done
  14137. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14138. * @returns an instance (or a clone) of the current node with its hiearchy
  14139. */
  14140. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14141. doNotInstantiate: boolean;
  14142. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14143. /**
  14144. * Prevents the World matrix to be computed any longer
  14145. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14146. * @returns the TransformNode.
  14147. */
  14148. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14149. /**
  14150. * Allows back the World matrix computation.
  14151. * @returns the TransformNode.
  14152. */
  14153. unfreezeWorldMatrix(): this;
  14154. /**
  14155. * True if the World matrix has been frozen.
  14156. */
  14157. get isWorldMatrixFrozen(): boolean;
  14158. /**
  14159. * Retuns the mesh absolute position in the World.
  14160. * @returns a Vector3.
  14161. */
  14162. getAbsolutePosition(): Vector3;
  14163. /**
  14164. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14165. * @param absolutePosition the absolute position to set
  14166. * @returns the TransformNode.
  14167. */
  14168. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14169. /**
  14170. * Sets the mesh position in its local space.
  14171. * @param vector3 the position to set in localspace
  14172. * @returns the TransformNode.
  14173. */
  14174. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14175. /**
  14176. * Returns the mesh position in the local space from the current World matrix values.
  14177. * @returns a new Vector3.
  14178. */
  14179. getPositionExpressedInLocalSpace(): Vector3;
  14180. /**
  14181. * Translates the mesh along the passed Vector3 in its local space.
  14182. * @param vector3 the distance to translate in localspace
  14183. * @returns the TransformNode.
  14184. */
  14185. locallyTranslate(vector3: Vector3): TransformNode;
  14186. private static _lookAtVectorCache;
  14187. /**
  14188. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14189. * @param targetPoint the position (must be in same space as current mesh) to look at
  14190. * @param yawCor optional yaw (y-axis) correction in radians
  14191. * @param pitchCor optional pitch (x-axis) correction in radians
  14192. * @param rollCor optional roll (z-axis) correction in radians
  14193. * @param space the choosen space of the target
  14194. * @returns the TransformNode.
  14195. */
  14196. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14197. /**
  14198. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14199. * This Vector3 is expressed in the World space.
  14200. * @param localAxis axis to rotate
  14201. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14202. */
  14203. getDirection(localAxis: Vector3): Vector3;
  14204. /**
  14205. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14206. * localAxis is expressed in the mesh local space.
  14207. * result is computed in the Wordl space from the mesh World matrix.
  14208. * @param localAxis axis to rotate
  14209. * @param result the resulting transformnode
  14210. * @returns this TransformNode.
  14211. */
  14212. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14213. /**
  14214. * Sets this transform node rotation to the given local axis.
  14215. * @param localAxis the axis in local space
  14216. * @param yawCor optional yaw (y-axis) correction in radians
  14217. * @param pitchCor optional pitch (x-axis) correction in radians
  14218. * @param rollCor optional roll (z-axis) correction in radians
  14219. * @returns this TransformNode
  14220. */
  14221. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14222. /**
  14223. * Sets a new pivot point to the current node
  14224. * @param point defines the new pivot point to use
  14225. * @param space defines if the point is in world or local space (local by default)
  14226. * @returns the current TransformNode
  14227. */
  14228. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14229. /**
  14230. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14231. * @returns the pivot point
  14232. */
  14233. getPivotPoint(): Vector3;
  14234. /**
  14235. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14236. * @param result the vector3 to store the result
  14237. * @returns this TransformNode.
  14238. */
  14239. getPivotPointToRef(result: Vector3): TransformNode;
  14240. /**
  14241. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14242. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14243. */
  14244. getAbsolutePivotPoint(): Vector3;
  14245. /**
  14246. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14247. * @param result vector3 to store the result
  14248. * @returns this TransformNode.
  14249. */
  14250. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14251. /**
  14252. * Defines the passed node as the parent of the current node.
  14253. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14254. * @see https://doc.babylonjs.com/how_to/parenting
  14255. * @param node the node ot set as the parent
  14256. * @returns this TransformNode.
  14257. */
  14258. setParent(node: Nullable<Node>): TransformNode;
  14259. private _nonUniformScaling;
  14260. /**
  14261. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14262. */
  14263. get nonUniformScaling(): boolean;
  14264. /** @hidden */
  14265. _updateNonUniformScalingState(value: boolean): boolean;
  14266. /**
  14267. * Attach the current TransformNode to another TransformNode associated with a bone
  14268. * @param bone Bone affecting the TransformNode
  14269. * @param affectedTransformNode TransformNode associated with the bone
  14270. * @returns this object
  14271. */
  14272. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14273. /**
  14274. * Detach the transform node if its associated with a bone
  14275. * @returns this object
  14276. */
  14277. detachFromBone(): TransformNode;
  14278. private static _rotationAxisCache;
  14279. /**
  14280. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14281. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14282. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14283. * The passed axis is also normalized.
  14284. * @param axis the axis to rotate around
  14285. * @param amount the amount to rotate in radians
  14286. * @param space Space to rotate in (Default: local)
  14287. * @returns the TransformNode.
  14288. */
  14289. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14290. /**
  14291. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14292. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14293. * The passed axis is also normalized. .
  14294. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14295. * @param point the point to rotate around
  14296. * @param axis the axis to rotate around
  14297. * @param amount the amount to rotate in radians
  14298. * @returns the TransformNode
  14299. */
  14300. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14301. /**
  14302. * Translates the mesh along the axis vector for the passed distance in the given space.
  14303. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14304. * @param axis the axis to translate in
  14305. * @param distance the distance to translate
  14306. * @param space Space to rotate in (Default: local)
  14307. * @returns the TransformNode.
  14308. */
  14309. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14310. /**
  14311. * Adds a rotation step to the mesh current rotation.
  14312. * x, y, z are Euler angles expressed in radians.
  14313. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14314. * This means this rotation is made in the mesh local space only.
  14315. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14316. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14317. * ```javascript
  14318. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14319. * ```
  14320. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14321. * 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.
  14322. * @param x Rotation to add
  14323. * @param y Rotation to add
  14324. * @param z Rotation to add
  14325. * @returns the TransformNode.
  14326. */
  14327. addRotation(x: number, y: number, z: number): TransformNode;
  14328. /**
  14329. * @hidden
  14330. */
  14331. protected _getEffectiveParent(): Nullable<Node>;
  14332. /**
  14333. * Computes the world matrix of the node
  14334. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14335. * @returns the world matrix
  14336. */
  14337. computeWorldMatrix(force?: boolean): Matrix;
  14338. /**
  14339. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14340. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14341. */
  14342. resetLocalMatrix(independentOfChildren?: boolean): void;
  14343. protected _afterComputeWorldMatrix(): void;
  14344. /**
  14345. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14346. * @param func callback function to add
  14347. *
  14348. * @returns the TransformNode.
  14349. */
  14350. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14351. /**
  14352. * Removes a registered callback function.
  14353. * @param func callback function to remove
  14354. * @returns the TransformNode.
  14355. */
  14356. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14357. /**
  14358. * Gets the position of the current mesh in camera space
  14359. * @param camera defines the camera to use
  14360. * @returns a position
  14361. */
  14362. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14363. /**
  14364. * Returns the distance from the mesh to the active camera
  14365. * @param camera defines the camera to use
  14366. * @returns the distance
  14367. */
  14368. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14369. /**
  14370. * Clone the current transform node
  14371. * @param name Name of the new clone
  14372. * @param newParent New parent for the clone
  14373. * @param doNotCloneChildren Do not clone children hierarchy
  14374. * @returns the new transform node
  14375. */
  14376. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14377. /**
  14378. * Serializes the objects information.
  14379. * @param currentSerializationObject defines the object to serialize in
  14380. * @returns the serialized object
  14381. */
  14382. serialize(currentSerializationObject?: any): any;
  14383. /**
  14384. * Returns a new TransformNode object parsed from the source provided.
  14385. * @param parsedTransformNode is the source.
  14386. * @param scene the scne the object belongs to
  14387. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14388. * @returns a new TransformNode object parsed from the source provided.
  14389. */
  14390. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14391. /**
  14392. * Get all child-transformNodes of this node
  14393. * @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
  14394. * @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
  14395. * @returns an array of TransformNode
  14396. */
  14397. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14398. /**
  14399. * Releases resources associated with this transform node.
  14400. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14401. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14402. */
  14403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14404. /**
  14405. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14406. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14407. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14408. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14409. * @returns the current mesh
  14410. */
  14411. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14412. private _syncAbsoluteScalingAndRotation;
  14413. }
  14414. }
  14415. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14416. /**
  14417. * Class used to override all child animations of a given target
  14418. */
  14419. export class AnimationPropertiesOverride {
  14420. /**
  14421. * Gets or sets a value indicating if animation blending must be used
  14422. */
  14423. enableBlending: boolean;
  14424. /**
  14425. * Gets or sets the blending speed to use when enableBlending is true
  14426. */
  14427. blendingSpeed: number;
  14428. /**
  14429. * Gets or sets the default loop mode to use
  14430. */
  14431. loopMode: number;
  14432. }
  14433. }
  14434. declare module "babylonjs/Bones/bone" {
  14435. import { Skeleton } from "babylonjs/Bones/skeleton";
  14436. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14437. import { Nullable } from "babylonjs/types";
  14438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14439. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14440. import { Node } from "babylonjs/node";
  14441. import { Space } from "babylonjs/Maths/math.axis";
  14442. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14443. /**
  14444. * Class used to store bone information
  14445. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14446. */
  14447. export class Bone extends Node {
  14448. /**
  14449. * defines the bone name
  14450. */
  14451. name: string;
  14452. private static _tmpVecs;
  14453. private static _tmpQuat;
  14454. private static _tmpMats;
  14455. /**
  14456. * Gets the list of child bones
  14457. */
  14458. children: Bone[];
  14459. /** Gets the animations associated with this bone */
  14460. animations: import("babylonjs/Animations/animation").Animation[];
  14461. /**
  14462. * Gets or sets bone length
  14463. */
  14464. length: number;
  14465. /**
  14466. * @hidden Internal only
  14467. * Set this value to map this bone to a different index in the transform matrices
  14468. * Set this value to -1 to exclude the bone from the transform matrices
  14469. */
  14470. _index: Nullable<number>;
  14471. private _skeleton;
  14472. private _localMatrix;
  14473. private _restPose;
  14474. private _baseMatrix;
  14475. private _absoluteTransform;
  14476. private _invertedAbsoluteTransform;
  14477. private _parent;
  14478. private _scalingDeterminant;
  14479. private _worldTransform;
  14480. private _localScaling;
  14481. private _localRotation;
  14482. private _localPosition;
  14483. private _needToDecompose;
  14484. private _needToCompose;
  14485. /** @hidden */
  14486. _linkedTransformNode: Nullable<TransformNode>;
  14487. /** @hidden */
  14488. _waitingTransformNodeId: Nullable<string>;
  14489. /** @hidden */
  14490. get _matrix(): Matrix;
  14491. /** @hidden */
  14492. set _matrix(value: Matrix);
  14493. /**
  14494. * Create a new bone
  14495. * @param name defines the bone name
  14496. * @param skeleton defines the parent skeleton
  14497. * @param parentBone defines the parent (can be null if the bone is the root)
  14498. * @param localMatrix defines the local matrix
  14499. * @param restPose defines the rest pose matrix
  14500. * @param baseMatrix defines the base matrix
  14501. * @param index defines index of the bone in the hiearchy
  14502. */
  14503. constructor(
  14504. /**
  14505. * defines the bone name
  14506. */
  14507. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14508. /**
  14509. * Gets the current object class name.
  14510. * @return the class name
  14511. */
  14512. getClassName(): string;
  14513. /**
  14514. * Gets the parent skeleton
  14515. * @returns a skeleton
  14516. */
  14517. getSkeleton(): Skeleton;
  14518. /**
  14519. * Gets parent bone
  14520. * @returns a bone or null if the bone is the root of the bone hierarchy
  14521. */
  14522. getParent(): Nullable<Bone>;
  14523. /**
  14524. * Returns an array containing the root bones
  14525. * @returns an array containing the root bones
  14526. */
  14527. getChildren(): Array<Bone>;
  14528. /**
  14529. * Gets the node index in matrix array generated for rendering
  14530. * @returns the node index
  14531. */
  14532. getIndex(): number;
  14533. /**
  14534. * Sets the parent bone
  14535. * @param parent defines the parent (can be null if the bone is the root)
  14536. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14537. */
  14538. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14539. /**
  14540. * Gets the local matrix
  14541. * @returns a matrix
  14542. */
  14543. getLocalMatrix(): Matrix;
  14544. /**
  14545. * Gets the base matrix (initial matrix which remains unchanged)
  14546. * @returns a matrix
  14547. */
  14548. getBaseMatrix(): Matrix;
  14549. /**
  14550. * Gets the rest pose matrix
  14551. * @returns a matrix
  14552. */
  14553. getRestPose(): Matrix;
  14554. /**
  14555. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14556. */
  14557. getWorldMatrix(): Matrix;
  14558. /**
  14559. * Sets the local matrix to rest pose matrix
  14560. */
  14561. returnToRest(): void;
  14562. /**
  14563. * Gets the inverse of the absolute transform matrix.
  14564. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14565. * @returns a matrix
  14566. */
  14567. getInvertedAbsoluteTransform(): Matrix;
  14568. /**
  14569. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14570. * @returns a matrix
  14571. */
  14572. getAbsoluteTransform(): Matrix;
  14573. /**
  14574. * Links with the given transform node.
  14575. * The local matrix of this bone is copied from the transform node every frame.
  14576. * @param transformNode defines the transform node to link to
  14577. */
  14578. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14579. /**
  14580. * Gets the node used to drive the bone's transformation
  14581. * @returns a transform node or null
  14582. */
  14583. getTransformNode(): Nullable<TransformNode>;
  14584. /** Gets or sets current position (in local space) */
  14585. get position(): Vector3;
  14586. set position(newPosition: Vector3);
  14587. /** Gets or sets current rotation (in local space) */
  14588. get rotation(): Vector3;
  14589. set rotation(newRotation: Vector3);
  14590. /** Gets or sets current rotation quaternion (in local space) */
  14591. get rotationQuaternion(): Quaternion;
  14592. set rotationQuaternion(newRotation: Quaternion);
  14593. /** Gets or sets current scaling (in local space) */
  14594. get scaling(): Vector3;
  14595. set scaling(newScaling: Vector3);
  14596. /**
  14597. * Gets the animation properties override
  14598. */
  14599. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14600. private _decompose;
  14601. private _compose;
  14602. /**
  14603. * Update the base and local matrices
  14604. * @param matrix defines the new base or local matrix
  14605. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14606. * @param updateLocalMatrix defines if the local matrix should be updated
  14607. */
  14608. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14609. /** @hidden */
  14610. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14611. /**
  14612. * Flag the bone as dirty (Forcing it to update everything)
  14613. */
  14614. markAsDirty(): void;
  14615. /** @hidden */
  14616. _markAsDirtyAndCompose(): void;
  14617. private _markAsDirtyAndDecompose;
  14618. /**
  14619. * Translate the bone in local or world space
  14620. * @param vec The amount to translate the bone
  14621. * @param space The space that the translation is in
  14622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14623. */
  14624. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14625. /**
  14626. * Set the postion of the bone in local or world space
  14627. * @param position The position to set the bone
  14628. * @param space The space that the position is in
  14629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14630. */
  14631. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14632. /**
  14633. * Set the absolute position of the bone (world space)
  14634. * @param position The position to set the bone
  14635. * @param mesh The mesh that this bone is attached to
  14636. */
  14637. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14638. /**
  14639. * Scale the bone on the x, y and z axes (in local space)
  14640. * @param x The amount to scale the bone on the x axis
  14641. * @param y The amount to scale the bone on the y axis
  14642. * @param z The amount to scale the bone on the z axis
  14643. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14644. */
  14645. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14646. /**
  14647. * Set the bone scaling in local space
  14648. * @param scale defines the scaling vector
  14649. */
  14650. setScale(scale: Vector3): void;
  14651. /**
  14652. * Gets the current scaling in local space
  14653. * @returns the current scaling vector
  14654. */
  14655. getScale(): Vector3;
  14656. /**
  14657. * Gets the current scaling in local space and stores it in a target vector
  14658. * @param result defines the target vector
  14659. */
  14660. getScaleToRef(result: Vector3): void;
  14661. /**
  14662. * Set the yaw, pitch, and roll of the bone in local or world space
  14663. * @param yaw The rotation of the bone on the y axis
  14664. * @param pitch The rotation of the bone on the x axis
  14665. * @param roll The rotation of the bone on the z axis
  14666. * @param space The space that the axes of rotation are in
  14667. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14668. */
  14669. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14670. /**
  14671. * Add a rotation to the bone on an axis in local or world space
  14672. * @param axis The axis to rotate the bone on
  14673. * @param amount The amount to rotate the bone
  14674. * @param space The space that the axis is in
  14675. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14676. */
  14677. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14678. /**
  14679. * Set the rotation of the bone to a particular axis angle in local or world space
  14680. * @param axis The axis to rotate the bone on
  14681. * @param angle The angle that the bone should be rotated to
  14682. * @param space The space that the axis is in
  14683. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14684. */
  14685. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14686. /**
  14687. * Set the euler rotation of the bone in local of world space
  14688. * @param rotation The euler rotation that the bone should be set to
  14689. * @param space The space that the rotation is in
  14690. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14691. */
  14692. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14693. /**
  14694. * Set the quaternion rotation of the bone in local of world space
  14695. * @param quat The quaternion rotation that the bone should be set to
  14696. * @param space The space that the rotation is in
  14697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14698. */
  14699. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14700. /**
  14701. * Set the rotation matrix of the bone in local of world space
  14702. * @param rotMat The rotation matrix that the bone should be set to
  14703. * @param space The space that the rotation is in
  14704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14705. */
  14706. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14707. private _rotateWithMatrix;
  14708. private _getNegativeRotationToRef;
  14709. /**
  14710. * Get the position of the bone in local or world space
  14711. * @param space The space that the returned position is in
  14712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14713. * @returns The position of the bone
  14714. */
  14715. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14716. /**
  14717. * Copy the position of the bone to a vector3 in local or world space
  14718. * @param space The space that the returned position is in
  14719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14720. * @param result The vector3 to copy the position to
  14721. */
  14722. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14723. /**
  14724. * Get the absolute position of the bone (world space)
  14725. * @param mesh The mesh that this bone is attached to
  14726. * @returns The absolute position of the bone
  14727. */
  14728. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14729. /**
  14730. * Copy the absolute position of the bone (world space) to the result param
  14731. * @param mesh The mesh that this bone is attached to
  14732. * @param result The vector3 to copy the absolute position to
  14733. */
  14734. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14735. /**
  14736. * Compute the absolute transforms of this bone and its children
  14737. */
  14738. computeAbsoluteTransforms(): void;
  14739. /**
  14740. * Get the world direction from an axis that is in the local space of the bone
  14741. * @param localAxis The local direction that is used to compute the world direction
  14742. * @param mesh The mesh that this bone is attached to
  14743. * @returns The world direction
  14744. */
  14745. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14746. /**
  14747. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14748. * @param localAxis The local direction that is used to compute the world direction
  14749. * @param mesh The mesh that this bone is attached to
  14750. * @param result The vector3 that the world direction will be copied to
  14751. */
  14752. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14753. /**
  14754. * Get the euler rotation of the bone in local or world space
  14755. * @param space The space that the rotation should be in
  14756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14757. * @returns The euler rotation
  14758. */
  14759. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14760. /**
  14761. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14762. * @param space The space that the rotation should be in
  14763. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14764. * @param result The vector3 that the rotation should be copied to
  14765. */
  14766. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14767. /**
  14768. * Get the quaternion rotation of the bone in either local or world space
  14769. * @param space The space that the rotation should be in
  14770. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14771. * @returns The quaternion rotation
  14772. */
  14773. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14774. /**
  14775. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14776. * @param space The space that the rotation should be in
  14777. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14778. * @param result The quaternion that the rotation should be copied to
  14779. */
  14780. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14781. /**
  14782. * Get the rotation matrix of the bone in local or world space
  14783. * @param space The space that the rotation should be in
  14784. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14785. * @returns The rotation matrix
  14786. */
  14787. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14788. /**
  14789. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14790. * @param space The space that the rotation should be in
  14791. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14792. * @param result The quaternion that the rotation should be copied to
  14793. */
  14794. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14795. /**
  14796. * Get the world position of a point that is in the local space of the bone
  14797. * @param position The local position
  14798. * @param mesh The mesh that this bone is attached to
  14799. * @returns The world position
  14800. */
  14801. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14802. /**
  14803. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14804. * @param position The local position
  14805. * @param mesh The mesh that this bone is attached to
  14806. * @param result The vector3 that the world position should be copied to
  14807. */
  14808. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14809. /**
  14810. * Get the local position of a point that is in world space
  14811. * @param position The world position
  14812. * @param mesh The mesh that this bone is attached to
  14813. * @returns The local position
  14814. */
  14815. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14816. /**
  14817. * Get the local position of a point that is in world space and copy it to the result param
  14818. * @param position The world position
  14819. * @param mesh The mesh that this bone is attached to
  14820. * @param result The vector3 that the local position should be copied to
  14821. */
  14822. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14823. }
  14824. }
  14825. declare module "babylonjs/Animations/runtimeAnimation" {
  14826. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14827. import { Animatable } from "babylonjs/Animations/animatable";
  14828. import { Scene } from "babylonjs/scene";
  14829. /**
  14830. * Defines a runtime animation
  14831. */
  14832. export class RuntimeAnimation {
  14833. private _events;
  14834. /**
  14835. * The current frame of the runtime animation
  14836. */
  14837. private _currentFrame;
  14838. /**
  14839. * The animation used by the runtime animation
  14840. */
  14841. private _animation;
  14842. /**
  14843. * The target of the runtime animation
  14844. */
  14845. private _target;
  14846. /**
  14847. * The initiating animatable
  14848. */
  14849. private _host;
  14850. /**
  14851. * The original value of the runtime animation
  14852. */
  14853. private _originalValue;
  14854. /**
  14855. * The original blend value of the runtime animation
  14856. */
  14857. private _originalBlendValue;
  14858. /**
  14859. * The offsets cache of the runtime animation
  14860. */
  14861. private _offsetsCache;
  14862. /**
  14863. * The high limits cache of the runtime animation
  14864. */
  14865. private _highLimitsCache;
  14866. /**
  14867. * Specifies if the runtime animation has been stopped
  14868. */
  14869. private _stopped;
  14870. /**
  14871. * The blending factor of the runtime animation
  14872. */
  14873. private _blendingFactor;
  14874. /**
  14875. * The BabylonJS scene
  14876. */
  14877. private _scene;
  14878. /**
  14879. * The current value of the runtime animation
  14880. */
  14881. private _currentValue;
  14882. /** @hidden */
  14883. _animationState: _IAnimationState;
  14884. /**
  14885. * The active target of the runtime animation
  14886. */
  14887. private _activeTargets;
  14888. private _currentActiveTarget;
  14889. private _directTarget;
  14890. /**
  14891. * The target path of the runtime animation
  14892. */
  14893. private _targetPath;
  14894. /**
  14895. * The weight of the runtime animation
  14896. */
  14897. private _weight;
  14898. /**
  14899. * The ratio offset of the runtime animation
  14900. */
  14901. private _ratioOffset;
  14902. /**
  14903. * The previous delay of the runtime animation
  14904. */
  14905. private _previousDelay;
  14906. /**
  14907. * The previous ratio of the runtime animation
  14908. */
  14909. private _previousRatio;
  14910. private _enableBlending;
  14911. private _keys;
  14912. private _minFrame;
  14913. private _maxFrame;
  14914. private _minValue;
  14915. private _maxValue;
  14916. private _targetIsArray;
  14917. /**
  14918. * Gets the current frame of the runtime animation
  14919. */
  14920. get currentFrame(): number;
  14921. /**
  14922. * Gets the weight of the runtime animation
  14923. */
  14924. get weight(): number;
  14925. /**
  14926. * Gets the current value of the runtime animation
  14927. */
  14928. get currentValue(): any;
  14929. /**
  14930. * Gets the target path of the runtime animation
  14931. */
  14932. get targetPath(): string;
  14933. /**
  14934. * Gets the actual target of the runtime animation
  14935. */
  14936. get target(): any;
  14937. /**
  14938. * Gets the additive state of the runtime animation
  14939. */
  14940. get isAdditive(): boolean;
  14941. /** @hidden */
  14942. _onLoop: () => void;
  14943. /**
  14944. * Create a new RuntimeAnimation object
  14945. * @param target defines the target of the animation
  14946. * @param animation defines the source animation object
  14947. * @param scene defines the hosting scene
  14948. * @param host defines the initiating Animatable
  14949. */
  14950. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14951. private _preparePath;
  14952. /**
  14953. * Gets the animation from the runtime animation
  14954. */
  14955. get animation(): Animation;
  14956. /**
  14957. * Resets the runtime animation to the beginning
  14958. * @param restoreOriginal defines whether to restore the target property to the original value
  14959. */
  14960. reset(restoreOriginal?: boolean): void;
  14961. /**
  14962. * Specifies if the runtime animation is stopped
  14963. * @returns Boolean specifying if the runtime animation is stopped
  14964. */
  14965. isStopped(): boolean;
  14966. /**
  14967. * Disposes of the runtime animation
  14968. */
  14969. dispose(): void;
  14970. /**
  14971. * Apply the interpolated value to the target
  14972. * @param currentValue defines the value computed by the animation
  14973. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14974. */
  14975. setValue(currentValue: any, weight: number): void;
  14976. private _getOriginalValues;
  14977. private _setValue;
  14978. /**
  14979. * Gets the loop pmode of the runtime animation
  14980. * @returns Loop Mode
  14981. */
  14982. private _getCorrectLoopMode;
  14983. /**
  14984. * Move the current animation to a given frame
  14985. * @param frame defines the frame to move to
  14986. */
  14987. goToFrame(frame: number): void;
  14988. /**
  14989. * @hidden Internal use only
  14990. */
  14991. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14992. /**
  14993. * Execute the current animation
  14994. * @param delay defines the delay to add to the current frame
  14995. * @param from defines the lower bound of the animation range
  14996. * @param to defines the upper bound of the animation range
  14997. * @param loop defines if the current animation must loop
  14998. * @param speedRatio defines the current speed ratio
  14999. * @param weight defines the weight of the animation (default is -1 so no weight)
  15000. * @param onLoop optional callback called when animation loops
  15001. * @returns a boolean indicating if the animation is running
  15002. */
  15003. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15004. }
  15005. }
  15006. declare module "babylonjs/Animations/animatable" {
  15007. import { Animation } from "babylonjs/Animations/animation";
  15008. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15009. import { Nullable } from "babylonjs/types";
  15010. import { Observable } from "babylonjs/Misc/observable";
  15011. import { Scene } from "babylonjs/scene";
  15012. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15013. import { Node } from "babylonjs/node";
  15014. /**
  15015. * Class used to store an actual running animation
  15016. */
  15017. export class Animatable {
  15018. /** defines the target object */
  15019. target: any;
  15020. /** defines the starting frame number (default is 0) */
  15021. fromFrame: number;
  15022. /** defines the ending frame number (default is 100) */
  15023. toFrame: number;
  15024. /** defines if the animation must loop (default is false) */
  15025. loopAnimation: boolean;
  15026. /** defines a callback to call when animation ends if it is not looping */
  15027. onAnimationEnd?: (() => void) | null | undefined;
  15028. /** defines a callback to call when animation loops */
  15029. onAnimationLoop?: (() => void) | null | undefined;
  15030. /** defines whether the animation should be evaluated additively */
  15031. isAdditive: boolean;
  15032. private _localDelayOffset;
  15033. private _pausedDelay;
  15034. private _runtimeAnimations;
  15035. private _paused;
  15036. private _scene;
  15037. private _speedRatio;
  15038. private _weight;
  15039. private _syncRoot;
  15040. /**
  15041. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15042. * This will only apply for non looping animation (default is true)
  15043. */
  15044. disposeOnEnd: boolean;
  15045. /**
  15046. * Gets a boolean indicating if the animation has started
  15047. */
  15048. animationStarted: boolean;
  15049. /**
  15050. * Observer raised when the animation ends
  15051. */
  15052. onAnimationEndObservable: Observable<Animatable>;
  15053. /**
  15054. * Observer raised when the animation loops
  15055. */
  15056. onAnimationLoopObservable: Observable<Animatable>;
  15057. /**
  15058. * Gets the root Animatable used to synchronize and normalize animations
  15059. */
  15060. get syncRoot(): Nullable<Animatable>;
  15061. /**
  15062. * Gets the current frame of the first RuntimeAnimation
  15063. * Used to synchronize Animatables
  15064. */
  15065. get masterFrame(): number;
  15066. /**
  15067. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15068. */
  15069. get weight(): number;
  15070. set weight(value: number);
  15071. /**
  15072. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15073. */
  15074. get speedRatio(): number;
  15075. set speedRatio(value: number);
  15076. /**
  15077. * Creates a new Animatable
  15078. * @param scene defines the hosting scene
  15079. * @param target defines the target object
  15080. * @param fromFrame defines the starting frame number (default is 0)
  15081. * @param toFrame defines the ending frame number (default is 100)
  15082. * @param loopAnimation defines if the animation must loop (default is false)
  15083. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15084. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15085. * @param animations defines a group of animation to add to the new Animatable
  15086. * @param onAnimationLoop defines a callback to call when animation loops
  15087. * @param isAdditive defines whether the animation should be evaluated additively
  15088. */
  15089. constructor(scene: Scene,
  15090. /** defines the target object */
  15091. target: any,
  15092. /** defines the starting frame number (default is 0) */
  15093. fromFrame?: number,
  15094. /** defines the ending frame number (default is 100) */
  15095. toFrame?: number,
  15096. /** defines if the animation must loop (default is false) */
  15097. loopAnimation?: boolean, speedRatio?: number,
  15098. /** defines a callback to call when animation ends if it is not looping */
  15099. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15100. /** defines a callback to call when animation loops */
  15101. onAnimationLoop?: (() => void) | null | undefined,
  15102. /** defines whether the animation should be evaluated additively */
  15103. isAdditive?: boolean);
  15104. /**
  15105. * Synchronize and normalize current Animatable with a source Animatable
  15106. * This is useful when using animation weights and when animations are not of the same length
  15107. * @param root defines the root Animatable to synchronize with
  15108. * @returns the current Animatable
  15109. */
  15110. syncWith(root: Animatable): Animatable;
  15111. /**
  15112. * Gets the list of runtime animations
  15113. * @returns an array of RuntimeAnimation
  15114. */
  15115. getAnimations(): RuntimeAnimation[];
  15116. /**
  15117. * Adds more animations to the current animatable
  15118. * @param target defines the target of the animations
  15119. * @param animations defines the new animations to add
  15120. */
  15121. appendAnimations(target: any, animations: Animation[]): void;
  15122. /**
  15123. * Gets the source animation for a specific property
  15124. * @param property defines the propertyu to look for
  15125. * @returns null or the source animation for the given property
  15126. */
  15127. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15128. /**
  15129. * Gets the runtime animation for a specific property
  15130. * @param property defines the propertyu to look for
  15131. * @returns null or the runtime animation for the given property
  15132. */
  15133. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15134. /**
  15135. * Resets the animatable to its original state
  15136. */
  15137. reset(): void;
  15138. /**
  15139. * Allows the animatable to blend with current running animations
  15140. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15141. * @param blendingSpeed defines the blending speed to use
  15142. */
  15143. enableBlending(blendingSpeed: number): void;
  15144. /**
  15145. * Disable animation blending
  15146. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15147. */
  15148. disableBlending(): void;
  15149. /**
  15150. * Jump directly to a given frame
  15151. * @param frame defines the frame to jump to
  15152. */
  15153. goToFrame(frame: number): void;
  15154. /**
  15155. * Pause the animation
  15156. */
  15157. pause(): void;
  15158. /**
  15159. * Restart the animation
  15160. */
  15161. restart(): void;
  15162. private _raiseOnAnimationEnd;
  15163. /**
  15164. * Stop and delete the current animation
  15165. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15166. * @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)
  15167. */
  15168. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15169. /**
  15170. * Wait asynchronously for the animation to end
  15171. * @returns a promise which will be fullfilled when the animation ends
  15172. */
  15173. waitAsync(): Promise<Animatable>;
  15174. /** @hidden */
  15175. _animate(delay: number): boolean;
  15176. }
  15177. module "babylonjs/scene" {
  15178. interface Scene {
  15179. /** @hidden */
  15180. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15181. /** @hidden */
  15182. _processLateAnimationBindingsForMatrices(holder: {
  15183. totalWeight: number;
  15184. totalAdditiveWeight: number;
  15185. animations: RuntimeAnimation[];
  15186. additiveAnimations: RuntimeAnimation[];
  15187. originalValue: Matrix;
  15188. }): any;
  15189. /** @hidden */
  15190. _processLateAnimationBindingsForQuaternions(holder: {
  15191. totalWeight: number;
  15192. totalAdditiveWeight: number;
  15193. animations: RuntimeAnimation[];
  15194. additiveAnimations: RuntimeAnimation[];
  15195. originalValue: Quaternion;
  15196. }, refQuaternion: Quaternion): Quaternion;
  15197. /** @hidden */
  15198. _processLateAnimationBindings(): void;
  15199. /**
  15200. * Will start the animation sequence of a given target
  15201. * @param target defines the target
  15202. * @param from defines from which frame should animation start
  15203. * @param to defines until which frame should animation run.
  15204. * @param weight defines the weight to apply to the animation (1.0 by default)
  15205. * @param loop defines if the animation loops
  15206. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15207. * @param onAnimationEnd defines the function to be executed when the animation ends
  15208. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15209. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15210. * @param onAnimationLoop defines the callback to call when an animation loops
  15211. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15212. * @returns the animatable object created for this animation
  15213. */
  15214. 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;
  15215. /**
  15216. * Will start the animation sequence of a given target
  15217. * @param target defines the target
  15218. * @param from defines from which frame should animation start
  15219. * @param to defines until which frame should animation run.
  15220. * @param loop defines if the animation loops
  15221. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15222. * @param onAnimationEnd defines the function to be executed when the animation ends
  15223. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15224. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15225. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15226. * @param onAnimationLoop defines the callback to call when an animation loops
  15227. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15228. * @returns the animatable object created for this animation
  15229. */
  15230. 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;
  15231. /**
  15232. * Will start the animation sequence of a given target and its hierarchy
  15233. * @param target defines the target
  15234. * @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.
  15235. * @param from defines from which frame should animation start
  15236. * @param to defines until which frame should animation run.
  15237. * @param loop defines if the animation loops
  15238. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15239. * @param onAnimationEnd defines the function to be executed when the animation ends
  15240. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15241. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15242. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15243. * @param onAnimationLoop defines the callback to call when an animation loops
  15244. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15245. * @returns the list of created animatables
  15246. */
  15247. 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[];
  15248. /**
  15249. * Begin a new animation on a given node
  15250. * @param target defines the target where the animation will take place
  15251. * @param animations defines the list of animations to start
  15252. * @param from defines the initial value
  15253. * @param to defines the final value
  15254. * @param loop defines if you want animation to loop (off by default)
  15255. * @param speedRatio defines the speed ratio to apply to all animations
  15256. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15257. * @param onAnimationLoop defines the callback to call when an animation loops
  15258. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15259. * @returns the list of created animatables
  15260. */
  15261. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15262. /**
  15263. * Begin a new animation on a given node and its hierarchy
  15264. * @param target defines the root node where the animation will take place
  15265. * @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.
  15266. * @param animations defines the list of animations to start
  15267. * @param from defines the initial value
  15268. * @param to defines the final value
  15269. * @param loop defines if you want animation to loop (off by default)
  15270. * @param speedRatio defines the speed ratio to apply to all animations
  15271. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15272. * @param onAnimationLoop defines the callback to call when an animation loops
  15273. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15274. * @returns the list of animatables created for all nodes
  15275. */
  15276. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15277. /**
  15278. * Gets the animatable associated with a specific target
  15279. * @param target defines the target of the animatable
  15280. * @returns the required animatable if found
  15281. */
  15282. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15283. /**
  15284. * Gets all animatables associated with a given target
  15285. * @param target defines the target to look animatables for
  15286. * @returns an array of Animatables
  15287. */
  15288. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15289. /**
  15290. * Stops and removes all animations that have been applied to the scene
  15291. */
  15292. stopAllAnimations(): void;
  15293. /**
  15294. * Gets the current delta time used by animation engine
  15295. */
  15296. deltaTime: number;
  15297. }
  15298. }
  15299. module "babylonjs/Bones/bone" {
  15300. interface Bone {
  15301. /**
  15302. * Copy an animation range from another bone
  15303. * @param source defines the source bone
  15304. * @param rangeName defines the range name to copy
  15305. * @param frameOffset defines the frame offset
  15306. * @param rescaleAsRequired defines if rescaling must be applied if required
  15307. * @param skelDimensionsRatio defines the scaling ratio
  15308. * @returns true if operation was successful
  15309. */
  15310. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15311. }
  15312. }
  15313. }
  15314. declare module "babylonjs/Bones/skeleton" {
  15315. import { Bone } from "babylonjs/Bones/bone";
  15316. import { Observable } from "babylonjs/Misc/observable";
  15317. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15318. import { Scene } from "babylonjs/scene";
  15319. import { Nullable } from "babylonjs/types";
  15320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15321. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15322. import { Animatable } from "babylonjs/Animations/animatable";
  15323. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15324. import { Animation } from "babylonjs/Animations/animation";
  15325. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15326. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15327. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15328. /**
  15329. * Class used to handle skinning animations
  15330. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15331. */
  15332. export class Skeleton implements IAnimatable {
  15333. /** defines the skeleton name */
  15334. name: string;
  15335. /** defines the skeleton Id */
  15336. id: string;
  15337. /**
  15338. * Defines the list of child bones
  15339. */
  15340. bones: Bone[];
  15341. /**
  15342. * Defines an estimate of the dimension of the skeleton at rest
  15343. */
  15344. dimensionsAtRest: Vector3;
  15345. /**
  15346. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15347. */
  15348. needInitialSkinMatrix: boolean;
  15349. /**
  15350. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15351. */
  15352. overrideMesh: Nullable<AbstractMesh>;
  15353. /**
  15354. * Gets the list of animations attached to this skeleton
  15355. */
  15356. animations: Array<Animation>;
  15357. private _scene;
  15358. private _isDirty;
  15359. private _transformMatrices;
  15360. private _transformMatrixTexture;
  15361. private _meshesWithPoseMatrix;
  15362. private _animatables;
  15363. private _identity;
  15364. private _synchronizedWithMesh;
  15365. private _ranges;
  15366. private _lastAbsoluteTransformsUpdateId;
  15367. private _canUseTextureForBones;
  15368. private _uniqueId;
  15369. /** @hidden */
  15370. _numBonesWithLinkedTransformNode: number;
  15371. /** @hidden */
  15372. _hasWaitingData: Nullable<boolean>;
  15373. /**
  15374. * Specifies if the skeleton should be serialized
  15375. */
  15376. doNotSerialize: boolean;
  15377. private _useTextureToStoreBoneMatrices;
  15378. /**
  15379. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15380. * Please note that this option is not available if the hardware does not support it
  15381. */
  15382. get useTextureToStoreBoneMatrices(): boolean;
  15383. set useTextureToStoreBoneMatrices(value: boolean);
  15384. private _animationPropertiesOverride;
  15385. /**
  15386. * Gets or sets the animation properties override
  15387. */
  15388. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15389. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15390. /**
  15391. * List of inspectable custom properties (used by the Inspector)
  15392. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15393. */
  15394. inspectableCustomProperties: IInspectable[];
  15395. /**
  15396. * An observable triggered before computing the skeleton's matrices
  15397. */
  15398. onBeforeComputeObservable: Observable<Skeleton>;
  15399. /**
  15400. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15401. */
  15402. get isUsingTextureForMatrices(): boolean;
  15403. /**
  15404. * Gets the unique ID of this skeleton
  15405. */
  15406. get uniqueId(): number;
  15407. /**
  15408. * Creates a new skeleton
  15409. * @param name defines the skeleton name
  15410. * @param id defines the skeleton Id
  15411. * @param scene defines the hosting scene
  15412. */
  15413. constructor(
  15414. /** defines the skeleton name */
  15415. name: string,
  15416. /** defines the skeleton Id */
  15417. id: string, scene: Scene);
  15418. /**
  15419. * Gets the current object class name.
  15420. * @return the class name
  15421. */
  15422. getClassName(): string;
  15423. /**
  15424. * Returns an array containing the root bones
  15425. * @returns an array containing the root bones
  15426. */
  15427. getChildren(): Array<Bone>;
  15428. /**
  15429. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15430. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15431. * @returns a Float32Array containing matrices data
  15432. */
  15433. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15434. /**
  15435. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15436. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15437. * @returns a raw texture containing the data
  15438. */
  15439. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15440. /**
  15441. * Gets the current hosting scene
  15442. * @returns a scene object
  15443. */
  15444. getScene(): Scene;
  15445. /**
  15446. * Gets a string representing the current skeleton data
  15447. * @param fullDetails defines a boolean indicating if we want a verbose version
  15448. * @returns a string representing the current skeleton data
  15449. */
  15450. toString(fullDetails?: boolean): string;
  15451. /**
  15452. * Get bone's index searching by name
  15453. * @param name defines bone's name to search for
  15454. * @return the indice of the bone. Returns -1 if not found
  15455. */
  15456. getBoneIndexByName(name: string): number;
  15457. /**
  15458. * Creater a new animation range
  15459. * @param name defines the name of the range
  15460. * @param from defines the start key
  15461. * @param to defines the end key
  15462. */
  15463. createAnimationRange(name: string, from: number, to: number): void;
  15464. /**
  15465. * Delete a specific animation range
  15466. * @param name defines the name of the range
  15467. * @param deleteFrames defines if frames must be removed as well
  15468. */
  15469. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15470. /**
  15471. * Gets a specific animation range
  15472. * @param name defines the name of the range to look for
  15473. * @returns the requested animation range or null if not found
  15474. */
  15475. getAnimationRange(name: string): Nullable<AnimationRange>;
  15476. /**
  15477. * Gets the list of all animation ranges defined on this skeleton
  15478. * @returns an array
  15479. */
  15480. getAnimationRanges(): Nullable<AnimationRange>[];
  15481. /**
  15482. * Copy animation range from a source skeleton.
  15483. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15484. * @param source defines the source skeleton
  15485. * @param name defines the name of the range to copy
  15486. * @param rescaleAsRequired defines if rescaling must be applied if required
  15487. * @returns true if operation was successful
  15488. */
  15489. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15490. /**
  15491. * Forces the skeleton to go to rest pose
  15492. */
  15493. returnToRest(): void;
  15494. private _getHighestAnimationFrame;
  15495. /**
  15496. * Begin a specific animation range
  15497. * @param name defines the name of the range to start
  15498. * @param loop defines if looping must be turned on (false by default)
  15499. * @param speedRatio defines the speed ratio to apply (1 by default)
  15500. * @param onAnimationEnd defines a callback which will be called when animation will end
  15501. * @returns a new animatable
  15502. */
  15503. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15504. /**
  15505. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15506. * @param skeleton defines the Skeleton containing the animation range to convert
  15507. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15508. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15509. * @returns the original skeleton
  15510. */
  15511. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15512. /** @hidden */
  15513. _markAsDirty(): void;
  15514. /** @hidden */
  15515. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15516. /** @hidden */
  15517. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15518. private _computeTransformMatrices;
  15519. /**
  15520. * Build all resources required to render a skeleton
  15521. */
  15522. prepare(): void;
  15523. /**
  15524. * Gets the list of animatables currently running for this skeleton
  15525. * @returns an array of animatables
  15526. */
  15527. getAnimatables(): IAnimatable[];
  15528. /**
  15529. * Clone the current skeleton
  15530. * @param name defines the name of the new skeleton
  15531. * @param id defines the id of the new skeleton
  15532. * @returns the new skeleton
  15533. */
  15534. clone(name: string, id?: string): Skeleton;
  15535. /**
  15536. * Enable animation blending for this skeleton
  15537. * @param blendingSpeed defines the blending speed to apply
  15538. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15539. */
  15540. enableBlending(blendingSpeed?: number): void;
  15541. /**
  15542. * Releases all resources associated with the current skeleton
  15543. */
  15544. dispose(): void;
  15545. /**
  15546. * Serialize the skeleton in a JSON object
  15547. * @returns a JSON object
  15548. */
  15549. serialize(): any;
  15550. /**
  15551. * Creates a new skeleton from serialized data
  15552. * @param parsedSkeleton defines the serialized data
  15553. * @param scene defines the hosting scene
  15554. * @returns a new skeleton
  15555. */
  15556. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15557. /**
  15558. * Compute all node absolute transforms
  15559. * @param forceUpdate defines if computation must be done even if cache is up to date
  15560. */
  15561. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15562. /**
  15563. * Gets the root pose matrix
  15564. * @returns a matrix
  15565. */
  15566. getPoseMatrix(): Nullable<Matrix>;
  15567. /**
  15568. * Sorts bones per internal index
  15569. */
  15570. sortBones(): void;
  15571. private _sortBones;
  15572. }
  15573. }
  15574. declare module "babylonjs/Meshes/instancedMesh" {
  15575. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15576. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15577. import { Camera } from "babylonjs/Cameras/camera";
  15578. import { Node } from "babylonjs/node";
  15579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15580. import { Mesh } from "babylonjs/Meshes/mesh";
  15581. import { Material } from "babylonjs/Materials/material";
  15582. import { Skeleton } from "babylonjs/Bones/skeleton";
  15583. import { Light } from "babylonjs/Lights/light";
  15584. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15585. /**
  15586. * Creates an instance based on a source mesh.
  15587. */
  15588. export class InstancedMesh extends AbstractMesh {
  15589. private _sourceMesh;
  15590. private _currentLOD;
  15591. /** @hidden */
  15592. _indexInSourceMeshInstanceArray: number;
  15593. constructor(name: string, source: Mesh);
  15594. /**
  15595. * Returns the string "InstancedMesh".
  15596. */
  15597. getClassName(): string;
  15598. /** Gets the list of lights affecting that mesh */
  15599. get lightSources(): Light[];
  15600. _resyncLightSources(): void;
  15601. _resyncLightSource(light: Light): void;
  15602. _removeLightSource(light: Light, dispose: boolean): void;
  15603. /**
  15604. * If the source mesh receives shadows
  15605. */
  15606. get receiveShadows(): boolean;
  15607. /**
  15608. * The material of the source mesh
  15609. */
  15610. get material(): Nullable<Material>;
  15611. /**
  15612. * Visibility of the source mesh
  15613. */
  15614. get visibility(): number;
  15615. /**
  15616. * Skeleton of the source mesh
  15617. */
  15618. get skeleton(): Nullable<Skeleton>;
  15619. /**
  15620. * Rendering ground id of the source mesh
  15621. */
  15622. get renderingGroupId(): number;
  15623. set renderingGroupId(value: number);
  15624. /**
  15625. * Returns the total number of vertices (integer).
  15626. */
  15627. getTotalVertices(): number;
  15628. /**
  15629. * Returns a positive integer : the total number of indices in this mesh geometry.
  15630. * @returns the numner of indices or zero if the mesh has no geometry.
  15631. */
  15632. getTotalIndices(): number;
  15633. /**
  15634. * The source mesh of the instance
  15635. */
  15636. get sourceMesh(): Mesh;
  15637. /**
  15638. * Is this node ready to be used/rendered
  15639. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15640. * @return {boolean} is it ready
  15641. */
  15642. isReady(completeCheck?: boolean): boolean;
  15643. /**
  15644. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15645. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15646. * @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.
  15647. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15648. */
  15649. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15650. /**
  15651. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15652. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15653. * The `data` are either a numeric array either a Float32Array.
  15654. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15655. * 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).
  15656. * Note that a new underlying VertexBuffer object is created each call.
  15657. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15658. *
  15659. * Possible `kind` values :
  15660. * - VertexBuffer.PositionKind
  15661. * - VertexBuffer.UVKind
  15662. * - VertexBuffer.UV2Kind
  15663. * - VertexBuffer.UV3Kind
  15664. * - VertexBuffer.UV4Kind
  15665. * - VertexBuffer.UV5Kind
  15666. * - VertexBuffer.UV6Kind
  15667. * - VertexBuffer.ColorKind
  15668. * - VertexBuffer.MatricesIndicesKind
  15669. * - VertexBuffer.MatricesIndicesExtraKind
  15670. * - VertexBuffer.MatricesWeightsKind
  15671. * - VertexBuffer.MatricesWeightsExtraKind
  15672. *
  15673. * Returns the Mesh.
  15674. */
  15675. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15676. /**
  15677. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15678. * If the mesh has no geometry, it is simply returned as it is.
  15679. * The `data` are either a numeric array either a Float32Array.
  15680. * No new underlying VertexBuffer object is created.
  15681. * 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.
  15682. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15683. *
  15684. * Possible `kind` values :
  15685. * - VertexBuffer.PositionKind
  15686. * - VertexBuffer.UVKind
  15687. * - VertexBuffer.UV2Kind
  15688. * - VertexBuffer.UV3Kind
  15689. * - VertexBuffer.UV4Kind
  15690. * - VertexBuffer.UV5Kind
  15691. * - VertexBuffer.UV6Kind
  15692. * - VertexBuffer.ColorKind
  15693. * - VertexBuffer.MatricesIndicesKind
  15694. * - VertexBuffer.MatricesIndicesExtraKind
  15695. * - VertexBuffer.MatricesWeightsKind
  15696. * - VertexBuffer.MatricesWeightsExtraKind
  15697. *
  15698. * Returns the Mesh.
  15699. */
  15700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15701. /**
  15702. * Sets the mesh indices.
  15703. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15704. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15705. * This method creates a new index buffer each call.
  15706. * Returns the Mesh.
  15707. */
  15708. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15709. /**
  15710. * Boolean : True if the mesh owns the requested kind of data.
  15711. */
  15712. isVerticesDataPresent(kind: string): boolean;
  15713. /**
  15714. * Returns an array of indices (IndicesArray).
  15715. */
  15716. getIndices(): Nullable<IndicesArray>;
  15717. get _positions(): Nullable<Vector3[]>;
  15718. /**
  15719. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15720. * This means the mesh underlying bounding box and sphere are recomputed.
  15721. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15722. * @returns the current mesh
  15723. */
  15724. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15725. /** @hidden */
  15726. _preActivate(): InstancedMesh;
  15727. /** @hidden */
  15728. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15729. /** @hidden */
  15730. _postActivate(): void;
  15731. getWorldMatrix(): Matrix;
  15732. get isAnInstance(): boolean;
  15733. /**
  15734. * Returns the current associated LOD AbstractMesh.
  15735. */
  15736. getLOD(camera: Camera): AbstractMesh;
  15737. /** @hidden */
  15738. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15739. /** @hidden */
  15740. _syncSubMeshes(): InstancedMesh;
  15741. /** @hidden */
  15742. _generatePointsArray(): boolean;
  15743. /**
  15744. * Creates a new InstancedMesh from the current mesh.
  15745. * - name (string) : the cloned mesh name
  15746. * - newParent (optional Node) : the optional Node to parent the clone to.
  15747. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15748. *
  15749. * Returns the clone.
  15750. */
  15751. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15752. /**
  15753. * Disposes the InstancedMesh.
  15754. * Returns nothing.
  15755. */
  15756. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15757. }
  15758. module "babylonjs/Meshes/mesh" {
  15759. interface Mesh {
  15760. /**
  15761. * Register a custom buffer that will be instanced
  15762. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15763. * @param kind defines the buffer kind
  15764. * @param stride defines the stride in floats
  15765. */
  15766. registerInstancedBuffer(kind: string, stride: number): void;
  15767. /** @hidden */
  15768. _userInstancedBuffersStorage: {
  15769. data: {
  15770. [key: string]: Float32Array;
  15771. };
  15772. sizes: {
  15773. [key: string]: number;
  15774. };
  15775. vertexBuffers: {
  15776. [key: string]: Nullable<VertexBuffer>;
  15777. };
  15778. strides: {
  15779. [key: string]: number;
  15780. };
  15781. };
  15782. }
  15783. }
  15784. module "babylonjs/Meshes/abstractMesh" {
  15785. interface AbstractMesh {
  15786. /**
  15787. * Object used to store instanced buffers defined by user
  15788. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15789. */
  15790. instancedBuffers: {
  15791. [key: string]: any;
  15792. };
  15793. }
  15794. }
  15795. }
  15796. declare module "babylonjs/Materials/shaderMaterial" {
  15797. import { Scene } from "babylonjs/scene";
  15798. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15800. import { Mesh } from "babylonjs/Meshes/mesh";
  15801. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15803. import { Material } from "babylonjs/Materials/material";
  15804. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15805. /**
  15806. * Defines the options associated with the creation of a shader material.
  15807. */
  15808. export interface IShaderMaterialOptions {
  15809. /**
  15810. * Does the material work in alpha blend mode
  15811. */
  15812. needAlphaBlending: boolean;
  15813. /**
  15814. * Does the material work in alpha test mode
  15815. */
  15816. needAlphaTesting: boolean;
  15817. /**
  15818. * The list of attribute names used in the shader
  15819. */
  15820. attributes: string[];
  15821. /**
  15822. * The list of unifrom names used in the shader
  15823. */
  15824. uniforms: string[];
  15825. /**
  15826. * The list of UBO names used in the shader
  15827. */
  15828. uniformBuffers: string[];
  15829. /**
  15830. * The list of sampler names used in the shader
  15831. */
  15832. samplers: string[];
  15833. /**
  15834. * The list of defines used in the shader
  15835. */
  15836. defines: string[];
  15837. }
  15838. /**
  15839. * 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.
  15840. *
  15841. * This returned material effects how the mesh will look based on the code in the shaders.
  15842. *
  15843. * @see http://doc.babylonjs.com/how_to/shader_material
  15844. */
  15845. export class ShaderMaterial extends Material {
  15846. private _shaderPath;
  15847. private _options;
  15848. private _textures;
  15849. private _textureArrays;
  15850. private _floats;
  15851. private _ints;
  15852. private _floatsArrays;
  15853. private _colors3;
  15854. private _colors3Arrays;
  15855. private _colors4;
  15856. private _colors4Arrays;
  15857. private _vectors2;
  15858. private _vectors3;
  15859. private _vectors4;
  15860. private _matrices;
  15861. private _matrixArrays;
  15862. private _matrices3x3;
  15863. private _matrices2x2;
  15864. private _vectors2Arrays;
  15865. private _vectors3Arrays;
  15866. private _vectors4Arrays;
  15867. private _cachedWorldViewMatrix;
  15868. private _cachedWorldViewProjectionMatrix;
  15869. private _renderId;
  15870. private _multiview;
  15871. /**
  15872. * Instantiate a new shader material.
  15873. * 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.
  15874. * This returned material effects how the mesh will look based on the code in the shaders.
  15875. * @see http://doc.babylonjs.com/how_to/shader_material
  15876. * @param name Define the name of the material in the scene
  15877. * @param scene Define the scene the material belongs to
  15878. * @param shaderPath Defines the route to the shader code in one of three ways:
  15879. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15880. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15881. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15882. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15883. * @param options Define the options used to create the shader
  15884. */
  15885. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15886. /**
  15887. * Gets the shader path used to define the shader code
  15888. * It can be modified to trigger a new compilation
  15889. */
  15890. get shaderPath(): any;
  15891. /**
  15892. * Sets the shader path used to define the shader code
  15893. * It can be modified to trigger a new compilation
  15894. */
  15895. set shaderPath(shaderPath: any);
  15896. /**
  15897. * Gets the options used to compile the shader.
  15898. * They can be modified to trigger a new compilation
  15899. */
  15900. get options(): IShaderMaterialOptions;
  15901. /**
  15902. * Gets the current class name of the material e.g. "ShaderMaterial"
  15903. * Mainly use in serialization.
  15904. * @returns the class name
  15905. */
  15906. getClassName(): string;
  15907. /**
  15908. * Specifies if the material will require alpha blending
  15909. * @returns a boolean specifying if alpha blending is needed
  15910. */
  15911. needAlphaBlending(): boolean;
  15912. /**
  15913. * Specifies if this material should be rendered in alpha test mode
  15914. * @returns a boolean specifying if an alpha test is needed.
  15915. */
  15916. needAlphaTesting(): boolean;
  15917. private _checkUniform;
  15918. /**
  15919. * Set a texture in the shader.
  15920. * @param name Define the name of the uniform samplers as defined in the shader
  15921. * @param texture Define the texture to bind to this sampler
  15922. * @return the material itself allowing "fluent" like uniform updates
  15923. */
  15924. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15925. /**
  15926. * Set a texture array in the shader.
  15927. * @param name Define the name of the uniform sampler array as defined in the shader
  15928. * @param textures Define the list of textures to bind to this sampler
  15929. * @return the material itself allowing "fluent" like uniform updates
  15930. */
  15931. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15932. /**
  15933. * Set a float in the shader.
  15934. * @param name Define the name of the uniform as defined in the shader
  15935. * @param value Define the value to give to the uniform
  15936. * @return the material itself allowing "fluent" like uniform updates
  15937. */
  15938. setFloat(name: string, value: number): ShaderMaterial;
  15939. /**
  15940. * Set a int in the shader.
  15941. * @param name Define the name of the uniform as defined in the shader
  15942. * @param value Define the value to give to the uniform
  15943. * @return the material itself allowing "fluent" like uniform updates
  15944. */
  15945. setInt(name: string, value: number): ShaderMaterial;
  15946. /**
  15947. * Set an array of floats in the shader.
  15948. * @param name Define the name of the uniform as defined in the shader
  15949. * @param value Define the value to give to the uniform
  15950. * @return the material itself allowing "fluent" like uniform updates
  15951. */
  15952. setFloats(name: string, value: number[]): ShaderMaterial;
  15953. /**
  15954. * Set a vec3 in the shader from a Color3.
  15955. * @param name Define the name of the uniform as defined in the shader
  15956. * @param value Define the value to give to the uniform
  15957. * @return the material itself allowing "fluent" like uniform updates
  15958. */
  15959. setColor3(name: string, value: Color3): ShaderMaterial;
  15960. /**
  15961. * Set a vec3 array in the shader from a Color3 array.
  15962. * @param name Define the name of the uniform as defined in the shader
  15963. * @param value Define the value to give to the uniform
  15964. * @return the material itself allowing "fluent" like uniform updates
  15965. */
  15966. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15967. /**
  15968. * Set a vec4 in the shader from a Color4.
  15969. * @param name Define the name of the uniform as defined in the shader
  15970. * @param value Define the value to give to the uniform
  15971. * @return the material itself allowing "fluent" like uniform updates
  15972. */
  15973. setColor4(name: string, value: Color4): ShaderMaterial;
  15974. /**
  15975. * Set a vec4 array in the shader from a Color4 array.
  15976. * @param name Define the name of the uniform as defined in the shader
  15977. * @param value Define the value to give to the uniform
  15978. * @return the material itself allowing "fluent" like uniform updates
  15979. */
  15980. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15981. /**
  15982. * Set a vec2 in the shader from a Vector2.
  15983. * @param name Define the name of the uniform as defined in the shader
  15984. * @param value Define the value to give to the uniform
  15985. * @return the material itself allowing "fluent" like uniform updates
  15986. */
  15987. setVector2(name: string, value: Vector2): ShaderMaterial;
  15988. /**
  15989. * Set a vec3 in the shader from a Vector3.
  15990. * @param name Define the name of the uniform as defined in the shader
  15991. * @param value Define the value to give to the uniform
  15992. * @return the material itself allowing "fluent" like uniform updates
  15993. */
  15994. setVector3(name: string, value: Vector3): ShaderMaterial;
  15995. /**
  15996. * Set a vec4 in the shader from a Vector4.
  15997. * @param name Define the name of the uniform as defined in the shader
  15998. * @param value Define the value to give to the uniform
  15999. * @return the material itself allowing "fluent" like uniform updates
  16000. */
  16001. setVector4(name: string, value: Vector4): ShaderMaterial;
  16002. /**
  16003. * Set a mat4 in the shader from a Matrix.
  16004. * @param name Define the name of the uniform as defined in the shader
  16005. * @param value Define the value to give to the uniform
  16006. * @return the material itself allowing "fluent" like uniform updates
  16007. */
  16008. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16009. /**
  16010. * Set a float32Array in the shader from a matrix array.
  16011. * @param name Define the name of the uniform as defined in the shader
  16012. * @param value Define the value to give to the uniform
  16013. * @return the material itself allowing "fluent" like uniform updates
  16014. */
  16015. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16016. /**
  16017. * Set a mat3 in the shader from a Float32Array.
  16018. * @param name Define the name of the uniform as defined in the shader
  16019. * @param value Define the value to give to the uniform
  16020. * @return the material itself allowing "fluent" like uniform updates
  16021. */
  16022. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16023. /**
  16024. * Set a mat2 in the shader from a Float32Array.
  16025. * @param name Define the name of the uniform as defined in the shader
  16026. * @param value Define the value to give to the uniform
  16027. * @return the material itself allowing "fluent" like uniform updates
  16028. */
  16029. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16030. /**
  16031. * Set a vec2 array in the shader from a number array.
  16032. * @param name Define the name of the uniform as defined in the shader
  16033. * @param value Define the value to give to the uniform
  16034. * @return the material itself allowing "fluent" like uniform updates
  16035. */
  16036. setArray2(name: string, value: number[]): ShaderMaterial;
  16037. /**
  16038. * Set a vec3 array in the shader from a number array.
  16039. * @param name Define the name of the uniform as defined in the shader
  16040. * @param value Define the value to give to the uniform
  16041. * @return the material itself allowing "fluent" like uniform updates
  16042. */
  16043. setArray3(name: string, value: number[]): ShaderMaterial;
  16044. /**
  16045. * Set a vec4 array in the shader from a number array.
  16046. * @param name Define the name of the uniform as defined in the shader
  16047. * @param value Define the value to give to the uniform
  16048. * @return the material itself allowing "fluent" like uniform updates
  16049. */
  16050. setArray4(name: string, value: number[]): ShaderMaterial;
  16051. private _checkCache;
  16052. /**
  16053. * Specifies that the submesh is ready to be used
  16054. * @param mesh defines the mesh to check
  16055. * @param subMesh defines which submesh to check
  16056. * @param useInstances specifies that instances should be used
  16057. * @returns a boolean indicating that the submesh is ready or not
  16058. */
  16059. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16060. /**
  16061. * Checks if the material is ready to render the requested mesh
  16062. * @param mesh Define the mesh to render
  16063. * @param useInstances Define whether or not the material is used with instances
  16064. * @returns true if ready, otherwise false
  16065. */
  16066. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16067. /**
  16068. * Binds the world matrix to the material
  16069. * @param world defines the world transformation matrix
  16070. */
  16071. bindOnlyWorldMatrix(world: Matrix): void;
  16072. /**
  16073. * Binds the material to the mesh
  16074. * @param world defines the world transformation matrix
  16075. * @param mesh defines the mesh to bind the material to
  16076. */
  16077. bind(world: Matrix, mesh?: Mesh): void;
  16078. /**
  16079. * Gets the active textures from the material
  16080. * @returns an array of textures
  16081. */
  16082. getActiveTextures(): BaseTexture[];
  16083. /**
  16084. * Specifies if the material uses a texture
  16085. * @param texture defines the texture to check against the material
  16086. * @returns a boolean specifying if the material uses the texture
  16087. */
  16088. hasTexture(texture: BaseTexture): boolean;
  16089. /**
  16090. * Makes a duplicate of the material, and gives it a new name
  16091. * @param name defines the new name for the duplicated material
  16092. * @returns the cloned material
  16093. */
  16094. clone(name: string): ShaderMaterial;
  16095. /**
  16096. * Disposes the material
  16097. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16098. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16099. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16100. */
  16101. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16102. /**
  16103. * Serializes this material in a JSON representation
  16104. * @returns the serialized material object
  16105. */
  16106. serialize(): any;
  16107. /**
  16108. * Creates a shader material from parsed shader material data
  16109. * @param source defines the JSON represnetation of the material
  16110. * @param scene defines the hosting scene
  16111. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16112. * @returns a new material
  16113. */
  16114. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16115. }
  16116. }
  16117. declare module "babylonjs/Shaders/color.fragment" {
  16118. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  16119. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  16120. /** @hidden */
  16121. export var colorPixelShader: {
  16122. name: string;
  16123. shader: string;
  16124. };
  16125. }
  16126. declare module "babylonjs/Shaders/color.vertex" {
  16127. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16128. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  16129. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16130. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16131. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16132. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  16133. /** @hidden */
  16134. export var colorVertexShader: {
  16135. name: string;
  16136. shader: string;
  16137. };
  16138. }
  16139. declare module "babylonjs/Meshes/linesMesh" {
  16140. import { Nullable } from "babylonjs/types";
  16141. import { Scene } from "babylonjs/scene";
  16142. import { Color3 } from "babylonjs/Maths/math.color";
  16143. import { Node } from "babylonjs/node";
  16144. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16145. import { Mesh } from "babylonjs/Meshes/mesh";
  16146. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16147. import { Effect } from "babylonjs/Materials/effect";
  16148. import { Material } from "babylonjs/Materials/material";
  16149. import "babylonjs/Shaders/color.fragment";
  16150. import "babylonjs/Shaders/color.vertex";
  16151. /**
  16152. * Line mesh
  16153. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16154. */
  16155. export class LinesMesh extends Mesh {
  16156. /**
  16157. * If vertex color should be applied to the mesh
  16158. */
  16159. readonly useVertexColor?: boolean | undefined;
  16160. /**
  16161. * If vertex alpha should be applied to the mesh
  16162. */
  16163. readonly useVertexAlpha?: boolean | undefined;
  16164. /**
  16165. * Color of the line (Default: White)
  16166. */
  16167. color: Color3;
  16168. /**
  16169. * Alpha of the line (Default: 1)
  16170. */
  16171. alpha: number;
  16172. /**
  16173. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16174. * This margin is expressed in world space coordinates, so its value may vary.
  16175. * Default value is 0.1
  16176. */
  16177. intersectionThreshold: number;
  16178. private _colorShader;
  16179. private color4;
  16180. /**
  16181. * Creates a new LinesMesh
  16182. * @param name defines the name
  16183. * @param scene defines the hosting scene
  16184. * @param parent defines the parent mesh if any
  16185. * @param source defines the optional source LinesMesh used to clone data from
  16186. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16187. * When false, achieved by calling a clone(), also passing False.
  16188. * This will make creation of children, recursive.
  16189. * @param useVertexColor defines if this LinesMesh supports vertex color
  16190. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16191. */
  16192. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16193. /**
  16194. * If vertex color should be applied to the mesh
  16195. */
  16196. useVertexColor?: boolean | undefined,
  16197. /**
  16198. * If vertex alpha should be applied to the mesh
  16199. */
  16200. useVertexAlpha?: boolean | undefined);
  16201. private _addClipPlaneDefine;
  16202. private _removeClipPlaneDefine;
  16203. isReady(): boolean;
  16204. /**
  16205. * Returns the string "LineMesh"
  16206. */
  16207. getClassName(): string;
  16208. /**
  16209. * @hidden
  16210. */
  16211. get material(): Material;
  16212. /**
  16213. * @hidden
  16214. */
  16215. set material(value: Material);
  16216. /**
  16217. * @hidden
  16218. */
  16219. get checkCollisions(): boolean;
  16220. /** @hidden */
  16221. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16222. /** @hidden */
  16223. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16224. /**
  16225. * Disposes of the line mesh
  16226. * @param doNotRecurse If children should be disposed
  16227. */
  16228. dispose(doNotRecurse?: boolean): void;
  16229. /**
  16230. * Returns a new LineMesh object cloned from the current one.
  16231. */
  16232. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16233. /**
  16234. * Creates a new InstancedLinesMesh object from the mesh model.
  16235. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16236. * @param name defines the name of the new instance
  16237. * @returns a new InstancedLinesMesh
  16238. */
  16239. createInstance(name: string): InstancedLinesMesh;
  16240. }
  16241. /**
  16242. * Creates an instance based on a source LinesMesh
  16243. */
  16244. export class InstancedLinesMesh extends InstancedMesh {
  16245. /**
  16246. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16247. * This margin is expressed in world space coordinates, so its value may vary.
  16248. * Initilized with the intersectionThreshold value of the source LinesMesh
  16249. */
  16250. intersectionThreshold: number;
  16251. constructor(name: string, source: LinesMesh);
  16252. /**
  16253. * Returns the string "InstancedLinesMesh".
  16254. */
  16255. getClassName(): string;
  16256. }
  16257. }
  16258. declare module "babylonjs/Shaders/line.fragment" {
  16259. /** @hidden */
  16260. export var linePixelShader: {
  16261. name: string;
  16262. shader: string;
  16263. };
  16264. }
  16265. declare module "babylonjs/Shaders/line.vertex" {
  16266. /** @hidden */
  16267. export var lineVertexShader: {
  16268. name: string;
  16269. shader: string;
  16270. };
  16271. }
  16272. declare module "babylonjs/Rendering/edgesRenderer" {
  16273. import { Nullable } from "babylonjs/types";
  16274. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16276. import { Vector3 } from "babylonjs/Maths/math.vector";
  16277. import { IDisposable } from "babylonjs/scene";
  16278. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16279. import "babylonjs/Shaders/line.fragment";
  16280. import "babylonjs/Shaders/line.vertex";
  16281. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16282. module "babylonjs/Meshes/abstractMesh" {
  16283. interface AbstractMesh {
  16284. /**
  16285. * Gets the edgesRenderer associated with the mesh
  16286. */
  16287. edgesRenderer: Nullable<EdgesRenderer>;
  16288. }
  16289. }
  16290. module "babylonjs/Meshes/linesMesh" {
  16291. interface LinesMesh {
  16292. /**
  16293. * Enables the edge rendering mode on the mesh.
  16294. * This mode makes the mesh edges visible
  16295. * @param epsilon defines the maximal distance between two angles to detect a face
  16296. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16297. * @returns the currentAbstractMesh
  16298. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16299. */
  16300. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16301. }
  16302. }
  16303. module "babylonjs/Meshes/linesMesh" {
  16304. interface InstancedLinesMesh {
  16305. /**
  16306. * Enables the edge rendering mode on the mesh.
  16307. * This mode makes the mesh edges visible
  16308. * @param epsilon defines the maximal distance between two angles to detect a face
  16309. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16310. * @returns the current InstancedLinesMesh
  16311. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16312. */
  16313. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16314. }
  16315. }
  16316. /**
  16317. * Defines the minimum contract an Edges renderer should follow.
  16318. */
  16319. export interface IEdgesRenderer extends IDisposable {
  16320. /**
  16321. * Gets or sets a boolean indicating if the edgesRenderer is active
  16322. */
  16323. isEnabled: boolean;
  16324. /**
  16325. * Renders the edges of the attached mesh,
  16326. */
  16327. render(): void;
  16328. /**
  16329. * Checks wether or not the edges renderer is ready to render.
  16330. * @return true if ready, otherwise false.
  16331. */
  16332. isReady(): boolean;
  16333. }
  16334. /**
  16335. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16336. */
  16337. export class EdgesRenderer implements IEdgesRenderer {
  16338. /**
  16339. * Define the size of the edges with an orthographic camera
  16340. */
  16341. edgesWidthScalerForOrthographic: number;
  16342. /**
  16343. * Define the size of the edges with a perspective camera
  16344. */
  16345. edgesWidthScalerForPerspective: number;
  16346. protected _source: AbstractMesh;
  16347. protected _linesPositions: number[];
  16348. protected _linesNormals: number[];
  16349. protected _linesIndices: number[];
  16350. protected _epsilon: number;
  16351. protected _indicesCount: number;
  16352. protected _lineShader: ShaderMaterial;
  16353. protected _ib: DataBuffer;
  16354. protected _buffers: {
  16355. [key: string]: Nullable<VertexBuffer>;
  16356. };
  16357. protected _checkVerticesInsteadOfIndices: boolean;
  16358. private _meshRebuildObserver;
  16359. private _meshDisposeObserver;
  16360. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16361. isEnabled: boolean;
  16362. /**
  16363. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16364. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16365. * @param source Mesh used to create edges
  16366. * @param epsilon sum of angles in adjacency to check for edge
  16367. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16368. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16369. */
  16370. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16371. protected _prepareRessources(): void;
  16372. /** @hidden */
  16373. _rebuild(): void;
  16374. /**
  16375. * Releases the required resources for the edges renderer
  16376. */
  16377. dispose(): void;
  16378. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16379. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16380. /**
  16381. * Checks if the pair of p0 and p1 is en edge
  16382. * @param faceIndex
  16383. * @param edge
  16384. * @param faceNormals
  16385. * @param p0
  16386. * @param p1
  16387. * @private
  16388. */
  16389. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16390. /**
  16391. * push line into the position, normal and index buffer
  16392. * @protected
  16393. */
  16394. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16395. /**
  16396. * Generates lines edges from adjacencjes
  16397. * @private
  16398. */
  16399. _generateEdgesLines(): void;
  16400. /**
  16401. * Checks wether or not the edges renderer is ready to render.
  16402. * @return true if ready, otherwise false.
  16403. */
  16404. isReady(): boolean;
  16405. /**
  16406. * Renders the edges of the attached mesh,
  16407. */
  16408. render(): void;
  16409. }
  16410. /**
  16411. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16412. */
  16413. export class LineEdgesRenderer extends EdgesRenderer {
  16414. /**
  16415. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16416. * @param source LineMesh used to generate edges
  16417. * @param epsilon not important (specified angle for edge detection)
  16418. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16419. */
  16420. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16421. /**
  16422. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16423. */
  16424. _generateEdgesLines(): void;
  16425. }
  16426. }
  16427. declare module "babylonjs/Rendering/renderingGroup" {
  16428. import { SmartArray } from "babylonjs/Misc/smartArray";
  16429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16431. import { Nullable } from "babylonjs/types";
  16432. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16433. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16434. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16435. import { Material } from "babylonjs/Materials/material";
  16436. import { Scene } from "babylonjs/scene";
  16437. /**
  16438. * This represents the object necessary to create a rendering group.
  16439. * This is exclusively used and created by the rendering manager.
  16440. * To modify the behavior, you use the available helpers in your scene or meshes.
  16441. * @hidden
  16442. */
  16443. export class RenderingGroup {
  16444. index: number;
  16445. private static _zeroVector;
  16446. private _scene;
  16447. private _opaqueSubMeshes;
  16448. private _transparentSubMeshes;
  16449. private _alphaTestSubMeshes;
  16450. private _depthOnlySubMeshes;
  16451. private _particleSystems;
  16452. private _spriteManagers;
  16453. private _opaqueSortCompareFn;
  16454. private _alphaTestSortCompareFn;
  16455. private _transparentSortCompareFn;
  16456. private _renderOpaque;
  16457. private _renderAlphaTest;
  16458. private _renderTransparent;
  16459. /** @hidden */
  16460. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16461. onBeforeTransparentRendering: () => void;
  16462. /**
  16463. * Set the opaque sort comparison function.
  16464. * If null the sub meshes will be render in the order they were created
  16465. */
  16466. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16467. /**
  16468. * Set the alpha test sort comparison function.
  16469. * If null the sub meshes will be render in the order they were created
  16470. */
  16471. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16472. /**
  16473. * Set the transparent sort comparison function.
  16474. * If null the sub meshes will be render in the order they were created
  16475. */
  16476. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16477. /**
  16478. * Creates a new rendering group.
  16479. * @param index The rendering group index
  16480. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16481. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16482. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16483. */
  16484. 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>);
  16485. /**
  16486. * Render all the sub meshes contained in the group.
  16487. * @param customRenderFunction Used to override the default render behaviour of the group.
  16488. * @returns true if rendered some submeshes.
  16489. */
  16490. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16491. /**
  16492. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16493. * @param subMeshes The submeshes to render
  16494. */
  16495. private renderOpaqueSorted;
  16496. /**
  16497. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16498. * @param subMeshes The submeshes to render
  16499. */
  16500. private renderAlphaTestSorted;
  16501. /**
  16502. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16503. * @param subMeshes The submeshes to render
  16504. */
  16505. private renderTransparentSorted;
  16506. /**
  16507. * Renders the submeshes in a specified order.
  16508. * @param subMeshes The submeshes to sort before render
  16509. * @param sortCompareFn The comparison function use to sort
  16510. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16511. * @param transparent Specifies to activate blending if true
  16512. */
  16513. private static renderSorted;
  16514. /**
  16515. * Renders the submeshes in the order they were dispatched (no sort applied).
  16516. * @param subMeshes The submeshes to render
  16517. */
  16518. private static renderUnsorted;
  16519. /**
  16520. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16521. * are rendered back to front if in the same alpha index.
  16522. *
  16523. * @param a The first submesh
  16524. * @param b The second submesh
  16525. * @returns The result of the comparison
  16526. */
  16527. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16528. /**
  16529. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16530. * are rendered back to front.
  16531. *
  16532. * @param a The first submesh
  16533. * @param b The second submesh
  16534. * @returns The result of the comparison
  16535. */
  16536. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16537. /**
  16538. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16539. * are rendered front to back (prevent overdraw).
  16540. *
  16541. * @param a The first submesh
  16542. * @param b The second submesh
  16543. * @returns The result of the comparison
  16544. */
  16545. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16546. /**
  16547. * Resets the different lists of submeshes to prepare a new frame.
  16548. */
  16549. prepare(): void;
  16550. dispose(): void;
  16551. /**
  16552. * Inserts the submesh in its correct queue depending on its material.
  16553. * @param subMesh The submesh to dispatch
  16554. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16555. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16556. */
  16557. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16558. dispatchSprites(spriteManager: ISpriteManager): void;
  16559. dispatchParticles(particleSystem: IParticleSystem): void;
  16560. private _renderParticles;
  16561. private _renderSprites;
  16562. }
  16563. }
  16564. declare module "babylonjs/Rendering/renderingManager" {
  16565. import { Nullable } from "babylonjs/types";
  16566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16567. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16568. import { SmartArray } from "babylonjs/Misc/smartArray";
  16569. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16570. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16571. import { Material } from "babylonjs/Materials/material";
  16572. import { Scene } from "babylonjs/scene";
  16573. import { Camera } from "babylonjs/Cameras/camera";
  16574. /**
  16575. * Interface describing the different options available in the rendering manager
  16576. * regarding Auto Clear between groups.
  16577. */
  16578. export interface IRenderingManagerAutoClearSetup {
  16579. /**
  16580. * Defines whether or not autoclear is enable.
  16581. */
  16582. autoClear: boolean;
  16583. /**
  16584. * Defines whether or not to autoclear the depth buffer.
  16585. */
  16586. depth: boolean;
  16587. /**
  16588. * Defines whether or not to autoclear the stencil buffer.
  16589. */
  16590. stencil: boolean;
  16591. }
  16592. /**
  16593. * This class is used by the onRenderingGroupObservable
  16594. */
  16595. export class RenderingGroupInfo {
  16596. /**
  16597. * The Scene that being rendered
  16598. */
  16599. scene: Scene;
  16600. /**
  16601. * The camera currently used for the rendering pass
  16602. */
  16603. camera: Nullable<Camera>;
  16604. /**
  16605. * The ID of the renderingGroup being processed
  16606. */
  16607. renderingGroupId: number;
  16608. }
  16609. /**
  16610. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16611. * It is enable to manage the different groups as well as the different necessary sort functions.
  16612. * This should not be used directly aside of the few static configurations
  16613. */
  16614. export class RenderingManager {
  16615. /**
  16616. * The max id used for rendering groups (not included)
  16617. */
  16618. static MAX_RENDERINGGROUPS: number;
  16619. /**
  16620. * The min id used for rendering groups (included)
  16621. */
  16622. static MIN_RENDERINGGROUPS: number;
  16623. /**
  16624. * Used to globally prevent autoclearing scenes.
  16625. */
  16626. static AUTOCLEAR: boolean;
  16627. /**
  16628. * @hidden
  16629. */
  16630. _useSceneAutoClearSetup: boolean;
  16631. private _scene;
  16632. private _renderingGroups;
  16633. private _depthStencilBufferAlreadyCleaned;
  16634. private _autoClearDepthStencil;
  16635. private _customOpaqueSortCompareFn;
  16636. private _customAlphaTestSortCompareFn;
  16637. private _customTransparentSortCompareFn;
  16638. private _renderingGroupInfo;
  16639. /**
  16640. * Instantiates a new rendering group for a particular scene
  16641. * @param scene Defines the scene the groups belongs to
  16642. */
  16643. constructor(scene: Scene);
  16644. private _clearDepthStencilBuffer;
  16645. /**
  16646. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16647. * @hidden
  16648. */
  16649. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16650. /**
  16651. * Resets the different information of the group to prepare a new frame
  16652. * @hidden
  16653. */
  16654. reset(): void;
  16655. /**
  16656. * Dispose and release the group and its associated resources.
  16657. * @hidden
  16658. */
  16659. dispose(): void;
  16660. /**
  16661. * Clear the info related to rendering groups preventing retention points during dispose.
  16662. */
  16663. freeRenderingGroups(): void;
  16664. private _prepareRenderingGroup;
  16665. /**
  16666. * Add a sprite manager to the rendering manager in order to render it this frame.
  16667. * @param spriteManager Define the sprite manager to render
  16668. */
  16669. dispatchSprites(spriteManager: ISpriteManager): void;
  16670. /**
  16671. * Add a particle system to the rendering manager in order to render it this frame.
  16672. * @param particleSystem Define the particle system to render
  16673. */
  16674. dispatchParticles(particleSystem: IParticleSystem): void;
  16675. /**
  16676. * Add a submesh to the manager in order to render it this frame
  16677. * @param subMesh The submesh to dispatch
  16678. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16679. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16680. */
  16681. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16682. /**
  16683. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16684. * This allowed control for front to back rendering or reversly depending of the special needs.
  16685. *
  16686. * @param renderingGroupId The rendering group id corresponding to its index
  16687. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16688. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16689. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16690. */
  16691. 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;
  16692. /**
  16693. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16694. *
  16695. * @param renderingGroupId The rendering group id corresponding to its index
  16696. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16697. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16698. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16699. */
  16700. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16701. /**
  16702. * Gets the current auto clear configuration for one rendering group of the rendering
  16703. * manager.
  16704. * @param index the rendering group index to get the information for
  16705. * @returns The auto clear setup for the requested rendering group
  16706. */
  16707. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16708. }
  16709. }
  16710. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16711. import { SmartArray } from "babylonjs/Misc/smartArray";
  16712. import { Nullable } from "babylonjs/types";
  16713. import { Scene } from "babylonjs/scene";
  16714. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16717. import { Mesh } from "babylonjs/Meshes/mesh";
  16718. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16719. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16720. import { Effect } from "babylonjs/Materials/effect";
  16721. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16722. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16723. import "babylonjs/Shaders/shadowMap.fragment";
  16724. import "babylonjs/Shaders/shadowMap.vertex";
  16725. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16726. import { Observable } from "babylonjs/Misc/observable";
  16727. /**
  16728. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16729. */
  16730. export interface ICustomShaderOptions {
  16731. /**
  16732. * Gets or sets the custom shader name to use
  16733. */
  16734. shaderName: string;
  16735. /**
  16736. * The list of attribute names used in the shader
  16737. */
  16738. attributes?: string[];
  16739. /**
  16740. * The list of unifrom names used in the shader
  16741. */
  16742. uniforms?: string[];
  16743. /**
  16744. * The list of sampler names used in the shader
  16745. */
  16746. samplers?: string[];
  16747. /**
  16748. * The list of defines used in the shader
  16749. */
  16750. defines?: string[];
  16751. }
  16752. /**
  16753. * Interface to implement to create a shadow generator compatible with BJS.
  16754. */
  16755. export interface IShadowGenerator {
  16756. /**
  16757. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16758. * @returns The render target texture if present otherwise, null
  16759. */
  16760. getShadowMap(): Nullable<RenderTargetTexture>;
  16761. /**
  16762. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16763. * @param subMesh The submesh we want to render in the shadow map
  16764. * @param useInstances Defines wether will draw in the map using instances
  16765. * @returns true if ready otherwise, false
  16766. */
  16767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16768. /**
  16769. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16770. * @param defines Defines of the material we want to update
  16771. * @param lightIndex Index of the light in the enabled light list of the material
  16772. */
  16773. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16774. /**
  16775. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16776. * defined in the generator but impacting the effect).
  16777. * It implies the unifroms available on the materials are the standard BJS ones.
  16778. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16779. * @param effect The effect we are binfing the information for
  16780. */
  16781. bindShadowLight(lightIndex: string, effect: Effect): void;
  16782. /**
  16783. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16784. * (eq to shadow prjection matrix * light transform matrix)
  16785. * @returns The transform matrix used to create the shadow map
  16786. */
  16787. getTransformMatrix(): Matrix;
  16788. /**
  16789. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16790. * Cube and 2D textures for instance.
  16791. */
  16792. recreateShadowMap(): void;
  16793. /**
  16794. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16795. * @param onCompiled Callback triggered at the and of the effects compilation
  16796. * @param options Sets of optional options forcing the compilation with different modes
  16797. */
  16798. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16799. useInstances: boolean;
  16800. }>): void;
  16801. /**
  16802. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16803. * @param options Sets of optional options forcing the compilation with different modes
  16804. * @returns A promise that resolves when the compilation completes
  16805. */
  16806. forceCompilationAsync(options?: Partial<{
  16807. useInstances: boolean;
  16808. }>): Promise<void>;
  16809. /**
  16810. * Serializes the shadow generator setup to a json object.
  16811. * @returns The serialized JSON object
  16812. */
  16813. serialize(): any;
  16814. /**
  16815. * Disposes the Shadow map and related Textures and effects.
  16816. */
  16817. dispose(): void;
  16818. }
  16819. /**
  16820. * Default implementation IShadowGenerator.
  16821. * This is the main object responsible of generating shadows in the framework.
  16822. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16823. */
  16824. export class ShadowGenerator implements IShadowGenerator {
  16825. /**
  16826. * Name of the shadow generator class
  16827. */
  16828. static CLASSNAME: string;
  16829. /**
  16830. * Shadow generator mode None: no filtering applied.
  16831. */
  16832. static readonly FILTER_NONE: number;
  16833. /**
  16834. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16835. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16836. */
  16837. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16838. /**
  16839. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16840. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16841. */
  16842. static readonly FILTER_POISSONSAMPLING: number;
  16843. /**
  16844. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16845. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16846. */
  16847. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16848. /**
  16849. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16850. * edge artifacts on steep falloff.
  16851. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16852. */
  16853. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16854. /**
  16855. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16856. * edge artifacts on steep falloff.
  16857. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16858. */
  16859. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16860. /**
  16861. * Shadow generator mode PCF: Percentage Closer Filtering
  16862. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16863. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16864. */
  16865. static readonly FILTER_PCF: number;
  16866. /**
  16867. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16868. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16869. * Contact Hardening
  16870. */
  16871. static readonly FILTER_PCSS: number;
  16872. /**
  16873. * Reserved for PCF and PCSS
  16874. * Highest Quality.
  16875. *
  16876. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16877. *
  16878. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16879. */
  16880. static readonly QUALITY_HIGH: number;
  16881. /**
  16882. * Reserved for PCF and PCSS
  16883. * Good tradeoff for quality/perf cross devices
  16884. *
  16885. * Execute PCF on a 3*3 kernel.
  16886. *
  16887. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16888. */
  16889. static readonly QUALITY_MEDIUM: number;
  16890. /**
  16891. * Reserved for PCF and PCSS
  16892. * The lowest quality but the fastest.
  16893. *
  16894. * Execute PCF on a 1*1 kernel.
  16895. *
  16896. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16897. */
  16898. static readonly QUALITY_LOW: number;
  16899. /** Gets or sets the custom shader name to use */
  16900. customShaderOptions: ICustomShaderOptions;
  16901. /**
  16902. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16903. */
  16904. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16905. /**
  16906. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16907. */
  16908. onAfterShadowMapRenderObservable: Observable<Effect>;
  16909. /**
  16910. * Observable triggered before a mesh is rendered in the shadow map.
  16911. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16912. */
  16913. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16914. /**
  16915. * Observable triggered after a mesh is rendered in the shadow map.
  16916. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16917. */
  16918. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16919. protected _bias: number;
  16920. /**
  16921. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16922. */
  16923. get bias(): number;
  16924. /**
  16925. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16926. */
  16927. set bias(bias: number);
  16928. protected _normalBias: number;
  16929. /**
  16930. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16931. */
  16932. get normalBias(): number;
  16933. /**
  16934. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16935. */
  16936. set normalBias(normalBias: number);
  16937. protected _blurBoxOffset: number;
  16938. /**
  16939. * Gets the blur box offset: offset applied during the blur pass.
  16940. * Only useful if useKernelBlur = false
  16941. */
  16942. get blurBoxOffset(): number;
  16943. /**
  16944. * Sets the blur box offset: offset applied during the blur pass.
  16945. * Only useful if useKernelBlur = false
  16946. */
  16947. set blurBoxOffset(value: number);
  16948. protected _blurScale: number;
  16949. /**
  16950. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16951. * 2 means half of the size.
  16952. */
  16953. get blurScale(): number;
  16954. /**
  16955. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16956. * 2 means half of the size.
  16957. */
  16958. set blurScale(value: number);
  16959. protected _blurKernel: number;
  16960. /**
  16961. * Gets the blur kernel: kernel size of the blur pass.
  16962. * Only useful if useKernelBlur = true
  16963. */
  16964. get blurKernel(): number;
  16965. /**
  16966. * Sets the blur kernel: kernel size of the blur pass.
  16967. * Only useful if useKernelBlur = true
  16968. */
  16969. set blurKernel(value: number);
  16970. protected _useKernelBlur: boolean;
  16971. /**
  16972. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16973. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16974. */
  16975. get useKernelBlur(): boolean;
  16976. /**
  16977. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16978. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16979. */
  16980. set useKernelBlur(value: boolean);
  16981. protected _depthScale: number;
  16982. /**
  16983. * Gets the depth scale used in ESM mode.
  16984. */
  16985. get depthScale(): number;
  16986. /**
  16987. * Sets the depth scale used in ESM mode.
  16988. * This can override the scale stored on the light.
  16989. */
  16990. set depthScale(value: number);
  16991. protected _validateFilter(filter: number): number;
  16992. protected _filter: number;
  16993. /**
  16994. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16995. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16996. */
  16997. get filter(): number;
  16998. /**
  16999. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17000. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17001. */
  17002. set filter(value: number);
  17003. /**
  17004. * Gets if the current filter is set to Poisson Sampling.
  17005. */
  17006. get usePoissonSampling(): boolean;
  17007. /**
  17008. * Sets the current filter to Poisson Sampling.
  17009. */
  17010. set usePoissonSampling(value: boolean);
  17011. /**
  17012. * Gets if the current filter is set to ESM.
  17013. */
  17014. get useExponentialShadowMap(): boolean;
  17015. /**
  17016. * Sets the current filter is to ESM.
  17017. */
  17018. set useExponentialShadowMap(value: boolean);
  17019. /**
  17020. * Gets if the current filter is set to filtered ESM.
  17021. */
  17022. get useBlurExponentialShadowMap(): boolean;
  17023. /**
  17024. * Gets if the current filter is set to filtered ESM.
  17025. */
  17026. set useBlurExponentialShadowMap(value: boolean);
  17027. /**
  17028. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17029. * exponential to prevent steep falloff artifacts).
  17030. */
  17031. get useCloseExponentialShadowMap(): boolean;
  17032. /**
  17033. * Sets the current filter to "close ESM" (using the inverse of the
  17034. * exponential to prevent steep falloff artifacts).
  17035. */
  17036. set useCloseExponentialShadowMap(value: boolean);
  17037. /**
  17038. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17039. * exponential to prevent steep falloff artifacts).
  17040. */
  17041. get useBlurCloseExponentialShadowMap(): boolean;
  17042. /**
  17043. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17044. * exponential to prevent steep falloff artifacts).
  17045. */
  17046. set useBlurCloseExponentialShadowMap(value: boolean);
  17047. /**
  17048. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17049. */
  17050. get usePercentageCloserFiltering(): boolean;
  17051. /**
  17052. * Sets the current filter to "PCF" (percentage closer filtering).
  17053. */
  17054. set usePercentageCloserFiltering(value: boolean);
  17055. protected _filteringQuality: number;
  17056. /**
  17057. * Gets the PCF or PCSS Quality.
  17058. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17059. */
  17060. get filteringQuality(): number;
  17061. /**
  17062. * Sets the PCF or PCSS Quality.
  17063. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17064. */
  17065. set filteringQuality(filteringQuality: number);
  17066. /**
  17067. * Gets if the current filter is set to "PCSS" (contact hardening).
  17068. */
  17069. get useContactHardeningShadow(): boolean;
  17070. /**
  17071. * Sets the current filter to "PCSS" (contact hardening).
  17072. */
  17073. set useContactHardeningShadow(value: boolean);
  17074. protected _contactHardeningLightSizeUVRatio: number;
  17075. /**
  17076. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17077. * Using a ratio helps keeping shape stability independently of the map size.
  17078. *
  17079. * It does not account for the light projection as it was having too much
  17080. * instability during the light setup or during light position changes.
  17081. *
  17082. * Only valid if useContactHardeningShadow is true.
  17083. */
  17084. get contactHardeningLightSizeUVRatio(): number;
  17085. /**
  17086. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17087. * Using a ratio helps keeping shape stability independently of the map size.
  17088. *
  17089. * It does not account for the light projection as it was having too much
  17090. * instability during the light setup or during light position changes.
  17091. *
  17092. * Only valid if useContactHardeningShadow is true.
  17093. */
  17094. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17095. protected _darkness: number;
  17096. /** Gets or sets the actual darkness of a shadow */
  17097. get darkness(): number;
  17098. set darkness(value: number);
  17099. /**
  17100. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17101. * 0 means strongest and 1 would means no shadow.
  17102. * @returns the darkness.
  17103. */
  17104. getDarkness(): number;
  17105. /**
  17106. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17107. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17108. * @returns the shadow generator allowing fluent coding.
  17109. */
  17110. setDarkness(darkness: number): ShadowGenerator;
  17111. protected _transparencyShadow: boolean;
  17112. /** Gets or sets the ability to have transparent shadow */
  17113. get transparencyShadow(): boolean;
  17114. set transparencyShadow(value: boolean);
  17115. /**
  17116. * Sets the ability to have transparent shadow (boolean).
  17117. * @param transparent True if transparent else False
  17118. * @returns the shadow generator allowing fluent coding
  17119. */
  17120. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17121. protected _shadowMap: Nullable<RenderTargetTexture>;
  17122. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17123. /**
  17124. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17125. * @returns The render target texture if present otherwise, null
  17126. */
  17127. getShadowMap(): Nullable<RenderTargetTexture>;
  17128. /**
  17129. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17130. * @returns The render target texture if the shadow map is present otherwise, null
  17131. */
  17132. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17133. /**
  17134. * Gets the class name of that object
  17135. * @returns "ShadowGenerator"
  17136. */
  17137. getClassName(): string;
  17138. /**
  17139. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17140. * @param mesh Mesh to add
  17141. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17142. * @returns the Shadow Generator itself
  17143. */
  17144. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17145. /**
  17146. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17147. * @param mesh Mesh to remove
  17148. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17149. * @returns the Shadow Generator itself
  17150. */
  17151. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17152. /**
  17153. * Controls the extent to which the shadows fade out at the edge of the frustum
  17154. */
  17155. frustumEdgeFalloff: number;
  17156. protected _light: IShadowLight;
  17157. /**
  17158. * Returns the associated light object.
  17159. * @returns the light generating the shadow
  17160. */
  17161. getLight(): IShadowLight;
  17162. /**
  17163. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17164. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17165. * It might on the other hand introduce peter panning.
  17166. */
  17167. forceBackFacesOnly: boolean;
  17168. protected _scene: Scene;
  17169. protected _lightDirection: Vector3;
  17170. protected _effect: Effect;
  17171. protected _viewMatrix: Matrix;
  17172. protected _projectionMatrix: Matrix;
  17173. protected _transformMatrix: Matrix;
  17174. protected _cachedPosition: Vector3;
  17175. protected _cachedDirection: Vector3;
  17176. protected _cachedDefines: string;
  17177. protected _currentRenderID: number;
  17178. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17179. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17180. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17181. protected _blurPostProcesses: PostProcess[];
  17182. protected _mapSize: number;
  17183. protected _currentFaceIndex: number;
  17184. protected _currentFaceIndexCache: number;
  17185. protected _textureType: number;
  17186. protected _defaultTextureMatrix: Matrix;
  17187. protected _storedUniqueId: Nullable<number>;
  17188. /** @hidden */
  17189. static _SceneComponentInitialization: (scene: Scene) => void;
  17190. /**
  17191. * Creates a ShadowGenerator object.
  17192. * A ShadowGenerator is the required tool to use the shadows.
  17193. * Each light casting shadows needs to use its own ShadowGenerator.
  17194. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17195. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17196. * @param light The light object generating the shadows.
  17197. * @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.
  17198. */
  17199. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17200. protected _initializeGenerator(): void;
  17201. protected _createTargetRenderTexture(): void;
  17202. protected _initializeShadowMap(): void;
  17203. protected _initializeBlurRTTAndPostProcesses(): void;
  17204. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17205. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17206. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17207. protected _applyFilterValues(): void;
  17208. /**
  17209. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17210. * @param onCompiled Callback triggered at the and of the effects compilation
  17211. * @param options Sets of optional options forcing the compilation with different modes
  17212. */
  17213. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17214. useInstances: boolean;
  17215. }>): void;
  17216. /**
  17217. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17218. * @param options Sets of optional options forcing the compilation with different modes
  17219. * @returns A promise that resolves when the compilation completes
  17220. */
  17221. forceCompilationAsync(options?: Partial<{
  17222. useInstances: boolean;
  17223. }>): Promise<void>;
  17224. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17225. /**
  17226. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17227. * @param subMesh The submesh we want to render in the shadow map
  17228. * @param useInstances Defines wether will draw in the map using instances
  17229. * @returns true if ready otherwise, false
  17230. */
  17231. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17232. /**
  17233. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17234. * @param defines Defines of the material we want to update
  17235. * @param lightIndex Index of the light in the enabled light list of the material
  17236. */
  17237. prepareDefines(defines: any, lightIndex: number): void;
  17238. /**
  17239. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17240. * defined in the generator but impacting the effect).
  17241. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17242. * @param effect The effect we are binfing the information for
  17243. */
  17244. bindShadowLight(lightIndex: string, effect: Effect): void;
  17245. /**
  17246. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17247. * (eq to shadow prjection matrix * light transform matrix)
  17248. * @returns The transform matrix used to create the shadow map
  17249. */
  17250. getTransformMatrix(): Matrix;
  17251. /**
  17252. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17253. * Cube and 2D textures for instance.
  17254. */
  17255. recreateShadowMap(): void;
  17256. protected _disposeBlurPostProcesses(): void;
  17257. protected _disposeRTTandPostProcesses(): void;
  17258. /**
  17259. * Disposes the ShadowGenerator.
  17260. * Returns nothing.
  17261. */
  17262. dispose(): void;
  17263. /**
  17264. * Serializes the shadow generator setup to a json object.
  17265. * @returns The serialized JSON object
  17266. */
  17267. serialize(): any;
  17268. /**
  17269. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17270. * @param parsedShadowGenerator The JSON object to parse
  17271. * @param scene The scene to create the shadow map for
  17272. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17273. * @returns The parsed shadow generator
  17274. */
  17275. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17276. }
  17277. }
  17278. declare module "babylonjs/Lights/light" {
  17279. import { Nullable } from "babylonjs/types";
  17280. import { Scene } from "babylonjs/scene";
  17281. import { Vector3 } from "babylonjs/Maths/math.vector";
  17282. import { Color3 } from "babylonjs/Maths/math.color";
  17283. import { Node } from "babylonjs/node";
  17284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17285. import { Effect } from "babylonjs/Materials/effect";
  17286. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17287. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17288. /**
  17289. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17290. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17291. * 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.
  17292. */
  17293. export abstract class Light extends Node {
  17294. /**
  17295. * Falloff Default: light is falling off following the material specification:
  17296. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17297. */
  17298. static readonly FALLOFF_DEFAULT: number;
  17299. /**
  17300. * Falloff Physical: light is falling off following the inverse squared distance law.
  17301. */
  17302. static readonly FALLOFF_PHYSICAL: number;
  17303. /**
  17304. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17305. * to enhance interoperability with other engines.
  17306. */
  17307. static readonly FALLOFF_GLTF: number;
  17308. /**
  17309. * Falloff Standard: light is falling off like in the standard material
  17310. * to enhance interoperability with other materials.
  17311. */
  17312. static readonly FALLOFF_STANDARD: number;
  17313. /**
  17314. * If every light affecting the material is in this lightmapMode,
  17315. * material.lightmapTexture adds or multiplies
  17316. * (depends on material.useLightmapAsShadowmap)
  17317. * after every other light calculations.
  17318. */
  17319. static readonly LIGHTMAP_DEFAULT: number;
  17320. /**
  17321. * material.lightmapTexture as only diffuse lighting from this light
  17322. * adds only specular lighting from this light
  17323. * adds dynamic shadows
  17324. */
  17325. static readonly LIGHTMAP_SPECULAR: number;
  17326. /**
  17327. * material.lightmapTexture as only lighting
  17328. * no light calculation from this light
  17329. * only adds dynamic shadows from this light
  17330. */
  17331. static readonly LIGHTMAP_SHADOWSONLY: number;
  17332. /**
  17333. * Each light type uses the default quantity according to its type:
  17334. * point/spot lights use luminous intensity
  17335. * directional lights use illuminance
  17336. */
  17337. static readonly INTENSITYMODE_AUTOMATIC: number;
  17338. /**
  17339. * lumen (lm)
  17340. */
  17341. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17342. /**
  17343. * candela (lm/sr)
  17344. */
  17345. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17346. /**
  17347. * lux (lm/m^2)
  17348. */
  17349. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17350. /**
  17351. * nit (cd/m^2)
  17352. */
  17353. static readonly INTENSITYMODE_LUMINANCE: number;
  17354. /**
  17355. * Light type const id of the point light.
  17356. */
  17357. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17358. /**
  17359. * Light type const id of the directional light.
  17360. */
  17361. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17362. /**
  17363. * Light type const id of the spot light.
  17364. */
  17365. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17366. /**
  17367. * Light type const id of the hemispheric light.
  17368. */
  17369. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17370. /**
  17371. * Diffuse gives the basic color to an object.
  17372. */
  17373. diffuse: Color3;
  17374. /**
  17375. * Specular produces a highlight color on an object.
  17376. * Note: This is note affecting PBR materials.
  17377. */
  17378. specular: Color3;
  17379. /**
  17380. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17381. * falling off base on range or angle.
  17382. * This can be set to any values in Light.FALLOFF_x.
  17383. *
  17384. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17385. * other types of materials.
  17386. */
  17387. falloffType: number;
  17388. /**
  17389. * Strength of the light.
  17390. * Note: By default it is define in the framework own unit.
  17391. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17392. */
  17393. intensity: number;
  17394. private _range;
  17395. protected _inverseSquaredRange: number;
  17396. /**
  17397. * Defines how far from the source the light is impacting in scene units.
  17398. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17399. */
  17400. get range(): number;
  17401. /**
  17402. * Defines how far from the source the light is impacting in scene units.
  17403. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17404. */
  17405. set range(value: number);
  17406. /**
  17407. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17408. * of light.
  17409. */
  17410. private _photometricScale;
  17411. private _intensityMode;
  17412. /**
  17413. * Gets the photometric scale used to interpret the intensity.
  17414. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17415. */
  17416. get intensityMode(): number;
  17417. /**
  17418. * Sets the photometric scale used to interpret the intensity.
  17419. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17420. */
  17421. set intensityMode(value: number);
  17422. private _radius;
  17423. /**
  17424. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17425. */
  17426. get radius(): number;
  17427. /**
  17428. * sets the light radius used by PBR Materials to simulate soft area lights.
  17429. */
  17430. set radius(value: number);
  17431. private _renderPriority;
  17432. /**
  17433. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17434. * exceeding the number allowed of the materials.
  17435. */
  17436. renderPriority: number;
  17437. private _shadowEnabled;
  17438. /**
  17439. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17440. * the current shadow generator.
  17441. */
  17442. get shadowEnabled(): boolean;
  17443. /**
  17444. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17445. * the current shadow generator.
  17446. */
  17447. set shadowEnabled(value: boolean);
  17448. private _includedOnlyMeshes;
  17449. /**
  17450. * Gets the only meshes impacted by this light.
  17451. */
  17452. get includedOnlyMeshes(): AbstractMesh[];
  17453. /**
  17454. * Sets the only meshes impacted by this light.
  17455. */
  17456. set includedOnlyMeshes(value: AbstractMesh[]);
  17457. private _excludedMeshes;
  17458. /**
  17459. * Gets the meshes not impacted by this light.
  17460. */
  17461. get excludedMeshes(): AbstractMesh[];
  17462. /**
  17463. * Sets the meshes not impacted by this light.
  17464. */
  17465. set excludedMeshes(value: AbstractMesh[]);
  17466. private _excludeWithLayerMask;
  17467. /**
  17468. * Gets the layer id use to find what meshes are not impacted by the light.
  17469. * Inactive if 0
  17470. */
  17471. get excludeWithLayerMask(): number;
  17472. /**
  17473. * Sets the layer id use to find what meshes are not impacted by the light.
  17474. * Inactive if 0
  17475. */
  17476. set excludeWithLayerMask(value: number);
  17477. private _includeOnlyWithLayerMask;
  17478. /**
  17479. * Gets the layer id use to find what meshes are impacted by the light.
  17480. * Inactive if 0
  17481. */
  17482. get includeOnlyWithLayerMask(): number;
  17483. /**
  17484. * Sets the layer id use to find what meshes are impacted by the light.
  17485. * Inactive if 0
  17486. */
  17487. set includeOnlyWithLayerMask(value: number);
  17488. private _lightmapMode;
  17489. /**
  17490. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17491. */
  17492. get lightmapMode(): number;
  17493. /**
  17494. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17495. */
  17496. set lightmapMode(value: number);
  17497. /**
  17498. * Shadow generator associted to the light.
  17499. * @hidden Internal use only.
  17500. */
  17501. _shadowGenerator: Nullable<IShadowGenerator>;
  17502. /**
  17503. * @hidden Internal use only.
  17504. */
  17505. _excludedMeshesIds: string[];
  17506. /**
  17507. * @hidden Internal use only.
  17508. */
  17509. _includedOnlyMeshesIds: string[];
  17510. /**
  17511. * The current light unifom buffer.
  17512. * @hidden Internal use only.
  17513. */
  17514. _uniformBuffer: UniformBuffer;
  17515. /** @hidden */
  17516. _renderId: number;
  17517. /**
  17518. * Creates a Light object in the scene.
  17519. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17520. * @param name The firendly name of the light
  17521. * @param scene The scene the light belongs too
  17522. */
  17523. constructor(name: string, scene: Scene);
  17524. protected abstract _buildUniformLayout(): void;
  17525. /**
  17526. * Sets the passed Effect "effect" with the Light information.
  17527. * @param effect The effect to update
  17528. * @param lightIndex The index of the light in the effect to update
  17529. * @returns The light
  17530. */
  17531. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17532. /**
  17533. * Sets the passed Effect "effect" with the Light textures.
  17534. * @param effect The effect to update
  17535. * @param lightIndex The index of the light in the effect to update
  17536. * @returns The light
  17537. */
  17538. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17539. /**
  17540. * Binds the lights information from the scene to the effect for the given mesh.
  17541. * @param lightIndex Light index
  17542. * @param scene The scene where the light belongs to
  17543. * @param effect The effect we are binding the data to
  17544. * @param useSpecular Defines if specular is supported
  17545. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17546. */
  17547. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17548. /**
  17549. * Sets the passed Effect "effect" with the Light information.
  17550. * @param effect The effect to update
  17551. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17552. * @returns The light
  17553. */
  17554. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17555. /**
  17556. * Returns the string "Light".
  17557. * @returns the class name
  17558. */
  17559. getClassName(): string;
  17560. /** @hidden */
  17561. readonly _isLight: boolean;
  17562. /**
  17563. * Converts the light information to a readable string for debug purpose.
  17564. * @param fullDetails Supports for multiple levels of logging within scene loading
  17565. * @returns the human readable light info
  17566. */
  17567. toString(fullDetails?: boolean): string;
  17568. /** @hidden */
  17569. protected _syncParentEnabledState(): void;
  17570. /**
  17571. * Set the enabled state of this node.
  17572. * @param value - the new enabled state
  17573. */
  17574. setEnabled(value: boolean): void;
  17575. /**
  17576. * Returns the Light associated shadow generator if any.
  17577. * @return the associated shadow generator.
  17578. */
  17579. getShadowGenerator(): Nullable<IShadowGenerator>;
  17580. /**
  17581. * Returns a Vector3, the absolute light position in the World.
  17582. * @returns the world space position of the light
  17583. */
  17584. getAbsolutePosition(): Vector3;
  17585. /**
  17586. * Specifies if the light will affect the passed mesh.
  17587. * @param mesh The mesh to test against the light
  17588. * @return true the mesh is affected otherwise, false.
  17589. */
  17590. canAffectMesh(mesh: AbstractMesh): boolean;
  17591. /**
  17592. * Sort function to order lights for rendering.
  17593. * @param a First Light object to compare to second.
  17594. * @param b Second Light object to compare first.
  17595. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17596. */
  17597. static CompareLightsPriority(a: Light, b: Light): number;
  17598. /**
  17599. * Releases resources associated with this node.
  17600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17602. */
  17603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17604. /**
  17605. * Returns the light type ID (integer).
  17606. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17607. */
  17608. getTypeID(): number;
  17609. /**
  17610. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17611. * @returns the scaled intensity in intensity mode unit
  17612. */
  17613. getScaledIntensity(): number;
  17614. /**
  17615. * Returns a new Light object, named "name", from the current one.
  17616. * @param name The name of the cloned light
  17617. * @returns the new created light
  17618. */
  17619. clone(name: string): Nullable<Light>;
  17620. /**
  17621. * Serializes the current light into a Serialization object.
  17622. * @returns the serialized object.
  17623. */
  17624. serialize(): any;
  17625. /**
  17626. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17627. * This new light is named "name" and added to the passed scene.
  17628. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17629. * @param name The friendly name of the light
  17630. * @param scene The scene the new light will belong to
  17631. * @returns the constructor function
  17632. */
  17633. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17634. /**
  17635. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17636. * @param parsedLight The JSON representation of the light
  17637. * @param scene The scene to create the parsed light in
  17638. * @returns the created light after parsing
  17639. */
  17640. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17641. private _hookArrayForExcluded;
  17642. private _hookArrayForIncludedOnly;
  17643. private _resyncMeshes;
  17644. /**
  17645. * Forces the meshes to update their light related information in their rendering used effects
  17646. * @hidden Internal Use Only
  17647. */
  17648. _markMeshesAsLightDirty(): void;
  17649. /**
  17650. * Recomputes the cached photometric scale if needed.
  17651. */
  17652. private _computePhotometricScale;
  17653. /**
  17654. * Returns the Photometric Scale according to the light type and intensity mode.
  17655. */
  17656. private _getPhotometricScale;
  17657. /**
  17658. * Reorder the light in the scene according to their defined priority.
  17659. * @hidden Internal Use Only
  17660. */
  17661. _reorderLightsInScene(): void;
  17662. /**
  17663. * Prepares the list of defines specific to the light type.
  17664. * @param defines the list of defines
  17665. * @param lightIndex defines the index of the light for the effect
  17666. */
  17667. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17668. }
  17669. }
  17670. declare module "babylonjs/Actions/action" {
  17671. import { Observable } from "babylonjs/Misc/observable";
  17672. import { Condition } from "babylonjs/Actions/condition";
  17673. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17674. import { ActionManager } from "babylonjs/Actions/actionManager";
  17675. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17676. /**
  17677. * Interface used to define Action
  17678. */
  17679. export interface IAction {
  17680. /**
  17681. * Trigger for the action
  17682. */
  17683. trigger: number;
  17684. /** Options of the trigger */
  17685. triggerOptions: any;
  17686. /**
  17687. * Gets the trigger parameters
  17688. * @returns the trigger parameters
  17689. */
  17690. getTriggerParameter(): any;
  17691. /**
  17692. * Internal only - executes current action event
  17693. * @hidden
  17694. */
  17695. _executeCurrent(evt?: ActionEvent): void;
  17696. /**
  17697. * Serialize placeholder for child classes
  17698. * @param parent of child
  17699. * @returns the serialized object
  17700. */
  17701. serialize(parent: any): any;
  17702. /**
  17703. * Internal only
  17704. * @hidden
  17705. */
  17706. _prepare(): void;
  17707. /**
  17708. * Internal only - manager for action
  17709. * @hidden
  17710. */
  17711. _actionManager: AbstractActionManager;
  17712. /**
  17713. * Adds action to chain of actions, may be a DoNothingAction
  17714. * @param action defines the next action to execute
  17715. * @returns The action passed in
  17716. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17717. */
  17718. then(action: IAction): IAction;
  17719. }
  17720. /**
  17721. * The action to be carried out following a trigger
  17722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17723. */
  17724. export class Action implements IAction {
  17725. /** the trigger, with or without parameters, for the action */
  17726. triggerOptions: any;
  17727. /**
  17728. * Trigger for the action
  17729. */
  17730. trigger: number;
  17731. /**
  17732. * Internal only - manager for action
  17733. * @hidden
  17734. */
  17735. _actionManager: ActionManager;
  17736. private _nextActiveAction;
  17737. private _child;
  17738. private _condition?;
  17739. private _triggerParameter;
  17740. /**
  17741. * An event triggered prior to action being executed.
  17742. */
  17743. onBeforeExecuteObservable: Observable<Action>;
  17744. /**
  17745. * Creates a new Action
  17746. * @param triggerOptions the trigger, with or without parameters, for the action
  17747. * @param condition an optional determinant of action
  17748. */
  17749. constructor(
  17750. /** the trigger, with or without parameters, for the action */
  17751. triggerOptions: any, condition?: Condition);
  17752. /**
  17753. * Internal only
  17754. * @hidden
  17755. */
  17756. _prepare(): void;
  17757. /**
  17758. * Gets the trigger parameters
  17759. * @returns the trigger parameters
  17760. */
  17761. getTriggerParameter(): any;
  17762. /**
  17763. * Internal only - executes current action event
  17764. * @hidden
  17765. */
  17766. _executeCurrent(evt?: ActionEvent): void;
  17767. /**
  17768. * Execute placeholder for child classes
  17769. * @param evt optional action event
  17770. */
  17771. execute(evt?: ActionEvent): void;
  17772. /**
  17773. * Skips to next active action
  17774. */
  17775. skipToNextActiveAction(): void;
  17776. /**
  17777. * Adds action to chain of actions, may be a DoNothingAction
  17778. * @param action defines the next action to execute
  17779. * @returns The action passed in
  17780. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17781. */
  17782. then(action: Action): Action;
  17783. /**
  17784. * Internal only
  17785. * @hidden
  17786. */
  17787. _getProperty(propertyPath: string): string;
  17788. /**
  17789. * Internal only
  17790. * @hidden
  17791. */
  17792. _getEffectiveTarget(target: any, propertyPath: string): any;
  17793. /**
  17794. * Serialize placeholder for child classes
  17795. * @param parent of child
  17796. * @returns the serialized object
  17797. */
  17798. serialize(parent: any): any;
  17799. /**
  17800. * Internal only called by serialize
  17801. * @hidden
  17802. */
  17803. protected _serialize(serializedAction: any, parent?: any): any;
  17804. /**
  17805. * Internal only
  17806. * @hidden
  17807. */
  17808. static _SerializeValueAsString: (value: any) => string;
  17809. /**
  17810. * Internal only
  17811. * @hidden
  17812. */
  17813. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17814. name: string;
  17815. targetType: string;
  17816. value: string;
  17817. };
  17818. }
  17819. }
  17820. declare module "babylonjs/Actions/condition" {
  17821. import { ActionManager } from "babylonjs/Actions/actionManager";
  17822. /**
  17823. * A Condition applied to an Action
  17824. */
  17825. export class Condition {
  17826. /**
  17827. * Internal only - manager for action
  17828. * @hidden
  17829. */
  17830. _actionManager: ActionManager;
  17831. /**
  17832. * Internal only
  17833. * @hidden
  17834. */
  17835. _evaluationId: number;
  17836. /**
  17837. * Internal only
  17838. * @hidden
  17839. */
  17840. _currentResult: boolean;
  17841. /**
  17842. * Creates a new Condition
  17843. * @param actionManager the manager of the action the condition is applied to
  17844. */
  17845. constructor(actionManager: ActionManager);
  17846. /**
  17847. * Check if the current condition is valid
  17848. * @returns a boolean
  17849. */
  17850. isValid(): boolean;
  17851. /**
  17852. * Internal only
  17853. * @hidden
  17854. */
  17855. _getProperty(propertyPath: string): string;
  17856. /**
  17857. * Internal only
  17858. * @hidden
  17859. */
  17860. _getEffectiveTarget(target: any, propertyPath: string): any;
  17861. /**
  17862. * Serialize placeholder for child classes
  17863. * @returns the serialized object
  17864. */
  17865. serialize(): any;
  17866. /**
  17867. * Internal only
  17868. * @hidden
  17869. */
  17870. protected _serialize(serializedCondition: any): any;
  17871. }
  17872. /**
  17873. * Defines specific conditional operators as extensions of Condition
  17874. */
  17875. export class ValueCondition extends Condition {
  17876. /** path to specify the property of the target the conditional operator uses */
  17877. propertyPath: string;
  17878. /** the value compared by the conditional operator against the current value of the property */
  17879. value: any;
  17880. /** the conditional operator, default ValueCondition.IsEqual */
  17881. operator: number;
  17882. /**
  17883. * Internal only
  17884. * @hidden
  17885. */
  17886. private static _IsEqual;
  17887. /**
  17888. * Internal only
  17889. * @hidden
  17890. */
  17891. private static _IsDifferent;
  17892. /**
  17893. * Internal only
  17894. * @hidden
  17895. */
  17896. private static _IsGreater;
  17897. /**
  17898. * Internal only
  17899. * @hidden
  17900. */
  17901. private static _IsLesser;
  17902. /**
  17903. * returns the number for IsEqual
  17904. */
  17905. static get IsEqual(): number;
  17906. /**
  17907. * Returns the number for IsDifferent
  17908. */
  17909. static get IsDifferent(): number;
  17910. /**
  17911. * Returns the number for IsGreater
  17912. */
  17913. static get IsGreater(): number;
  17914. /**
  17915. * Returns the number for IsLesser
  17916. */
  17917. static get IsLesser(): number;
  17918. /**
  17919. * Internal only The action manager for the condition
  17920. * @hidden
  17921. */
  17922. _actionManager: ActionManager;
  17923. /**
  17924. * Internal only
  17925. * @hidden
  17926. */
  17927. private _target;
  17928. /**
  17929. * Internal only
  17930. * @hidden
  17931. */
  17932. private _effectiveTarget;
  17933. /**
  17934. * Internal only
  17935. * @hidden
  17936. */
  17937. private _property;
  17938. /**
  17939. * Creates a new ValueCondition
  17940. * @param actionManager manager for the action the condition applies to
  17941. * @param target for the action
  17942. * @param propertyPath path to specify the property of the target the conditional operator uses
  17943. * @param value the value compared by the conditional operator against the current value of the property
  17944. * @param operator the conditional operator, default ValueCondition.IsEqual
  17945. */
  17946. constructor(actionManager: ActionManager, target: any,
  17947. /** path to specify the property of the target the conditional operator uses */
  17948. propertyPath: string,
  17949. /** the value compared by the conditional operator against the current value of the property */
  17950. value: any,
  17951. /** the conditional operator, default ValueCondition.IsEqual */
  17952. operator?: number);
  17953. /**
  17954. * Compares the given value with the property value for the specified conditional operator
  17955. * @returns the result of the comparison
  17956. */
  17957. isValid(): boolean;
  17958. /**
  17959. * Serialize the ValueCondition into a JSON compatible object
  17960. * @returns serialization object
  17961. */
  17962. serialize(): any;
  17963. /**
  17964. * Gets the name of the conditional operator for the ValueCondition
  17965. * @param operator the conditional operator
  17966. * @returns the name
  17967. */
  17968. static GetOperatorName(operator: number): string;
  17969. }
  17970. /**
  17971. * Defines a predicate condition as an extension of Condition
  17972. */
  17973. export class PredicateCondition extends Condition {
  17974. /** defines the predicate function used to validate the condition */
  17975. predicate: () => boolean;
  17976. /**
  17977. * Internal only - manager for action
  17978. * @hidden
  17979. */
  17980. _actionManager: ActionManager;
  17981. /**
  17982. * Creates a new PredicateCondition
  17983. * @param actionManager manager for the action the condition applies to
  17984. * @param predicate defines the predicate function used to validate the condition
  17985. */
  17986. constructor(actionManager: ActionManager,
  17987. /** defines the predicate function used to validate the condition */
  17988. predicate: () => boolean);
  17989. /**
  17990. * @returns the validity of the predicate condition
  17991. */
  17992. isValid(): boolean;
  17993. }
  17994. /**
  17995. * Defines a state condition as an extension of Condition
  17996. */
  17997. export class StateCondition extends Condition {
  17998. /** Value to compare with target state */
  17999. value: string;
  18000. /**
  18001. * Internal only - manager for action
  18002. * @hidden
  18003. */
  18004. _actionManager: ActionManager;
  18005. /**
  18006. * Internal only
  18007. * @hidden
  18008. */
  18009. private _target;
  18010. /**
  18011. * Creates a new StateCondition
  18012. * @param actionManager manager for the action the condition applies to
  18013. * @param target of the condition
  18014. * @param value to compare with target state
  18015. */
  18016. constructor(actionManager: ActionManager, target: any,
  18017. /** Value to compare with target state */
  18018. value: string);
  18019. /**
  18020. * Gets a boolean indicating if the current condition is met
  18021. * @returns the validity of the state
  18022. */
  18023. isValid(): boolean;
  18024. /**
  18025. * Serialize the StateCondition into a JSON compatible object
  18026. * @returns serialization object
  18027. */
  18028. serialize(): any;
  18029. }
  18030. }
  18031. declare module "babylonjs/Actions/directActions" {
  18032. import { Action } from "babylonjs/Actions/action";
  18033. import { Condition } from "babylonjs/Actions/condition";
  18034. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  18035. /**
  18036. * This defines an action responsible to toggle a boolean once triggered.
  18037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18038. */
  18039. export class SwitchBooleanAction extends Action {
  18040. /**
  18041. * The path to the boolean property in the target object
  18042. */
  18043. propertyPath: string;
  18044. private _target;
  18045. private _effectiveTarget;
  18046. private _property;
  18047. /**
  18048. * Instantiate the action
  18049. * @param triggerOptions defines the trigger options
  18050. * @param target defines the object containing the boolean
  18051. * @param propertyPath defines the path to the boolean property in the target object
  18052. * @param condition defines the trigger related conditions
  18053. */
  18054. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  18055. /** @hidden */
  18056. _prepare(): void;
  18057. /**
  18058. * Execute the action toggle the boolean value.
  18059. */
  18060. execute(): void;
  18061. /**
  18062. * Serializes the actions and its related information.
  18063. * @param parent defines the object to serialize in
  18064. * @returns the serialized object
  18065. */
  18066. serialize(parent: any): any;
  18067. }
  18068. /**
  18069. * This defines an action responsible to set a the state field of the target
  18070. * to a desired value once triggered.
  18071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18072. */
  18073. export class SetStateAction extends Action {
  18074. /**
  18075. * The value to store in the state field.
  18076. */
  18077. value: string;
  18078. private _target;
  18079. /**
  18080. * Instantiate the action
  18081. * @param triggerOptions defines the trigger options
  18082. * @param target defines the object containing the state property
  18083. * @param value defines the value to store in the state field
  18084. * @param condition defines the trigger related conditions
  18085. */
  18086. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  18087. /**
  18088. * Execute the action and store the value on the target state property.
  18089. */
  18090. execute(): void;
  18091. /**
  18092. * Serializes the actions and its related information.
  18093. * @param parent defines the object to serialize in
  18094. * @returns the serialized object
  18095. */
  18096. serialize(parent: any): any;
  18097. }
  18098. /**
  18099. * This defines an action responsible to set a property of the target
  18100. * to a desired value once triggered.
  18101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18102. */
  18103. export class SetValueAction extends Action {
  18104. /**
  18105. * The path of the property to set in the target.
  18106. */
  18107. propertyPath: string;
  18108. /**
  18109. * The value to set in the property
  18110. */
  18111. value: any;
  18112. private _target;
  18113. private _effectiveTarget;
  18114. private _property;
  18115. /**
  18116. * Instantiate the action
  18117. * @param triggerOptions defines the trigger options
  18118. * @param target defines the object containing the property
  18119. * @param propertyPath defines the path of the property to set in the target
  18120. * @param value defines the value to set in the property
  18121. * @param condition defines the trigger related conditions
  18122. */
  18123. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18124. /** @hidden */
  18125. _prepare(): void;
  18126. /**
  18127. * Execute the action and set the targetted property to the desired value.
  18128. */
  18129. execute(): void;
  18130. /**
  18131. * Serializes the actions and its related information.
  18132. * @param parent defines the object to serialize in
  18133. * @returns the serialized object
  18134. */
  18135. serialize(parent: any): any;
  18136. }
  18137. /**
  18138. * This defines an action responsible to increment the target value
  18139. * to a desired value once triggered.
  18140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18141. */
  18142. export class IncrementValueAction extends Action {
  18143. /**
  18144. * The path of the property to increment in the target.
  18145. */
  18146. propertyPath: string;
  18147. /**
  18148. * The value we should increment the property by.
  18149. */
  18150. value: any;
  18151. private _target;
  18152. private _effectiveTarget;
  18153. private _property;
  18154. /**
  18155. * Instantiate the action
  18156. * @param triggerOptions defines the trigger options
  18157. * @param target defines the object containing the property
  18158. * @param propertyPath defines the path of the property to increment in the target
  18159. * @param value defines the value value we should increment the property by
  18160. * @param condition defines the trigger related conditions
  18161. */
  18162. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  18163. /** @hidden */
  18164. _prepare(): void;
  18165. /**
  18166. * Execute the action and increment the target of the value amount.
  18167. */
  18168. execute(): void;
  18169. /**
  18170. * Serializes the actions and its related information.
  18171. * @param parent defines the object to serialize in
  18172. * @returns the serialized object
  18173. */
  18174. serialize(parent: any): any;
  18175. }
  18176. /**
  18177. * This defines an action responsible to start an animation once triggered.
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18179. */
  18180. export class PlayAnimationAction extends Action {
  18181. /**
  18182. * Where the animation should start (animation frame)
  18183. */
  18184. from: number;
  18185. /**
  18186. * Where the animation should stop (animation frame)
  18187. */
  18188. to: number;
  18189. /**
  18190. * Define if the animation should loop or stop after the first play.
  18191. */
  18192. loop?: boolean;
  18193. private _target;
  18194. /**
  18195. * Instantiate the action
  18196. * @param triggerOptions defines the trigger options
  18197. * @param target defines the target animation or animation name
  18198. * @param from defines from where the animation should start (animation frame)
  18199. * @param end defines where the animation should stop (animation frame)
  18200. * @param loop defines if the animation should loop or stop after the first play
  18201. * @param condition defines the trigger related conditions
  18202. */
  18203. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18204. /** @hidden */
  18205. _prepare(): void;
  18206. /**
  18207. * Execute the action and play the animation.
  18208. */
  18209. execute(): void;
  18210. /**
  18211. * Serializes the actions and its related information.
  18212. * @param parent defines the object to serialize in
  18213. * @returns the serialized object
  18214. */
  18215. serialize(parent: any): any;
  18216. }
  18217. /**
  18218. * This defines an action responsible to stop an animation once triggered.
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18220. */
  18221. export class StopAnimationAction extends Action {
  18222. private _target;
  18223. /**
  18224. * Instantiate the action
  18225. * @param triggerOptions defines the trigger options
  18226. * @param target defines the target animation or animation name
  18227. * @param condition defines the trigger related conditions
  18228. */
  18229. constructor(triggerOptions: any, target: any, condition?: Condition);
  18230. /** @hidden */
  18231. _prepare(): void;
  18232. /**
  18233. * Execute the action and stop the animation.
  18234. */
  18235. execute(): void;
  18236. /**
  18237. * Serializes the actions and its related information.
  18238. * @param parent defines the object to serialize in
  18239. * @returns the serialized object
  18240. */
  18241. serialize(parent: any): any;
  18242. }
  18243. /**
  18244. * This defines an action responsible that does nothing once triggered.
  18245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18246. */
  18247. export class DoNothingAction extends Action {
  18248. /**
  18249. * Instantiate the action
  18250. * @param triggerOptions defines the trigger options
  18251. * @param condition defines the trigger related conditions
  18252. */
  18253. constructor(triggerOptions?: any, condition?: Condition);
  18254. /**
  18255. * Execute the action and do nothing.
  18256. */
  18257. execute(): void;
  18258. /**
  18259. * Serializes the actions and its related information.
  18260. * @param parent defines the object to serialize in
  18261. * @returns the serialized object
  18262. */
  18263. serialize(parent: any): any;
  18264. }
  18265. /**
  18266. * This defines an action responsible to trigger several actions once triggered.
  18267. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18268. */
  18269. export class CombineAction extends Action {
  18270. /**
  18271. * The list of aggregated animations to run.
  18272. */
  18273. children: Action[];
  18274. /**
  18275. * Instantiate the action
  18276. * @param triggerOptions defines the trigger options
  18277. * @param children defines the list of aggregated animations to run
  18278. * @param condition defines the trigger related conditions
  18279. */
  18280. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18281. /** @hidden */
  18282. _prepare(): void;
  18283. /**
  18284. * Execute the action and executes all the aggregated actions.
  18285. */
  18286. execute(evt: ActionEvent): void;
  18287. /**
  18288. * Serializes the actions and its related information.
  18289. * @param parent defines the object to serialize in
  18290. * @returns the serialized object
  18291. */
  18292. serialize(parent: any): any;
  18293. }
  18294. /**
  18295. * This defines an action responsible to run code (external event) once triggered.
  18296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18297. */
  18298. export class ExecuteCodeAction extends Action {
  18299. /**
  18300. * The callback function to run.
  18301. */
  18302. func: (evt: ActionEvent) => void;
  18303. /**
  18304. * Instantiate the action
  18305. * @param triggerOptions defines the trigger options
  18306. * @param func defines the callback function to run
  18307. * @param condition defines the trigger related conditions
  18308. */
  18309. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18310. /**
  18311. * Execute the action and run the attached code.
  18312. */
  18313. execute(evt: ActionEvent): void;
  18314. }
  18315. /**
  18316. * This defines an action responsible to set the parent property of the target once triggered.
  18317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18318. */
  18319. export class SetParentAction extends Action {
  18320. private _parent;
  18321. private _target;
  18322. /**
  18323. * Instantiate the action
  18324. * @param triggerOptions defines the trigger options
  18325. * @param target defines the target containing the parent property
  18326. * @param parent defines from where the animation should start (animation frame)
  18327. * @param condition defines the trigger related conditions
  18328. */
  18329. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18330. /** @hidden */
  18331. _prepare(): void;
  18332. /**
  18333. * Execute the action and set the parent property.
  18334. */
  18335. execute(): void;
  18336. /**
  18337. * Serializes the actions and its related information.
  18338. * @param parent defines the object to serialize in
  18339. * @returns the serialized object
  18340. */
  18341. serialize(parent: any): any;
  18342. }
  18343. }
  18344. declare module "babylonjs/Actions/actionManager" {
  18345. import { Nullable } from "babylonjs/types";
  18346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18347. import { Scene } from "babylonjs/scene";
  18348. import { IAction } from "babylonjs/Actions/action";
  18349. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18350. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18351. /**
  18352. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18353. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18355. */
  18356. export class ActionManager extends AbstractActionManager {
  18357. /**
  18358. * Nothing
  18359. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18360. */
  18361. static readonly NothingTrigger: number;
  18362. /**
  18363. * On pick
  18364. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18365. */
  18366. static readonly OnPickTrigger: number;
  18367. /**
  18368. * On left pick
  18369. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18370. */
  18371. static readonly OnLeftPickTrigger: number;
  18372. /**
  18373. * On right pick
  18374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18375. */
  18376. static readonly OnRightPickTrigger: number;
  18377. /**
  18378. * On center pick
  18379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18380. */
  18381. static readonly OnCenterPickTrigger: number;
  18382. /**
  18383. * On pick down
  18384. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18385. */
  18386. static readonly OnPickDownTrigger: number;
  18387. /**
  18388. * On double pick
  18389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18390. */
  18391. static readonly OnDoublePickTrigger: number;
  18392. /**
  18393. * On pick up
  18394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18395. */
  18396. static readonly OnPickUpTrigger: number;
  18397. /**
  18398. * On pick out.
  18399. * This trigger will only be raised if you also declared a OnPickDown
  18400. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18401. */
  18402. static readonly OnPickOutTrigger: number;
  18403. /**
  18404. * On long press
  18405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18406. */
  18407. static readonly OnLongPressTrigger: number;
  18408. /**
  18409. * On pointer over
  18410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18411. */
  18412. static readonly OnPointerOverTrigger: number;
  18413. /**
  18414. * On pointer out
  18415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18416. */
  18417. static readonly OnPointerOutTrigger: number;
  18418. /**
  18419. * On every frame
  18420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18421. */
  18422. static readonly OnEveryFrameTrigger: number;
  18423. /**
  18424. * On intersection enter
  18425. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18426. */
  18427. static readonly OnIntersectionEnterTrigger: number;
  18428. /**
  18429. * On intersection exit
  18430. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18431. */
  18432. static readonly OnIntersectionExitTrigger: number;
  18433. /**
  18434. * On key down
  18435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18436. */
  18437. static readonly OnKeyDownTrigger: number;
  18438. /**
  18439. * On key up
  18440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18441. */
  18442. static readonly OnKeyUpTrigger: number;
  18443. private _scene;
  18444. /**
  18445. * Creates a new action manager
  18446. * @param scene defines the hosting scene
  18447. */
  18448. constructor(scene: Scene);
  18449. /**
  18450. * Releases all associated resources
  18451. */
  18452. dispose(): void;
  18453. /**
  18454. * Gets hosting scene
  18455. * @returns the hosting scene
  18456. */
  18457. getScene(): Scene;
  18458. /**
  18459. * Does this action manager handles actions of any of the given triggers
  18460. * @param triggers defines the triggers to be tested
  18461. * @return a boolean indicating whether one (or more) of the triggers is handled
  18462. */
  18463. hasSpecificTriggers(triggers: number[]): boolean;
  18464. /**
  18465. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18466. * speed.
  18467. * @param triggerA defines the trigger to be tested
  18468. * @param triggerB defines the trigger to be tested
  18469. * @return a boolean indicating whether one (or more) of the triggers is handled
  18470. */
  18471. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18472. /**
  18473. * Does this action manager handles actions of a given trigger
  18474. * @param trigger defines the trigger to be tested
  18475. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18476. * @return whether the trigger is handled
  18477. */
  18478. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18479. /**
  18480. * Does this action manager has pointer triggers
  18481. */
  18482. get hasPointerTriggers(): boolean;
  18483. /**
  18484. * Does this action manager has pick triggers
  18485. */
  18486. get hasPickTriggers(): boolean;
  18487. /**
  18488. * Registers an action to this action manager
  18489. * @param action defines the action to be registered
  18490. * @return the action amended (prepared) after registration
  18491. */
  18492. registerAction(action: IAction): Nullable<IAction>;
  18493. /**
  18494. * Unregisters an action to this action manager
  18495. * @param action defines the action to be unregistered
  18496. * @return a boolean indicating whether the action has been unregistered
  18497. */
  18498. unregisterAction(action: IAction): Boolean;
  18499. /**
  18500. * Process a specific trigger
  18501. * @param trigger defines the trigger to process
  18502. * @param evt defines the event details to be processed
  18503. */
  18504. processTrigger(trigger: number, evt?: IActionEvent): void;
  18505. /** @hidden */
  18506. _getEffectiveTarget(target: any, propertyPath: string): any;
  18507. /** @hidden */
  18508. _getProperty(propertyPath: string): string;
  18509. /**
  18510. * Serialize this manager to a JSON object
  18511. * @param name defines the property name to store this manager
  18512. * @returns a JSON representation of this manager
  18513. */
  18514. serialize(name: string): any;
  18515. /**
  18516. * Creates a new ActionManager from a JSON data
  18517. * @param parsedActions defines the JSON data to read from
  18518. * @param object defines the hosting mesh
  18519. * @param scene defines the hosting scene
  18520. */
  18521. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18522. /**
  18523. * Get a trigger name by index
  18524. * @param trigger defines the trigger index
  18525. * @returns a trigger name
  18526. */
  18527. static GetTriggerName(trigger: number): string;
  18528. }
  18529. }
  18530. declare module "babylonjs/Sprites/sprite" {
  18531. import { Vector3 } from "babylonjs/Maths/math.vector";
  18532. import { Nullable } from "babylonjs/types";
  18533. import { ActionManager } from "babylonjs/Actions/actionManager";
  18534. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18535. import { Color4 } from "babylonjs/Maths/math.color";
  18536. /**
  18537. * Class used to represent a sprite
  18538. * @see http://doc.babylonjs.com/babylon101/sprites
  18539. */
  18540. export class Sprite {
  18541. /** defines the name */
  18542. name: string;
  18543. /** Gets or sets the current world position */
  18544. position: Vector3;
  18545. /** Gets or sets the main color */
  18546. color: Color4;
  18547. /** Gets or sets the width */
  18548. width: number;
  18549. /** Gets or sets the height */
  18550. height: number;
  18551. /** Gets or sets rotation angle */
  18552. angle: number;
  18553. /** Gets or sets the cell index in the sprite sheet */
  18554. cellIndex: number;
  18555. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18556. cellRef: string;
  18557. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18558. invertU: number;
  18559. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18560. invertV: number;
  18561. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18562. disposeWhenFinishedAnimating: boolean;
  18563. /** Gets the list of attached animations */
  18564. animations: Animation[];
  18565. /** Gets or sets a boolean indicating if the sprite can be picked */
  18566. isPickable: boolean;
  18567. /**
  18568. * Gets or sets the associated action manager
  18569. */
  18570. actionManager: Nullable<ActionManager>;
  18571. private _animationStarted;
  18572. private _loopAnimation;
  18573. private _fromIndex;
  18574. private _toIndex;
  18575. private _delay;
  18576. private _direction;
  18577. private _manager;
  18578. private _time;
  18579. private _onAnimationEnd;
  18580. /**
  18581. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18582. */
  18583. isVisible: boolean;
  18584. /**
  18585. * Gets or sets the sprite size
  18586. */
  18587. get size(): number;
  18588. set size(value: number);
  18589. /**
  18590. * Creates a new Sprite
  18591. * @param name defines the name
  18592. * @param manager defines the manager
  18593. */
  18594. constructor(
  18595. /** defines the name */
  18596. name: string, manager: ISpriteManager);
  18597. /**
  18598. * Starts an animation
  18599. * @param from defines the initial key
  18600. * @param to defines the end key
  18601. * @param loop defines if the animation must loop
  18602. * @param delay defines the start delay (in ms)
  18603. * @param onAnimationEnd defines a callback to call when animation ends
  18604. */
  18605. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18606. /** Stops current animation (if any) */
  18607. stopAnimation(): void;
  18608. /** @hidden */
  18609. _animate(deltaTime: number): void;
  18610. /** Release associated resources */
  18611. dispose(): void;
  18612. }
  18613. }
  18614. declare module "babylonjs/Collisions/pickingInfo" {
  18615. import { Nullable } from "babylonjs/types";
  18616. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18618. import { Sprite } from "babylonjs/Sprites/sprite";
  18619. import { Ray } from "babylonjs/Culling/ray";
  18620. /**
  18621. * Information about the result of picking within a scene
  18622. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18623. */
  18624. export class PickingInfo {
  18625. /** @hidden */
  18626. _pickingUnavailable: boolean;
  18627. /**
  18628. * If the pick collided with an object
  18629. */
  18630. hit: boolean;
  18631. /**
  18632. * Distance away where the pick collided
  18633. */
  18634. distance: number;
  18635. /**
  18636. * The location of pick collision
  18637. */
  18638. pickedPoint: Nullable<Vector3>;
  18639. /**
  18640. * The mesh corresponding the the pick collision
  18641. */
  18642. pickedMesh: Nullable<AbstractMesh>;
  18643. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18644. bu: number;
  18645. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18646. bv: number;
  18647. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18648. faceId: number;
  18649. /** Id of the the submesh that was picked */
  18650. subMeshId: number;
  18651. /** If a sprite was picked, this will be the sprite the pick collided with */
  18652. pickedSprite: Nullable<Sprite>;
  18653. /**
  18654. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18655. */
  18656. originMesh: Nullable<AbstractMesh>;
  18657. /**
  18658. * The ray that was used to perform the picking.
  18659. */
  18660. ray: Nullable<Ray>;
  18661. /**
  18662. * Gets the normal correspodning to the face the pick collided with
  18663. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18664. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18665. * @returns The normal correspodning to the face the pick collided with
  18666. */
  18667. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18668. /**
  18669. * Gets the texture coordinates of where the pick occured
  18670. * @returns the vector containing the coordnates of the texture
  18671. */
  18672. getTextureCoordinates(): Nullable<Vector2>;
  18673. }
  18674. }
  18675. declare module "babylonjs/Events/pointerEvents" {
  18676. import { Nullable } from "babylonjs/types";
  18677. import { Vector2 } from "babylonjs/Maths/math.vector";
  18678. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18679. import { Ray } from "babylonjs/Culling/ray";
  18680. /**
  18681. * Gather the list of pointer event types as constants.
  18682. */
  18683. export class PointerEventTypes {
  18684. /**
  18685. * 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.
  18686. */
  18687. static readonly POINTERDOWN: number;
  18688. /**
  18689. * The pointerup event is fired when a pointer is no longer active.
  18690. */
  18691. static readonly POINTERUP: number;
  18692. /**
  18693. * The pointermove event is fired when a pointer changes coordinates.
  18694. */
  18695. static readonly POINTERMOVE: number;
  18696. /**
  18697. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18698. */
  18699. static readonly POINTERWHEEL: number;
  18700. /**
  18701. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18702. */
  18703. static readonly POINTERPICK: number;
  18704. /**
  18705. * The pointertap event is fired when a the object has been touched and released without drag.
  18706. */
  18707. static readonly POINTERTAP: number;
  18708. /**
  18709. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18710. */
  18711. static readonly POINTERDOUBLETAP: number;
  18712. }
  18713. /**
  18714. * Base class of pointer info types.
  18715. */
  18716. export class PointerInfoBase {
  18717. /**
  18718. * Defines the type of event (PointerEventTypes)
  18719. */
  18720. type: number;
  18721. /**
  18722. * Defines the related dom event
  18723. */
  18724. event: PointerEvent | MouseWheelEvent;
  18725. /**
  18726. * Instantiates the base class of pointers info.
  18727. * @param type Defines the type of event (PointerEventTypes)
  18728. * @param event Defines the related dom event
  18729. */
  18730. constructor(
  18731. /**
  18732. * Defines the type of event (PointerEventTypes)
  18733. */
  18734. type: number,
  18735. /**
  18736. * Defines the related dom event
  18737. */
  18738. event: PointerEvent | MouseWheelEvent);
  18739. }
  18740. /**
  18741. * This class is used to store pointer related info for the onPrePointerObservable event.
  18742. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18743. */
  18744. export class PointerInfoPre extends PointerInfoBase {
  18745. /**
  18746. * Ray from a pointer if availible (eg. 6dof controller)
  18747. */
  18748. ray: Nullable<Ray>;
  18749. /**
  18750. * Defines the local position of the pointer on the canvas.
  18751. */
  18752. localPosition: Vector2;
  18753. /**
  18754. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18755. */
  18756. skipOnPointerObservable: boolean;
  18757. /**
  18758. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18759. * @param type Defines the type of event (PointerEventTypes)
  18760. * @param event Defines the related dom event
  18761. * @param localX Defines the local x coordinates of the pointer when the event occured
  18762. * @param localY Defines the local y coordinates of the pointer when the event occured
  18763. */
  18764. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18765. }
  18766. /**
  18767. * This type contains all the data related to a pointer event in Babylon.js.
  18768. * 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.
  18769. */
  18770. export class PointerInfo extends PointerInfoBase {
  18771. /**
  18772. * Defines the picking info associated to the info (if any)\
  18773. */
  18774. pickInfo: Nullable<PickingInfo>;
  18775. /**
  18776. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18777. * @param type Defines the type of event (PointerEventTypes)
  18778. * @param event Defines the related dom event
  18779. * @param pickInfo Defines the picking info associated to the info (if any)\
  18780. */
  18781. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18782. /**
  18783. * Defines the picking info associated to the info (if any)\
  18784. */
  18785. pickInfo: Nullable<PickingInfo>);
  18786. }
  18787. /**
  18788. * Data relating to a touch event on the screen.
  18789. */
  18790. export interface PointerTouch {
  18791. /**
  18792. * X coordinate of touch.
  18793. */
  18794. x: number;
  18795. /**
  18796. * Y coordinate of touch.
  18797. */
  18798. y: number;
  18799. /**
  18800. * Id of touch. Unique for each finger.
  18801. */
  18802. pointerId: number;
  18803. /**
  18804. * Event type passed from DOM.
  18805. */
  18806. type: any;
  18807. }
  18808. }
  18809. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18810. import { Observable } from "babylonjs/Misc/observable";
  18811. import { Nullable } from "babylonjs/types";
  18812. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18813. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18814. /**
  18815. * Manage the mouse inputs to control the movement of a free camera.
  18816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18817. */
  18818. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18819. /**
  18820. * Define if touch is enabled in the mouse input
  18821. */
  18822. touchEnabled: boolean;
  18823. /**
  18824. * Defines the camera the input is attached to.
  18825. */
  18826. camera: FreeCamera;
  18827. /**
  18828. * Defines the buttons associated with the input to handle camera move.
  18829. */
  18830. buttons: number[];
  18831. /**
  18832. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18833. */
  18834. angularSensibility: number;
  18835. private _pointerInput;
  18836. private _onMouseMove;
  18837. private _observer;
  18838. private previousPosition;
  18839. /**
  18840. * Observable for when a pointer move event occurs containing the move offset
  18841. */
  18842. onPointerMovedObservable: Observable<{
  18843. offsetX: number;
  18844. offsetY: number;
  18845. }>;
  18846. /**
  18847. * @hidden
  18848. * If the camera should be rotated automatically based on pointer movement
  18849. */
  18850. _allowCameraRotation: boolean;
  18851. /**
  18852. * Manage the mouse inputs to control the movement of a free camera.
  18853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18854. * @param touchEnabled Defines if touch is enabled or not
  18855. */
  18856. constructor(
  18857. /**
  18858. * Define if touch is enabled in the mouse input
  18859. */
  18860. touchEnabled?: boolean);
  18861. /**
  18862. * Attach the input controls to a specific dom element to get the input from.
  18863. * @param element Defines the element the controls should be listened from
  18864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18865. */
  18866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18867. /**
  18868. * Called on JS contextmenu event.
  18869. * Override this method to provide functionality.
  18870. */
  18871. protected onContextMenu(evt: PointerEvent): void;
  18872. /**
  18873. * Detach the current controls from the specified dom element.
  18874. * @param element Defines the element to stop listening the inputs from
  18875. */
  18876. detachControl(element: Nullable<HTMLElement>): void;
  18877. /**
  18878. * Gets the class name of the current intput.
  18879. * @returns the class name
  18880. */
  18881. getClassName(): string;
  18882. /**
  18883. * Get the friendly name associated with the input class.
  18884. * @returns the input friendly name
  18885. */
  18886. getSimpleName(): string;
  18887. }
  18888. }
  18889. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18890. import { Nullable } from "babylonjs/types";
  18891. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18892. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18893. /**
  18894. * Manage the touch inputs to control the movement of a free camera.
  18895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18896. */
  18897. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18898. /**
  18899. * Defines the camera the input is attached to.
  18900. */
  18901. camera: FreeCamera;
  18902. /**
  18903. * Defines the touch sensibility for rotation.
  18904. * The higher the faster.
  18905. */
  18906. touchAngularSensibility: number;
  18907. /**
  18908. * Defines the touch sensibility for move.
  18909. * The higher the faster.
  18910. */
  18911. touchMoveSensibility: number;
  18912. private _offsetX;
  18913. private _offsetY;
  18914. private _pointerPressed;
  18915. private _pointerInput;
  18916. private _observer;
  18917. private _onLostFocus;
  18918. /**
  18919. * Attach the input controls to a specific dom element to get the input from.
  18920. * @param element Defines the element the controls should be listened from
  18921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18922. */
  18923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18924. /**
  18925. * Detach the current controls from the specified dom element.
  18926. * @param element Defines the element to stop listening the inputs from
  18927. */
  18928. detachControl(element: Nullable<HTMLElement>): void;
  18929. /**
  18930. * Update the current camera state depending on the inputs that have been used this frame.
  18931. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18932. */
  18933. checkInputs(): void;
  18934. /**
  18935. * Gets the class name of the current intput.
  18936. * @returns the class name
  18937. */
  18938. getClassName(): string;
  18939. /**
  18940. * Get the friendly name associated with the input class.
  18941. * @returns the input friendly name
  18942. */
  18943. getSimpleName(): string;
  18944. }
  18945. }
  18946. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18947. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18948. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18949. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18950. import { Nullable } from "babylonjs/types";
  18951. /**
  18952. * Default Inputs manager for the FreeCamera.
  18953. * It groups all the default supported inputs for ease of use.
  18954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18955. */
  18956. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18957. /**
  18958. * @hidden
  18959. */
  18960. _mouseInput: Nullable<FreeCameraMouseInput>;
  18961. /**
  18962. * Instantiates a new FreeCameraInputsManager.
  18963. * @param camera Defines the camera the inputs belong to
  18964. */
  18965. constructor(camera: FreeCamera);
  18966. /**
  18967. * Add keyboard input support to the input manager.
  18968. * @returns the current input manager
  18969. */
  18970. addKeyboard(): FreeCameraInputsManager;
  18971. /**
  18972. * Add mouse input support to the input manager.
  18973. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18974. * @returns the current input manager
  18975. */
  18976. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18977. /**
  18978. * Removes the mouse input support from the manager
  18979. * @returns the current input manager
  18980. */
  18981. removeMouse(): FreeCameraInputsManager;
  18982. /**
  18983. * Add touch input support to the input manager.
  18984. * @returns the current input manager
  18985. */
  18986. addTouch(): FreeCameraInputsManager;
  18987. /**
  18988. * Remove all attached input methods from a camera
  18989. */
  18990. clear(): void;
  18991. }
  18992. }
  18993. declare module "babylonjs/Cameras/freeCamera" {
  18994. import { Vector3 } from "babylonjs/Maths/math.vector";
  18995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18996. import { Scene } from "babylonjs/scene";
  18997. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18998. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18999. /**
  19000. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19001. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19002. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19003. */
  19004. export class FreeCamera extends TargetCamera {
  19005. /**
  19006. * Define the collision ellipsoid of the camera.
  19007. * This is helpful to simulate a camera body like the player body around the camera
  19008. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19009. */
  19010. ellipsoid: Vector3;
  19011. /**
  19012. * Define an offset for the position of the ellipsoid around the camera.
  19013. * This can be helpful to determine the center of the body near the gravity center of the body
  19014. * instead of its head.
  19015. */
  19016. ellipsoidOffset: Vector3;
  19017. /**
  19018. * Enable or disable collisions of the camera with the rest of the scene objects.
  19019. */
  19020. checkCollisions: boolean;
  19021. /**
  19022. * Enable or disable gravity on the camera.
  19023. */
  19024. applyGravity: boolean;
  19025. /**
  19026. * Define the input manager associated to the camera.
  19027. */
  19028. inputs: FreeCameraInputsManager;
  19029. /**
  19030. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19031. * Higher values reduce sensitivity.
  19032. */
  19033. get angularSensibility(): number;
  19034. /**
  19035. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19036. * Higher values reduce sensitivity.
  19037. */
  19038. set angularSensibility(value: number);
  19039. /**
  19040. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19041. */
  19042. get keysUp(): number[];
  19043. set keysUp(value: number[]);
  19044. /**
  19045. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19046. */
  19047. get keysUpward(): number[];
  19048. set keysUpward(value: number[]);
  19049. /**
  19050. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19051. */
  19052. get keysDown(): number[];
  19053. set keysDown(value: number[]);
  19054. /**
  19055. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19056. */
  19057. get keysDownward(): number[];
  19058. set keysDownward(value: number[]);
  19059. /**
  19060. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19061. */
  19062. get keysLeft(): number[];
  19063. set keysLeft(value: number[]);
  19064. /**
  19065. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19066. */
  19067. get keysRight(): number[];
  19068. set keysRight(value: number[]);
  19069. /**
  19070. * Event raised when the camera collide with a mesh in the scene.
  19071. */
  19072. onCollide: (collidedMesh: AbstractMesh) => void;
  19073. private _collider;
  19074. private _needMoveForGravity;
  19075. private _oldPosition;
  19076. private _diffPosition;
  19077. private _newPosition;
  19078. /** @hidden */
  19079. _localDirection: Vector3;
  19080. /** @hidden */
  19081. _transformedDirection: Vector3;
  19082. /**
  19083. * Instantiates a Free Camera.
  19084. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19085. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19086. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  19087. * @param name Define the name of the camera in the scene
  19088. * @param position Define the start position of the camera in the scene
  19089. * @param scene Define the scene the camera belongs to
  19090. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19091. */
  19092. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19093. /**
  19094. * Attached controls to the current camera.
  19095. * @param element Defines the element the controls should be listened from
  19096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19097. */
  19098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19099. /**
  19100. * Detach the current controls from the camera.
  19101. * The camera will stop reacting to inputs.
  19102. * @param element Defines the element to stop listening the inputs from
  19103. */
  19104. detachControl(element: HTMLElement): void;
  19105. private _collisionMask;
  19106. /**
  19107. * Define a collision mask to limit the list of object the camera can collide with
  19108. */
  19109. get collisionMask(): number;
  19110. set collisionMask(mask: number);
  19111. /** @hidden */
  19112. _collideWithWorld(displacement: Vector3): void;
  19113. private _onCollisionPositionChange;
  19114. /** @hidden */
  19115. _checkInputs(): void;
  19116. /** @hidden */
  19117. _decideIfNeedsToMove(): boolean;
  19118. /** @hidden */
  19119. _updatePosition(): void;
  19120. /**
  19121. * Destroy the camera and release the current resources hold by it.
  19122. */
  19123. dispose(): void;
  19124. /**
  19125. * Gets the current object class name.
  19126. * @return the class name
  19127. */
  19128. getClassName(): string;
  19129. }
  19130. }
  19131. declare module "babylonjs/Gamepads/gamepad" {
  19132. import { Observable } from "babylonjs/Misc/observable";
  19133. /**
  19134. * Represents a gamepad control stick position
  19135. */
  19136. export class StickValues {
  19137. /**
  19138. * The x component of the control stick
  19139. */
  19140. x: number;
  19141. /**
  19142. * The y component of the control stick
  19143. */
  19144. y: number;
  19145. /**
  19146. * Initializes the gamepad x and y control stick values
  19147. * @param x The x component of the gamepad control stick value
  19148. * @param y The y component of the gamepad control stick value
  19149. */
  19150. constructor(
  19151. /**
  19152. * The x component of the control stick
  19153. */
  19154. x: number,
  19155. /**
  19156. * The y component of the control stick
  19157. */
  19158. y: number);
  19159. }
  19160. /**
  19161. * An interface which manages callbacks for gamepad button changes
  19162. */
  19163. export interface GamepadButtonChanges {
  19164. /**
  19165. * Called when a gamepad has been changed
  19166. */
  19167. changed: boolean;
  19168. /**
  19169. * Called when a gamepad press event has been triggered
  19170. */
  19171. pressChanged: boolean;
  19172. /**
  19173. * Called when a touch event has been triggered
  19174. */
  19175. touchChanged: boolean;
  19176. /**
  19177. * Called when a value has changed
  19178. */
  19179. valueChanged: boolean;
  19180. }
  19181. /**
  19182. * Represents a gamepad
  19183. */
  19184. export class Gamepad {
  19185. /**
  19186. * The id of the gamepad
  19187. */
  19188. id: string;
  19189. /**
  19190. * The index of the gamepad
  19191. */
  19192. index: number;
  19193. /**
  19194. * The browser gamepad
  19195. */
  19196. browserGamepad: any;
  19197. /**
  19198. * Specifies what type of gamepad this represents
  19199. */
  19200. type: number;
  19201. private _leftStick;
  19202. private _rightStick;
  19203. /** @hidden */
  19204. _isConnected: boolean;
  19205. private _leftStickAxisX;
  19206. private _leftStickAxisY;
  19207. private _rightStickAxisX;
  19208. private _rightStickAxisY;
  19209. /**
  19210. * Triggered when the left control stick has been changed
  19211. */
  19212. private _onleftstickchanged;
  19213. /**
  19214. * Triggered when the right control stick has been changed
  19215. */
  19216. private _onrightstickchanged;
  19217. /**
  19218. * Represents a gamepad controller
  19219. */
  19220. static GAMEPAD: number;
  19221. /**
  19222. * Represents a generic controller
  19223. */
  19224. static GENERIC: number;
  19225. /**
  19226. * Represents an XBox controller
  19227. */
  19228. static XBOX: number;
  19229. /**
  19230. * Represents a pose-enabled controller
  19231. */
  19232. static POSE_ENABLED: number;
  19233. /**
  19234. * Represents an Dual Shock controller
  19235. */
  19236. static DUALSHOCK: number;
  19237. /**
  19238. * Specifies whether the left control stick should be Y-inverted
  19239. */
  19240. protected _invertLeftStickY: boolean;
  19241. /**
  19242. * Specifies if the gamepad has been connected
  19243. */
  19244. get isConnected(): boolean;
  19245. /**
  19246. * Initializes the gamepad
  19247. * @param id The id of the gamepad
  19248. * @param index The index of the gamepad
  19249. * @param browserGamepad The browser gamepad
  19250. * @param leftStickX The x component of the left joystick
  19251. * @param leftStickY The y component of the left joystick
  19252. * @param rightStickX The x component of the right joystick
  19253. * @param rightStickY The y component of the right joystick
  19254. */
  19255. constructor(
  19256. /**
  19257. * The id of the gamepad
  19258. */
  19259. id: string,
  19260. /**
  19261. * The index of the gamepad
  19262. */
  19263. index: number,
  19264. /**
  19265. * The browser gamepad
  19266. */
  19267. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19268. /**
  19269. * Callback triggered when the left joystick has changed
  19270. * @param callback
  19271. */
  19272. onleftstickchanged(callback: (values: StickValues) => void): void;
  19273. /**
  19274. * Callback triggered when the right joystick has changed
  19275. * @param callback
  19276. */
  19277. onrightstickchanged(callback: (values: StickValues) => void): void;
  19278. /**
  19279. * Gets the left joystick
  19280. */
  19281. get leftStick(): StickValues;
  19282. /**
  19283. * Sets the left joystick values
  19284. */
  19285. set leftStick(newValues: StickValues);
  19286. /**
  19287. * Gets the right joystick
  19288. */
  19289. get rightStick(): StickValues;
  19290. /**
  19291. * Sets the right joystick value
  19292. */
  19293. set rightStick(newValues: StickValues);
  19294. /**
  19295. * Updates the gamepad joystick positions
  19296. */
  19297. update(): void;
  19298. /**
  19299. * Disposes the gamepad
  19300. */
  19301. dispose(): void;
  19302. }
  19303. /**
  19304. * Represents a generic gamepad
  19305. */
  19306. export class GenericPad extends Gamepad {
  19307. private _buttons;
  19308. private _onbuttondown;
  19309. private _onbuttonup;
  19310. /**
  19311. * Observable triggered when a button has been pressed
  19312. */
  19313. onButtonDownObservable: Observable<number>;
  19314. /**
  19315. * Observable triggered when a button has been released
  19316. */
  19317. onButtonUpObservable: Observable<number>;
  19318. /**
  19319. * Callback triggered when a button has been pressed
  19320. * @param callback Called when a button has been pressed
  19321. */
  19322. onbuttondown(callback: (buttonPressed: number) => void): void;
  19323. /**
  19324. * Callback triggered when a button has been released
  19325. * @param callback Called when a button has been released
  19326. */
  19327. onbuttonup(callback: (buttonReleased: number) => void): void;
  19328. /**
  19329. * Initializes the generic gamepad
  19330. * @param id The id of the generic gamepad
  19331. * @param index The index of the generic gamepad
  19332. * @param browserGamepad The browser gamepad
  19333. */
  19334. constructor(id: string, index: number, browserGamepad: any);
  19335. private _setButtonValue;
  19336. /**
  19337. * Updates the generic gamepad
  19338. */
  19339. update(): void;
  19340. /**
  19341. * Disposes the generic gamepad
  19342. */
  19343. dispose(): void;
  19344. }
  19345. }
  19346. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19347. import { Observable } from "babylonjs/Misc/observable";
  19348. import { Nullable } from "babylonjs/types";
  19349. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19352. import { Ray } from "babylonjs/Culling/ray";
  19353. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19354. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19355. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19356. /**
  19357. * Defines the types of pose enabled controllers that are supported
  19358. */
  19359. export enum PoseEnabledControllerType {
  19360. /**
  19361. * HTC Vive
  19362. */
  19363. VIVE = 0,
  19364. /**
  19365. * Oculus Rift
  19366. */
  19367. OCULUS = 1,
  19368. /**
  19369. * Windows mixed reality
  19370. */
  19371. WINDOWS = 2,
  19372. /**
  19373. * Samsung gear VR
  19374. */
  19375. GEAR_VR = 3,
  19376. /**
  19377. * Google Daydream
  19378. */
  19379. DAYDREAM = 4,
  19380. /**
  19381. * Generic
  19382. */
  19383. GENERIC = 5
  19384. }
  19385. /**
  19386. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19387. */
  19388. export interface MutableGamepadButton {
  19389. /**
  19390. * Value of the button/trigger
  19391. */
  19392. value: number;
  19393. /**
  19394. * If the button/trigger is currently touched
  19395. */
  19396. touched: boolean;
  19397. /**
  19398. * If the button/trigger is currently pressed
  19399. */
  19400. pressed: boolean;
  19401. }
  19402. /**
  19403. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19404. * @hidden
  19405. */
  19406. export interface ExtendedGamepadButton extends GamepadButton {
  19407. /**
  19408. * If the button/trigger is currently pressed
  19409. */
  19410. readonly pressed: boolean;
  19411. /**
  19412. * If the button/trigger is currently touched
  19413. */
  19414. readonly touched: boolean;
  19415. /**
  19416. * Value of the button/trigger
  19417. */
  19418. readonly value: number;
  19419. }
  19420. /** @hidden */
  19421. export interface _GamePadFactory {
  19422. /**
  19423. * Returns whether or not the current gamepad can be created for this type of controller.
  19424. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19425. * @returns true if it can be created, otherwise false
  19426. */
  19427. canCreate(gamepadInfo: any): boolean;
  19428. /**
  19429. * Creates a new instance of the Gamepad.
  19430. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19431. * @returns the new gamepad instance
  19432. */
  19433. create(gamepadInfo: any): Gamepad;
  19434. }
  19435. /**
  19436. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19437. */
  19438. export class PoseEnabledControllerHelper {
  19439. /** @hidden */
  19440. static _ControllerFactories: _GamePadFactory[];
  19441. /** @hidden */
  19442. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19443. /**
  19444. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19445. * @param vrGamepad the gamepad to initialized
  19446. * @returns a vr controller of the type the gamepad identified as
  19447. */
  19448. static InitiateController(vrGamepad: any): Gamepad;
  19449. }
  19450. /**
  19451. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19452. */
  19453. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19454. /**
  19455. * If the controller is used in a webXR session
  19456. */
  19457. isXR: boolean;
  19458. private _deviceRoomPosition;
  19459. private _deviceRoomRotationQuaternion;
  19460. /**
  19461. * The device position in babylon space
  19462. */
  19463. devicePosition: Vector3;
  19464. /**
  19465. * The device rotation in babylon space
  19466. */
  19467. deviceRotationQuaternion: Quaternion;
  19468. /**
  19469. * The scale factor of the device in babylon space
  19470. */
  19471. deviceScaleFactor: number;
  19472. /**
  19473. * (Likely devicePosition should be used instead) The device position in its room space
  19474. */
  19475. position: Vector3;
  19476. /**
  19477. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19478. */
  19479. rotationQuaternion: Quaternion;
  19480. /**
  19481. * The type of controller (Eg. Windows mixed reality)
  19482. */
  19483. controllerType: PoseEnabledControllerType;
  19484. protected _calculatedPosition: Vector3;
  19485. private _calculatedRotation;
  19486. /**
  19487. * The raw pose from the device
  19488. */
  19489. rawPose: DevicePose;
  19490. private _trackPosition;
  19491. private _maxRotationDistFromHeadset;
  19492. private _draggedRoomRotation;
  19493. /**
  19494. * @hidden
  19495. */
  19496. _disableTrackPosition(fixedPosition: Vector3): void;
  19497. /**
  19498. * Internal, the mesh attached to the controller
  19499. * @hidden
  19500. */
  19501. _mesh: Nullable<AbstractMesh>;
  19502. private _poseControlledCamera;
  19503. private _leftHandSystemQuaternion;
  19504. /**
  19505. * Internal, matrix used to convert room space to babylon space
  19506. * @hidden
  19507. */
  19508. _deviceToWorld: Matrix;
  19509. /**
  19510. * Node to be used when casting a ray from the controller
  19511. * @hidden
  19512. */
  19513. _pointingPoseNode: Nullable<TransformNode>;
  19514. /**
  19515. * Name of the child mesh that can be used to cast a ray from the controller
  19516. */
  19517. static readonly POINTING_POSE: string;
  19518. /**
  19519. * Creates a new PoseEnabledController from a gamepad
  19520. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19521. */
  19522. constructor(browserGamepad: any);
  19523. private _workingMatrix;
  19524. /**
  19525. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19526. */
  19527. update(): void;
  19528. /**
  19529. * Updates only the pose device and mesh without doing any button event checking
  19530. */
  19531. protected _updatePoseAndMesh(): void;
  19532. /**
  19533. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19534. * @param poseData raw pose fromthe device
  19535. */
  19536. updateFromDevice(poseData: DevicePose): void;
  19537. /**
  19538. * @hidden
  19539. */
  19540. _meshAttachedObservable: Observable<AbstractMesh>;
  19541. /**
  19542. * Attaches a mesh to the controller
  19543. * @param mesh the mesh to be attached
  19544. */
  19545. attachToMesh(mesh: AbstractMesh): void;
  19546. /**
  19547. * Attaches the controllers mesh to a camera
  19548. * @param camera the camera the mesh should be attached to
  19549. */
  19550. attachToPoseControlledCamera(camera: TargetCamera): void;
  19551. /**
  19552. * Disposes of the controller
  19553. */
  19554. dispose(): void;
  19555. /**
  19556. * The mesh that is attached to the controller
  19557. */
  19558. get mesh(): Nullable<AbstractMesh>;
  19559. /**
  19560. * Gets the ray of the controller in the direction the controller is pointing
  19561. * @param length the length the resulting ray should be
  19562. * @returns a ray in the direction the controller is pointing
  19563. */
  19564. getForwardRay(length?: number): Ray;
  19565. }
  19566. }
  19567. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19568. import { Observable } from "babylonjs/Misc/observable";
  19569. import { Scene } from "babylonjs/scene";
  19570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19571. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19572. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19573. import { Nullable } from "babylonjs/types";
  19574. /**
  19575. * Defines the WebVRController object that represents controllers tracked in 3D space
  19576. */
  19577. export abstract class WebVRController extends PoseEnabledController {
  19578. /**
  19579. * Internal, the default controller model for the controller
  19580. */
  19581. protected _defaultModel: Nullable<AbstractMesh>;
  19582. /**
  19583. * Fired when the trigger state has changed
  19584. */
  19585. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19586. /**
  19587. * Fired when the main button state has changed
  19588. */
  19589. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19590. /**
  19591. * Fired when the secondary button state has changed
  19592. */
  19593. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19594. /**
  19595. * Fired when the pad state has changed
  19596. */
  19597. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19598. /**
  19599. * Fired when controllers stick values have changed
  19600. */
  19601. onPadValuesChangedObservable: Observable<StickValues>;
  19602. /**
  19603. * Array of button availible on the controller
  19604. */
  19605. protected _buttons: Array<MutableGamepadButton>;
  19606. private _onButtonStateChange;
  19607. /**
  19608. * Fired when a controller button's state has changed
  19609. * @param callback the callback containing the button that was modified
  19610. */
  19611. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19612. /**
  19613. * X and Y axis corresponding to the controllers joystick
  19614. */
  19615. pad: StickValues;
  19616. /**
  19617. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19618. */
  19619. hand: string;
  19620. /**
  19621. * The default controller model for the controller
  19622. */
  19623. get defaultModel(): Nullable<AbstractMesh>;
  19624. /**
  19625. * Creates a new WebVRController from a gamepad
  19626. * @param vrGamepad the gamepad that the WebVRController should be created from
  19627. */
  19628. constructor(vrGamepad: any);
  19629. /**
  19630. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19631. */
  19632. update(): void;
  19633. /**
  19634. * Function to be called when a button is modified
  19635. */
  19636. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19637. /**
  19638. * Loads a mesh and attaches it to the controller
  19639. * @param scene the scene the mesh should be added to
  19640. * @param meshLoaded callback for when the mesh has been loaded
  19641. */
  19642. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19643. private _setButtonValue;
  19644. private _changes;
  19645. private _checkChanges;
  19646. /**
  19647. * Disposes of th webVRCOntroller
  19648. */
  19649. dispose(): void;
  19650. }
  19651. }
  19652. declare module "babylonjs/Lights/hemisphericLight" {
  19653. import { Nullable } from "babylonjs/types";
  19654. import { Scene } from "babylonjs/scene";
  19655. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19656. import { Color3 } from "babylonjs/Maths/math.color";
  19657. import { Effect } from "babylonjs/Materials/effect";
  19658. import { Light } from "babylonjs/Lights/light";
  19659. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19660. /**
  19661. * The HemisphericLight simulates the ambient environment light,
  19662. * so the passed direction is the light reflection direction, not the incoming direction.
  19663. */
  19664. export class HemisphericLight extends Light {
  19665. /**
  19666. * The groundColor is the light in the opposite direction to the one specified during creation.
  19667. * 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.
  19668. */
  19669. groundColor: Color3;
  19670. /**
  19671. * The light reflection direction, not the incoming direction.
  19672. */
  19673. direction: Vector3;
  19674. /**
  19675. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19676. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19677. * The HemisphericLight can't cast shadows.
  19678. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19679. * @param name The friendly name of the light
  19680. * @param direction The direction of the light reflection
  19681. * @param scene The scene the light belongs to
  19682. */
  19683. constructor(name: string, direction: Vector3, scene: Scene);
  19684. protected _buildUniformLayout(): void;
  19685. /**
  19686. * Returns the string "HemisphericLight".
  19687. * @return The class name
  19688. */
  19689. getClassName(): string;
  19690. /**
  19691. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19692. * Returns the updated direction.
  19693. * @param target The target the direction should point to
  19694. * @return The computed direction
  19695. */
  19696. setDirectionToTarget(target: Vector3): Vector3;
  19697. /**
  19698. * Returns the shadow generator associated to the light.
  19699. * @returns Always null for hemispheric lights because it does not support shadows.
  19700. */
  19701. getShadowGenerator(): Nullable<IShadowGenerator>;
  19702. /**
  19703. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19704. * @param effect The effect to update
  19705. * @param lightIndex The index of the light in the effect to update
  19706. * @returns The hemispheric light
  19707. */
  19708. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19709. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19710. /**
  19711. * Computes the world matrix of the node
  19712. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19713. * @param useWasUpdatedFlag defines a reserved property
  19714. * @returns the world matrix
  19715. */
  19716. computeWorldMatrix(): Matrix;
  19717. /**
  19718. * Returns the integer 3.
  19719. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19720. */
  19721. getTypeID(): number;
  19722. /**
  19723. * Prepares the list of defines specific to the light type.
  19724. * @param defines the list of defines
  19725. * @param lightIndex defines the index of the light for the effect
  19726. */
  19727. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19728. }
  19729. }
  19730. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19731. /** @hidden */
  19732. export var vrMultiviewToSingleviewPixelShader: {
  19733. name: string;
  19734. shader: string;
  19735. };
  19736. }
  19737. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19738. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19739. import { Scene } from "babylonjs/scene";
  19740. /**
  19741. * Renders to multiple views with a single draw call
  19742. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19743. */
  19744. export class MultiviewRenderTarget extends RenderTargetTexture {
  19745. /**
  19746. * Creates a multiview render target
  19747. * @param scene scene used with the render target
  19748. * @param size the size of the render target (used for each view)
  19749. */
  19750. constructor(scene: Scene, size?: number | {
  19751. width: number;
  19752. height: number;
  19753. } | {
  19754. ratio: number;
  19755. });
  19756. /**
  19757. * @hidden
  19758. * @param faceIndex the face index, if its a cube texture
  19759. */
  19760. _bindFrameBuffer(faceIndex?: number): void;
  19761. /**
  19762. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19763. * @returns the view count
  19764. */
  19765. getViewCount(): number;
  19766. }
  19767. }
  19768. declare module "babylonjs/Maths/math.frustum" {
  19769. import { Matrix } from "babylonjs/Maths/math.vector";
  19770. import { DeepImmutable } from "babylonjs/types";
  19771. import { Plane } from "babylonjs/Maths/math.plane";
  19772. /**
  19773. * Represents a camera frustum
  19774. */
  19775. export class Frustum {
  19776. /**
  19777. * Gets the planes representing the frustum
  19778. * @param transform matrix to be applied to the returned planes
  19779. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19780. */
  19781. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19782. /**
  19783. * Gets the near frustum plane transformed by the transform matrix
  19784. * @param transform transformation matrix to be applied to the resulting frustum plane
  19785. * @param frustumPlane the resuling frustum plane
  19786. */
  19787. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19788. /**
  19789. * Gets the far frustum plane transformed by the transform matrix
  19790. * @param transform transformation matrix to be applied to the resulting frustum plane
  19791. * @param frustumPlane the resuling frustum plane
  19792. */
  19793. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19794. /**
  19795. * Gets the left frustum plane transformed by the transform matrix
  19796. * @param transform transformation matrix to be applied to the resulting frustum plane
  19797. * @param frustumPlane the resuling frustum plane
  19798. */
  19799. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19800. /**
  19801. * Gets the right frustum plane transformed by the transform matrix
  19802. * @param transform transformation matrix to be applied to the resulting frustum plane
  19803. * @param frustumPlane the resuling frustum plane
  19804. */
  19805. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19806. /**
  19807. * Gets the top frustum plane transformed by the transform matrix
  19808. * @param transform transformation matrix to be applied to the resulting frustum plane
  19809. * @param frustumPlane the resuling frustum plane
  19810. */
  19811. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19812. /**
  19813. * Gets the bottom frustum plane transformed by the transform matrix
  19814. * @param transform transformation matrix to be applied to the resulting frustum plane
  19815. * @param frustumPlane the resuling frustum plane
  19816. */
  19817. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19818. /**
  19819. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19820. * @param transform transformation matrix to be applied to the resulting frustum planes
  19821. * @param frustumPlanes the resuling frustum planes
  19822. */
  19823. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19824. }
  19825. }
  19826. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19827. import { Camera } from "babylonjs/Cameras/camera";
  19828. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19829. import { Nullable } from "babylonjs/types";
  19830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19831. import { Matrix } from "babylonjs/Maths/math.vector";
  19832. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19833. module "babylonjs/Engines/engine" {
  19834. interface Engine {
  19835. /**
  19836. * Creates a new multiview render target
  19837. * @param width defines the width of the texture
  19838. * @param height defines the height of the texture
  19839. * @returns the created multiview texture
  19840. */
  19841. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19842. /**
  19843. * Binds a multiview framebuffer to be drawn to
  19844. * @param multiviewTexture texture to bind
  19845. */
  19846. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19847. }
  19848. }
  19849. module "babylonjs/Cameras/camera" {
  19850. interface Camera {
  19851. /**
  19852. * @hidden
  19853. * 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)
  19854. */
  19855. _useMultiviewToSingleView: boolean;
  19856. /**
  19857. * @hidden
  19858. * 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)
  19859. */
  19860. _multiviewTexture: Nullable<RenderTargetTexture>;
  19861. /**
  19862. * @hidden
  19863. * ensures the multiview texture of the camera exists and has the specified width/height
  19864. * @param width height to set on the multiview texture
  19865. * @param height width to set on the multiview texture
  19866. */
  19867. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19868. }
  19869. }
  19870. module "babylonjs/scene" {
  19871. interface Scene {
  19872. /** @hidden */
  19873. _transformMatrixR: Matrix;
  19874. /** @hidden */
  19875. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19876. /** @hidden */
  19877. _createMultiviewUbo(): void;
  19878. /** @hidden */
  19879. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19880. /** @hidden */
  19881. _renderMultiviewToSingleView(camera: Camera): void;
  19882. }
  19883. }
  19884. }
  19885. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19886. import { Camera } from "babylonjs/Cameras/camera";
  19887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19888. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19889. import "babylonjs/Engines/Extensions/engine.multiview";
  19890. /**
  19891. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19892. * This will not be used for webXR as it supports displaying texture arrays directly
  19893. */
  19894. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19895. /**
  19896. * Initializes a VRMultiviewToSingleview
  19897. * @param name name of the post process
  19898. * @param camera camera to be applied to
  19899. * @param scaleFactor scaling factor to the size of the output texture
  19900. */
  19901. constructor(name: string, camera: Camera, scaleFactor: number);
  19902. }
  19903. }
  19904. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19905. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19906. import { Nullable } from "babylonjs/types";
  19907. import { Size } from "babylonjs/Maths/math.size";
  19908. import { Observable } from "babylonjs/Misc/observable";
  19909. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19910. /**
  19911. * Interface used to define additional presentation attributes
  19912. */
  19913. export interface IVRPresentationAttributes {
  19914. /**
  19915. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19916. */
  19917. highRefreshRate: boolean;
  19918. /**
  19919. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19920. */
  19921. foveationLevel: number;
  19922. }
  19923. module "babylonjs/Engines/engine" {
  19924. interface Engine {
  19925. /** @hidden */
  19926. _vrDisplay: any;
  19927. /** @hidden */
  19928. _vrSupported: boolean;
  19929. /** @hidden */
  19930. _oldSize: Size;
  19931. /** @hidden */
  19932. _oldHardwareScaleFactor: number;
  19933. /** @hidden */
  19934. _vrExclusivePointerMode: boolean;
  19935. /** @hidden */
  19936. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19937. /** @hidden */
  19938. _onVRDisplayPointerRestricted: () => void;
  19939. /** @hidden */
  19940. _onVRDisplayPointerUnrestricted: () => void;
  19941. /** @hidden */
  19942. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19943. /** @hidden */
  19944. _onVrDisplayDisconnect: Nullable<() => void>;
  19945. /** @hidden */
  19946. _onVrDisplayPresentChange: Nullable<() => void>;
  19947. /**
  19948. * Observable signaled when VR display mode changes
  19949. */
  19950. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19951. /**
  19952. * Observable signaled when VR request present is complete
  19953. */
  19954. onVRRequestPresentComplete: Observable<boolean>;
  19955. /**
  19956. * Observable signaled when VR request present starts
  19957. */
  19958. onVRRequestPresentStart: Observable<Engine>;
  19959. /**
  19960. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19961. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19962. */
  19963. isInVRExclusivePointerMode: boolean;
  19964. /**
  19965. * Gets a boolean indicating if a webVR device was detected
  19966. * @returns true if a webVR device was detected
  19967. */
  19968. isVRDevicePresent(): boolean;
  19969. /**
  19970. * Gets the current webVR device
  19971. * @returns the current webVR device (or null)
  19972. */
  19973. getVRDevice(): any;
  19974. /**
  19975. * Initializes a webVR display and starts listening to display change events
  19976. * The onVRDisplayChangedObservable will be notified upon these changes
  19977. * @returns A promise containing a VRDisplay and if vr is supported
  19978. */
  19979. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19980. /** @hidden */
  19981. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19982. /**
  19983. * Gets or sets the presentation attributes used to configure VR rendering
  19984. */
  19985. vrPresentationAttributes?: IVRPresentationAttributes;
  19986. /**
  19987. * Call this function to switch to webVR mode
  19988. * Will do nothing if webVR is not supported or if there is no webVR device
  19989. * @param options the webvr options provided to the camera. mainly used for multiview
  19990. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19991. */
  19992. enableVR(options: WebVROptions): void;
  19993. /** @hidden */
  19994. _onVRFullScreenTriggered(): void;
  19995. }
  19996. }
  19997. }
  19998. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19999. import { Nullable } from "babylonjs/types";
  20000. import { Observable } from "babylonjs/Misc/observable";
  20001. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20002. import { Scene } from "babylonjs/scene";
  20003. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20004. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20005. import { Node } from "babylonjs/node";
  20006. import { Ray } from "babylonjs/Culling/ray";
  20007. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20008. import "babylonjs/Engines/Extensions/engine.webVR";
  20009. /**
  20010. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20011. * IMPORTANT!! The data is right-hand data.
  20012. * @export
  20013. * @interface DevicePose
  20014. */
  20015. export interface DevicePose {
  20016. /**
  20017. * The position of the device, values in array are [x,y,z].
  20018. */
  20019. readonly position: Nullable<Float32Array>;
  20020. /**
  20021. * The linearVelocity of the device, values in array are [x,y,z].
  20022. */
  20023. readonly linearVelocity: Nullable<Float32Array>;
  20024. /**
  20025. * The linearAcceleration of the device, values in array are [x,y,z].
  20026. */
  20027. readonly linearAcceleration: Nullable<Float32Array>;
  20028. /**
  20029. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20030. */
  20031. readonly orientation: Nullable<Float32Array>;
  20032. /**
  20033. * The angularVelocity of the device, values in array are [x,y,z].
  20034. */
  20035. readonly angularVelocity: Nullable<Float32Array>;
  20036. /**
  20037. * The angularAcceleration of the device, values in array are [x,y,z].
  20038. */
  20039. readonly angularAcceleration: Nullable<Float32Array>;
  20040. }
  20041. /**
  20042. * Interface representing a pose controlled object in Babylon.
  20043. * A pose controlled object has both regular pose values as well as pose values
  20044. * from an external device such as a VR head mounted display
  20045. */
  20046. export interface PoseControlled {
  20047. /**
  20048. * The position of the object in babylon space.
  20049. */
  20050. position: Vector3;
  20051. /**
  20052. * The rotation quaternion of the object in babylon space.
  20053. */
  20054. rotationQuaternion: Quaternion;
  20055. /**
  20056. * The position of the device in babylon space.
  20057. */
  20058. devicePosition?: Vector3;
  20059. /**
  20060. * The rotation quaternion of the device in babylon space.
  20061. */
  20062. deviceRotationQuaternion: Quaternion;
  20063. /**
  20064. * The raw pose coming from the device.
  20065. */
  20066. rawPose: Nullable<DevicePose>;
  20067. /**
  20068. * The scale of the device to be used when translating from device space to babylon space.
  20069. */
  20070. deviceScaleFactor: number;
  20071. /**
  20072. * Updates the poseControlled values based on the input device pose.
  20073. * @param poseData the pose data to update the object with
  20074. */
  20075. updateFromDevice(poseData: DevicePose): void;
  20076. }
  20077. /**
  20078. * Set of options to customize the webVRCamera
  20079. */
  20080. export interface WebVROptions {
  20081. /**
  20082. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20083. */
  20084. trackPosition?: boolean;
  20085. /**
  20086. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20087. */
  20088. positionScale?: number;
  20089. /**
  20090. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20091. */
  20092. displayName?: string;
  20093. /**
  20094. * Should the native controller meshes be initialized. (default: true)
  20095. */
  20096. controllerMeshes?: boolean;
  20097. /**
  20098. * Creating a default HemiLight only on controllers. (default: true)
  20099. */
  20100. defaultLightingOnControllers?: boolean;
  20101. /**
  20102. * If you don't want to use the default VR button of the helper. (default: false)
  20103. */
  20104. useCustomVRButton?: boolean;
  20105. /**
  20106. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20107. */
  20108. customVRButton?: HTMLButtonElement;
  20109. /**
  20110. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20111. */
  20112. rayLength?: number;
  20113. /**
  20114. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20115. */
  20116. defaultHeight?: number;
  20117. /**
  20118. * If multiview should be used if availible (default: false)
  20119. */
  20120. useMultiview?: boolean;
  20121. }
  20122. /**
  20123. * This represents a WebVR camera.
  20124. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20125. * @example http://doc.babylonjs.com/how_to/webvr_camera
  20126. */
  20127. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20128. private webVROptions;
  20129. /**
  20130. * @hidden
  20131. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20132. */
  20133. _vrDevice: any;
  20134. /**
  20135. * The rawPose of the vrDevice.
  20136. */
  20137. rawPose: Nullable<DevicePose>;
  20138. private _onVREnabled;
  20139. private _specsVersion;
  20140. private _attached;
  20141. private _frameData;
  20142. protected _descendants: Array<Node>;
  20143. private _deviceRoomPosition;
  20144. /** @hidden */
  20145. _deviceRoomRotationQuaternion: Quaternion;
  20146. private _standingMatrix;
  20147. /**
  20148. * Represents device position in babylon space.
  20149. */
  20150. devicePosition: Vector3;
  20151. /**
  20152. * Represents device rotation in babylon space.
  20153. */
  20154. deviceRotationQuaternion: Quaternion;
  20155. /**
  20156. * The scale of the device to be used when translating from device space to babylon space.
  20157. */
  20158. deviceScaleFactor: number;
  20159. private _deviceToWorld;
  20160. private _worldToDevice;
  20161. /**
  20162. * References to the webVR controllers for the vrDevice.
  20163. */
  20164. controllers: Array<WebVRController>;
  20165. /**
  20166. * Emits an event when a controller is attached.
  20167. */
  20168. onControllersAttachedObservable: Observable<WebVRController[]>;
  20169. /**
  20170. * Emits an event when a controller's mesh has been loaded;
  20171. */
  20172. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20173. /**
  20174. * Emits an event when the HMD's pose has been updated.
  20175. */
  20176. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20177. private _poseSet;
  20178. /**
  20179. * If the rig cameras be used as parent instead of this camera.
  20180. */
  20181. rigParenting: boolean;
  20182. private _lightOnControllers;
  20183. private _defaultHeight?;
  20184. /**
  20185. * Instantiates a WebVRFreeCamera.
  20186. * @param name The name of the WebVRFreeCamera
  20187. * @param position The starting anchor position for the camera
  20188. * @param scene The scene the camera belongs to
  20189. * @param webVROptions a set of customizable options for the webVRCamera
  20190. */
  20191. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20192. /**
  20193. * Gets the device distance from the ground in meters.
  20194. * @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.
  20195. */
  20196. deviceDistanceToRoomGround(): number;
  20197. /**
  20198. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20199. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20200. */
  20201. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20202. /**
  20203. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20204. * @returns A promise with a boolean set to if the standing matrix is supported.
  20205. */
  20206. useStandingMatrixAsync(): Promise<boolean>;
  20207. /**
  20208. * Disposes the camera
  20209. */
  20210. dispose(): void;
  20211. /**
  20212. * Gets a vrController by name.
  20213. * @param name The name of the controller to retreive
  20214. * @returns the controller matching the name specified or null if not found
  20215. */
  20216. getControllerByName(name: string): Nullable<WebVRController>;
  20217. private _leftController;
  20218. /**
  20219. * The controller corresponding to the users left hand.
  20220. */
  20221. get leftController(): Nullable<WebVRController>;
  20222. private _rightController;
  20223. /**
  20224. * The controller corresponding to the users right hand.
  20225. */
  20226. get rightController(): Nullable<WebVRController>;
  20227. /**
  20228. * Casts a ray forward from the vrCamera's gaze.
  20229. * @param length Length of the ray (default: 100)
  20230. * @returns the ray corresponding to the gaze
  20231. */
  20232. getForwardRay(length?: number): Ray;
  20233. /**
  20234. * @hidden
  20235. * Updates the camera based on device's frame data
  20236. */
  20237. _checkInputs(): void;
  20238. /**
  20239. * Updates the poseControlled values based on the input device pose.
  20240. * @param poseData Pose coming from the device
  20241. */
  20242. updateFromDevice(poseData: DevicePose): void;
  20243. private _htmlElementAttached;
  20244. private _detachIfAttached;
  20245. /**
  20246. * WebVR's attach control will start broadcasting frames to the device.
  20247. * Note that in certain browsers (chrome for example) this function must be called
  20248. * within a user-interaction callback. Example:
  20249. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20250. *
  20251. * @param element html element to attach the vrDevice to
  20252. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20253. */
  20254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20255. /**
  20256. * Detaches the camera from the html element and disables VR
  20257. *
  20258. * @param element html element to detach from
  20259. */
  20260. detachControl(element: HTMLElement): void;
  20261. /**
  20262. * @returns the name of this class
  20263. */
  20264. getClassName(): string;
  20265. /**
  20266. * Calls resetPose on the vrDisplay
  20267. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20268. */
  20269. resetToCurrentRotation(): void;
  20270. /**
  20271. * @hidden
  20272. * Updates the rig cameras (left and right eye)
  20273. */
  20274. _updateRigCameras(): void;
  20275. private _workingVector;
  20276. private _oneVector;
  20277. private _workingMatrix;
  20278. private updateCacheCalled;
  20279. private _correctPositionIfNotTrackPosition;
  20280. /**
  20281. * @hidden
  20282. * Updates the cached values of the camera
  20283. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20284. */
  20285. _updateCache(ignoreParentClass?: boolean): void;
  20286. /**
  20287. * @hidden
  20288. * Get current device position in babylon world
  20289. */
  20290. _computeDevicePosition(): void;
  20291. /**
  20292. * Updates the current device position and rotation in the babylon world
  20293. */
  20294. update(): void;
  20295. /**
  20296. * @hidden
  20297. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20298. * @returns an identity matrix
  20299. */
  20300. _getViewMatrix(): Matrix;
  20301. private _tmpMatrix;
  20302. /**
  20303. * This function is called by the two RIG cameras.
  20304. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20305. * @hidden
  20306. */
  20307. _getWebVRViewMatrix(): Matrix;
  20308. /** @hidden */
  20309. _getWebVRProjectionMatrix(): Matrix;
  20310. private _onGamepadConnectedObserver;
  20311. private _onGamepadDisconnectedObserver;
  20312. private _updateCacheWhenTrackingDisabledObserver;
  20313. /**
  20314. * Initializes the controllers and their meshes
  20315. */
  20316. initControllers(): void;
  20317. }
  20318. }
  20319. declare module "babylonjs/PostProcesses/postProcess" {
  20320. import { Nullable } from "babylonjs/types";
  20321. import { SmartArray } from "babylonjs/Misc/smartArray";
  20322. import { Observable } from "babylonjs/Misc/observable";
  20323. import { Vector2 } from "babylonjs/Maths/math.vector";
  20324. import { Camera } from "babylonjs/Cameras/camera";
  20325. import { Effect } from "babylonjs/Materials/effect";
  20326. import "babylonjs/Shaders/postprocess.vertex";
  20327. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20328. import { Engine } from "babylonjs/Engines/engine";
  20329. import { Color4 } from "babylonjs/Maths/math.color";
  20330. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20331. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20332. /**
  20333. * Size options for a post process
  20334. */
  20335. export type PostProcessOptions = {
  20336. width: number;
  20337. height: number;
  20338. };
  20339. /**
  20340. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20341. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20342. */
  20343. export class PostProcess {
  20344. /** Name of the PostProcess. */
  20345. name: string;
  20346. /**
  20347. * Gets or sets the unique id of the post process
  20348. */
  20349. uniqueId: number;
  20350. /**
  20351. * Width of the texture to apply the post process on
  20352. */
  20353. width: number;
  20354. /**
  20355. * Height of the texture to apply the post process on
  20356. */
  20357. height: number;
  20358. /**
  20359. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20360. * @hidden
  20361. */
  20362. _outputTexture: Nullable<InternalTexture>;
  20363. /**
  20364. * Sampling mode used by the shader
  20365. * See https://doc.babylonjs.com/classes/3.1/texture
  20366. */
  20367. renderTargetSamplingMode: number;
  20368. /**
  20369. * Clear color to use when screen clearing
  20370. */
  20371. clearColor: Color4;
  20372. /**
  20373. * If the buffer needs to be cleared before applying the post process. (default: true)
  20374. * Should be set to false if shader will overwrite all previous pixels.
  20375. */
  20376. autoClear: boolean;
  20377. /**
  20378. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20379. */
  20380. alphaMode: number;
  20381. /**
  20382. * Sets the setAlphaBlendConstants of the babylon engine
  20383. */
  20384. alphaConstants: Color4;
  20385. /**
  20386. * Animations to be used for the post processing
  20387. */
  20388. animations: import("babylonjs/Animations/animation").Animation[];
  20389. /**
  20390. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20391. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20392. */
  20393. enablePixelPerfectMode: boolean;
  20394. /**
  20395. * Force the postprocess to be applied without taking in account viewport
  20396. */
  20397. forceFullscreenViewport: boolean;
  20398. /**
  20399. * List of inspectable custom properties (used by the Inspector)
  20400. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20401. */
  20402. inspectableCustomProperties: IInspectable[];
  20403. /**
  20404. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20405. *
  20406. * | Value | Type | Description |
  20407. * | ----- | ----------------------------------- | ----------- |
  20408. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20409. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20410. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20411. *
  20412. */
  20413. scaleMode: number;
  20414. /**
  20415. * Force textures to be a power of two (default: false)
  20416. */
  20417. alwaysForcePOT: boolean;
  20418. private _samples;
  20419. /**
  20420. * Number of sample textures (default: 1)
  20421. */
  20422. get samples(): number;
  20423. set samples(n: number);
  20424. /**
  20425. * Modify the scale of the post process to be the same as the viewport (default: false)
  20426. */
  20427. adaptScaleToCurrentViewport: boolean;
  20428. private _camera;
  20429. private _scene;
  20430. private _engine;
  20431. private _options;
  20432. private _reusable;
  20433. private _textureType;
  20434. private _textureFormat;
  20435. /**
  20436. * Smart array of input and output textures for the post process.
  20437. * @hidden
  20438. */
  20439. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20440. /**
  20441. * The index in _textures that corresponds to the output texture.
  20442. * @hidden
  20443. */
  20444. _currentRenderTextureInd: number;
  20445. private _effect;
  20446. private _samplers;
  20447. private _fragmentUrl;
  20448. private _vertexUrl;
  20449. private _parameters;
  20450. private _scaleRatio;
  20451. protected _indexParameters: any;
  20452. private _shareOutputWithPostProcess;
  20453. private _texelSize;
  20454. private _forcedOutputTexture;
  20455. /**
  20456. * Returns the fragment url or shader name used in the post process.
  20457. * @returns the fragment url or name in the shader store.
  20458. */
  20459. getEffectName(): string;
  20460. /**
  20461. * An event triggered when the postprocess is activated.
  20462. */
  20463. onActivateObservable: Observable<Camera>;
  20464. private _onActivateObserver;
  20465. /**
  20466. * A function that is added to the onActivateObservable
  20467. */
  20468. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20469. /**
  20470. * An event triggered when the postprocess changes its size.
  20471. */
  20472. onSizeChangedObservable: Observable<PostProcess>;
  20473. private _onSizeChangedObserver;
  20474. /**
  20475. * A function that is added to the onSizeChangedObservable
  20476. */
  20477. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20478. /**
  20479. * An event triggered when the postprocess applies its effect.
  20480. */
  20481. onApplyObservable: Observable<Effect>;
  20482. private _onApplyObserver;
  20483. /**
  20484. * A function that is added to the onApplyObservable
  20485. */
  20486. set onApply(callback: (effect: Effect) => void);
  20487. /**
  20488. * An event triggered before rendering the postprocess
  20489. */
  20490. onBeforeRenderObservable: Observable<Effect>;
  20491. private _onBeforeRenderObserver;
  20492. /**
  20493. * A function that is added to the onBeforeRenderObservable
  20494. */
  20495. set onBeforeRender(callback: (effect: Effect) => void);
  20496. /**
  20497. * An event triggered after rendering the postprocess
  20498. */
  20499. onAfterRenderObservable: Observable<Effect>;
  20500. private _onAfterRenderObserver;
  20501. /**
  20502. * A function that is added to the onAfterRenderObservable
  20503. */
  20504. set onAfterRender(callback: (efect: Effect) => void);
  20505. /**
  20506. * 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
  20507. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20508. */
  20509. get inputTexture(): InternalTexture;
  20510. set inputTexture(value: InternalTexture);
  20511. /**
  20512. * Gets the camera which post process is applied to.
  20513. * @returns The camera the post process is applied to.
  20514. */
  20515. getCamera(): Camera;
  20516. /**
  20517. * Gets the texel size of the postprocess.
  20518. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20519. */
  20520. get texelSize(): Vector2;
  20521. /**
  20522. * Creates a new instance PostProcess
  20523. * @param name The name of the PostProcess.
  20524. * @param fragmentUrl The url of the fragment shader to be used.
  20525. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20526. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20527. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20528. * @param camera The camera to apply the render pass to.
  20529. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20530. * @param engine The engine which the post process will be applied. (default: current engine)
  20531. * @param reusable If the post process can be reused on the same frame. (default: false)
  20532. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20533. * @param textureType Type of textures used when performing the post process. (default: 0)
  20534. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20535. * @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
  20536. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20537. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20538. */
  20539. constructor(
  20540. /** Name of the PostProcess. */
  20541. 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);
  20542. /**
  20543. * Gets a string idenfifying the name of the class
  20544. * @returns "PostProcess" string
  20545. */
  20546. getClassName(): string;
  20547. /**
  20548. * Gets the engine which this post process belongs to.
  20549. * @returns The engine the post process was enabled with.
  20550. */
  20551. getEngine(): Engine;
  20552. /**
  20553. * The effect that is created when initializing the post process.
  20554. * @returns The created effect corresponding the the postprocess.
  20555. */
  20556. getEffect(): Effect;
  20557. /**
  20558. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20559. * @param postProcess The post process to share the output with.
  20560. * @returns This post process.
  20561. */
  20562. shareOutputWith(postProcess: PostProcess): PostProcess;
  20563. /**
  20564. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20565. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20566. */
  20567. useOwnOutput(): void;
  20568. /**
  20569. * Updates the effect with the current post process compile time values and recompiles the shader.
  20570. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20571. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20572. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20573. * @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
  20574. * @param onCompiled Called when the shader has been compiled.
  20575. * @param onError Called if there is an error when compiling a shader.
  20576. */
  20577. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20578. /**
  20579. * The post process is reusable if it can be used multiple times within one frame.
  20580. * @returns If the post process is reusable
  20581. */
  20582. isReusable(): boolean;
  20583. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20584. markTextureDirty(): void;
  20585. /**
  20586. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20587. * 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.
  20588. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20589. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20590. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20591. * @returns The target texture that was bound to be written to.
  20592. */
  20593. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20594. /**
  20595. * If the post process is supported.
  20596. */
  20597. get isSupported(): boolean;
  20598. /**
  20599. * The aspect ratio of the output texture.
  20600. */
  20601. get aspectRatio(): number;
  20602. /**
  20603. * Get a value indicating if the post-process is ready to be used
  20604. * @returns true if the post-process is ready (shader is compiled)
  20605. */
  20606. isReady(): boolean;
  20607. /**
  20608. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20609. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20610. */
  20611. apply(): Nullable<Effect>;
  20612. private _disposeTextures;
  20613. /**
  20614. * Disposes the post process.
  20615. * @param camera The camera to dispose the post process on.
  20616. */
  20617. dispose(camera?: Camera): void;
  20618. }
  20619. }
  20620. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20621. /** @hidden */
  20622. export var kernelBlurVaryingDeclaration: {
  20623. name: string;
  20624. shader: string;
  20625. };
  20626. }
  20627. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20628. /** @hidden */
  20629. export var kernelBlurFragment: {
  20630. name: string;
  20631. shader: string;
  20632. };
  20633. }
  20634. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20635. /** @hidden */
  20636. export var kernelBlurFragment2: {
  20637. name: string;
  20638. shader: string;
  20639. };
  20640. }
  20641. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20642. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20643. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20644. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20645. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20646. /** @hidden */
  20647. export var kernelBlurPixelShader: {
  20648. name: string;
  20649. shader: string;
  20650. };
  20651. }
  20652. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20653. /** @hidden */
  20654. export var kernelBlurVertex: {
  20655. name: string;
  20656. shader: string;
  20657. };
  20658. }
  20659. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20660. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20661. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20662. /** @hidden */
  20663. export var kernelBlurVertexShader: {
  20664. name: string;
  20665. shader: string;
  20666. };
  20667. }
  20668. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20669. import { Vector2 } from "babylonjs/Maths/math.vector";
  20670. import { Nullable } from "babylonjs/types";
  20671. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20672. import { Camera } from "babylonjs/Cameras/camera";
  20673. import { Effect } from "babylonjs/Materials/effect";
  20674. import { Engine } from "babylonjs/Engines/engine";
  20675. import "babylonjs/Shaders/kernelBlur.fragment";
  20676. import "babylonjs/Shaders/kernelBlur.vertex";
  20677. /**
  20678. * The Blur Post Process which blurs an image based on a kernel and direction.
  20679. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20680. */
  20681. export class BlurPostProcess extends PostProcess {
  20682. /** The direction in which to blur the image. */
  20683. direction: Vector2;
  20684. private blockCompilation;
  20685. protected _kernel: number;
  20686. protected _idealKernel: number;
  20687. protected _packedFloat: boolean;
  20688. private _staticDefines;
  20689. /**
  20690. * Sets the length in pixels of the blur sample region
  20691. */
  20692. set kernel(v: number);
  20693. /**
  20694. * Gets the length in pixels of the blur sample region
  20695. */
  20696. get kernel(): number;
  20697. /**
  20698. * Sets wether or not the blur needs to unpack/repack floats
  20699. */
  20700. set packedFloat(v: boolean);
  20701. /**
  20702. * Gets wether or not the blur is unpacking/repacking floats
  20703. */
  20704. get packedFloat(): boolean;
  20705. /**
  20706. * Creates a new instance BlurPostProcess
  20707. * @param name The name of the effect.
  20708. * @param direction The direction in which to blur the image.
  20709. * @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.
  20710. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20711. * @param camera The camera to apply the render pass to.
  20712. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20713. * @param engine The engine which the post process will be applied. (default: current engine)
  20714. * @param reusable If the post process can be reused on the same frame. (default: false)
  20715. * @param textureType Type of textures used when performing the post process. (default: 0)
  20716. * @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)
  20717. */
  20718. constructor(name: string,
  20719. /** The direction in which to blur the image. */
  20720. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20721. /**
  20722. * Updates the effect with the current post process compile time values and recompiles the shader.
  20723. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20724. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20725. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20726. * @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
  20727. * @param onCompiled Called when the shader has been compiled.
  20728. * @param onError Called if there is an error when compiling a shader.
  20729. */
  20730. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20731. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20732. /**
  20733. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20734. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20735. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20736. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20737. * The gaps between physical kernels are compensated for in the weighting of the samples
  20738. * @param idealKernel Ideal blur kernel.
  20739. * @return Nearest best kernel.
  20740. */
  20741. protected _nearestBestKernel(idealKernel: number): number;
  20742. /**
  20743. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20744. * @param x The point on the Gaussian distribution to sample.
  20745. * @return the value of the Gaussian function at x.
  20746. */
  20747. protected _gaussianWeight(x: number): number;
  20748. /**
  20749. * Generates a string that can be used as a floating point number in GLSL.
  20750. * @param x Value to print.
  20751. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20752. * @return GLSL float string.
  20753. */
  20754. protected _glslFloat(x: number, decimalFigures?: number): string;
  20755. }
  20756. }
  20757. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20758. import { Scene } from "babylonjs/scene";
  20759. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20760. import { Plane } from "babylonjs/Maths/math.plane";
  20761. /**
  20762. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20763. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20764. * You can then easily use it as a reflectionTexture on a flat surface.
  20765. * In case the surface is not a plane, please consider relying on reflection probes.
  20766. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20767. */
  20768. export class MirrorTexture extends RenderTargetTexture {
  20769. private scene;
  20770. /**
  20771. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20772. * 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.
  20773. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20774. */
  20775. mirrorPlane: Plane;
  20776. /**
  20777. * Define the blur ratio used to blur the reflection if needed.
  20778. */
  20779. set blurRatio(value: number);
  20780. get blurRatio(): number;
  20781. /**
  20782. * Define the adaptive blur kernel used to blur the reflection if needed.
  20783. * This will autocompute the closest best match for the `blurKernel`
  20784. */
  20785. set adaptiveBlurKernel(value: number);
  20786. /**
  20787. * Define the blur kernel used to blur the reflection if needed.
  20788. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20789. */
  20790. set blurKernel(value: number);
  20791. /**
  20792. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20793. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20794. */
  20795. set blurKernelX(value: number);
  20796. get blurKernelX(): number;
  20797. /**
  20798. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20799. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20800. */
  20801. set blurKernelY(value: number);
  20802. get blurKernelY(): number;
  20803. private _autoComputeBlurKernel;
  20804. protected _onRatioRescale(): void;
  20805. private _updateGammaSpace;
  20806. private _imageProcessingConfigChangeObserver;
  20807. private _transformMatrix;
  20808. private _mirrorMatrix;
  20809. private _savedViewMatrix;
  20810. private _blurX;
  20811. private _blurY;
  20812. private _adaptiveBlurKernel;
  20813. private _blurKernelX;
  20814. private _blurKernelY;
  20815. private _blurRatio;
  20816. /**
  20817. * Instantiates a Mirror Texture.
  20818. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20819. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20820. * You can then easily use it as a reflectionTexture on a flat surface.
  20821. * In case the surface is not a plane, please consider relying on reflection probes.
  20822. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20823. * @param name
  20824. * @param size
  20825. * @param scene
  20826. * @param generateMipMaps
  20827. * @param type
  20828. * @param samplingMode
  20829. * @param generateDepthBuffer
  20830. */
  20831. constructor(name: string, size: number | {
  20832. width: number;
  20833. height: number;
  20834. } | {
  20835. ratio: number;
  20836. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20837. private _preparePostProcesses;
  20838. /**
  20839. * Clone the mirror texture.
  20840. * @returns the cloned texture
  20841. */
  20842. clone(): MirrorTexture;
  20843. /**
  20844. * Serialize the texture to a JSON representation you could use in Parse later on
  20845. * @returns the serialized JSON representation
  20846. */
  20847. serialize(): any;
  20848. /**
  20849. * Dispose the texture and release its associated resources.
  20850. */
  20851. dispose(): void;
  20852. }
  20853. }
  20854. declare module "babylonjs/Materials/Textures/texture" {
  20855. import { Observable } from "babylonjs/Misc/observable";
  20856. import { Nullable } from "babylonjs/types";
  20857. import { Matrix } from "babylonjs/Maths/math.vector";
  20858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20859. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20860. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20861. import { Scene } from "babylonjs/scene";
  20862. /**
  20863. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20864. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20865. */
  20866. export class Texture extends BaseTexture {
  20867. /**
  20868. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20869. */
  20870. static SerializeBuffers: boolean;
  20871. /** @hidden */
  20872. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20873. /** @hidden */
  20874. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20875. /** @hidden */
  20876. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20877. /** nearest is mag = nearest and min = nearest and mip = linear */
  20878. static readonly NEAREST_SAMPLINGMODE: number;
  20879. /** nearest is mag = nearest and min = nearest and mip = linear */
  20880. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20881. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20882. static readonly BILINEAR_SAMPLINGMODE: number;
  20883. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20884. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20885. /** Trilinear is mag = linear and min = linear and mip = linear */
  20886. static readonly TRILINEAR_SAMPLINGMODE: number;
  20887. /** Trilinear is mag = linear and min = linear and mip = linear */
  20888. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20889. /** mag = nearest and min = nearest and mip = nearest */
  20890. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20891. /** mag = nearest and min = linear and mip = nearest */
  20892. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20893. /** mag = nearest and min = linear and mip = linear */
  20894. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20895. /** mag = nearest and min = linear and mip = none */
  20896. static readonly NEAREST_LINEAR: number;
  20897. /** mag = nearest and min = nearest and mip = none */
  20898. static readonly NEAREST_NEAREST: number;
  20899. /** mag = linear and min = nearest and mip = nearest */
  20900. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20901. /** mag = linear and min = nearest and mip = linear */
  20902. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20903. /** mag = linear and min = linear and mip = none */
  20904. static readonly LINEAR_LINEAR: number;
  20905. /** mag = linear and min = nearest and mip = none */
  20906. static readonly LINEAR_NEAREST: number;
  20907. /** Explicit coordinates mode */
  20908. static readonly EXPLICIT_MODE: number;
  20909. /** Spherical coordinates mode */
  20910. static readonly SPHERICAL_MODE: number;
  20911. /** Planar coordinates mode */
  20912. static readonly PLANAR_MODE: number;
  20913. /** Cubic coordinates mode */
  20914. static readonly CUBIC_MODE: number;
  20915. /** Projection coordinates mode */
  20916. static readonly PROJECTION_MODE: number;
  20917. /** Inverse Cubic coordinates mode */
  20918. static readonly SKYBOX_MODE: number;
  20919. /** Inverse Cubic coordinates mode */
  20920. static readonly INVCUBIC_MODE: number;
  20921. /** Equirectangular coordinates mode */
  20922. static readonly EQUIRECTANGULAR_MODE: number;
  20923. /** Equirectangular Fixed coordinates mode */
  20924. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20925. /** Equirectangular Fixed Mirrored coordinates mode */
  20926. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20927. /** Texture is not repeating outside of 0..1 UVs */
  20928. static readonly CLAMP_ADDRESSMODE: number;
  20929. /** Texture is repeating outside of 0..1 UVs */
  20930. static readonly WRAP_ADDRESSMODE: number;
  20931. /** Texture is repeating and mirrored */
  20932. static readonly MIRROR_ADDRESSMODE: number;
  20933. /**
  20934. * 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
  20935. */
  20936. static UseSerializedUrlIfAny: boolean;
  20937. /**
  20938. * Define the url of the texture.
  20939. */
  20940. url: Nullable<string>;
  20941. /**
  20942. * Define an offset on the texture to offset the u coordinates of the UVs
  20943. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20944. */
  20945. uOffset: number;
  20946. /**
  20947. * Define an offset on the texture to offset the v coordinates of the UVs
  20948. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20949. */
  20950. vOffset: number;
  20951. /**
  20952. * Define an offset on the texture to scale the u coordinates of the UVs
  20953. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20954. */
  20955. uScale: number;
  20956. /**
  20957. * Define an offset on the texture to scale the v coordinates of the UVs
  20958. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20959. */
  20960. vScale: number;
  20961. /**
  20962. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20963. * @see http://doc.babylonjs.com/how_to/more_materials
  20964. */
  20965. uAng: number;
  20966. /**
  20967. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20968. * @see http://doc.babylonjs.com/how_to/more_materials
  20969. */
  20970. vAng: number;
  20971. /**
  20972. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20973. * @see http://doc.babylonjs.com/how_to/more_materials
  20974. */
  20975. wAng: number;
  20976. /**
  20977. * Defines the center of rotation (U)
  20978. */
  20979. uRotationCenter: number;
  20980. /**
  20981. * Defines the center of rotation (V)
  20982. */
  20983. vRotationCenter: number;
  20984. /**
  20985. * Defines the center of rotation (W)
  20986. */
  20987. wRotationCenter: number;
  20988. /**
  20989. * Are mip maps generated for this texture or not.
  20990. */
  20991. get noMipmap(): boolean;
  20992. /**
  20993. * List of inspectable custom properties (used by the Inspector)
  20994. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20995. */
  20996. inspectableCustomProperties: Nullable<IInspectable[]>;
  20997. private _noMipmap;
  20998. /** @hidden */
  20999. _invertY: boolean;
  21000. private _rowGenerationMatrix;
  21001. private _cachedTextureMatrix;
  21002. private _projectionModeMatrix;
  21003. private _t0;
  21004. private _t1;
  21005. private _t2;
  21006. private _cachedUOffset;
  21007. private _cachedVOffset;
  21008. private _cachedUScale;
  21009. private _cachedVScale;
  21010. private _cachedUAng;
  21011. private _cachedVAng;
  21012. private _cachedWAng;
  21013. private _cachedProjectionMatrixId;
  21014. private _cachedCoordinatesMode;
  21015. /** @hidden */
  21016. protected _initialSamplingMode: number;
  21017. /** @hidden */
  21018. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  21019. private _deleteBuffer;
  21020. protected _format: Nullable<number>;
  21021. private _delayedOnLoad;
  21022. private _delayedOnError;
  21023. private _mimeType?;
  21024. /**
  21025. * Observable triggered once the texture has been loaded.
  21026. */
  21027. onLoadObservable: Observable<Texture>;
  21028. protected _isBlocking: boolean;
  21029. /**
  21030. * Is the texture preventing material to render while loading.
  21031. * If false, a default texture will be used instead of the loading one during the preparation step.
  21032. */
  21033. set isBlocking(value: boolean);
  21034. get isBlocking(): boolean;
  21035. /**
  21036. * Get the current sampling mode associated with the texture.
  21037. */
  21038. get samplingMode(): number;
  21039. /**
  21040. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  21041. */
  21042. get invertY(): boolean;
  21043. /**
  21044. * Instantiates a new texture.
  21045. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  21046. * @see http://doc.babylonjs.com/babylon101/materials#texture
  21047. * @param url defines the url of the picture to load as a texture
  21048. * @param scene defines the scene or engine the texture will belong to
  21049. * @param noMipmap defines if the texture will require mip maps or not
  21050. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  21051. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21052. * @param onLoad defines a callback triggered when the texture has been loaded
  21053. * @param onError defines a callback triggered when an error occurred during the loading session
  21054. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  21055. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  21056. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21057. * @param mimeType defines an optional mime type information
  21058. */
  21059. 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);
  21060. /**
  21061. * Update the url (and optional buffer) of this texture if url was null during construction.
  21062. * @param url the url of the texture
  21063. * @param buffer the buffer of the texture (defaults to null)
  21064. * @param onLoad callback called when the texture is loaded (defaults to null)
  21065. */
  21066. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  21067. /**
  21068. * Finish the loading sequence of a texture flagged as delayed load.
  21069. * @hidden
  21070. */
  21071. delayLoad(): void;
  21072. private _prepareRowForTextureGeneration;
  21073. /**
  21074. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  21075. * @returns the transform matrix of the texture.
  21076. */
  21077. getTextureMatrix(uBase?: number): Matrix;
  21078. /**
  21079. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  21080. * @returns The reflection texture transform
  21081. */
  21082. getReflectionTextureMatrix(): Matrix;
  21083. /**
  21084. * Clones the texture.
  21085. * @returns the cloned texture
  21086. */
  21087. clone(): Texture;
  21088. /**
  21089. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21090. * @returns The JSON representation of the texture
  21091. */
  21092. serialize(): any;
  21093. /**
  21094. * Get the current class name of the texture useful for serialization or dynamic coding.
  21095. * @returns "Texture"
  21096. */
  21097. getClassName(): string;
  21098. /**
  21099. * Dispose the texture and release its associated resources.
  21100. */
  21101. dispose(): void;
  21102. /**
  21103. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  21104. * @param parsedTexture Define the JSON representation of the texture
  21105. * @param scene Define the scene the parsed texture should be instantiated in
  21106. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  21107. * @returns The parsed texture if successful
  21108. */
  21109. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21110. /**
  21111. * Creates a texture from its base 64 representation.
  21112. * @param data Define the base64 payload without the data: prefix
  21113. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21114. * @param scene Define the scene the texture should belong to
  21115. * @param noMipmap Forces the texture to not create mip map information if true
  21116. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21117. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21118. * @param onLoad define a callback triggered when the texture has been loaded
  21119. * @param onError define a callback triggered when an error occurred during the loading session
  21120. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21121. * @returns the created texture
  21122. */
  21123. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21124. /**
  21125. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  21126. * @param data Define the base64 payload without the data: prefix
  21127. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  21128. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  21129. * @param scene Define the scene the texture should belong to
  21130. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  21131. * @param noMipmap Forces the texture to not create mip map information if true
  21132. * @param invertY define if the texture needs to be inverted on the y axis during loading
  21133. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  21134. * @param onLoad define a callback triggered when the texture has been loaded
  21135. * @param onError define a callback triggered when an error occurred during the loading session
  21136. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  21137. * @returns the created texture
  21138. */
  21139. 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;
  21140. }
  21141. }
  21142. declare module "babylonjs/PostProcesses/postProcessManager" {
  21143. import { Nullable } from "babylonjs/types";
  21144. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21145. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21146. import { Scene } from "babylonjs/scene";
  21147. /**
  21148. * PostProcessManager is used to manage one or more post processes or post process pipelines
  21149. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  21150. */
  21151. export class PostProcessManager {
  21152. private _scene;
  21153. private _indexBuffer;
  21154. private _vertexBuffers;
  21155. /**
  21156. * Creates a new instance PostProcess
  21157. * @param scene The scene that the post process is associated with.
  21158. */
  21159. constructor(scene: Scene);
  21160. private _prepareBuffers;
  21161. private _buildIndexBuffer;
  21162. /**
  21163. * Rebuilds the vertex buffers of the manager.
  21164. * @hidden
  21165. */
  21166. _rebuild(): void;
  21167. /**
  21168. * Prepares a frame to be run through a post process.
  21169. * @param sourceTexture The input texture to the post procesess. (default: null)
  21170. * @param postProcesses An array of post processes to be run. (default: null)
  21171. * @returns True if the post processes were able to be run.
  21172. * @hidden
  21173. */
  21174. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  21175. /**
  21176. * Manually render a set of post processes to a texture.
  21177. * @param postProcesses An array of post processes to be run.
  21178. * @param targetTexture The target texture to render to.
  21179. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  21180. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  21181. * @param lodLevel defines which lod of the texture to render to
  21182. */
  21183. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  21184. /**
  21185. * Finalize the result of the output of the postprocesses.
  21186. * @param doNotPresent If true the result will not be displayed to the screen.
  21187. * @param targetTexture The target texture to render to.
  21188. * @param faceIndex The index of the face to bind the target texture to.
  21189. * @param postProcesses The array of post processes to render.
  21190. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  21191. * @hidden
  21192. */
  21193. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  21194. /**
  21195. * Disposes of the post process manager.
  21196. */
  21197. dispose(): void;
  21198. }
  21199. }
  21200. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21201. import { Observable } from "babylonjs/Misc/observable";
  21202. import { SmartArray } from "babylonjs/Misc/smartArray";
  21203. import { Nullable, Immutable } from "babylonjs/types";
  21204. import { Camera } from "babylonjs/Cameras/camera";
  21205. import { Scene } from "babylonjs/scene";
  21206. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21207. import { Color4 } from "babylonjs/Maths/math.color";
  21208. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21210. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21212. import { Texture } from "babylonjs/Materials/Textures/texture";
  21213. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21214. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21215. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21216. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21217. import { Engine } from "babylonjs/Engines/engine";
  21218. /**
  21219. * This Helps creating a texture that will be created from a camera in your scene.
  21220. * It is basically a dynamic texture that could be used to create special effects for instance.
  21221. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21222. */
  21223. export class RenderTargetTexture extends Texture {
  21224. isCube: boolean;
  21225. /**
  21226. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21227. */
  21228. static readonly REFRESHRATE_RENDER_ONCE: number;
  21229. /**
  21230. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21231. */
  21232. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21233. /**
  21234. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21235. * the central point of your effect and can save a lot of performances.
  21236. */
  21237. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21238. /**
  21239. * Use this predicate to dynamically define the list of mesh you want to render.
  21240. * If set, the renderList property will be overwritten.
  21241. */
  21242. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21243. private _renderList;
  21244. /**
  21245. * Use this list to define the list of mesh you want to render.
  21246. */
  21247. get renderList(): Nullable<Array<AbstractMesh>>;
  21248. set renderList(value: Nullable<Array<AbstractMesh>>);
  21249. /**
  21250. * Use this function to overload the renderList array at rendering time.
  21251. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21252. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21253. * the cube (if the RTT is a cube, else layerOrFace=0).
  21254. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21255. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21256. * hold dummy elements!
  21257. */
  21258. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21259. private _hookArray;
  21260. /**
  21261. * Define if particles should be rendered in your texture.
  21262. */
  21263. renderParticles: boolean;
  21264. /**
  21265. * Define if sprites should be rendered in your texture.
  21266. */
  21267. renderSprites: boolean;
  21268. /**
  21269. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21270. */
  21271. coordinatesMode: number;
  21272. /**
  21273. * Define the camera used to render the texture.
  21274. */
  21275. activeCamera: Nullable<Camera>;
  21276. /**
  21277. * Override the mesh isReady function with your own one.
  21278. */
  21279. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  21280. /**
  21281. * Override the render function of the texture with your own one.
  21282. */
  21283. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21284. /**
  21285. * Define if camera post processes should be use while rendering the texture.
  21286. */
  21287. useCameraPostProcesses: boolean;
  21288. /**
  21289. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21290. */
  21291. ignoreCameraViewport: boolean;
  21292. private _postProcessManager;
  21293. private _postProcesses;
  21294. private _resizeObserver;
  21295. /**
  21296. * An event triggered when the texture is unbind.
  21297. */
  21298. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21299. /**
  21300. * An event triggered when the texture is unbind.
  21301. */
  21302. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21303. private _onAfterUnbindObserver;
  21304. /**
  21305. * Set a after unbind callback in the texture.
  21306. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21307. */
  21308. set onAfterUnbind(callback: () => void);
  21309. /**
  21310. * An event triggered before rendering the texture
  21311. */
  21312. onBeforeRenderObservable: Observable<number>;
  21313. private _onBeforeRenderObserver;
  21314. /**
  21315. * Set a before render callback in the texture.
  21316. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21317. */
  21318. set onBeforeRender(callback: (faceIndex: number) => void);
  21319. /**
  21320. * An event triggered after rendering the texture
  21321. */
  21322. onAfterRenderObservable: Observable<number>;
  21323. private _onAfterRenderObserver;
  21324. /**
  21325. * Set a after render callback in the texture.
  21326. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21327. */
  21328. set onAfterRender(callback: (faceIndex: number) => void);
  21329. /**
  21330. * An event triggered after the texture clear
  21331. */
  21332. onClearObservable: Observable<Engine>;
  21333. private _onClearObserver;
  21334. /**
  21335. * Set a clear callback in the texture.
  21336. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21337. */
  21338. set onClear(callback: (Engine: Engine) => void);
  21339. /**
  21340. * An event triggered when the texture is resized.
  21341. */
  21342. onResizeObservable: Observable<RenderTargetTexture>;
  21343. /**
  21344. * Define the clear color of the Render Target if it should be different from the scene.
  21345. */
  21346. clearColor: Color4;
  21347. protected _size: number | {
  21348. width: number;
  21349. height: number;
  21350. layers?: number;
  21351. };
  21352. protected _initialSizeParameter: number | {
  21353. width: number;
  21354. height: number;
  21355. } | {
  21356. ratio: number;
  21357. };
  21358. protected _sizeRatio: Nullable<number>;
  21359. /** @hidden */
  21360. _generateMipMaps: boolean;
  21361. protected _renderingManager: RenderingManager;
  21362. /** @hidden */
  21363. _waitingRenderList: string[];
  21364. protected _doNotChangeAspectRatio: boolean;
  21365. protected _currentRefreshId: number;
  21366. protected _refreshRate: number;
  21367. protected _textureMatrix: Matrix;
  21368. protected _samples: number;
  21369. protected _renderTargetOptions: RenderTargetCreationOptions;
  21370. /**
  21371. * Gets render target creation options that were used.
  21372. */
  21373. get renderTargetOptions(): RenderTargetCreationOptions;
  21374. protected _engine: Engine;
  21375. protected _onRatioRescale(): void;
  21376. /**
  21377. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21378. * It must define where the camera used to render the texture is set
  21379. */
  21380. boundingBoxPosition: Vector3;
  21381. private _boundingBoxSize;
  21382. /**
  21383. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21384. * When defined, the cubemap will switch to local mode
  21385. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21386. * @example https://www.babylonjs-playground.com/#RNASML
  21387. */
  21388. set boundingBoxSize(value: Vector3);
  21389. get boundingBoxSize(): Vector3;
  21390. /**
  21391. * In case the RTT has been created with a depth texture, get the associated
  21392. * depth texture.
  21393. * Otherwise, return null.
  21394. */
  21395. get depthStencilTexture(): Nullable<InternalTexture>;
  21396. /**
  21397. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21398. * or used a shadow, depth texture...
  21399. * @param name The friendly name of the texture
  21400. * @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)
  21401. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21402. * @param generateMipMaps True if mip maps need to be generated after render.
  21403. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21404. * @param type The type of the buffer in the RTT (int, half float, float...)
  21405. * @param isCube True if a cube texture needs to be created
  21406. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21407. * @param generateDepthBuffer True to generate a depth buffer
  21408. * @param generateStencilBuffer True to generate a stencil buffer
  21409. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21410. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21411. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21412. */
  21413. constructor(name: string, size: number | {
  21414. width: number;
  21415. height: number;
  21416. layers?: number;
  21417. } | {
  21418. ratio: number;
  21419. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21420. /**
  21421. * Creates a depth stencil texture.
  21422. * This is only available in WebGL 2 or with the depth texture extension available.
  21423. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21424. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21425. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21426. */
  21427. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21428. private _processSizeParameter;
  21429. /**
  21430. * Define the number of samples to use in case of MSAA.
  21431. * It defaults to one meaning no MSAA has been enabled.
  21432. */
  21433. get samples(): number;
  21434. set samples(value: number);
  21435. /**
  21436. * Resets the refresh counter of the texture and start bak from scratch.
  21437. * Could be useful to regenerate the texture if it is setup to render only once.
  21438. */
  21439. resetRefreshCounter(): void;
  21440. /**
  21441. * Define the refresh rate of the texture or the rendering frequency.
  21442. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21443. */
  21444. get refreshRate(): number;
  21445. set refreshRate(value: number);
  21446. /**
  21447. * Adds a post process to the render target rendering passes.
  21448. * @param postProcess define the post process to add
  21449. */
  21450. addPostProcess(postProcess: PostProcess): void;
  21451. /**
  21452. * Clear all the post processes attached to the render target
  21453. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21454. */
  21455. clearPostProcesses(dispose?: boolean): void;
  21456. /**
  21457. * Remove one of the post process from the list of attached post processes to the texture
  21458. * @param postProcess define the post process to remove from the list
  21459. */
  21460. removePostProcess(postProcess: PostProcess): void;
  21461. /** @hidden */
  21462. _shouldRender(): boolean;
  21463. /**
  21464. * Gets the actual render size of the texture.
  21465. * @returns the width of the render size
  21466. */
  21467. getRenderSize(): number;
  21468. /**
  21469. * Gets the actual render width of the texture.
  21470. * @returns the width of the render size
  21471. */
  21472. getRenderWidth(): number;
  21473. /**
  21474. * Gets the actual render height of the texture.
  21475. * @returns the height of the render size
  21476. */
  21477. getRenderHeight(): number;
  21478. /**
  21479. * Gets the actual number of layers of the texture.
  21480. * @returns the number of layers
  21481. */
  21482. getRenderLayers(): number;
  21483. /**
  21484. * Get if the texture can be rescaled or not.
  21485. */
  21486. get canRescale(): boolean;
  21487. /**
  21488. * Resize the texture using a ratio.
  21489. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21490. */
  21491. scale(ratio: number): void;
  21492. /**
  21493. * Get the texture reflection matrix used to rotate/transform the reflection.
  21494. * @returns the reflection matrix
  21495. */
  21496. getReflectionTextureMatrix(): Matrix;
  21497. /**
  21498. * Resize the texture to a new desired size.
  21499. * Be carrefull as it will recreate all the data in the new texture.
  21500. * @param size Define the new size. It can be:
  21501. * - a number for squared texture,
  21502. * - an object containing { width: number, height: number }
  21503. * - or an object containing a ratio { ratio: number }
  21504. */
  21505. resize(size: number | {
  21506. width: number;
  21507. height: number;
  21508. } | {
  21509. ratio: number;
  21510. }): void;
  21511. private _defaultRenderListPrepared;
  21512. /**
  21513. * Renders all the objects from the render list into the texture.
  21514. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21515. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21516. */
  21517. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21518. private _bestReflectionRenderTargetDimension;
  21519. private _prepareRenderingManager;
  21520. /**
  21521. * @hidden
  21522. * @param faceIndex face index to bind to if this is a cubetexture
  21523. * @param layer defines the index of the texture to bind in the array
  21524. */
  21525. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21526. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21527. private renderToTarget;
  21528. /**
  21529. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21530. * This allowed control for front to back rendering or reversly depending of the special needs.
  21531. *
  21532. * @param renderingGroupId The rendering group id corresponding to its index
  21533. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21534. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21535. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21536. */
  21537. 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;
  21538. /**
  21539. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21540. *
  21541. * @param renderingGroupId The rendering group id corresponding to its index
  21542. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21543. */
  21544. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21545. /**
  21546. * Clones the texture.
  21547. * @returns the cloned texture
  21548. */
  21549. clone(): RenderTargetTexture;
  21550. /**
  21551. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21552. * @returns The JSON representation of the texture
  21553. */
  21554. serialize(): any;
  21555. /**
  21556. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21557. */
  21558. disposeFramebufferObjects(): void;
  21559. /**
  21560. * Dispose the texture and release its associated resources.
  21561. */
  21562. dispose(): void;
  21563. /** @hidden */
  21564. _rebuild(): void;
  21565. /**
  21566. * Clear the info related to rendering groups preventing retention point in material dispose.
  21567. */
  21568. freeRenderingGroups(): void;
  21569. /**
  21570. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21571. * @returns the view count
  21572. */
  21573. getViewCount(): number;
  21574. }
  21575. }
  21576. declare module "babylonjs/Materials/material" {
  21577. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21578. import { SmartArray } from "babylonjs/Misc/smartArray";
  21579. import { Observable } from "babylonjs/Misc/observable";
  21580. import { Nullable } from "babylonjs/types";
  21581. import { Scene } from "babylonjs/scene";
  21582. import { Matrix } from "babylonjs/Maths/math.vector";
  21583. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21585. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21586. import { Effect } from "babylonjs/Materials/effect";
  21587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21588. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21589. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21590. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21591. import { Mesh } from "babylonjs/Meshes/mesh";
  21592. import { Animation } from "babylonjs/Animations/animation";
  21593. /**
  21594. * Options for compiling materials.
  21595. */
  21596. export interface IMaterialCompilationOptions {
  21597. /**
  21598. * Defines whether clip planes are enabled.
  21599. */
  21600. clipPlane: boolean;
  21601. /**
  21602. * Defines whether instances are enabled.
  21603. */
  21604. useInstances: boolean;
  21605. }
  21606. /**
  21607. * Base class for the main features of a material in Babylon.js
  21608. */
  21609. export class Material implements IAnimatable {
  21610. /**
  21611. * Returns the triangle fill mode
  21612. */
  21613. static readonly TriangleFillMode: number;
  21614. /**
  21615. * Returns the wireframe mode
  21616. */
  21617. static readonly WireFrameFillMode: number;
  21618. /**
  21619. * Returns the point fill mode
  21620. */
  21621. static readonly PointFillMode: number;
  21622. /**
  21623. * Returns the point list draw mode
  21624. */
  21625. static readonly PointListDrawMode: number;
  21626. /**
  21627. * Returns the line list draw mode
  21628. */
  21629. static readonly LineListDrawMode: number;
  21630. /**
  21631. * Returns the line loop draw mode
  21632. */
  21633. static readonly LineLoopDrawMode: number;
  21634. /**
  21635. * Returns the line strip draw mode
  21636. */
  21637. static readonly LineStripDrawMode: number;
  21638. /**
  21639. * Returns the triangle strip draw mode
  21640. */
  21641. static readonly TriangleStripDrawMode: number;
  21642. /**
  21643. * Returns the triangle fan draw mode
  21644. */
  21645. static readonly TriangleFanDrawMode: number;
  21646. /**
  21647. * Stores the clock-wise side orientation
  21648. */
  21649. static readonly ClockWiseSideOrientation: number;
  21650. /**
  21651. * Stores the counter clock-wise side orientation
  21652. */
  21653. static readonly CounterClockWiseSideOrientation: number;
  21654. /**
  21655. * The dirty texture flag value
  21656. */
  21657. static readonly TextureDirtyFlag: number;
  21658. /**
  21659. * The dirty light flag value
  21660. */
  21661. static readonly LightDirtyFlag: number;
  21662. /**
  21663. * The dirty fresnel flag value
  21664. */
  21665. static readonly FresnelDirtyFlag: number;
  21666. /**
  21667. * The dirty attribute flag value
  21668. */
  21669. static readonly AttributesDirtyFlag: number;
  21670. /**
  21671. * The dirty misc flag value
  21672. */
  21673. static readonly MiscDirtyFlag: number;
  21674. /**
  21675. * The all dirty flag value
  21676. */
  21677. static readonly AllDirtyFlag: number;
  21678. /**
  21679. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21680. */
  21681. static readonly MATERIAL_OPAQUE: number;
  21682. /**
  21683. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21684. */
  21685. static readonly MATERIAL_ALPHATEST: number;
  21686. /**
  21687. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21688. */
  21689. static readonly MATERIAL_ALPHABLEND: number;
  21690. /**
  21691. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21692. * They are also discarded below the alpha cutoff threshold to improve performances.
  21693. */
  21694. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21695. /**
  21696. * The ID of the material
  21697. */
  21698. id: string;
  21699. /**
  21700. * Gets or sets the unique id of the material
  21701. */
  21702. uniqueId: number;
  21703. /**
  21704. * The name of the material
  21705. */
  21706. name: string;
  21707. /**
  21708. * Gets or sets user defined metadata
  21709. */
  21710. metadata: any;
  21711. /**
  21712. * For internal use only. Please do not use.
  21713. */
  21714. reservedDataStore: any;
  21715. /**
  21716. * Specifies if the ready state should be checked on each call
  21717. */
  21718. checkReadyOnEveryCall: boolean;
  21719. /**
  21720. * Specifies if the ready state should be checked once
  21721. */
  21722. checkReadyOnlyOnce: boolean;
  21723. /**
  21724. * The state of the material
  21725. */
  21726. state: string;
  21727. /**
  21728. * The alpha value of the material
  21729. */
  21730. protected _alpha: number;
  21731. /**
  21732. * List of inspectable custom properties (used by the Inspector)
  21733. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21734. */
  21735. inspectableCustomProperties: IInspectable[];
  21736. /**
  21737. * Sets the alpha value of the material
  21738. */
  21739. set alpha(value: number);
  21740. /**
  21741. * Gets the alpha value of the material
  21742. */
  21743. get alpha(): number;
  21744. /**
  21745. * Specifies if back face culling is enabled
  21746. */
  21747. protected _backFaceCulling: boolean;
  21748. /**
  21749. * Sets the back-face culling state
  21750. */
  21751. set backFaceCulling(value: boolean);
  21752. /**
  21753. * Gets the back-face culling state
  21754. */
  21755. get backFaceCulling(): boolean;
  21756. /**
  21757. * Stores the value for side orientation
  21758. */
  21759. sideOrientation: number;
  21760. /**
  21761. * Callback triggered when the material is compiled
  21762. */
  21763. onCompiled: Nullable<(effect: Effect) => void>;
  21764. /**
  21765. * Callback triggered when an error occurs
  21766. */
  21767. onError: Nullable<(effect: Effect, errors: string) => void>;
  21768. /**
  21769. * Callback triggered to get the render target textures
  21770. */
  21771. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21772. /**
  21773. * Gets a boolean indicating that current material needs to register RTT
  21774. */
  21775. get hasRenderTargetTextures(): boolean;
  21776. /**
  21777. * Specifies if the material should be serialized
  21778. */
  21779. doNotSerialize: boolean;
  21780. /**
  21781. * @hidden
  21782. */
  21783. _storeEffectOnSubMeshes: boolean;
  21784. /**
  21785. * Stores the animations for the material
  21786. */
  21787. animations: Nullable<Array<Animation>>;
  21788. /**
  21789. * An event triggered when the material is disposed
  21790. */
  21791. onDisposeObservable: Observable<Material>;
  21792. /**
  21793. * An observer which watches for dispose events
  21794. */
  21795. private _onDisposeObserver;
  21796. private _onUnBindObservable;
  21797. /**
  21798. * Called during a dispose event
  21799. */
  21800. set onDispose(callback: () => void);
  21801. private _onBindObservable;
  21802. /**
  21803. * An event triggered when the material is bound
  21804. */
  21805. get onBindObservable(): Observable<AbstractMesh>;
  21806. /**
  21807. * An observer which watches for bind events
  21808. */
  21809. private _onBindObserver;
  21810. /**
  21811. * Called during a bind event
  21812. */
  21813. set onBind(callback: (Mesh: AbstractMesh) => void);
  21814. /**
  21815. * An event triggered when the material is unbound
  21816. */
  21817. get onUnBindObservable(): Observable<Material>;
  21818. /**
  21819. * Stores the value of the alpha mode
  21820. */
  21821. private _alphaMode;
  21822. /**
  21823. * Sets the value of the alpha mode.
  21824. *
  21825. * | Value | Type | Description |
  21826. * | --- | --- | --- |
  21827. * | 0 | ALPHA_DISABLE | |
  21828. * | 1 | ALPHA_ADD | |
  21829. * | 2 | ALPHA_COMBINE | |
  21830. * | 3 | ALPHA_SUBTRACT | |
  21831. * | 4 | ALPHA_MULTIPLY | |
  21832. * | 5 | ALPHA_MAXIMIZED | |
  21833. * | 6 | ALPHA_ONEONE | |
  21834. * | 7 | ALPHA_PREMULTIPLIED | |
  21835. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21836. * | 9 | ALPHA_INTERPOLATE | |
  21837. * | 10 | ALPHA_SCREENMODE | |
  21838. *
  21839. */
  21840. set alphaMode(value: number);
  21841. /**
  21842. * Gets the value of the alpha mode
  21843. */
  21844. get alphaMode(): number;
  21845. /**
  21846. * Stores the state of the need depth pre-pass value
  21847. */
  21848. private _needDepthPrePass;
  21849. /**
  21850. * Sets the need depth pre-pass value
  21851. */
  21852. set needDepthPrePass(value: boolean);
  21853. /**
  21854. * Gets the depth pre-pass value
  21855. */
  21856. get needDepthPrePass(): boolean;
  21857. /**
  21858. * Specifies if depth writing should be disabled
  21859. */
  21860. disableDepthWrite: boolean;
  21861. /**
  21862. * Specifies if depth writing should be forced
  21863. */
  21864. forceDepthWrite: boolean;
  21865. /**
  21866. * Specifies the depth function that should be used. 0 means the default engine function
  21867. */
  21868. depthFunction: number;
  21869. /**
  21870. * Specifies if there should be a separate pass for culling
  21871. */
  21872. separateCullingPass: boolean;
  21873. /**
  21874. * Stores the state specifing if fog should be enabled
  21875. */
  21876. private _fogEnabled;
  21877. /**
  21878. * Sets the state for enabling fog
  21879. */
  21880. set fogEnabled(value: boolean);
  21881. /**
  21882. * Gets the value of the fog enabled state
  21883. */
  21884. get fogEnabled(): boolean;
  21885. /**
  21886. * Stores the size of points
  21887. */
  21888. pointSize: number;
  21889. /**
  21890. * Stores the z offset value
  21891. */
  21892. zOffset: number;
  21893. /**
  21894. * Gets a value specifying if wireframe mode is enabled
  21895. */
  21896. get wireframe(): boolean;
  21897. /**
  21898. * Sets the state of wireframe mode
  21899. */
  21900. set wireframe(value: boolean);
  21901. /**
  21902. * Gets the value specifying if point clouds are enabled
  21903. */
  21904. get pointsCloud(): boolean;
  21905. /**
  21906. * Sets the state of point cloud mode
  21907. */
  21908. set pointsCloud(value: boolean);
  21909. /**
  21910. * Gets the material fill mode
  21911. */
  21912. get fillMode(): number;
  21913. /**
  21914. * Sets the material fill mode
  21915. */
  21916. set fillMode(value: number);
  21917. /**
  21918. * @hidden
  21919. * Stores the effects for the material
  21920. */
  21921. _effect: Nullable<Effect>;
  21922. /**
  21923. * Specifies if uniform buffers should be used
  21924. */
  21925. private _useUBO;
  21926. /**
  21927. * Stores a reference to the scene
  21928. */
  21929. private _scene;
  21930. /**
  21931. * Stores the fill mode state
  21932. */
  21933. private _fillMode;
  21934. /**
  21935. * Specifies if the depth write state should be cached
  21936. */
  21937. private _cachedDepthWriteState;
  21938. /**
  21939. * Specifies if the depth function state should be cached
  21940. */
  21941. private _cachedDepthFunctionState;
  21942. /**
  21943. * Stores the uniform buffer
  21944. */
  21945. protected _uniformBuffer: UniformBuffer;
  21946. /** @hidden */
  21947. _indexInSceneMaterialArray: number;
  21948. /** @hidden */
  21949. meshMap: Nullable<{
  21950. [id: string]: AbstractMesh | undefined;
  21951. }>;
  21952. /**
  21953. * Creates a material instance
  21954. * @param name defines the name of the material
  21955. * @param scene defines the scene to reference
  21956. * @param doNotAdd specifies if the material should be added to the scene
  21957. */
  21958. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21959. /**
  21960. * Returns a string representation of the current material
  21961. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21962. * @returns a string with material information
  21963. */
  21964. toString(fullDetails?: boolean): string;
  21965. /**
  21966. * Gets the class name of the material
  21967. * @returns a string with the class name of the material
  21968. */
  21969. getClassName(): string;
  21970. /**
  21971. * Specifies if updates for the material been locked
  21972. */
  21973. get isFrozen(): boolean;
  21974. /**
  21975. * Locks updates for the material
  21976. */
  21977. freeze(): void;
  21978. /**
  21979. * Unlocks updates for the material
  21980. */
  21981. unfreeze(): void;
  21982. /**
  21983. * Specifies if the material is ready to be used
  21984. * @param mesh defines the mesh to check
  21985. * @param useInstances specifies if instances should be used
  21986. * @returns a boolean indicating if the material is ready to be used
  21987. */
  21988. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21989. /**
  21990. * Specifies that the submesh is ready to be used
  21991. * @param mesh defines the mesh to check
  21992. * @param subMesh defines which submesh to check
  21993. * @param useInstances specifies that instances should be used
  21994. * @returns a boolean indicating that the submesh is ready or not
  21995. */
  21996. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21997. /**
  21998. * Returns the material effect
  21999. * @returns the effect associated with the material
  22000. */
  22001. getEffect(): Nullable<Effect>;
  22002. /**
  22003. * Returns the current scene
  22004. * @returns a Scene
  22005. */
  22006. getScene(): Scene;
  22007. /**
  22008. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22009. */
  22010. protected _forceAlphaTest: boolean;
  22011. /**
  22012. * The transparency mode of the material.
  22013. */
  22014. protected _transparencyMode: Nullable<number>;
  22015. /**
  22016. * Gets the current transparency mode.
  22017. */
  22018. get transparencyMode(): Nullable<number>;
  22019. /**
  22020. * Sets the transparency mode of the material.
  22021. *
  22022. * | Value | Type | Description |
  22023. * | ----- | ----------------------------------- | ----------- |
  22024. * | 0 | OPAQUE | |
  22025. * | 1 | ALPHATEST | |
  22026. * | 2 | ALPHABLEND | |
  22027. * | 3 | ALPHATESTANDBLEND | |
  22028. *
  22029. */
  22030. set transparencyMode(value: Nullable<number>);
  22031. /**
  22032. * Returns true if alpha blending should be disabled.
  22033. */
  22034. protected get _disableAlphaBlending(): boolean;
  22035. /**
  22036. * Specifies whether or not this material should be rendered in alpha blend mode.
  22037. * @returns a boolean specifying if alpha blending is needed
  22038. */
  22039. needAlphaBlending(): boolean;
  22040. /**
  22041. * Specifies if the mesh will require alpha blending
  22042. * @param mesh defines the mesh to check
  22043. * @returns a boolean specifying if alpha blending is needed for the mesh
  22044. */
  22045. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22046. /**
  22047. * Specifies whether or not this material should be rendered in alpha test mode.
  22048. * @returns a boolean specifying if an alpha test is needed.
  22049. */
  22050. needAlphaTesting(): boolean;
  22051. /**
  22052. * Specifies if material alpha testing should be turned on for the mesh
  22053. * @param mesh defines the mesh to check
  22054. */
  22055. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22056. /**
  22057. * Gets the texture used for the alpha test
  22058. * @returns the texture to use for alpha testing
  22059. */
  22060. getAlphaTestTexture(): Nullable<BaseTexture>;
  22061. /**
  22062. * Marks the material to indicate that it needs to be re-calculated
  22063. */
  22064. markDirty(): void;
  22065. /** @hidden */
  22066. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22067. /**
  22068. * Binds the material to the mesh
  22069. * @param world defines the world transformation matrix
  22070. * @param mesh defines the mesh to bind the material to
  22071. */
  22072. bind(world: Matrix, mesh?: Mesh): void;
  22073. /**
  22074. * Binds the submesh to the material
  22075. * @param world defines the world transformation matrix
  22076. * @param mesh defines the mesh containing the submesh
  22077. * @param subMesh defines the submesh to bind the material to
  22078. */
  22079. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22080. /**
  22081. * Binds the world matrix to the material
  22082. * @param world defines the world transformation matrix
  22083. */
  22084. bindOnlyWorldMatrix(world: Matrix): void;
  22085. /**
  22086. * Binds the scene's uniform buffer to the effect.
  22087. * @param effect defines the effect to bind to the scene uniform buffer
  22088. * @param sceneUbo defines the uniform buffer storing scene data
  22089. */
  22090. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22091. /**
  22092. * Binds the view matrix to the effect
  22093. * @param effect defines the effect to bind the view matrix to
  22094. */
  22095. bindView(effect: Effect): void;
  22096. /**
  22097. * Binds the view projection matrix to the effect
  22098. * @param effect defines the effect to bind the view projection matrix to
  22099. */
  22100. bindViewProjection(effect: Effect): void;
  22101. /**
  22102. * Processes to execute after binding the material to a mesh
  22103. * @param mesh defines the rendered mesh
  22104. */
  22105. protected _afterBind(mesh?: Mesh): void;
  22106. /**
  22107. * Unbinds the material from the mesh
  22108. */
  22109. unbind(): void;
  22110. /**
  22111. * Gets the active textures from the material
  22112. * @returns an array of textures
  22113. */
  22114. getActiveTextures(): BaseTexture[];
  22115. /**
  22116. * Specifies if the material uses a texture
  22117. * @param texture defines the texture to check against the material
  22118. * @returns a boolean specifying if the material uses the texture
  22119. */
  22120. hasTexture(texture: BaseTexture): boolean;
  22121. /**
  22122. * Makes a duplicate of the material, and gives it a new name
  22123. * @param name defines the new name for the duplicated material
  22124. * @returns the cloned material
  22125. */
  22126. clone(name: string): Nullable<Material>;
  22127. /**
  22128. * Gets the meshes bound to the material
  22129. * @returns an array of meshes bound to the material
  22130. */
  22131. getBindedMeshes(): AbstractMesh[];
  22132. /**
  22133. * Force shader compilation
  22134. * @param mesh defines the mesh associated with this material
  22135. * @param onCompiled defines a function to execute once the material is compiled
  22136. * @param options defines the options to configure the compilation
  22137. * @param onError defines a function to execute if the material fails compiling
  22138. */
  22139. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  22140. /**
  22141. * Force shader compilation
  22142. * @param mesh defines the mesh that will use this material
  22143. * @param options defines additional options for compiling the shaders
  22144. * @returns a promise that resolves when the compilation completes
  22145. */
  22146. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  22147. private static readonly _AllDirtyCallBack;
  22148. private static readonly _ImageProcessingDirtyCallBack;
  22149. private static readonly _TextureDirtyCallBack;
  22150. private static readonly _FresnelDirtyCallBack;
  22151. private static readonly _MiscDirtyCallBack;
  22152. private static readonly _LightsDirtyCallBack;
  22153. private static readonly _AttributeDirtyCallBack;
  22154. private static _FresnelAndMiscDirtyCallBack;
  22155. private static _TextureAndMiscDirtyCallBack;
  22156. private static readonly _DirtyCallbackArray;
  22157. private static readonly _RunDirtyCallBacks;
  22158. /**
  22159. * Marks a define in the material to indicate that it needs to be re-computed
  22160. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22161. */
  22162. markAsDirty(flag: number): void;
  22163. /**
  22164. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22165. * @param func defines a function which checks material defines against the submeshes
  22166. */
  22167. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22168. /**
  22169. * Indicates that we need to re-calculated for all submeshes
  22170. */
  22171. protected _markAllSubMeshesAsAllDirty(): void;
  22172. /**
  22173. * Indicates that image processing needs to be re-calculated for all submeshes
  22174. */
  22175. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22176. /**
  22177. * Indicates that textures need to be re-calculated for all submeshes
  22178. */
  22179. protected _markAllSubMeshesAsTexturesDirty(): void;
  22180. /**
  22181. * Indicates that fresnel needs to be re-calculated for all submeshes
  22182. */
  22183. protected _markAllSubMeshesAsFresnelDirty(): void;
  22184. /**
  22185. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22186. */
  22187. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22188. /**
  22189. * Indicates that lights need to be re-calculated for all submeshes
  22190. */
  22191. protected _markAllSubMeshesAsLightsDirty(): void;
  22192. /**
  22193. * Indicates that attributes need to be re-calculated for all submeshes
  22194. */
  22195. protected _markAllSubMeshesAsAttributesDirty(): void;
  22196. /**
  22197. * Indicates that misc needs to be re-calculated for all submeshes
  22198. */
  22199. protected _markAllSubMeshesAsMiscDirty(): void;
  22200. /**
  22201. * Indicates that textures and misc need to be re-calculated for all submeshes
  22202. */
  22203. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22204. /**
  22205. * Disposes the material
  22206. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22207. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22208. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22209. */
  22210. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22211. /** @hidden */
  22212. private releaseVertexArrayObject;
  22213. /**
  22214. * Serializes this material
  22215. * @returns the serialized material object
  22216. */
  22217. serialize(): any;
  22218. /**
  22219. * Creates a material from parsed material data
  22220. * @param parsedMaterial defines parsed material data
  22221. * @param scene defines the hosting scene
  22222. * @param rootUrl defines the root URL to use to load textures
  22223. * @returns a new material
  22224. */
  22225. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22226. }
  22227. }
  22228. declare module "babylonjs/Materials/multiMaterial" {
  22229. import { Nullable } from "babylonjs/types";
  22230. import { Scene } from "babylonjs/scene";
  22231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22232. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  22233. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22234. import { Material } from "babylonjs/Materials/material";
  22235. /**
  22236. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22237. * separate meshes. This can be use to improve performances.
  22238. * @see http://doc.babylonjs.com/how_to/multi_materials
  22239. */
  22240. export class MultiMaterial extends Material {
  22241. private _subMaterials;
  22242. /**
  22243. * Gets or Sets the list of Materials used within the multi material.
  22244. * They need to be ordered according to the submeshes order in the associated mesh
  22245. */
  22246. get subMaterials(): Nullable<Material>[];
  22247. set subMaterials(value: Nullable<Material>[]);
  22248. /**
  22249. * Function used to align with Node.getChildren()
  22250. * @returns the list of Materials used within the multi material
  22251. */
  22252. getChildren(): Nullable<Material>[];
  22253. /**
  22254. * Instantiates a new Multi Material
  22255. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22256. * separate meshes. This can be use to improve performances.
  22257. * @see http://doc.babylonjs.com/how_to/multi_materials
  22258. * @param name Define the name in the scene
  22259. * @param scene Define the scene the material belongs to
  22260. */
  22261. constructor(name: string, scene: Scene);
  22262. private _hookArray;
  22263. /**
  22264. * Get one of the submaterial by its index in the submaterials array
  22265. * @param index The index to look the sub material at
  22266. * @returns The Material if the index has been defined
  22267. */
  22268. getSubMaterial(index: number): Nullable<Material>;
  22269. /**
  22270. * Get the list of active textures for the whole sub materials list.
  22271. * @returns All the textures that will be used during the rendering
  22272. */
  22273. getActiveTextures(): BaseTexture[];
  22274. /**
  22275. * Gets the current class name of the material e.g. "MultiMaterial"
  22276. * Mainly use in serialization.
  22277. * @returns the class name
  22278. */
  22279. getClassName(): string;
  22280. /**
  22281. * Checks if the material is ready to render the requested sub mesh
  22282. * @param mesh Define the mesh the submesh belongs to
  22283. * @param subMesh Define the sub mesh to look readyness for
  22284. * @param useInstances Define whether or not the material is used with instances
  22285. * @returns true if ready, otherwise false
  22286. */
  22287. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22288. /**
  22289. * Clones the current material and its related sub materials
  22290. * @param name Define the name of the newly cloned material
  22291. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22292. * @returns the cloned material
  22293. */
  22294. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22295. /**
  22296. * Serializes the materials into a JSON representation.
  22297. * @returns the JSON representation
  22298. */
  22299. serialize(): any;
  22300. /**
  22301. * Dispose the material and release its associated resources
  22302. * @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)
  22303. * @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)
  22304. * @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)
  22305. */
  22306. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22307. /**
  22308. * Creates a MultiMaterial from parsed MultiMaterial data.
  22309. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22310. * @param scene defines the hosting scene
  22311. * @returns a new MultiMaterial
  22312. */
  22313. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22314. }
  22315. }
  22316. declare module "babylonjs/Meshes/subMesh" {
  22317. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22318. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22319. import { Engine } from "babylonjs/Engines/engine";
  22320. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22321. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22322. import { Effect } from "babylonjs/Materials/effect";
  22323. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22324. import { Plane } from "babylonjs/Maths/math.plane";
  22325. import { Collider } from "babylonjs/Collisions/collider";
  22326. import { Material } from "babylonjs/Materials/material";
  22327. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22329. import { Mesh } from "babylonjs/Meshes/mesh";
  22330. import { Ray } from "babylonjs/Culling/ray";
  22331. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22332. /**
  22333. * Base class for submeshes
  22334. */
  22335. export class BaseSubMesh {
  22336. /** @hidden */
  22337. _materialDefines: Nullable<MaterialDefines>;
  22338. /** @hidden */
  22339. _materialEffect: Nullable<Effect>;
  22340. /**
  22341. * Gets material defines used by the effect associated to the sub mesh
  22342. */
  22343. get materialDefines(): Nullable<MaterialDefines>;
  22344. /**
  22345. * Sets material defines used by the effect associated to the sub mesh
  22346. */
  22347. set materialDefines(defines: Nullable<MaterialDefines>);
  22348. /**
  22349. * Gets associated effect
  22350. */
  22351. get effect(): Nullable<Effect>;
  22352. /**
  22353. * Sets associated effect (effect used to render this submesh)
  22354. * @param effect defines the effect to associate with
  22355. * @param defines defines the set of defines used to compile this effect
  22356. */
  22357. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22358. }
  22359. /**
  22360. * Defines a subdivision inside a mesh
  22361. */
  22362. export class SubMesh extends BaseSubMesh implements ICullable {
  22363. /** the material index to use */
  22364. materialIndex: number;
  22365. /** vertex index start */
  22366. verticesStart: number;
  22367. /** vertices count */
  22368. verticesCount: number;
  22369. /** index start */
  22370. indexStart: number;
  22371. /** indices count */
  22372. indexCount: number;
  22373. /** @hidden */
  22374. _linesIndexCount: number;
  22375. private _mesh;
  22376. private _renderingMesh;
  22377. private _boundingInfo;
  22378. private _linesIndexBuffer;
  22379. /** @hidden */
  22380. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22381. /** @hidden */
  22382. _trianglePlanes: Plane[];
  22383. /** @hidden */
  22384. _lastColliderTransformMatrix: Nullable<Matrix>;
  22385. /** @hidden */
  22386. _renderId: number;
  22387. /** @hidden */
  22388. _alphaIndex: number;
  22389. /** @hidden */
  22390. _distanceToCamera: number;
  22391. /** @hidden */
  22392. _id: number;
  22393. private _currentMaterial;
  22394. /**
  22395. * Add a new submesh to a mesh
  22396. * @param materialIndex defines the material index to use
  22397. * @param verticesStart defines vertex index start
  22398. * @param verticesCount defines vertices count
  22399. * @param indexStart defines index start
  22400. * @param indexCount defines indices count
  22401. * @param mesh defines the parent mesh
  22402. * @param renderingMesh defines an optional rendering mesh
  22403. * @param createBoundingBox defines if bounding box should be created for this submesh
  22404. * @returns the new submesh
  22405. */
  22406. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22407. /**
  22408. * Creates a new submesh
  22409. * @param materialIndex defines the material index to use
  22410. * @param verticesStart defines vertex index start
  22411. * @param verticesCount defines vertices count
  22412. * @param indexStart defines index start
  22413. * @param indexCount defines indices count
  22414. * @param mesh defines the parent mesh
  22415. * @param renderingMesh defines an optional rendering mesh
  22416. * @param createBoundingBox defines if bounding box should be created for this submesh
  22417. */
  22418. constructor(
  22419. /** the material index to use */
  22420. materialIndex: number,
  22421. /** vertex index start */
  22422. verticesStart: number,
  22423. /** vertices count */
  22424. verticesCount: number,
  22425. /** index start */
  22426. indexStart: number,
  22427. /** indices count */
  22428. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22429. /**
  22430. * Returns true if this submesh covers the entire parent mesh
  22431. * @ignorenaming
  22432. */
  22433. get IsGlobal(): boolean;
  22434. /**
  22435. * Returns the submesh BoudingInfo object
  22436. * @returns current bounding info (or mesh's one if the submesh is global)
  22437. */
  22438. getBoundingInfo(): BoundingInfo;
  22439. /**
  22440. * Sets the submesh BoundingInfo
  22441. * @param boundingInfo defines the new bounding info to use
  22442. * @returns the SubMesh
  22443. */
  22444. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22445. /**
  22446. * Returns the mesh of the current submesh
  22447. * @return the parent mesh
  22448. */
  22449. getMesh(): AbstractMesh;
  22450. /**
  22451. * Returns the rendering mesh of the submesh
  22452. * @returns the rendering mesh (could be different from parent mesh)
  22453. */
  22454. getRenderingMesh(): Mesh;
  22455. /**
  22456. * Returns the submesh material
  22457. * @returns null or the current material
  22458. */
  22459. getMaterial(): Nullable<Material>;
  22460. /**
  22461. * Sets a new updated BoundingInfo object to the submesh
  22462. * @param data defines an optional position array to use to determine the bounding info
  22463. * @returns the SubMesh
  22464. */
  22465. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22466. /** @hidden */
  22467. _checkCollision(collider: Collider): boolean;
  22468. /**
  22469. * Updates the submesh BoundingInfo
  22470. * @param world defines the world matrix to use to update the bounding info
  22471. * @returns the submesh
  22472. */
  22473. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22474. /**
  22475. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22476. * @param frustumPlanes defines the frustum planes
  22477. * @returns true if the submesh is intersecting with the frustum
  22478. */
  22479. isInFrustum(frustumPlanes: Plane[]): boolean;
  22480. /**
  22481. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22482. * @param frustumPlanes defines the frustum planes
  22483. * @returns true if the submesh is inside the frustum
  22484. */
  22485. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22486. /**
  22487. * Renders the submesh
  22488. * @param enableAlphaMode defines if alpha needs to be used
  22489. * @returns the submesh
  22490. */
  22491. render(enableAlphaMode: boolean): SubMesh;
  22492. /**
  22493. * @hidden
  22494. */
  22495. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22496. /**
  22497. * Checks if the submesh intersects with a ray
  22498. * @param ray defines the ray to test
  22499. * @returns true is the passed ray intersects the submesh bounding box
  22500. */
  22501. canIntersects(ray: Ray): boolean;
  22502. /**
  22503. * Intersects current submesh with a ray
  22504. * @param ray defines the ray to test
  22505. * @param positions defines mesh's positions array
  22506. * @param indices defines mesh's indices array
  22507. * @param fastCheck defines if only bounding info should be used
  22508. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22509. * @returns intersection info or null if no intersection
  22510. */
  22511. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22512. /** @hidden */
  22513. private _intersectLines;
  22514. /** @hidden */
  22515. private _intersectUnIndexedLines;
  22516. /** @hidden */
  22517. private _intersectTriangles;
  22518. /** @hidden */
  22519. private _intersectUnIndexedTriangles;
  22520. /** @hidden */
  22521. _rebuild(): void;
  22522. /**
  22523. * Creates a new submesh from the passed mesh
  22524. * @param newMesh defines the new hosting mesh
  22525. * @param newRenderingMesh defines an optional rendering mesh
  22526. * @returns the new submesh
  22527. */
  22528. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22529. /**
  22530. * Release associated resources
  22531. */
  22532. dispose(): void;
  22533. /**
  22534. * Gets the class name
  22535. * @returns the string "SubMesh".
  22536. */
  22537. getClassName(): string;
  22538. /**
  22539. * Creates a new submesh from indices data
  22540. * @param materialIndex the index of the main mesh material
  22541. * @param startIndex the index where to start the copy in the mesh indices array
  22542. * @param indexCount the number of indices to copy then from the startIndex
  22543. * @param mesh the main mesh to create the submesh from
  22544. * @param renderingMesh the optional rendering mesh
  22545. * @returns a new submesh
  22546. */
  22547. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22548. }
  22549. }
  22550. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22551. /**
  22552. * Class used to represent data loading progression
  22553. */
  22554. export class SceneLoaderFlags {
  22555. private static _ForceFullSceneLoadingForIncremental;
  22556. private static _ShowLoadingScreen;
  22557. private static _CleanBoneMatrixWeights;
  22558. private static _loggingLevel;
  22559. /**
  22560. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22561. */
  22562. static get ForceFullSceneLoadingForIncremental(): boolean;
  22563. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22564. /**
  22565. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22566. */
  22567. static get ShowLoadingScreen(): boolean;
  22568. static set ShowLoadingScreen(value: boolean);
  22569. /**
  22570. * Defines the current logging level (while loading the scene)
  22571. * @ignorenaming
  22572. */
  22573. static get loggingLevel(): number;
  22574. static set loggingLevel(value: number);
  22575. /**
  22576. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22577. */
  22578. static get CleanBoneMatrixWeights(): boolean;
  22579. static set CleanBoneMatrixWeights(value: boolean);
  22580. }
  22581. }
  22582. declare module "babylonjs/Meshes/geometry" {
  22583. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22584. import { Scene } from "babylonjs/scene";
  22585. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22586. import { Engine } from "babylonjs/Engines/engine";
  22587. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22588. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22589. import { Effect } from "babylonjs/Materials/effect";
  22590. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22591. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22592. import { Mesh } from "babylonjs/Meshes/mesh";
  22593. /**
  22594. * Class used to store geometry data (vertex buffers + index buffer)
  22595. */
  22596. export class Geometry implements IGetSetVerticesData {
  22597. /**
  22598. * Gets or sets the ID of the geometry
  22599. */
  22600. id: string;
  22601. /**
  22602. * Gets or sets the unique ID of the geometry
  22603. */
  22604. uniqueId: number;
  22605. /**
  22606. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22607. */
  22608. delayLoadState: number;
  22609. /**
  22610. * Gets the file containing the data to load when running in delay load state
  22611. */
  22612. delayLoadingFile: Nullable<string>;
  22613. /**
  22614. * Callback called when the geometry is updated
  22615. */
  22616. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22617. private _scene;
  22618. private _engine;
  22619. private _meshes;
  22620. private _totalVertices;
  22621. /** @hidden */
  22622. _indices: IndicesArray;
  22623. /** @hidden */
  22624. _vertexBuffers: {
  22625. [key: string]: VertexBuffer;
  22626. };
  22627. private _isDisposed;
  22628. private _extend;
  22629. private _boundingBias;
  22630. /** @hidden */
  22631. _delayInfo: Array<string>;
  22632. private _indexBuffer;
  22633. private _indexBufferIsUpdatable;
  22634. /** @hidden */
  22635. _boundingInfo: Nullable<BoundingInfo>;
  22636. /** @hidden */
  22637. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22638. /** @hidden */
  22639. _softwareSkinningFrameId: number;
  22640. private _vertexArrayObjects;
  22641. private _updatable;
  22642. /** @hidden */
  22643. _positions: Nullable<Vector3[]>;
  22644. /**
  22645. * 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
  22646. */
  22647. get boundingBias(): Vector2;
  22648. /**
  22649. * 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
  22650. */
  22651. set boundingBias(value: Vector2);
  22652. /**
  22653. * Static function used to attach a new empty geometry to a mesh
  22654. * @param mesh defines the mesh to attach the geometry to
  22655. * @returns the new Geometry
  22656. */
  22657. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22658. /** Get the list of meshes using this geometry */
  22659. get meshes(): Mesh[];
  22660. /**
  22661. * Creates a new geometry
  22662. * @param id defines the unique ID
  22663. * @param scene defines the hosting scene
  22664. * @param vertexData defines the VertexData used to get geometry data
  22665. * @param updatable defines if geometry must be updatable (false by default)
  22666. * @param mesh defines the mesh that will be associated with the geometry
  22667. */
  22668. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22669. /**
  22670. * Gets the current extend of the geometry
  22671. */
  22672. get extend(): {
  22673. minimum: Vector3;
  22674. maximum: Vector3;
  22675. };
  22676. /**
  22677. * Gets the hosting scene
  22678. * @returns the hosting Scene
  22679. */
  22680. getScene(): Scene;
  22681. /**
  22682. * Gets the hosting engine
  22683. * @returns the hosting Engine
  22684. */
  22685. getEngine(): Engine;
  22686. /**
  22687. * Defines if the geometry is ready to use
  22688. * @returns true if the geometry is ready to be used
  22689. */
  22690. isReady(): boolean;
  22691. /**
  22692. * Gets a value indicating that the geometry should not be serialized
  22693. */
  22694. get doNotSerialize(): boolean;
  22695. /** @hidden */
  22696. _rebuild(): void;
  22697. /**
  22698. * Affects all geometry data in one call
  22699. * @param vertexData defines the geometry data
  22700. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22701. */
  22702. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22703. /**
  22704. * Set specific vertex data
  22705. * @param kind defines the data kind (Position, normal, etc...)
  22706. * @param data defines the vertex data to use
  22707. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22708. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22709. */
  22710. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22711. /**
  22712. * Removes a specific vertex data
  22713. * @param kind defines the data kind (Position, normal, etc...)
  22714. */
  22715. removeVerticesData(kind: string): void;
  22716. /**
  22717. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22718. * @param buffer defines the vertex buffer to use
  22719. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22720. */
  22721. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22722. /**
  22723. * Update a specific vertex buffer
  22724. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22725. * It will do nothing if the buffer is not updatable
  22726. * @param kind defines the data kind (Position, normal, etc...)
  22727. * @param data defines the data to use
  22728. * @param offset defines the offset in the target buffer where to store the data
  22729. * @param useBytes set to true if the offset is in bytes
  22730. */
  22731. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22732. /**
  22733. * Update a specific vertex buffer
  22734. * This function will create a new buffer if the current one is not updatable
  22735. * @param kind defines the data kind (Position, normal, etc...)
  22736. * @param data defines the data to use
  22737. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22738. */
  22739. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22740. private _updateBoundingInfo;
  22741. /** @hidden */
  22742. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22743. /**
  22744. * Gets total number of vertices
  22745. * @returns the total number of vertices
  22746. */
  22747. getTotalVertices(): number;
  22748. /**
  22749. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22750. * @param kind defines the data kind (Position, normal, etc...)
  22751. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22752. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22753. * @returns a float array containing vertex data
  22754. */
  22755. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22756. /**
  22757. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22758. * @param kind defines the data kind (Position, normal, etc...)
  22759. * @returns true if the vertex buffer with the specified kind is updatable
  22760. */
  22761. isVertexBufferUpdatable(kind: string): boolean;
  22762. /**
  22763. * Gets a specific vertex buffer
  22764. * @param kind defines the data kind (Position, normal, etc...)
  22765. * @returns a VertexBuffer
  22766. */
  22767. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22768. /**
  22769. * Returns all vertex buffers
  22770. * @return an object holding all vertex buffers indexed by kind
  22771. */
  22772. getVertexBuffers(): Nullable<{
  22773. [key: string]: VertexBuffer;
  22774. }>;
  22775. /**
  22776. * Gets a boolean indicating if specific vertex buffer is present
  22777. * @param kind defines the data kind (Position, normal, etc...)
  22778. * @returns true if data is present
  22779. */
  22780. isVerticesDataPresent(kind: string): boolean;
  22781. /**
  22782. * Gets a list of all attached data kinds (Position, normal, etc...)
  22783. * @returns a list of string containing all kinds
  22784. */
  22785. getVerticesDataKinds(): string[];
  22786. /**
  22787. * Update index buffer
  22788. * @param indices defines the indices to store in the index buffer
  22789. * @param offset defines the offset in the target buffer where to store the data
  22790. * @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)
  22791. */
  22792. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22793. /**
  22794. * Creates a new index buffer
  22795. * @param indices defines the indices to store in the index buffer
  22796. * @param totalVertices defines the total number of vertices (could be null)
  22797. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22798. */
  22799. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22800. /**
  22801. * Return the total number of indices
  22802. * @returns the total number of indices
  22803. */
  22804. getTotalIndices(): number;
  22805. /**
  22806. * Gets the index buffer array
  22807. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22808. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22809. * @returns the index buffer array
  22810. */
  22811. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22812. /**
  22813. * Gets the index buffer
  22814. * @return the index buffer
  22815. */
  22816. getIndexBuffer(): Nullable<DataBuffer>;
  22817. /** @hidden */
  22818. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22819. /**
  22820. * Release the associated resources for a specific mesh
  22821. * @param mesh defines the source mesh
  22822. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22823. */
  22824. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22825. /**
  22826. * Apply current geometry to a given mesh
  22827. * @param mesh defines the mesh to apply geometry to
  22828. */
  22829. applyToMesh(mesh: Mesh): void;
  22830. private _updateExtend;
  22831. private _applyToMesh;
  22832. private notifyUpdate;
  22833. /**
  22834. * Load the geometry if it was flagged as delay loaded
  22835. * @param scene defines the hosting scene
  22836. * @param onLoaded defines a callback called when the geometry is loaded
  22837. */
  22838. load(scene: Scene, onLoaded?: () => void): void;
  22839. private _queueLoad;
  22840. /**
  22841. * Invert the geometry to move from a right handed system to a left handed one.
  22842. */
  22843. toLeftHanded(): void;
  22844. /** @hidden */
  22845. _resetPointsArrayCache(): void;
  22846. /** @hidden */
  22847. _generatePointsArray(): boolean;
  22848. /**
  22849. * Gets a value indicating if the geometry is disposed
  22850. * @returns true if the geometry was disposed
  22851. */
  22852. isDisposed(): boolean;
  22853. private _disposeVertexArrayObjects;
  22854. /**
  22855. * Free all associated resources
  22856. */
  22857. dispose(): void;
  22858. /**
  22859. * Clone the current geometry into a new geometry
  22860. * @param id defines the unique ID of the new geometry
  22861. * @returns a new geometry object
  22862. */
  22863. copy(id: string): Geometry;
  22864. /**
  22865. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22866. * @return a JSON representation of the current geometry data (without the vertices data)
  22867. */
  22868. serialize(): any;
  22869. private toNumberArray;
  22870. /**
  22871. * Serialize all vertices data into a JSON oject
  22872. * @returns a JSON representation of the current geometry data
  22873. */
  22874. serializeVerticeData(): any;
  22875. /**
  22876. * Extracts a clone of a mesh geometry
  22877. * @param mesh defines the source mesh
  22878. * @param id defines the unique ID of the new geometry object
  22879. * @returns the new geometry object
  22880. */
  22881. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22882. /**
  22883. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22884. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22885. * Be aware Math.random() could cause collisions, but:
  22886. * "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"
  22887. * @returns a string containing a new GUID
  22888. */
  22889. static RandomId(): string;
  22890. /** @hidden */
  22891. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22892. private static _CleanMatricesWeights;
  22893. /**
  22894. * Create a new geometry from persisted data (Using .babylon file format)
  22895. * @param parsedVertexData defines the persisted data
  22896. * @param scene defines the hosting scene
  22897. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22898. * @returns the new geometry object
  22899. */
  22900. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22901. }
  22902. }
  22903. declare module "babylonjs/Meshes/mesh.vertexData" {
  22904. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22905. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22906. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22907. import { Geometry } from "babylonjs/Meshes/geometry";
  22908. import { Mesh } from "babylonjs/Meshes/mesh";
  22909. /**
  22910. * Define an interface for all classes that will get and set the data on vertices
  22911. */
  22912. export interface IGetSetVerticesData {
  22913. /**
  22914. * Gets a boolean indicating if specific vertex data is present
  22915. * @param kind defines the vertex data kind to use
  22916. * @returns true is data kind is present
  22917. */
  22918. isVerticesDataPresent(kind: string): boolean;
  22919. /**
  22920. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22921. * @param kind defines the data kind (Position, normal, etc...)
  22922. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22923. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22924. * @returns a float array containing vertex data
  22925. */
  22926. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22927. /**
  22928. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22929. * @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.
  22930. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22931. * @returns the indices array or an empty array if the mesh has no geometry
  22932. */
  22933. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22934. /**
  22935. * Set specific vertex data
  22936. * @param kind defines the data kind (Position, normal, etc...)
  22937. * @param data defines the vertex data to use
  22938. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22939. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22940. */
  22941. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22942. /**
  22943. * Update a specific associated vertex buffer
  22944. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22945. * - VertexBuffer.PositionKind
  22946. * - VertexBuffer.UVKind
  22947. * - VertexBuffer.UV2Kind
  22948. * - VertexBuffer.UV3Kind
  22949. * - VertexBuffer.UV4Kind
  22950. * - VertexBuffer.UV5Kind
  22951. * - VertexBuffer.UV6Kind
  22952. * - VertexBuffer.ColorKind
  22953. * - VertexBuffer.MatricesIndicesKind
  22954. * - VertexBuffer.MatricesIndicesExtraKind
  22955. * - VertexBuffer.MatricesWeightsKind
  22956. * - VertexBuffer.MatricesWeightsExtraKind
  22957. * @param data defines the data source
  22958. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22959. * @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)
  22960. */
  22961. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22962. /**
  22963. * Creates a new index buffer
  22964. * @param indices defines the indices to store in the index buffer
  22965. * @param totalVertices defines the total number of vertices (could be null)
  22966. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22967. */
  22968. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22969. }
  22970. /**
  22971. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22972. */
  22973. export class VertexData {
  22974. /**
  22975. * Mesh side orientation : usually the external or front surface
  22976. */
  22977. static readonly FRONTSIDE: number;
  22978. /**
  22979. * Mesh side orientation : usually the internal or back surface
  22980. */
  22981. static readonly BACKSIDE: number;
  22982. /**
  22983. * Mesh side orientation : both internal and external or front and back surfaces
  22984. */
  22985. static readonly DOUBLESIDE: number;
  22986. /**
  22987. * Mesh side orientation : by default, `FRONTSIDE`
  22988. */
  22989. static readonly DEFAULTSIDE: number;
  22990. /**
  22991. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22992. */
  22993. positions: Nullable<FloatArray>;
  22994. /**
  22995. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22996. */
  22997. normals: Nullable<FloatArray>;
  22998. /**
  22999. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23000. */
  23001. tangents: Nullable<FloatArray>;
  23002. /**
  23003. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23004. */
  23005. uvs: Nullable<FloatArray>;
  23006. /**
  23007. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23008. */
  23009. uvs2: Nullable<FloatArray>;
  23010. /**
  23011. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23012. */
  23013. uvs3: Nullable<FloatArray>;
  23014. /**
  23015. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23016. */
  23017. uvs4: Nullable<FloatArray>;
  23018. /**
  23019. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23020. */
  23021. uvs5: Nullable<FloatArray>;
  23022. /**
  23023. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23024. */
  23025. uvs6: Nullable<FloatArray>;
  23026. /**
  23027. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23028. */
  23029. colors: Nullable<FloatArray>;
  23030. /**
  23031. * 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).
  23032. */
  23033. matricesIndices: Nullable<FloatArray>;
  23034. /**
  23035. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23036. */
  23037. matricesWeights: Nullable<FloatArray>;
  23038. /**
  23039. * An array extending the number of possible indices
  23040. */
  23041. matricesIndicesExtra: Nullable<FloatArray>;
  23042. /**
  23043. * An array extending the number of possible weights when the number of indices is extended
  23044. */
  23045. matricesWeightsExtra: Nullable<FloatArray>;
  23046. /**
  23047. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23048. */
  23049. indices: Nullable<IndicesArray>;
  23050. /**
  23051. * Uses the passed data array to set the set the values for the specified kind of data
  23052. * @param data a linear array of floating numbers
  23053. * @param kind the type of data that is being set, eg positions, colors etc
  23054. */
  23055. set(data: FloatArray, kind: string): void;
  23056. /**
  23057. * Associates the vertexData to the passed Mesh.
  23058. * Sets it as updatable or not (default `false`)
  23059. * @param mesh the mesh the vertexData is applied to
  23060. * @param updatable when used and having the value true allows new data to update the vertexData
  23061. * @returns the VertexData
  23062. */
  23063. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23064. /**
  23065. * Associates the vertexData to the passed Geometry.
  23066. * Sets it as updatable or not (default `false`)
  23067. * @param geometry the geometry the vertexData is applied to
  23068. * @param updatable when used and having the value true allows new data to update the vertexData
  23069. * @returns VertexData
  23070. */
  23071. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23072. /**
  23073. * Updates the associated mesh
  23074. * @param mesh the mesh to be updated
  23075. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23076. * @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
  23077. * @returns VertexData
  23078. */
  23079. updateMesh(mesh: Mesh): VertexData;
  23080. /**
  23081. * Updates the associated geometry
  23082. * @param geometry the geometry to be updated
  23083. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23084. * @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
  23085. * @returns VertexData.
  23086. */
  23087. updateGeometry(geometry: Geometry): VertexData;
  23088. private _applyTo;
  23089. private _update;
  23090. /**
  23091. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23092. * @param matrix the transforming matrix
  23093. * @returns the VertexData
  23094. */
  23095. transform(matrix: Matrix): VertexData;
  23096. /**
  23097. * Merges the passed VertexData into the current one
  23098. * @param other the VertexData to be merged into the current one
  23099. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23100. * @returns the modified VertexData
  23101. */
  23102. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23103. private _mergeElement;
  23104. private _validate;
  23105. /**
  23106. * Serializes the VertexData
  23107. * @returns a serialized object
  23108. */
  23109. serialize(): any;
  23110. /**
  23111. * Extracts the vertexData from a mesh
  23112. * @param mesh the mesh from which to extract the VertexData
  23113. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23114. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23115. * @returns the object VertexData associated to the passed mesh
  23116. */
  23117. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23118. /**
  23119. * Extracts the vertexData from the geometry
  23120. * @param geometry the geometry from which to extract the VertexData
  23121. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23122. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23123. * @returns the object VertexData associated to the passed mesh
  23124. */
  23125. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23126. private static _ExtractFrom;
  23127. /**
  23128. * Creates the VertexData for a Ribbon
  23129. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23130. * * pathArray array of paths, each of which an array of successive Vector3
  23131. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23132. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23133. * * 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
  23134. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23135. * * 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)
  23136. * * 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)
  23137. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23138. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23139. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23140. * @returns the VertexData of the ribbon
  23141. */
  23142. static CreateRibbon(options: {
  23143. pathArray: Vector3[][];
  23144. closeArray?: boolean;
  23145. closePath?: boolean;
  23146. offset?: number;
  23147. sideOrientation?: number;
  23148. frontUVs?: Vector4;
  23149. backUVs?: Vector4;
  23150. invertUV?: boolean;
  23151. uvs?: Vector2[];
  23152. colors?: Color4[];
  23153. }): VertexData;
  23154. /**
  23155. * Creates the VertexData for a box
  23156. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23157. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23158. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23159. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23160. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23161. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23162. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23163. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23164. * * 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)
  23165. * * 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)
  23166. * @returns the VertexData of the box
  23167. */
  23168. static CreateBox(options: {
  23169. size?: number;
  23170. width?: number;
  23171. height?: number;
  23172. depth?: number;
  23173. faceUV?: Vector4[];
  23174. faceColors?: Color4[];
  23175. sideOrientation?: number;
  23176. frontUVs?: Vector4;
  23177. backUVs?: Vector4;
  23178. }): VertexData;
  23179. /**
  23180. * Creates the VertexData for a tiled box
  23181. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23182. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23183. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23184. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23186. * @returns the VertexData of the box
  23187. */
  23188. static CreateTiledBox(options: {
  23189. pattern?: number;
  23190. width?: number;
  23191. height?: number;
  23192. depth?: number;
  23193. tileSize?: number;
  23194. tileWidth?: number;
  23195. tileHeight?: number;
  23196. alignHorizontal?: number;
  23197. alignVertical?: number;
  23198. faceUV?: Vector4[];
  23199. faceColors?: Color4[];
  23200. sideOrientation?: number;
  23201. }): VertexData;
  23202. /**
  23203. * Creates the VertexData for a tiled plane
  23204. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23205. * * pattern a limited pattern arrangement depending on the number
  23206. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23207. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23208. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23210. * * 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)
  23211. * * 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)
  23212. * @returns the VertexData of the tiled plane
  23213. */
  23214. static CreateTiledPlane(options: {
  23215. pattern?: number;
  23216. tileSize?: number;
  23217. tileWidth?: number;
  23218. tileHeight?: number;
  23219. size?: number;
  23220. width?: number;
  23221. height?: number;
  23222. alignHorizontal?: number;
  23223. alignVertical?: number;
  23224. sideOrientation?: number;
  23225. frontUVs?: Vector4;
  23226. backUVs?: Vector4;
  23227. }): VertexData;
  23228. /**
  23229. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23230. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23231. * * segments sets the number of horizontal strips optional, default 32
  23232. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23233. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23234. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23235. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23236. * * 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
  23237. * * 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
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * 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)
  23240. * * 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)
  23241. * @returns the VertexData of the ellipsoid
  23242. */
  23243. static CreateSphere(options: {
  23244. segments?: number;
  23245. diameter?: number;
  23246. diameterX?: number;
  23247. diameterY?: number;
  23248. diameterZ?: number;
  23249. arc?: number;
  23250. slice?: number;
  23251. sideOrientation?: number;
  23252. frontUVs?: Vector4;
  23253. backUVs?: Vector4;
  23254. }): VertexData;
  23255. /**
  23256. * Creates the VertexData for a cylinder, cone or prism
  23257. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23258. * * height sets the height (y direction) of the cylinder, optional, default 2
  23259. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23260. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23261. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23262. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23263. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23264. * * 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
  23265. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23266. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23267. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23268. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23270. * * 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)
  23271. * * 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)
  23272. * @returns the VertexData of the cylinder, cone or prism
  23273. */
  23274. static CreateCylinder(options: {
  23275. height?: number;
  23276. diameterTop?: number;
  23277. diameterBottom?: number;
  23278. diameter?: number;
  23279. tessellation?: number;
  23280. subdivisions?: number;
  23281. arc?: number;
  23282. faceColors?: Color4[];
  23283. faceUV?: Vector4[];
  23284. hasRings?: boolean;
  23285. enclose?: boolean;
  23286. sideOrientation?: number;
  23287. frontUVs?: Vector4;
  23288. backUVs?: Vector4;
  23289. }): VertexData;
  23290. /**
  23291. * Creates the VertexData for a torus
  23292. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23293. * * diameter the diameter of the torus, optional default 1
  23294. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23295. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23297. * * 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)
  23298. * * 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)
  23299. * @returns the VertexData of the torus
  23300. */
  23301. static CreateTorus(options: {
  23302. diameter?: number;
  23303. thickness?: number;
  23304. tessellation?: number;
  23305. sideOrientation?: number;
  23306. frontUVs?: Vector4;
  23307. backUVs?: Vector4;
  23308. }): VertexData;
  23309. /**
  23310. * Creates the VertexData of the LineSystem
  23311. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23312. * - lines an array of lines, each line being an array of successive Vector3
  23313. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23314. * @returns the VertexData of the LineSystem
  23315. */
  23316. static CreateLineSystem(options: {
  23317. lines: Vector3[][];
  23318. colors?: Nullable<Color4[][]>;
  23319. }): VertexData;
  23320. /**
  23321. * Create the VertexData for a DashedLines
  23322. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23323. * - points an array successive Vector3
  23324. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23325. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23326. * - dashNb the intended total number of dashes, optional, default 200
  23327. * @returns the VertexData for the DashedLines
  23328. */
  23329. static CreateDashedLines(options: {
  23330. points: Vector3[];
  23331. dashSize?: number;
  23332. gapSize?: number;
  23333. dashNb?: number;
  23334. }): VertexData;
  23335. /**
  23336. * Creates the VertexData for a Ground
  23337. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23338. * - width the width (x direction) of the ground, optional, default 1
  23339. * - height the height (z direction) of the ground, optional, default 1
  23340. * - subdivisions the number of subdivisions per side, optional, default 1
  23341. * @returns the VertexData of the Ground
  23342. */
  23343. static CreateGround(options: {
  23344. width?: number;
  23345. height?: number;
  23346. subdivisions?: number;
  23347. subdivisionsX?: number;
  23348. subdivisionsY?: number;
  23349. }): VertexData;
  23350. /**
  23351. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23352. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23353. * * xmin the ground minimum X coordinate, optional, default -1
  23354. * * zmin the ground minimum Z coordinate, optional, default -1
  23355. * * xmax the ground maximum X coordinate, optional, default 1
  23356. * * zmax the ground maximum Z coordinate, optional, default 1
  23357. * * 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}
  23358. * * 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}
  23359. * @returns the VertexData of the TiledGround
  23360. */
  23361. static CreateTiledGround(options: {
  23362. xmin: number;
  23363. zmin: number;
  23364. xmax: number;
  23365. zmax: number;
  23366. subdivisions?: {
  23367. w: number;
  23368. h: number;
  23369. };
  23370. precision?: {
  23371. w: number;
  23372. h: number;
  23373. };
  23374. }): VertexData;
  23375. /**
  23376. * Creates the VertexData of the Ground designed from a heightmap
  23377. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23378. * * width the width (x direction) of the ground
  23379. * * height the height (z direction) of the ground
  23380. * * subdivisions the number of subdivisions per side
  23381. * * minHeight the minimum altitude on the ground, optional, default 0
  23382. * * maxHeight the maximum altitude on the ground, optional default 1
  23383. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23384. * * buffer the array holding the image color data
  23385. * * bufferWidth the width of image
  23386. * * bufferHeight the height of image
  23387. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23388. * @returns the VertexData of the Ground designed from a heightmap
  23389. */
  23390. static CreateGroundFromHeightMap(options: {
  23391. width: number;
  23392. height: number;
  23393. subdivisions: number;
  23394. minHeight: number;
  23395. maxHeight: number;
  23396. colorFilter: Color3;
  23397. buffer: Uint8Array;
  23398. bufferWidth: number;
  23399. bufferHeight: number;
  23400. alphaFilter: number;
  23401. }): VertexData;
  23402. /**
  23403. * Creates the VertexData for a Plane
  23404. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23405. * * size sets the width and height of the plane to the value of size, optional default 1
  23406. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23407. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23408. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23409. * * 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)
  23410. * * 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)
  23411. * @returns the VertexData of the box
  23412. */
  23413. static CreatePlane(options: {
  23414. size?: number;
  23415. width?: number;
  23416. height?: number;
  23417. sideOrientation?: number;
  23418. frontUVs?: Vector4;
  23419. backUVs?: Vector4;
  23420. }): VertexData;
  23421. /**
  23422. * Creates the VertexData of the Disc or regular Polygon
  23423. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23424. * * radius the radius of the disc, optional default 0.5
  23425. * * tessellation the number of polygon sides, optional, default 64
  23426. * * 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
  23427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23428. * * 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)
  23429. * * 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)
  23430. * @returns the VertexData of the box
  23431. */
  23432. static CreateDisc(options: {
  23433. radius?: number;
  23434. tessellation?: number;
  23435. arc?: number;
  23436. sideOrientation?: number;
  23437. frontUVs?: Vector4;
  23438. backUVs?: Vector4;
  23439. }): VertexData;
  23440. /**
  23441. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23442. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23443. * @param polygon a mesh built from polygonTriangulation.build()
  23444. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23445. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23446. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23447. * @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)
  23448. * @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)
  23449. * @returns the VertexData of the Polygon
  23450. */
  23451. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23452. /**
  23453. * Creates the VertexData of the IcoSphere
  23454. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23455. * * radius the radius of the IcoSphere, optional default 1
  23456. * * radiusX allows stretching in the x direction, optional, default radius
  23457. * * radiusY allows stretching in the y direction, optional, default radius
  23458. * * radiusZ allows stretching in the z direction, optional, default radius
  23459. * * flat when true creates a flat shaded mesh, optional, default true
  23460. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23462. * * 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)
  23463. * * 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)
  23464. * @returns the VertexData of the IcoSphere
  23465. */
  23466. static CreateIcoSphere(options: {
  23467. radius?: number;
  23468. radiusX?: number;
  23469. radiusY?: number;
  23470. radiusZ?: number;
  23471. flat?: boolean;
  23472. subdivisions?: number;
  23473. sideOrientation?: number;
  23474. frontUVs?: Vector4;
  23475. backUVs?: Vector4;
  23476. }): VertexData;
  23477. /**
  23478. * Creates the VertexData for a Polyhedron
  23479. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23480. * * type provided types are:
  23481. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23482. * * 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)
  23483. * * size the size of the IcoSphere, optional default 1
  23484. * * sizeX allows stretching in the x direction, optional, default size
  23485. * * sizeY allows stretching in the y direction, optional, default size
  23486. * * sizeZ allows stretching in the z direction, optional, default size
  23487. * * 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
  23488. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23489. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23490. * * flat when true creates a flat shaded mesh, optional, default true
  23491. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23493. * * 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)
  23494. * * 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)
  23495. * @returns the VertexData of the Polyhedron
  23496. */
  23497. static CreatePolyhedron(options: {
  23498. type?: number;
  23499. size?: number;
  23500. sizeX?: number;
  23501. sizeY?: number;
  23502. sizeZ?: number;
  23503. custom?: any;
  23504. faceUV?: Vector4[];
  23505. faceColors?: Color4[];
  23506. flat?: boolean;
  23507. sideOrientation?: number;
  23508. frontUVs?: Vector4;
  23509. backUVs?: Vector4;
  23510. }): VertexData;
  23511. /**
  23512. * Creates the VertexData for a TorusKnot
  23513. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23514. * * radius the radius of the torus knot, optional, default 2
  23515. * * tube the thickness of the tube, optional, default 0.5
  23516. * * radialSegments the number of sides on each tube segments, optional, default 32
  23517. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23518. * * p the number of windings around the z axis, optional, default 2
  23519. * * q the number of windings around the x axis, optional, default 3
  23520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23521. * * 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)
  23522. * * 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)
  23523. * @returns the VertexData of the Torus Knot
  23524. */
  23525. static CreateTorusKnot(options: {
  23526. radius?: number;
  23527. tube?: number;
  23528. radialSegments?: number;
  23529. tubularSegments?: number;
  23530. p?: number;
  23531. q?: number;
  23532. sideOrientation?: number;
  23533. frontUVs?: Vector4;
  23534. backUVs?: Vector4;
  23535. }): VertexData;
  23536. /**
  23537. * Compute normals for given positions and indices
  23538. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23539. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23540. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23541. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23542. * * facetNormals : optional array of facet normals (vector3)
  23543. * * facetPositions : optional array of facet positions (vector3)
  23544. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23545. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23546. * * bInfo : optional bounding info, required for facetPartitioning computation
  23547. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23548. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23549. * * useRightHandedSystem: optional boolean to for right handed system computation
  23550. * * depthSort : optional boolean to enable the facet depth sort computation
  23551. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23552. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23553. */
  23554. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23555. facetNormals?: any;
  23556. facetPositions?: any;
  23557. facetPartitioning?: any;
  23558. ratio?: number;
  23559. bInfo?: any;
  23560. bbSize?: Vector3;
  23561. subDiv?: any;
  23562. useRightHandedSystem?: boolean;
  23563. depthSort?: boolean;
  23564. distanceTo?: Vector3;
  23565. depthSortedFacets?: any;
  23566. }): void;
  23567. /** @hidden */
  23568. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23569. /**
  23570. * Applies VertexData created from the imported parameters to the geometry
  23571. * @param parsedVertexData the parsed data from an imported file
  23572. * @param geometry the geometry to apply the VertexData to
  23573. */
  23574. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23575. }
  23576. }
  23577. declare module "babylonjs/Morph/morphTarget" {
  23578. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23579. import { Observable } from "babylonjs/Misc/observable";
  23580. import { Nullable, FloatArray } from "babylonjs/types";
  23581. import { Scene } from "babylonjs/scene";
  23582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23583. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23584. /**
  23585. * Defines a target to use with MorphTargetManager
  23586. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23587. */
  23588. export class MorphTarget implements IAnimatable {
  23589. /** defines the name of the target */
  23590. name: string;
  23591. /**
  23592. * Gets or sets the list of animations
  23593. */
  23594. animations: import("babylonjs/Animations/animation").Animation[];
  23595. private _scene;
  23596. private _positions;
  23597. private _normals;
  23598. private _tangents;
  23599. private _uvs;
  23600. private _influence;
  23601. private _uniqueId;
  23602. /**
  23603. * Observable raised when the influence changes
  23604. */
  23605. onInfluenceChanged: Observable<boolean>;
  23606. /** @hidden */
  23607. _onDataLayoutChanged: Observable<void>;
  23608. /**
  23609. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23610. */
  23611. get influence(): number;
  23612. set influence(influence: number);
  23613. /**
  23614. * Gets or sets the id of the morph Target
  23615. */
  23616. id: string;
  23617. private _animationPropertiesOverride;
  23618. /**
  23619. * Gets or sets the animation properties override
  23620. */
  23621. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23622. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23623. /**
  23624. * Creates a new MorphTarget
  23625. * @param name defines the name of the target
  23626. * @param influence defines the influence to use
  23627. * @param scene defines the scene the morphtarget belongs to
  23628. */
  23629. constructor(
  23630. /** defines the name of the target */
  23631. name: string, influence?: number, scene?: Nullable<Scene>);
  23632. /**
  23633. * Gets the unique ID of this manager
  23634. */
  23635. get uniqueId(): number;
  23636. /**
  23637. * Gets a boolean defining if the target contains position data
  23638. */
  23639. get hasPositions(): boolean;
  23640. /**
  23641. * Gets a boolean defining if the target contains normal data
  23642. */
  23643. get hasNormals(): boolean;
  23644. /**
  23645. * Gets a boolean defining if the target contains tangent data
  23646. */
  23647. get hasTangents(): boolean;
  23648. /**
  23649. * Gets a boolean defining if the target contains texture coordinates data
  23650. */
  23651. get hasUVs(): boolean;
  23652. /**
  23653. * Affects position data to this target
  23654. * @param data defines the position data to use
  23655. */
  23656. setPositions(data: Nullable<FloatArray>): void;
  23657. /**
  23658. * Gets the position data stored in this target
  23659. * @returns a FloatArray containing the position data (or null if not present)
  23660. */
  23661. getPositions(): Nullable<FloatArray>;
  23662. /**
  23663. * Affects normal data to this target
  23664. * @param data defines the normal data to use
  23665. */
  23666. setNormals(data: Nullable<FloatArray>): void;
  23667. /**
  23668. * Gets the normal data stored in this target
  23669. * @returns a FloatArray containing the normal data (or null if not present)
  23670. */
  23671. getNormals(): Nullable<FloatArray>;
  23672. /**
  23673. * Affects tangent data to this target
  23674. * @param data defines the tangent data to use
  23675. */
  23676. setTangents(data: Nullable<FloatArray>): void;
  23677. /**
  23678. * Gets the tangent data stored in this target
  23679. * @returns a FloatArray containing the tangent data (or null if not present)
  23680. */
  23681. getTangents(): Nullable<FloatArray>;
  23682. /**
  23683. * Affects texture coordinates data to this target
  23684. * @param data defines the texture coordinates data to use
  23685. */
  23686. setUVs(data: Nullable<FloatArray>): void;
  23687. /**
  23688. * Gets the texture coordinates data stored in this target
  23689. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23690. */
  23691. getUVs(): Nullable<FloatArray>;
  23692. /**
  23693. * Clone the current target
  23694. * @returns a new MorphTarget
  23695. */
  23696. clone(): MorphTarget;
  23697. /**
  23698. * Serializes the current target into a Serialization object
  23699. * @returns the serialized object
  23700. */
  23701. serialize(): any;
  23702. /**
  23703. * Returns the string "MorphTarget"
  23704. * @returns "MorphTarget"
  23705. */
  23706. getClassName(): string;
  23707. /**
  23708. * Creates a new target from serialized data
  23709. * @param serializationObject defines the serialized data to use
  23710. * @returns a new MorphTarget
  23711. */
  23712. static Parse(serializationObject: any): MorphTarget;
  23713. /**
  23714. * Creates a MorphTarget from mesh data
  23715. * @param mesh defines the source mesh
  23716. * @param name defines the name to use for the new target
  23717. * @param influence defines the influence to attach to the target
  23718. * @returns a new MorphTarget
  23719. */
  23720. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23721. }
  23722. }
  23723. declare module "babylonjs/Morph/morphTargetManager" {
  23724. import { Nullable } from "babylonjs/types";
  23725. import { Scene } from "babylonjs/scene";
  23726. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23727. /**
  23728. * This class is used to deform meshes using morphing between different targets
  23729. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23730. */
  23731. export class MorphTargetManager {
  23732. private _targets;
  23733. private _targetInfluenceChangedObservers;
  23734. private _targetDataLayoutChangedObservers;
  23735. private _activeTargets;
  23736. private _scene;
  23737. private _influences;
  23738. private _supportsNormals;
  23739. private _supportsTangents;
  23740. private _supportsUVs;
  23741. private _vertexCount;
  23742. private _uniqueId;
  23743. private _tempInfluences;
  23744. /**
  23745. * Gets or sets a boolean indicating if normals must be morphed
  23746. */
  23747. enableNormalMorphing: boolean;
  23748. /**
  23749. * Gets or sets a boolean indicating if tangents must be morphed
  23750. */
  23751. enableTangentMorphing: boolean;
  23752. /**
  23753. * Gets or sets a boolean indicating if UV must be morphed
  23754. */
  23755. enableUVMorphing: boolean;
  23756. /**
  23757. * Creates a new MorphTargetManager
  23758. * @param scene defines the current scene
  23759. */
  23760. constructor(scene?: Nullable<Scene>);
  23761. /**
  23762. * Gets the unique ID of this manager
  23763. */
  23764. get uniqueId(): number;
  23765. /**
  23766. * Gets the number of vertices handled by this manager
  23767. */
  23768. get vertexCount(): number;
  23769. /**
  23770. * Gets a boolean indicating if this manager supports morphing of normals
  23771. */
  23772. get supportsNormals(): boolean;
  23773. /**
  23774. * Gets a boolean indicating if this manager supports morphing of tangents
  23775. */
  23776. get supportsTangents(): boolean;
  23777. /**
  23778. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23779. */
  23780. get supportsUVs(): boolean;
  23781. /**
  23782. * Gets the number of targets stored in this manager
  23783. */
  23784. get numTargets(): number;
  23785. /**
  23786. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23787. */
  23788. get numInfluencers(): number;
  23789. /**
  23790. * Gets the list of influences (one per target)
  23791. */
  23792. get influences(): Float32Array;
  23793. /**
  23794. * Gets the active target at specified index. An active target is a target with an influence > 0
  23795. * @param index defines the index to check
  23796. * @returns the requested target
  23797. */
  23798. getActiveTarget(index: number): MorphTarget;
  23799. /**
  23800. * Gets the target at specified index
  23801. * @param index defines the index to check
  23802. * @returns the requested target
  23803. */
  23804. getTarget(index: number): MorphTarget;
  23805. /**
  23806. * Add a new target to this manager
  23807. * @param target defines the target to add
  23808. */
  23809. addTarget(target: MorphTarget): void;
  23810. /**
  23811. * Removes a target from the manager
  23812. * @param target defines the target to remove
  23813. */
  23814. removeTarget(target: MorphTarget): void;
  23815. /**
  23816. * Clone the current manager
  23817. * @returns a new MorphTargetManager
  23818. */
  23819. clone(): MorphTargetManager;
  23820. /**
  23821. * Serializes the current manager into a Serialization object
  23822. * @returns the serialized object
  23823. */
  23824. serialize(): any;
  23825. private _syncActiveTargets;
  23826. /**
  23827. * Syncrhonize the targets with all the meshes using this morph target manager
  23828. */
  23829. synchronize(): void;
  23830. /**
  23831. * Creates a new MorphTargetManager from serialized data
  23832. * @param serializationObject defines the serialized data
  23833. * @param scene defines the hosting scene
  23834. * @returns the new MorphTargetManager
  23835. */
  23836. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23837. }
  23838. }
  23839. declare module "babylonjs/Meshes/meshLODLevel" {
  23840. import { Mesh } from "babylonjs/Meshes/mesh";
  23841. import { Nullable } from "babylonjs/types";
  23842. /**
  23843. * Class used to represent a specific level of detail of a mesh
  23844. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23845. */
  23846. export class MeshLODLevel {
  23847. /** Defines the distance where this level should start being displayed */
  23848. distance: number;
  23849. /** Defines the mesh to use to render this level */
  23850. mesh: Nullable<Mesh>;
  23851. /**
  23852. * Creates a new LOD level
  23853. * @param distance defines the distance where this level should star being displayed
  23854. * @param mesh defines the mesh to use to render this level
  23855. */
  23856. constructor(
  23857. /** Defines the distance where this level should start being displayed */
  23858. distance: number,
  23859. /** Defines the mesh to use to render this level */
  23860. mesh: Nullable<Mesh>);
  23861. }
  23862. }
  23863. declare module "babylonjs/Meshes/groundMesh" {
  23864. import { Scene } from "babylonjs/scene";
  23865. import { Vector3 } from "babylonjs/Maths/math.vector";
  23866. import { Mesh } from "babylonjs/Meshes/mesh";
  23867. /**
  23868. * Mesh representing the gorund
  23869. */
  23870. export class GroundMesh extends Mesh {
  23871. /** If octree should be generated */
  23872. generateOctree: boolean;
  23873. private _heightQuads;
  23874. /** @hidden */
  23875. _subdivisionsX: number;
  23876. /** @hidden */
  23877. _subdivisionsY: number;
  23878. /** @hidden */
  23879. _width: number;
  23880. /** @hidden */
  23881. _height: number;
  23882. /** @hidden */
  23883. _minX: number;
  23884. /** @hidden */
  23885. _maxX: number;
  23886. /** @hidden */
  23887. _minZ: number;
  23888. /** @hidden */
  23889. _maxZ: number;
  23890. constructor(name: string, scene: Scene);
  23891. /**
  23892. * "GroundMesh"
  23893. * @returns "GroundMesh"
  23894. */
  23895. getClassName(): string;
  23896. /**
  23897. * The minimum of x and y subdivisions
  23898. */
  23899. get subdivisions(): number;
  23900. /**
  23901. * X subdivisions
  23902. */
  23903. get subdivisionsX(): number;
  23904. /**
  23905. * Y subdivisions
  23906. */
  23907. get subdivisionsY(): number;
  23908. /**
  23909. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23910. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23911. * @param chunksCount the number of subdivisions for x and y
  23912. * @param octreeBlocksSize (Default: 32)
  23913. */
  23914. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23915. /**
  23916. * Returns a height (y) value in the Worl system :
  23917. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23918. * @param x x coordinate
  23919. * @param z z coordinate
  23920. * @returns the ground y position if (x, z) are outside the ground surface.
  23921. */
  23922. getHeightAtCoordinates(x: number, z: number): number;
  23923. /**
  23924. * Returns a normalized vector (Vector3) orthogonal to the ground
  23925. * at the ground coordinates (x, z) expressed in the World system.
  23926. * @param x x coordinate
  23927. * @param z z coordinate
  23928. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23929. */
  23930. getNormalAtCoordinates(x: number, z: number): Vector3;
  23931. /**
  23932. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23933. * at the ground coordinates (x, z) expressed in the World system.
  23934. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23935. * @param x x coordinate
  23936. * @param z z coordinate
  23937. * @param ref vector to store the result
  23938. * @returns the GroundMesh.
  23939. */
  23940. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23941. /**
  23942. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23943. * if the ground has been updated.
  23944. * This can be used in the render loop.
  23945. * @returns the GroundMesh.
  23946. */
  23947. updateCoordinateHeights(): GroundMesh;
  23948. private _getFacetAt;
  23949. private _initHeightQuads;
  23950. private _computeHeightQuads;
  23951. /**
  23952. * Serializes this ground mesh
  23953. * @param serializationObject object to write serialization to
  23954. */
  23955. serialize(serializationObject: any): void;
  23956. /**
  23957. * Parses a serialized ground mesh
  23958. * @param parsedMesh the serialized mesh
  23959. * @param scene the scene to create the ground mesh in
  23960. * @returns the created ground mesh
  23961. */
  23962. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23963. }
  23964. }
  23965. declare module "babylonjs/Physics/physicsJoint" {
  23966. import { Vector3 } from "babylonjs/Maths/math.vector";
  23967. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23968. /**
  23969. * Interface for Physics-Joint data
  23970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23971. */
  23972. export interface PhysicsJointData {
  23973. /**
  23974. * The main pivot of the joint
  23975. */
  23976. mainPivot?: Vector3;
  23977. /**
  23978. * The connected pivot of the joint
  23979. */
  23980. connectedPivot?: Vector3;
  23981. /**
  23982. * The main axis of the joint
  23983. */
  23984. mainAxis?: Vector3;
  23985. /**
  23986. * The connected axis of the joint
  23987. */
  23988. connectedAxis?: Vector3;
  23989. /**
  23990. * The collision of the joint
  23991. */
  23992. collision?: boolean;
  23993. /**
  23994. * Native Oimo/Cannon/Energy data
  23995. */
  23996. nativeParams?: any;
  23997. }
  23998. /**
  23999. * This is a holder class for the physics joint created by the physics plugin
  24000. * It holds a set of functions to control the underlying joint
  24001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24002. */
  24003. export class PhysicsJoint {
  24004. /**
  24005. * The type of the physics joint
  24006. */
  24007. type: number;
  24008. /**
  24009. * The data for the physics joint
  24010. */
  24011. jointData: PhysicsJointData;
  24012. private _physicsJoint;
  24013. protected _physicsPlugin: IPhysicsEnginePlugin;
  24014. /**
  24015. * Initializes the physics joint
  24016. * @param type The type of the physics joint
  24017. * @param jointData The data for the physics joint
  24018. */
  24019. constructor(
  24020. /**
  24021. * The type of the physics joint
  24022. */
  24023. type: number,
  24024. /**
  24025. * The data for the physics joint
  24026. */
  24027. jointData: PhysicsJointData);
  24028. /**
  24029. * Gets the physics joint
  24030. */
  24031. get physicsJoint(): any;
  24032. /**
  24033. * Sets the physics joint
  24034. */
  24035. set physicsJoint(newJoint: any);
  24036. /**
  24037. * Sets the physics plugin
  24038. */
  24039. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  24040. /**
  24041. * Execute a function that is physics-plugin specific.
  24042. * @param {Function} func the function that will be executed.
  24043. * It accepts two parameters: the physics world and the physics joint
  24044. */
  24045. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  24046. /**
  24047. * Distance-Joint type
  24048. */
  24049. static DistanceJoint: number;
  24050. /**
  24051. * Hinge-Joint type
  24052. */
  24053. static HingeJoint: number;
  24054. /**
  24055. * Ball-and-Socket joint type
  24056. */
  24057. static BallAndSocketJoint: number;
  24058. /**
  24059. * Wheel-Joint type
  24060. */
  24061. static WheelJoint: number;
  24062. /**
  24063. * Slider-Joint type
  24064. */
  24065. static SliderJoint: number;
  24066. /**
  24067. * Prismatic-Joint type
  24068. */
  24069. static PrismaticJoint: number;
  24070. /**
  24071. * Universal-Joint type
  24072. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  24073. */
  24074. static UniversalJoint: number;
  24075. /**
  24076. * Hinge-Joint 2 type
  24077. */
  24078. static Hinge2Joint: number;
  24079. /**
  24080. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  24081. */
  24082. static PointToPointJoint: number;
  24083. /**
  24084. * Spring-Joint type
  24085. */
  24086. static SpringJoint: number;
  24087. /**
  24088. * Lock-Joint type
  24089. */
  24090. static LockJoint: number;
  24091. }
  24092. /**
  24093. * A class representing a physics distance joint
  24094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24095. */
  24096. export class DistanceJoint extends PhysicsJoint {
  24097. /**
  24098. *
  24099. * @param jointData The data for the Distance-Joint
  24100. */
  24101. constructor(jointData: DistanceJointData);
  24102. /**
  24103. * Update the predefined distance.
  24104. * @param maxDistance The maximum preferred distance
  24105. * @param minDistance The minimum preferred distance
  24106. */
  24107. updateDistance(maxDistance: number, minDistance?: number): void;
  24108. }
  24109. /**
  24110. * Represents a Motor-Enabled Joint
  24111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24112. */
  24113. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  24114. /**
  24115. * Initializes the Motor-Enabled Joint
  24116. * @param type The type of the joint
  24117. * @param jointData The physica joint data for the joint
  24118. */
  24119. constructor(type: number, jointData: PhysicsJointData);
  24120. /**
  24121. * Set the motor values.
  24122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24123. * @param force the force to apply
  24124. * @param maxForce max force for this motor.
  24125. */
  24126. setMotor(force?: number, maxForce?: number): void;
  24127. /**
  24128. * Set the motor's limits.
  24129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24130. * @param upperLimit The upper limit of the motor
  24131. * @param lowerLimit The lower limit of the motor
  24132. */
  24133. setLimit(upperLimit: number, lowerLimit?: number): void;
  24134. }
  24135. /**
  24136. * This class represents a single physics Hinge-Joint
  24137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24138. */
  24139. export class HingeJoint extends MotorEnabledJoint {
  24140. /**
  24141. * Initializes the Hinge-Joint
  24142. * @param jointData The joint data for the Hinge-Joint
  24143. */
  24144. constructor(jointData: PhysicsJointData);
  24145. /**
  24146. * Set the motor values.
  24147. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24148. * @param {number} force the force to apply
  24149. * @param {number} maxForce max force for this motor.
  24150. */
  24151. setMotor(force?: number, maxForce?: number): void;
  24152. /**
  24153. * Set the motor's limits.
  24154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24155. * @param upperLimit The upper limit of the motor
  24156. * @param lowerLimit The lower limit of the motor
  24157. */
  24158. setLimit(upperLimit: number, lowerLimit?: number): void;
  24159. }
  24160. /**
  24161. * This class represents a dual hinge physics joint (same as wheel joint)
  24162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24163. */
  24164. export class Hinge2Joint extends MotorEnabledJoint {
  24165. /**
  24166. * Initializes the Hinge2-Joint
  24167. * @param jointData The joint data for the Hinge2-Joint
  24168. */
  24169. constructor(jointData: PhysicsJointData);
  24170. /**
  24171. * Set the motor values.
  24172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24173. * @param {number} targetSpeed the speed the motor is to reach
  24174. * @param {number} maxForce max force for this motor.
  24175. * @param {motorIndex} the motor's index, 0 or 1.
  24176. */
  24177. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  24178. /**
  24179. * Set the motor limits.
  24180. * Attention, this function is plugin specific. Engines won't react 100% the same.
  24181. * @param {number} upperLimit the upper limit
  24182. * @param {number} lowerLimit lower limit
  24183. * @param {motorIndex} the motor's index, 0 or 1.
  24184. */
  24185. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24186. }
  24187. /**
  24188. * Interface for a motor enabled joint
  24189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24190. */
  24191. export interface IMotorEnabledJoint {
  24192. /**
  24193. * Physics joint
  24194. */
  24195. physicsJoint: any;
  24196. /**
  24197. * Sets the motor of the motor-enabled joint
  24198. * @param force The force of the motor
  24199. * @param maxForce The maximum force of the motor
  24200. * @param motorIndex The index of the motor
  24201. */
  24202. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  24203. /**
  24204. * Sets the limit of the motor
  24205. * @param upperLimit The upper limit of the motor
  24206. * @param lowerLimit The lower limit of the motor
  24207. * @param motorIndex The index of the motor
  24208. */
  24209. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24210. }
  24211. /**
  24212. * Joint data for a Distance-Joint
  24213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24214. */
  24215. export interface DistanceJointData extends PhysicsJointData {
  24216. /**
  24217. * Max distance the 2 joint objects can be apart
  24218. */
  24219. maxDistance: number;
  24220. }
  24221. /**
  24222. * Joint data from a spring joint
  24223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24224. */
  24225. export interface SpringJointData extends PhysicsJointData {
  24226. /**
  24227. * Length of the spring
  24228. */
  24229. length: number;
  24230. /**
  24231. * Stiffness of the spring
  24232. */
  24233. stiffness: number;
  24234. /**
  24235. * Damping of the spring
  24236. */
  24237. damping: number;
  24238. /** this callback will be called when applying the force to the impostors. */
  24239. forceApplicationCallback: () => void;
  24240. }
  24241. }
  24242. declare module "babylonjs/Physics/physicsRaycastResult" {
  24243. import { Vector3 } from "babylonjs/Maths/math.vector";
  24244. /**
  24245. * Holds the data for the raycast result
  24246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24247. */
  24248. export class PhysicsRaycastResult {
  24249. private _hasHit;
  24250. private _hitDistance;
  24251. private _hitNormalWorld;
  24252. private _hitPointWorld;
  24253. private _rayFromWorld;
  24254. private _rayToWorld;
  24255. /**
  24256. * Gets if there was a hit
  24257. */
  24258. get hasHit(): boolean;
  24259. /**
  24260. * Gets the distance from the hit
  24261. */
  24262. get hitDistance(): number;
  24263. /**
  24264. * Gets the hit normal/direction in the world
  24265. */
  24266. get hitNormalWorld(): Vector3;
  24267. /**
  24268. * Gets the hit point in the world
  24269. */
  24270. get hitPointWorld(): Vector3;
  24271. /**
  24272. * Gets the ray "start point" of the ray in the world
  24273. */
  24274. get rayFromWorld(): Vector3;
  24275. /**
  24276. * Gets the ray "end point" of the ray in the world
  24277. */
  24278. get rayToWorld(): Vector3;
  24279. /**
  24280. * Sets the hit data (normal & point in world space)
  24281. * @param hitNormalWorld defines the normal in world space
  24282. * @param hitPointWorld defines the point in world space
  24283. */
  24284. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24285. /**
  24286. * Sets the distance from the start point to the hit point
  24287. * @param distance
  24288. */
  24289. setHitDistance(distance: number): void;
  24290. /**
  24291. * Calculates the distance manually
  24292. */
  24293. calculateHitDistance(): void;
  24294. /**
  24295. * Resets all the values to default
  24296. * @param from The from point on world space
  24297. * @param to The to point on world space
  24298. */
  24299. reset(from?: Vector3, to?: Vector3): void;
  24300. }
  24301. /**
  24302. * Interface for the size containing width and height
  24303. */
  24304. interface IXYZ {
  24305. /**
  24306. * X
  24307. */
  24308. x: number;
  24309. /**
  24310. * Y
  24311. */
  24312. y: number;
  24313. /**
  24314. * Z
  24315. */
  24316. z: number;
  24317. }
  24318. }
  24319. declare module "babylonjs/Physics/IPhysicsEngine" {
  24320. import { Nullable } from "babylonjs/types";
  24321. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24323. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24324. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24325. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24326. /**
  24327. * Interface used to describe a physics joint
  24328. */
  24329. export interface PhysicsImpostorJoint {
  24330. /** Defines the main impostor to which the joint is linked */
  24331. mainImpostor: PhysicsImpostor;
  24332. /** Defines the impostor that is connected to the main impostor using this joint */
  24333. connectedImpostor: PhysicsImpostor;
  24334. /** Defines the joint itself */
  24335. joint: PhysicsJoint;
  24336. }
  24337. /** @hidden */
  24338. export interface IPhysicsEnginePlugin {
  24339. world: any;
  24340. name: string;
  24341. setGravity(gravity: Vector3): void;
  24342. setTimeStep(timeStep: number): void;
  24343. getTimeStep(): number;
  24344. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24345. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24346. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24347. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24348. removePhysicsBody(impostor: PhysicsImpostor): void;
  24349. generateJoint(joint: PhysicsImpostorJoint): void;
  24350. removeJoint(joint: PhysicsImpostorJoint): void;
  24351. isSupported(): boolean;
  24352. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24353. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24354. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24355. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24357. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24358. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24359. getBodyMass(impostor: PhysicsImpostor): number;
  24360. getBodyFriction(impostor: PhysicsImpostor): number;
  24361. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24362. getBodyRestitution(impostor: PhysicsImpostor): number;
  24363. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24364. getBodyPressure?(impostor: PhysicsImpostor): number;
  24365. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24366. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24367. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24368. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24369. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24370. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24371. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24372. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24373. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24374. sleepBody(impostor: PhysicsImpostor): void;
  24375. wakeUpBody(impostor: PhysicsImpostor): void;
  24376. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24377. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24378. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24379. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24380. getRadius(impostor: PhysicsImpostor): number;
  24381. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24382. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24383. dispose(): void;
  24384. }
  24385. /**
  24386. * Interface used to define a physics engine
  24387. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24388. */
  24389. export interface IPhysicsEngine {
  24390. /**
  24391. * Gets the gravity vector used by the simulation
  24392. */
  24393. gravity: Vector3;
  24394. /**
  24395. * Sets the gravity vector used by the simulation
  24396. * @param gravity defines the gravity vector to use
  24397. */
  24398. setGravity(gravity: Vector3): void;
  24399. /**
  24400. * Set the time step of the physics engine.
  24401. * Default is 1/60.
  24402. * To slow it down, enter 1/600 for example.
  24403. * To speed it up, 1/30
  24404. * @param newTimeStep the new timestep to apply to this world.
  24405. */
  24406. setTimeStep(newTimeStep: number): void;
  24407. /**
  24408. * Get the time step of the physics engine.
  24409. * @returns the current time step
  24410. */
  24411. getTimeStep(): number;
  24412. /**
  24413. * Set the sub time step of the physics engine.
  24414. * Default is 0 meaning there is no sub steps
  24415. * To increase physics resolution precision, set a small value (like 1 ms)
  24416. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24417. */
  24418. setSubTimeStep(subTimeStep: number): void;
  24419. /**
  24420. * Get the sub time step of the physics engine.
  24421. * @returns the current sub time step
  24422. */
  24423. getSubTimeStep(): number;
  24424. /**
  24425. * Release all resources
  24426. */
  24427. dispose(): void;
  24428. /**
  24429. * Gets the name of the current physics plugin
  24430. * @returns the name of the plugin
  24431. */
  24432. getPhysicsPluginName(): string;
  24433. /**
  24434. * Adding a new impostor for the impostor tracking.
  24435. * This will be done by the impostor itself.
  24436. * @param impostor the impostor to add
  24437. */
  24438. addImpostor(impostor: PhysicsImpostor): void;
  24439. /**
  24440. * Remove an impostor from the engine.
  24441. * This impostor and its mesh will not longer be updated by the physics engine.
  24442. * @param impostor the impostor to remove
  24443. */
  24444. removeImpostor(impostor: PhysicsImpostor): void;
  24445. /**
  24446. * Add a joint to the physics engine
  24447. * @param mainImpostor defines the main impostor to which the joint is added.
  24448. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24449. * @param joint defines the joint that will connect both impostors.
  24450. */
  24451. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24452. /**
  24453. * Removes a joint from the simulation
  24454. * @param mainImpostor defines the impostor used with the joint
  24455. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24456. * @param joint defines the joint to remove
  24457. */
  24458. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24459. /**
  24460. * Gets the current plugin used to run the simulation
  24461. * @returns current plugin
  24462. */
  24463. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24464. /**
  24465. * Gets the list of physic impostors
  24466. * @returns an array of PhysicsImpostor
  24467. */
  24468. getImpostors(): Array<PhysicsImpostor>;
  24469. /**
  24470. * Gets the impostor for a physics enabled object
  24471. * @param object defines the object impersonated by the impostor
  24472. * @returns the PhysicsImpostor or null if not found
  24473. */
  24474. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24475. /**
  24476. * Gets the impostor for a physics body object
  24477. * @param body defines physics body used by the impostor
  24478. * @returns the PhysicsImpostor or null if not found
  24479. */
  24480. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24481. /**
  24482. * Does a raycast in the physics world
  24483. * @param from when should the ray start?
  24484. * @param to when should the ray end?
  24485. * @returns PhysicsRaycastResult
  24486. */
  24487. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24488. /**
  24489. * Called by the scene. No need to call it.
  24490. * @param delta defines the timespam between frames
  24491. */
  24492. _step(delta: number): void;
  24493. }
  24494. }
  24495. declare module "babylonjs/Physics/physicsImpostor" {
  24496. import { Nullable, IndicesArray } from "babylonjs/types";
  24497. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24498. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24500. import { Scene } from "babylonjs/scene";
  24501. import { Bone } from "babylonjs/Bones/bone";
  24502. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24503. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24504. import { Space } from "babylonjs/Maths/math.axis";
  24505. /**
  24506. * The interface for the physics imposter parameters
  24507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24508. */
  24509. export interface PhysicsImpostorParameters {
  24510. /**
  24511. * The mass of the physics imposter
  24512. */
  24513. mass: number;
  24514. /**
  24515. * The friction of the physics imposter
  24516. */
  24517. friction?: number;
  24518. /**
  24519. * The coefficient of restitution of the physics imposter
  24520. */
  24521. restitution?: number;
  24522. /**
  24523. * The native options of the physics imposter
  24524. */
  24525. nativeOptions?: any;
  24526. /**
  24527. * Specifies if the parent should be ignored
  24528. */
  24529. ignoreParent?: boolean;
  24530. /**
  24531. * Specifies if bi-directional transformations should be disabled
  24532. */
  24533. disableBidirectionalTransformation?: boolean;
  24534. /**
  24535. * The pressure inside the physics imposter, soft object only
  24536. */
  24537. pressure?: number;
  24538. /**
  24539. * The stiffness the physics imposter, soft object only
  24540. */
  24541. stiffness?: number;
  24542. /**
  24543. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24544. */
  24545. velocityIterations?: number;
  24546. /**
  24547. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24548. */
  24549. positionIterations?: number;
  24550. /**
  24551. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24552. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24553. * Add to fix multiple points
  24554. */
  24555. fixedPoints?: number;
  24556. /**
  24557. * The collision margin around a soft object
  24558. */
  24559. margin?: number;
  24560. /**
  24561. * The collision margin around a soft object
  24562. */
  24563. damping?: number;
  24564. /**
  24565. * The path for a rope based on an extrusion
  24566. */
  24567. path?: any;
  24568. /**
  24569. * The shape of an extrusion used for a rope based on an extrusion
  24570. */
  24571. shape?: any;
  24572. }
  24573. /**
  24574. * Interface for a physics-enabled object
  24575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24576. */
  24577. export interface IPhysicsEnabledObject {
  24578. /**
  24579. * The position of the physics-enabled object
  24580. */
  24581. position: Vector3;
  24582. /**
  24583. * The rotation of the physics-enabled object
  24584. */
  24585. rotationQuaternion: Nullable<Quaternion>;
  24586. /**
  24587. * The scale of the physics-enabled object
  24588. */
  24589. scaling: Vector3;
  24590. /**
  24591. * The rotation of the physics-enabled object
  24592. */
  24593. rotation?: Vector3;
  24594. /**
  24595. * The parent of the physics-enabled object
  24596. */
  24597. parent?: any;
  24598. /**
  24599. * The bounding info of the physics-enabled object
  24600. * @returns The bounding info of the physics-enabled object
  24601. */
  24602. getBoundingInfo(): BoundingInfo;
  24603. /**
  24604. * Computes the world matrix
  24605. * @param force Specifies if the world matrix should be computed by force
  24606. * @returns A world matrix
  24607. */
  24608. computeWorldMatrix(force: boolean): Matrix;
  24609. /**
  24610. * Gets the world matrix
  24611. * @returns A world matrix
  24612. */
  24613. getWorldMatrix?(): Matrix;
  24614. /**
  24615. * Gets the child meshes
  24616. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24617. * @returns An array of abstract meshes
  24618. */
  24619. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24620. /**
  24621. * Gets the vertex data
  24622. * @param kind The type of vertex data
  24623. * @returns A nullable array of numbers, or a float32 array
  24624. */
  24625. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24626. /**
  24627. * Gets the indices from the mesh
  24628. * @returns A nullable array of index arrays
  24629. */
  24630. getIndices?(): Nullable<IndicesArray>;
  24631. /**
  24632. * Gets the scene from the mesh
  24633. * @returns the indices array or null
  24634. */
  24635. getScene?(): Scene;
  24636. /**
  24637. * Gets the absolute position from the mesh
  24638. * @returns the absolute position
  24639. */
  24640. getAbsolutePosition(): Vector3;
  24641. /**
  24642. * Gets the absolute pivot point from the mesh
  24643. * @returns the absolute pivot point
  24644. */
  24645. getAbsolutePivotPoint(): Vector3;
  24646. /**
  24647. * Rotates the mesh
  24648. * @param axis The axis of rotation
  24649. * @param amount The amount of rotation
  24650. * @param space The space of the rotation
  24651. * @returns The rotation transform node
  24652. */
  24653. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24654. /**
  24655. * Translates the mesh
  24656. * @param axis The axis of translation
  24657. * @param distance The distance of translation
  24658. * @param space The space of the translation
  24659. * @returns The transform node
  24660. */
  24661. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24662. /**
  24663. * Sets the absolute position of the mesh
  24664. * @param absolutePosition The absolute position of the mesh
  24665. * @returns The transform node
  24666. */
  24667. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24668. /**
  24669. * Gets the class name of the mesh
  24670. * @returns The class name
  24671. */
  24672. getClassName(): string;
  24673. }
  24674. /**
  24675. * Represents a physics imposter
  24676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24677. */
  24678. export class PhysicsImpostor {
  24679. /**
  24680. * The physics-enabled object used as the physics imposter
  24681. */
  24682. object: IPhysicsEnabledObject;
  24683. /**
  24684. * The type of the physics imposter
  24685. */
  24686. type: number;
  24687. private _options;
  24688. private _scene?;
  24689. /**
  24690. * The default object size of the imposter
  24691. */
  24692. static DEFAULT_OBJECT_SIZE: Vector3;
  24693. /**
  24694. * The identity quaternion of the imposter
  24695. */
  24696. static IDENTITY_QUATERNION: Quaternion;
  24697. /** @hidden */
  24698. _pluginData: any;
  24699. private _physicsEngine;
  24700. private _physicsBody;
  24701. private _bodyUpdateRequired;
  24702. private _onBeforePhysicsStepCallbacks;
  24703. private _onAfterPhysicsStepCallbacks;
  24704. /** @hidden */
  24705. _onPhysicsCollideCallbacks: Array<{
  24706. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24707. otherImpostors: Array<PhysicsImpostor>;
  24708. }>;
  24709. private _deltaPosition;
  24710. private _deltaRotation;
  24711. private _deltaRotationConjugated;
  24712. /** @hidden */
  24713. _isFromLine: boolean;
  24714. private _parent;
  24715. private _isDisposed;
  24716. private static _tmpVecs;
  24717. private static _tmpQuat;
  24718. /**
  24719. * Specifies if the physics imposter is disposed
  24720. */
  24721. get isDisposed(): boolean;
  24722. /**
  24723. * Gets the mass of the physics imposter
  24724. */
  24725. get mass(): number;
  24726. set mass(value: number);
  24727. /**
  24728. * Gets the coefficient of friction
  24729. */
  24730. get friction(): number;
  24731. /**
  24732. * Sets the coefficient of friction
  24733. */
  24734. set friction(value: number);
  24735. /**
  24736. * Gets the coefficient of restitution
  24737. */
  24738. get restitution(): number;
  24739. /**
  24740. * Sets the coefficient of restitution
  24741. */
  24742. set restitution(value: number);
  24743. /**
  24744. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24745. */
  24746. get pressure(): number;
  24747. /**
  24748. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24749. */
  24750. set pressure(value: number);
  24751. /**
  24752. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24753. */
  24754. get stiffness(): number;
  24755. /**
  24756. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24757. */
  24758. set stiffness(value: number);
  24759. /**
  24760. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24761. */
  24762. get velocityIterations(): number;
  24763. /**
  24764. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24765. */
  24766. set velocityIterations(value: number);
  24767. /**
  24768. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24769. */
  24770. get positionIterations(): number;
  24771. /**
  24772. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24773. */
  24774. set positionIterations(value: number);
  24775. /**
  24776. * The unique id of the physics imposter
  24777. * set by the physics engine when adding this impostor to the array
  24778. */
  24779. uniqueId: number;
  24780. /**
  24781. * @hidden
  24782. */
  24783. soft: boolean;
  24784. /**
  24785. * @hidden
  24786. */
  24787. segments: number;
  24788. private _joints;
  24789. /**
  24790. * Initializes the physics imposter
  24791. * @param object The physics-enabled object used as the physics imposter
  24792. * @param type The type of the physics imposter
  24793. * @param _options The options for the physics imposter
  24794. * @param _scene The Babylon scene
  24795. */
  24796. constructor(
  24797. /**
  24798. * The physics-enabled object used as the physics imposter
  24799. */
  24800. object: IPhysicsEnabledObject,
  24801. /**
  24802. * The type of the physics imposter
  24803. */
  24804. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24805. /**
  24806. * This function will completly initialize this impostor.
  24807. * It will create a new body - but only if this mesh has no parent.
  24808. * If it has, this impostor will not be used other than to define the impostor
  24809. * of the child mesh.
  24810. * @hidden
  24811. */
  24812. _init(): void;
  24813. private _getPhysicsParent;
  24814. /**
  24815. * Should a new body be generated.
  24816. * @returns boolean specifying if body initialization is required
  24817. */
  24818. isBodyInitRequired(): boolean;
  24819. /**
  24820. * Sets the updated scaling
  24821. * @param updated Specifies if the scaling is updated
  24822. */
  24823. setScalingUpdated(): void;
  24824. /**
  24825. * Force a regeneration of this or the parent's impostor's body.
  24826. * Use under cautious - This will remove all joints already implemented.
  24827. */
  24828. forceUpdate(): void;
  24829. /**
  24830. * Gets the body that holds this impostor. Either its own, or its parent.
  24831. */
  24832. get physicsBody(): any;
  24833. /**
  24834. * Get the parent of the physics imposter
  24835. * @returns Physics imposter or null
  24836. */
  24837. get parent(): Nullable<PhysicsImpostor>;
  24838. /**
  24839. * Sets the parent of the physics imposter
  24840. */
  24841. set parent(value: Nullable<PhysicsImpostor>);
  24842. /**
  24843. * Set the physics body. Used mainly by the physics engine/plugin
  24844. */
  24845. set physicsBody(physicsBody: any);
  24846. /**
  24847. * Resets the update flags
  24848. */
  24849. resetUpdateFlags(): void;
  24850. /**
  24851. * Gets the object extend size
  24852. * @returns the object extend size
  24853. */
  24854. getObjectExtendSize(): Vector3;
  24855. /**
  24856. * Gets the object center
  24857. * @returns The object center
  24858. */
  24859. getObjectCenter(): Vector3;
  24860. /**
  24861. * Get a specific parameter from the options parameters
  24862. * @param paramName The object parameter name
  24863. * @returns The object parameter
  24864. */
  24865. getParam(paramName: string): any;
  24866. /**
  24867. * Sets a specific parameter in the options given to the physics plugin
  24868. * @param paramName The parameter name
  24869. * @param value The value of the parameter
  24870. */
  24871. setParam(paramName: string, value: number): void;
  24872. /**
  24873. * Specifically change the body's mass option. Won't recreate the physics body object
  24874. * @param mass The mass of the physics imposter
  24875. */
  24876. setMass(mass: number): void;
  24877. /**
  24878. * Gets the linear velocity
  24879. * @returns linear velocity or null
  24880. */
  24881. getLinearVelocity(): Nullable<Vector3>;
  24882. /**
  24883. * Sets the linear velocity
  24884. * @param velocity linear velocity or null
  24885. */
  24886. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24887. /**
  24888. * Gets the angular velocity
  24889. * @returns angular velocity or null
  24890. */
  24891. getAngularVelocity(): Nullable<Vector3>;
  24892. /**
  24893. * Sets the angular velocity
  24894. * @param velocity The velocity or null
  24895. */
  24896. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24897. /**
  24898. * Execute a function with the physics plugin native code
  24899. * Provide a function the will have two variables - the world object and the physics body object
  24900. * @param func The function to execute with the physics plugin native code
  24901. */
  24902. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24903. /**
  24904. * Register a function that will be executed before the physics world is stepping forward
  24905. * @param func The function to execute before the physics world is stepped forward
  24906. */
  24907. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24908. /**
  24909. * Unregister a function that will be executed before the physics world is stepping forward
  24910. * @param func The function to execute before the physics world is stepped forward
  24911. */
  24912. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24913. /**
  24914. * Register a function that will be executed after the physics step
  24915. * @param func The function to execute after physics step
  24916. */
  24917. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24918. /**
  24919. * Unregisters a function that will be executed after the physics step
  24920. * @param func The function to execute after physics step
  24921. */
  24922. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24923. /**
  24924. * register a function that will be executed when this impostor collides against a different body
  24925. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24926. * @param func Callback that is executed on collision
  24927. */
  24928. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24929. /**
  24930. * Unregisters the physics imposter on contact
  24931. * @param collideAgainst The physics object to collide against
  24932. * @param func Callback to execute on collision
  24933. */
  24934. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24935. private _tmpQuat;
  24936. private _tmpQuat2;
  24937. /**
  24938. * Get the parent rotation
  24939. * @returns The parent rotation
  24940. */
  24941. getParentsRotation(): Quaternion;
  24942. /**
  24943. * this function is executed by the physics engine.
  24944. */
  24945. beforeStep: () => void;
  24946. /**
  24947. * this function is executed by the physics engine
  24948. */
  24949. afterStep: () => void;
  24950. /**
  24951. * Legacy collision detection event support
  24952. */
  24953. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24954. /**
  24955. * event and body object due to cannon's event-based architecture.
  24956. */
  24957. onCollide: (e: {
  24958. body: any;
  24959. }) => void;
  24960. /**
  24961. * Apply a force
  24962. * @param force The force to apply
  24963. * @param contactPoint The contact point for the force
  24964. * @returns The physics imposter
  24965. */
  24966. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24967. /**
  24968. * Apply an impulse
  24969. * @param force The impulse force
  24970. * @param contactPoint The contact point for the impulse force
  24971. * @returns The physics imposter
  24972. */
  24973. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24974. /**
  24975. * A help function to create a joint
  24976. * @param otherImpostor A physics imposter used to create a joint
  24977. * @param jointType The type of joint
  24978. * @param jointData The data for the joint
  24979. * @returns The physics imposter
  24980. */
  24981. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24982. /**
  24983. * Add a joint to this impostor with a different impostor
  24984. * @param otherImpostor A physics imposter used to add a joint
  24985. * @param joint The joint to add
  24986. * @returns The physics imposter
  24987. */
  24988. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24989. /**
  24990. * Add an anchor to a cloth impostor
  24991. * @param otherImpostor rigid impostor to anchor to
  24992. * @param width ratio across width from 0 to 1
  24993. * @param height ratio up height from 0 to 1
  24994. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24995. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24996. * @returns impostor the soft imposter
  24997. */
  24998. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24999. /**
  25000. * Add a hook to a rope impostor
  25001. * @param otherImpostor rigid impostor to anchor to
  25002. * @param length ratio across rope from 0 to 1
  25003. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  25004. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  25005. * @returns impostor the rope imposter
  25006. */
  25007. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  25008. /**
  25009. * Will keep this body still, in a sleep mode.
  25010. * @returns the physics imposter
  25011. */
  25012. sleep(): PhysicsImpostor;
  25013. /**
  25014. * Wake the body up.
  25015. * @returns The physics imposter
  25016. */
  25017. wakeUp(): PhysicsImpostor;
  25018. /**
  25019. * Clones the physics imposter
  25020. * @param newObject The physics imposter clones to this physics-enabled object
  25021. * @returns A nullable physics imposter
  25022. */
  25023. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  25024. /**
  25025. * Disposes the physics imposter
  25026. */
  25027. dispose(): void;
  25028. /**
  25029. * Sets the delta position
  25030. * @param position The delta position amount
  25031. */
  25032. setDeltaPosition(position: Vector3): void;
  25033. /**
  25034. * Sets the delta rotation
  25035. * @param rotation The delta rotation amount
  25036. */
  25037. setDeltaRotation(rotation: Quaternion): void;
  25038. /**
  25039. * Gets the box size of the physics imposter and stores the result in the input parameter
  25040. * @param result Stores the box size
  25041. * @returns The physics imposter
  25042. */
  25043. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  25044. /**
  25045. * Gets the radius of the physics imposter
  25046. * @returns Radius of the physics imposter
  25047. */
  25048. getRadius(): number;
  25049. /**
  25050. * Sync a bone with this impostor
  25051. * @param bone The bone to sync to the impostor.
  25052. * @param boneMesh The mesh that the bone is influencing.
  25053. * @param jointPivot The pivot of the joint / bone in local space.
  25054. * @param distToJoint Optional distance from the impostor to the joint.
  25055. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25056. */
  25057. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  25058. /**
  25059. * Sync impostor to a bone
  25060. * @param bone The bone that the impostor will be synced to.
  25061. * @param boneMesh The mesh that the bone is influencing.
  25062. * @param jointPivot The pivot of the joint / bone in local space.
  25063. * @param distToJoint Optional distance from the impostor to the joint.
  25064. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  25065. * @param boneAxis Optional vector3 axis the bone is aligned with
  25066. */
  25067. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  25068. /**
  25069. * No-Imposter type
  25070. */
  25071. static NoImpostor: number;
  25072. /**
  25073. * Sphere-Imposter type
  25074. */
  25075. static SphereImpostor: number;
  25076. /**
  25077. * Box-Imposter type
  25078. */
  25079. static BoxImpostor: number;
  25080. /**
  25081. * Plane-Imposter type
  25082. */
  25083. static PlaneImpostor: number;
  25084. /**
  25085. * Mesh-imposter type
  25086. */
  25087. static MeshImpostor: number;
  25088. /**
  25089. * Capsule-Impostor type (Ammo.js plugin only)
  25090. */
  25091. static CapsuleImpostor: number;
  25092. /**
  25093. * Cylinder-Imposter type
  25094. */
  25095. static CylinderImpostor: number;
  25096. /**
  25097. * Particle-Imposter type
  25098. */
  25099. static ParticleImpostor: number;
  25100. /**
  25101. * Heightmap-Imposter type
  25102. */
  25103. static HeightmapImpostor: number;
  25104. /**
  25105. * ConvexHull-Impostor type (Ammo.js plugin only)
  25106. */
  25107. static ConvexHullImpostor: number;
  25108. /**
  25109. * Custom-Imposter type (Ammo.js plugin only)
  25110. */
  25111. static CustomImpostor: number;
  25112. /**
  25113. * Rope-Imposter type
  25114. */
  25115. static RopeImpostor: number;
  25116. /**
  25117. * Cloth-Imposter type
  25118. */
  25119. static ClothImpostor: number;
  25120. /**
  25121. * Softbody-Imposter type
  25122. */
  25123. static SoftbodyImpostor: number;
  25124. }
  25125. }
  25126. declare module "babylonjs/Meshes/mesh" {
  25127. import { Observable } from "babylonjs/Misc/observable";
  25128. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25129. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25130. import { Camera } from "babylonjs/Cameras/camera";
  25131. import { Scene } from "babylonjs/scene";
  25132. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25133. import { Color4 } from "babylonjs/Maths/math.color";
  25134. import { Engine } from "babylonjs/Engines/engine";
  25135. import { Node } from "babylonjs/node";
  25136. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25137. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25138. import { Buffer } from "babylonjs/Meshes/buffer";
  25139. import { Geometry } from "babylonjs/Meshes/geometry";
  25140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25141. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25142. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  25143. import { Effect } from "babylonjs/Materials/effect";
  25144. import { Material } from "babylonjs/Materials/material";
  25145. import { Skeleton } from "babylonjs/Bones/skeleton";
  25146. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  25147. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  25148. import { Path3D } from "babylonjs/Maths/math.path";
  25149. import { Plane } from "babylonjs/Maths/math.plane";
  25150. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25151. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  25152. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  25153. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  25154. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  25155. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  25156. /**
  25157. * @hidden
  25158. **/
  25159. export class _CreationDataStorage {
  25160. closePath?: boolean;
  25161. closeArray?: boolean;
  25162. idx: number[];
  25163. dashSize: number;
  25164. gapSize: number;
  25165. path3D: Path3D;
  25166. pathArray: Vector3[][];
  25167. arc: number;
  25168. radius: number;
  25169. cap: number;
  25170. tessellation: number;
  25171. }
  25172. /**
  25173. * @hidden
  25174. **/
  25175. class _InstanceDataStorage {
  25176. visibleInstances: any;
  25177. batchCache: _InstancesBatch;
  25178. instancesBufferSize: number;
  25179. instancesBuffer: Nullable<Buffer>;
  25180. instancesData: Float32Array;
  25181. overridenInstanceCount: number;
  25182. isFrozen: boolean;
  25183. previousBatch: Nullable<_InstancesBatch>;
  25184. hardwareInstancedRendering: boolean;
  25185. sideOrientation: number;
  25186. manualUpdate: boolean;
  25187. }
  25188. /**
  25189. * @hidden
  25190. **/
  25191. export class _InstancesBatch {
  25192. mustReturn: boolean;
  25193. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  25194. renderSelf: boolean[];
  25195. hardwareInstancedRendering: boolean[];
  25196. }
  25197. /**
  25198. * Class used to represent renderable models
  25199. */
  25200. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  25201. /**
  25202. * Mesh side orientation : usually the external or front surface
  25203. */
  25204. static readonly FRONTSIDE: number;
  25205. /**
  25206. * Mesh side orientation : usually the internal or back surface
  25207. */
  25208. static readonly BACKSIDE: number;
  25209. /**
  25210. * Mesh side orientation : both internal and external or front and back surfaces
  25211. */
  25212. static readonly DOUBLESIDE: number;
  25213. /**
  25214. * Mesh side orientation : by default, `FRONTSIDE`
  25215. */
  25216. static readonly DEFAULTSIDE: number;
  25217. /**
  25218. * Mesh cap setting : no cap
  25219. */
  25220. static readonly NO_CAP: number;
  25221. /**
  25222. * Mesh cap setting : one cap at the beginning of the mesh
  25223. */
  25224. static readonly CAP_START: number;
  25225. /**
  25226. * Mesh cap setting : one cap at the end of the mesh
  25227. */
  25228. static readonly CAP_END: number;
  25229. /**
  25230. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  25231. */
  25232. static readonly CAP_ALL: number;
  25233. /**
  25234. * Mesh pattern setting : no flip or rotate
  25235. */
  25236. static readonly NO_FLIP: number;
  25237. /**
  25238. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  25239. */
  25240. static readonly FLIP_TILE: number;
  25241. /**
  25242. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  25243. */
  25244. static readonly ROTATE_TILE: number;
  25245. /**
  25246. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  25247. */
  25248. static readonly FLIP_ROW: number;
  25249. /**
  25250. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  25251. */
  25252. static readonly ROTATE_ROW: number;
  25253. /**
  25254. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25255. */
  25256. static readonly FLIP_N_ROTATE_TILE: number;
  25257. /**
  25258. * Mesh pattern setting : rotate pattern and rotate
  25259. */
  25260. static readonly FLIP_N_ROTATE_ROW: number;
  25261. /**
  25262. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25263. */
  25264. static readonly CENTER: number;
  25265. /**
  25266. * Mesh tile positioning : part tiles on left
  25267. */
  25268. static readonly LEFT: number;
  25269. /**
  25270. * Mesh tile positioning : part tiles on right
  25271. */
  25272. static readonly RIGHT: number;
  25273. /**
  25274. * Mesh tile positioning : part tiles on top
  25275. */
  25276. static readonly TOP: number;
  25277. /**
  25278. * Mesh tile positioning : part tiles on bottom
  25279. */
  25280. static readonly BOTTOM: number;
  25281. /**
  25282. * Gets the default side orientation.
  25283. * @param orientation the orientation to value to attempt to get
  25284. * @returns the default orientation
  25285. * @hidden
  25286. */
  25287. static _GetDefaultSideOrientation(orientation?: number): number;
  25288. private _internalMeshDataInfo;
  25289. /**
  25290. * An event triggered before rendering the mesh
  25291. */
  25292. get onBeforeRenderObservable(): Observable<Mesh>;
  25293. /**
  25294. * An event triggered before binding the mesh
  25295. */
  25296. get onBeforeBindObservable(): Observable<Mesh>;
  25297. /**
  25298. * An event triggered after rendering the mesh
  25299. */
  25300. get onAfterRenderObservable(): Observable<Mesh>;
  25301. /**
  25302. * An event triggered before drawing the mesh
  25303. */
  25304. get onBeforeDrawObservable(): Observable<Mesh>;
  25305. private _onBeforeDrawObserver;
  25306. /**
  25307. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25308. */
  25309. set onBeforeDraw(callback: () => void);
  25310. get hasInstances(): boolean;
  25311. /**
  25312. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25313. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25314. */
  25315. delayLoadState: number;
  25316. /**
  25317. * Gets the list of instances created from this mesh
  25318. * it is not supposed to be modified manually.
  25319. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25320. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25321. */
  25322. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25323. /**
  25324. * Gets the file containing delay loading data for this mesh
  25325. */
  25326. delayLoadingFile: string;
  25327. /** @hidden */
  25328. _binaryInfo: any;
  25329. /**
  25330. * User defined function used to change how LOD level selection is done
  25331. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25332. */
  25333. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25334. /**
  25335. * Gets or sets the morph target manager
  25336. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25337. */
  25338. get morphTargetManager(): Nullable<MorphTargetManager>;
  25339. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25340. /** @hidden */
  25341. _creationDataStorage: Nullable<_CreationDataStorage>;
  25342. /** @hidden */
  25343. _geometry: Nullable<Geometry>;
  25344. /** @hidden */
  25345. _delayInfo: Array<string>;
  25346. /** @hidden */
  25347. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25348. /** @hidden */
  25349. _instanceDataStorage: _InstanceDataStorage;
  25350. private _effectiveMaterial;
  25351. /** @hidden */
  25352. _shouldGenerateFlatShading: boolean;
  25353. /** @hidden */
  25354. _originalBuilderSideOrientation: number;
  25355. /**
  25356. * Use this property to change the original side orientation defined at construction time
  25357. */
  25358. overrideMaterialSideOrientation: Nullable<number>;
  25359. /**
  25360. * Gets the source mesh (the one used to clone this one from)
  25361. */
  25362. get source(): Nullable<Mesh>;
  25363. /**
  25364. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25365. */
  25366. get isUnIndexed(): boolean;
  25367. set isUnIndexed(value: boolean);
  25368. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25369. get worldMatrixInstancedBuffer(): Float32Array;
  25370. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25371. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25372. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25373. /**
  25374. * @constructor
  25375. * @param name The value used by scene.getMeshByName() to do a lookup.
  25376. * @param scene The scene to add this mesh to.
  25377. * @param parent The parent of this mesh, if it has one
  25378. * @param source An optional Mesh from which geometry is shared, cloned.
  25379. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25380. * When false, achieved by calling a clone(), also passing False.
  25381. * This will make creation of children, recursive.
  25382. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25383. */
  25384. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25385. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25386. doNotInstantiate: boolean;
  25387. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25388. /**
  25389. * Gets the class name
  25390. * @returns the string "Mesh".
  25391. */
  25392. getClassName(): string;
  25393. /** @hidden */
  25394. get _isMesh(): boolean;
  25395. /**
  25396. * Returns a description of this mesh
  25397. * @param fullDetails define if full details about this mesh must be used
  25398. * @returns a descriptive string representing this mesh
  25399. */
  25400. toString(fullDetails?: boolean): string;
  25401. /** @hidden */
  25402. _unBindEffect(): void;
  25403. /**
  25404. * Gets a boolean indicating if this mesh has LOD
  25405. */
  25406. get hasLODLevels(): boolean;
  25407. /**
  25408. * Gets the list of MeshLODLevel associated with the current mesh
  25409. * @returns an array of MeshLODLevel
  25410. */
  25411. getLODLevels(): MeshLODLevel[];
  25412. private _sortLODLevels;
  25413. /**
  25414. * Add a mesh as LOD level triggered at the given distance.
  25415. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25416. * @param distance The distance from the center of the object to show this level
  25417. * @param mesh The mesh to be added as LOD level (can be null)
  25418. * @return This mesh (for chaining)
  25419. */
  25420. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25421. /**
  25422. * Returns the LOD level mesh at the passed distance or null if not found.
  25423. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25424. * @param distance The distance from the center of the object to show this level
  25425. * @returns a Mesh or `null`
  25426. */
  25427. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25428. /**
  25429. * Remove a mesh from the LOD array
  25430. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25431. * @param mesh defines the mesh to be removed
  25432. * @return This mesh (for chaining)
  25433. */
  25434. removeLODLevel(mesh: Mesh): Mesh;
  25435. /**
  25436. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25438. * @param camera defines the camera to use to compute distance
  25439. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25440. * @return This mesh (for chaining)
  25441. */
  25442. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25443. /**
  25444. * Gets the mesh internal Geometry object
  25445. */
  25446. get geometry(): Nullable<Geometry>;
  25447. /**
  25448. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25449. * @returns the total number of vertices
  25450. */
  25451. getTotalVertices(): number;
  25452. /**
  25453. * Returns the content of an associated vertex buffer
  25454. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25455. * - VertexBuffer.PositionKind
  25456. * - VertexBuffer.UVKind
  25457. * - VertexBuffer.UV2Kind
  25458. * - VertexBuffer.UV3Kind
  25459. * - VertexBuffer.UV4Kind
  25460. * - VertexBuffer.UV5Kind
  25461. * - VertexBuffer.UV6Kind
  25462. * - VertexBuffer.ColorKind
  25463. * - VertexBuffer.MatricesIndicesKind
  25464. * - VertexBuffer.MatricesIndicesExtraKind
  25465. * - VertexBuffer.MatricesWeightsKind
  25466. * - VertexBuffer.MatricesWeightsExtraKind
  25467. * @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
  25468. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25469. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25470. */
  25471. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25472. /**
  25473. * Returns the mesh VertexBuffer object from the requested `kind`
  25474. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25475. * - VertexBuffer.PositionKind
  25476. * - VertexBuffer.NormalKind
  25477. * - VertexBuffer.UVKind
  25478. * - VertexBuffer.UV2Kind
  25479. * - VertexBuffer.UV3Kind
  25480. * - VertexBuffer.UV4Kind
  25481. * - VertexBuffer.UV5Kind
  25482. * - VertexBuffer.UV6Kind
  25483. * - VertexBuffer.ColorKind
  25484. * - VertexBuffer.MatricesIndicesKind
  25485. * - VertexBuffer.MatricesIndicesExtraKind
  25486. * - VertexBuffer.MatricesWeightsKind
  25487. * - VertexBuffer.MatricesWeightsExtraKind
  25488. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25489. */
  25490. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25491. /**
  25492. * Tests if a specific vertex buffer is associated with this mesh
  25493. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25494. * - VertexBuffer.PositionKind
  25495. * - VertexBuffer.NormalKind
  25496. * - VertexBuffer.UVKind
  25497. * - VertexBuffer.UV2Kind
  25498. * - VertexBuffer.UV3Kind
  25499. * - VertexBuffer.UV4Kind
  25500. * - VertexBuffer.UV5Kind
  25501. * - VertexBuffer.UV6Kind
  25502. * - VertexBuffer.ColorKind
  25503. * - VertexBuffer.MatricesIndicesKind
  25504. * - VertexBuffer.MatricesIndicesExtraKind
  25505. * - VertexBuffer.MatricesWeightsKind
  25506. * - VertexBuffer.MatricesWeightsExtraKind
  25507. * @returns a boolean
  25508. */
  25509. isVerticesDataPresent(kind: string): boolean;
  25510. /**
  25511. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25512. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25513. * - VertexBuffer.PositionKind
  25514. * - VertexBuffer.UVKind
  25515. * - VertexBuffer.UV2Kind
  25516. * - VertexBuffer.UV3Kind
  25517. * - VertexBuffer.UV4Kind
  25518. * - VertexBuffer.UV5Kind
  25519. * - VertexBuffer.UV6Kind
  25520. * - VertexBuffer.ColorKind
  25521. * - VertexBuffer.MatricesIndicesKind
  25522. * - VertexBuffer.MatricesIndicesExtraKind
  25523. * - VertexBuffer.MatricesWeightsKind
  25524. * - VertexBuffer.MatricesWeightsExtraKind
  25525. * @returns a boolean
  25526. */
  25527. isVertexBufferUpdatable(kind: string): boolean;
  25528. /**
  25529. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25530. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25531. * - VertexBuffer.PositionKind
  25532. * - VertexBuffer.NormalKind
  25533. * - VertexBuffer.UVKind
  25534. * - VertexBuffer.UV2Kind
  25535. * - VertexBuffer.UV3Kind
  25536. * - VertexBuffer.UV4Kind
  25537. * - VertexBuffer.UV5Kind
  25538. * - VertexBuffer.UV6Kind
  25539. * - VertexBuffer.ColorKind
  25540. * - VertexBuffer.MatricesIndicesKind
  25541. * - VertexBuffer.MatricesIndicesExtraKind
  25542. * - VertexBuffer.MatricesWeightsKind
  25543. * - VertexBuffer.MatricesWeightsExtraKind
  25544. * @returns an array of strings
  25545. */
  25546. getVerticesDataKinds(): string[];
  25547. /**
  25548. * Returns a positive integer : the total number of indices in this mesh geometry.
  25549. * @returns the numner of indices or zero if the mesh has no geometry.
  25550. */
  25551. getTotalIndices(): number;
  25552. /**
  25553. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25554. * @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.
  25555. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25556. * @returns the indices array or an empty array if the mesh has no geometry
  25557. */
  25558. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25559. get isBlocked(): boolean;
  25560. /**
  25561. * Determine if the current mesh is ready to be rendered
  25562. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25563. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25564. * @returns true if all associated assets are ready (material, textures, shaders)
  25565. */
  25566. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25567. /**
  25568. * 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.
  25569. */
  25570. get areNormalsFrozen(): boolean;
  25571. /**
  25572. * 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.
  25573. * @returns the current mesh
  25574. */
  25575. freezeNormals(): Mesh;
  25576. /**
  25577. * 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
  25578. * @returns the current mesh
  25579. */
  25580. unfreezeNormals(): Mesh;
  25581. /**
  25582. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25583. */
  25584. set overridenInstanceCount(count: number);
  25585. /** @hidden */
  25586. _preActivate(): Mesh;
  25587. /** @hidden */
  25588. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25589. /** @hidden */
  25590. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25591. /**
  25592. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25593. * This means the mesh underlying bounding box and sphere are recomputed.
  25594. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25595. * @returns the current mesh
  25596. */
  25597. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25598. /** @hidden */
  25599. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25600. /**
  25601. * This function will subdivide the mesh into multiple submeshes
  25602. * @param count defines the expected number of submeshes
  25603. */
  25604. subdivide(count: number): void;
  25605. /**
  25606. * Copy a FloatArray into a specific associated vertex buffer
  25607. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25608. * - VertexBuffer.PositionKind
  25609. * - VertexBuffer.UVKind
  25610. * - VertexBuffer.UV2Kind
  25611. * - VertexBuffer.UV3Kind
  25612. * - VertexBuffer.UV4Kind
  25613. * - VertexBuffer.UV5Kind
  25614. * - VertexBuffer.UV6Kind
  25615. * - VertexBuffer.ColorKind
  25616. * - VertexBuffer.MatricesIndicesKind
  25617. * - VertexBuffer.MatricesIndicesExtraKind
  25618. * - VertexBuffer.MatricesWeightsKind
  25619. * - VertexBuffer.MatricesWeightsExtraKind
  25620. * @param data defines the data source
  25621. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25622. * @param stride defines the data stride size (can be null)
  25623. * @returns the current mesh
  25624. */
  25625. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25626. /**
  25627. * Delete a vertex buffer associated with this mesh
  25628. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25629. * - VertexBuffer.PositionKind
  25630. * - VertexBuffer.UVKind
  25631. * - VertexBuffer.UV2Kind
  25632. * - VertexBuffer.UV3Kind
  25633. * - VertexBuffer.UV4Kind
  25634. * - VertexBuffer.UV5Kind
  25635. * - VertexBuffer.UV6Kind
  25636. * - VertexBuffer.ColorKind
  25637. * - VertexBuffer.MatricesIndicesKind
  25638. * - VertexBuffer.MatricesIndicesExtraKind
  25639. * - VertexBuffer.MatricesWeightsKind
  25640. * - VertexBuffer.MatricesWeightsExtraKind
  25641. */
  25642. removeVerticesData(kind: string): void;
  25643. /**
  25644. * Flags an associated vertex buffer as updatable
  25645. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25646. * - VertexBuffer.PositionKind
  25647. * - VertexBuffer.UVKind
  25648. * - VertexBuffer.UV2Kind
  25649. * - VertexBuffer.UV3Kind
  25650. * - VertexBuffer.UV4Kind
  25651. * - VertexBuffer.UV5Kind
  25652. * - VertexBuffer.UV6Kind
  25653. * - VertexBuffer.ColorKind
  25654. * - VertexBuffer.MatricesIndicesKind
  25655. * - VertexBuffer.MatricesIndicesExtraKind
  25656. * - VertexBuffer.MatricesWeightsKind
  25657. * - VertexBuffer.MatricesWeightsExtraKind
  25658. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25659. */
  25660. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25661. /**
  25662. * Sets the mesh global Vertex Buffer
  25663. * @param buffer defines the buffer to use
  25664. * @returns the current mesh
  25665. */
  25666. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25667. /**
  25668. * Update a specific associated vertex buffer
  25669. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25670. * - VertexBuffer.PositionKind
  25671. * - VertexBuffer.UVKind
  25672. * - VertexBuffer.UV2Kind
  25673. * - VertexBuffer.UV3Kind
  25674. * - VertexBuffer.UV4Kind
  25675. * - VertexBuffer.UV5Kind
  25676. * - VertexBuffer.UV6Kind
  25677. * - VertexBuffer.ColorKind
  25678. * - VertexBuffer.MatricesIndicesKind
  25679. * - VertexBuffer.MatricesIndicesExtraKind
  25680. * - VertexBuffer.MatricesWeightsKind
  25681. * - VertexBuffer.MatricesWeightsExtraKind
  25682. * @param data defines the data source
  25683. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25684. * @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)
  25685. * @returns the current mesh
  25686. */
  25687. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25688. /**
  25689. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25690. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25691. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25692. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25693. * @returns the current mesh
  25694. */
  25695. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25696. /**
  25697. * Creates a un-shared specific occurence of the geometry for the mesh.
  25698. * @returns the current mesh
  25699. */
  25700. makeGeometryUnique(): Mesh;
  25701. /**
  25702. * Set the index buffer of this mesh
  25703. * @param indices defines the source data
  25704. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25705. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25706. * @returns the current mesh
  25707. */
  25708. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25709. /**
  25710. * Update the current index buffer
  25711. * @param indices defines the source data
  25712. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25713. * @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)
  25714. * @returns the current mesh
  25715. */
  25716. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25717. /**
  25718. * Invert the geometry to move from a right handed system to a left handed one.
  25719. * @returns the current mesh
  25720. */
  25721. toLeftHanded(): Mesh;
  25722. /** @hidden */
  25723. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25724. /** @hidden */
  25725. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25726. /**
  25727. * Registers for this mesh a javascript function called just before the rendering process
  25728. * @param func defines the function to call before rendering this mesh
  25729. * @returns the current mesh
  25730. */
  25731. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25732. /**
  25733. * Disposes a previously registered javascript function called before the rendering
  25734. * @param func defines the function to remove
  25735. * @returns the current mesh
  25736. */
  25737. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25738. /**
  25739. * Registers for this mesh a javascript function called just after the rendering is complete
  25740. * @param func defines the function to call after rendering this mesh
  25741. * @returns the current mesh
  25742. */
  25743. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25744. /**
  25745. * Disposes a previously registered javascript function called after the rendering.
  25746. * @param func defines the function to remove
  25747. * @returns the current mesh
  25748. */
  25749. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25750. /** @hidden */
  25751. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25752. /** @hidden */
  25753. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25754. /** @hidden */
  25755. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25756. /** @hidden */
  25757. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25758. /** @hidden */
  25759. _rebuild(): void;
  25760. /** @hidden */
  25761. _freeze(): void;
  25762. /** @hidden */
  25763. _unFreeze(): void;
  25764. /**
  25765. * 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
  25766. * @param subMesh defines the subMesh to render
  25767. * @param enableAlphaMode defines if alpha mode can be changed
  25768. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25769. * @returns the current mesh
  25770. */
  25771. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25772. private _onBeforeDraw;
  25773. /**
  25774. * Renormalize the mesh and patch it up if there are no weights
  25775. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25776. * However in the case of zero weights then we set just a single influence to 1.
  25777. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25778. */
  25779. cleanMatrixWeights(): void;
  25780. private normalizeSkinFourWeights;
  25781. private normalizeSkinWeightsAndExtra;
  25782. /**
  25783. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25784. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25785. * the user know there was an issue with importing the mesh
  25786. * @returns a validation object with skinned, valid and report string
  25787. */
  25788. validateSkinning(): {
  25789. skinned: boolean;
  25790. valid: boolean;
  25791. report: string;
  25792. };
  25793. /** @hidden */
  25794. _checkDelayState(): Mesh;
  25795. private _queueLoad;
  25796. /**
  25797. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25798. * A mesh is in the frustum if its bounding box intersects the frustum
  25799. * @param frustumPlanes defines the frustum to test
  25800. * @returns true if the mesh is in the frustum planes
  25801. */
  25802. isInFrustum(frustumPlanes: Plane[]): boolean;
  25803. /**
  25804. * Sets the mesh material by the material or multiMaterial `id` property
  25805. * @param id is a string identifying the material or the multiMaterial
  25806. * @returns the current mesh
  25807. */
  25808. setMaterialByID(id: string): Mesh;
  25809. /**
  25810. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25811. * @returns an array of IAnimatable
  25812. */
  25813. getAnimatables(): IAnimatable[];
  25814. /**
  25815. * Modifies the mesh geometry according to the passed transformation matrix.
  25816. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25817. * The mesh normals are modified using the same transformation.
  25818. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25819. * @param transform defines the transform matrix to use
  25820. * @see http://doc.babylonjs.com/resources/baking_transformations
  25821. * @returns the current mesh
  25822. */
  25823. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25824. /**
  25825. * Modifies the mesh geometry according to its own current World Matrix.
  25826. * The mesh World Matrix is then reset.
  25827. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25828. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25829. * @see http://doc.babylonjs.com/resources/baking_transformations
  25830. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25831. * @returns the current mesh
  25832. */
  25833. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25834. /** @hidden */
  25835. get _positions(): Nullable<Vector3[]>;
  25836. /** @hidden */
  25837. _resetPointsArrayCache(): Mesh;
  25838. /** @hidden */
  25839. _generatePointsArray(): boolean;
  25840. /**
  25841. * Returns a new Mesh object generated from the current mesh properties.
  25842. * This method must not get confused with createInstance()
  25843. * @param name is a string, the name given to the new mesh
  25844. * @param newParent can be any Node object (default `null`)
  25845. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25846. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25847. * @returns a new mesh
  25848. */
  25849. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25850. /**
  25851. * Releases resources associated with this mesh.
  25852. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25853. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25854. */
  25855. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25856. /** @hidden */
  25857. _disposeInstanceSpecificData(): void;
  25858. /**
  25859. * Modifies the mesh geometry according to a displacement map.
  25860. * 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.
  25861. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25862. * @param url is a string, the URL from the image file is to be downloaded.
  25863. * @param minHeight is the lower limit of the displacement.
  25864. * @param maxHeight is the upper limit of the displacement.
  25865. * @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.
  25866. * @param uvOffset is an optional vector2 used to offset UV.
  25867. * @param uvScale is an optional vector2 used to scale UV.
  25868. * @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.
  25869. * @returns the Mesh.
  25870. */
  25871. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25872. /**
  25873. * Modifies the mesh geometry according to a displacementMap buffer.
  25874. * 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.
  25875. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25876. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25877. * @param heightMapWidth is the width of the buffer image.
  25878. * @param heightMapHeight is the height of the buffer image.
  25879. * @param minHeight is the lower limit of the displacement.
  25880. * @param maxHeight is the upper limit of the displacement.
  25881. * @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.
  25882. * @param uvOffset is an optional vector2 used to offset UV.
  25883. * @param uvScale is an optional vector2 used to scale UV.
  25884. * @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.
  25885. * @returns the Mesh.
  25886. */
  25887. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25888. /**
  25889. * Modify the mesh to get a flat shading rendering.
  25890. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25891. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25892. * @returns current mesh
  25893. */
  25894. convertToFlatShadedMesh(): Mesh;
  25895. /**
  25896. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25897. * In other words, more vertices, no more indices and a single bigger VBO.
  25898. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25899. * @returns current mesh
  25900. */
  25901. convertToUnIndexedMesh(): Mesh;
  25902. /**
  25903. * Inverses facet orientations.
  25904. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25905. * @param flipNormals will also inverts the normals
  25906. * @returns current mesh
  25907. */
  25908. flipFaces(flipNormals?: boolean): Mesh;
  25909. /**
  25910. * Increase the number of facets and hence vertices in a mesh
  25911. * Vertex normals are interpolated from existing vertex normals
  25912. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25913. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25914. */
  25915. increaseVertices(numberPerEdge: number): void;
  25916. /**
  25917. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25918. * This will undo any application of covertToFlatShadedMesh
  25919. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25920. */
  25921. forceSharedVertices(): void;
  25922. /** @hidden */
  25923. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25924. /** @hidden */
  25925. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25926. /**
  25927. * Creates a new InstancedMesh object from the mesh model.
  25928. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25929. * @param name defines the name of the new instance
  25930. * @returns a new InstancedMesh
  25931. */
  25932. createInstance(name: string): InstancedMesh;
  25933. /**
  25934. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25935. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25936. * @returns the current mesh
  25937. */
  25938. synchronizeInstances(): Mesh;
  25939. /**
  25940. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25941. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25942. * This should be used together with the simplification to avoid disappearing triangles.
  25943. * @param successCallback an optional success callback to be called after the optimization finished.
  25944. * @returns the current mesh
  25945. */
  25946. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25947. /**
  25948. * Serialize current mesh
  25949. * @param serializationObject defines the object which will receive the serialization data
  25950. */
  25951. serialize(serializationObject: any): void;
  25952. /** @hidden */
  25953. _syncGeometryWithMorphTargetManager(): void;
  25954. /** @hidden */
  25955. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25956. /**
  25957. * Returns a new Mesh object parsed from the source provided.
  25958. * @param parsedMesh is the source
  25959. * @param scene defines the hosting scene
  25960. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25961. * @returns a new Mesh
  25962. */
  25963. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25964. /**
  25965. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25966. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25967. * @param name defines the name of the mesh to create
  25968. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25969. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25970. * @param closePath creates a seam between the first and the last points of each path of the path array
  25971. * @param offset is taken in account only if the `pathArray` is containing a single path
  25972. * @param scene defines the hosting scene
  25973. * @param updatable defines if the mesh must be flagged as updatable
  25974. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25975. * @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)
  25976. * @returns a new Mesh
  25977. */
  25978. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25979. /**
  25980. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25981. * @param name defines the name of the mesh to create
  25982. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25983. * @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
  25984. * @param scene defines the hosting scene
  25985. * @param updatable defines if the mesh must be flagged as updatable
  25986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25987. * @returns a new Mesh
  25988. */
  25989. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25990. /**
  25991. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25992. * @param name defines the name of the mesh to create
  25993. * @param size sets the size (float) of each box side (default 1)
  25994. * @param scene defines the hosting scene
  25995. * @param updatable defines if the mesh must be flagged as updatable
  25996. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25997. * @returns a new Mesh
  25998. */
  25999. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  26000. /**
  26001. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  26002. * @param name defines the name of the mesh to create
  26003. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26004. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26005. * @param scene defines the hosting scene
  26006. * @param updatable defines if the mesh must be flagged as updatable
  26007. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26008. * @returns a new Mesh
  26009. */
  26010. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26011. /**
  26012. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  26013. * @param name defines the name of the mesh to create
  26014. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  26015. * @param diameter sets the diameter size (float) of the sphere (default 1)
  26016. * @param scene defines the hosting scene
  26017. * @returns a new Mesh
  26018. */
  26019. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  26020. /**
  26021. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  26022. * @param name defines the name of the mesh to create
  26023. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  26024. * @param diameterTop set the top cap diameter (floats, default 1)
  26025. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  26026. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  26027. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  26028. * @param scene defines the hosting scene
  26029. * @param updatable defines if the mesh must be flagged as updatable
  26030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26031. * @returns a new Mesh
  26032. */
  26033. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  26034. /**
  26035. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  26036. * @param name defines the name of the mesh to create
  26037. * @param diameter sets the diameter size (float) of the torus (default 1)
  26038. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  26039. * @param tessellation sets the number of torus sides (postive integer, default 16)
  26040. * @param scene defines the hosting scene
  26041. * @param updatable defines if the mesh must be flagged as updatable
  26042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26043. * @returns a new Mesh
  26044. */
  26045. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26046. /**
  26047. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  26048. * @param name defines the name of the mesh to create
  26049. * @param radius sets the global radius size (float) of the torus knot (default 2)
  26050. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  26051. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  26052. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  26053. * @param p the number of windings on X axis (positive integers, default 2)
  26054. * @param q the number of windings on Y axis (positive integers, default 3)
  26055. * @param scene defines the hosting scene
  26056. * @param updatable defines if the mesh must be flagged as updatable
  26057. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26058. * @returns a new Mesh
  26059. */
  26060. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26061. /**
  26062. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  26063. * @param name defines the name of the mesh to create
  26064. * @param points is an array successive Vector3
  26065. * @param scene defines the hosting scene
  26066. * @param updatable defines if the mesh must be flagged as updatable
  26067. * @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).
  26068. * @returns a new Mesh
  26069. */
  26070. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  26071. /**
  26072. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  26073. * @param name defines the name of the mesh to create
  26074. * @param points is an array successive Vector3
  26075. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  26076. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  26077. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  26078. * @param scene defines the hosting scene
  26079. * @param updatable defines if the mesh must be flagged as updatable
  26080. * @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)
  26081. * @returns a new Mesh
  26082. */
  26083. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  26084. /**
  26085. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  26086. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  26087. * 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.
  26088. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26089. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  26090. * Remember you can only change the shape positions, not their number when updating a polygon.
  26091. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  26092. * @param name defines the name of the mesh to create
  26093. * @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
  26094. * @param scene defines the hosting scene
  26095. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26096. * @param updatable defines if the mesh must be flagged as updatable
  26097. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26098. * @param earcutInjection can be used to inject your own earcut reference
  26099. * @returns a new Mesh
  26100. */
  26101. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26102. /**
  26103. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  26104. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  26105. * @param name defines the name of the mesh to create
  26106. * @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
  26107. * @param depth defines the height of extrusion
  26108. * @param scene defines the hosting scene
  26109. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  26110. * @param updatable defines if the mesh must be flagged as updatable
  26111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26112. * @param earcutInjection can be used to inject your own earcut reference
  26113. * @returns a new Mesh
  26114. */
  26115. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  26116. /**
  26117. * Creates an extruded shape mesh.
  26118. * 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
  26119. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26120. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26121. * @param name defines the name of the mesh to create
  26122. * @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
  26123. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26124. * @param scale is the value to scale the shape
  26125. * @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
  26126. * @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
  26127. * @param scene defines the hosting scene
  26128. * @param updatable defines if the mesh must be flagged as updatable
  26129. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26130. * @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)
  26131. * @returns a new Mesh
  26132. */
  26133. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26134. /**
  26135. * Creates an custom extruded shape mesh.
  26136. * The custom extrusion is a parametric shape.
  26137. * It has no predefined shape. Its final shape will depend on the input parameters.
  26138. * Please consider using the same method from the MeshBuilder class instead
  26139. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  26140. * @param name defines the name of the mesh to create
  26141. * @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
  26142. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  26143. * @param scaleFunction is a custom Javascript function called on each path point
  26144. * @param rotationFunction is a custom Javascript function called on each path point
  26145. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  26146. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  26147. * @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
  26148. * @param scene defines the hosting scene
  26149. * @param updatable defines if the mesh must be flagged as updatable
  26150. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26151. * @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)
  26152. * @returns a new Mesh
  26153. */
  26154. 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;
  26155. /**
  26156. * Creates lathe mesh.
  26157. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  26158. * Please consider using the same method from the MeshBuilder class instead
  26159. * @param name defines the name of the mesh to create
  26160. * @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
  26161. * @param radius is the radius value of the lathe
  26162. * @param tessellation is the side number of the lathe.
  26163. * @param scene defines the hosting scene
  26164. * @param updatable defines if the mesh must be flagged as updatable
  26165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26166. * @returns a new Mesh
  26167. */
  26168. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26169. /**
  26170. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  26171. * @param name defines the name of the mesh to create
  26172. * @param size sets the size (float) of both sides of the plane at once (default 1)
  26173. * @param scene defines the hosting scene
  26174. * @param updatable defines if the mesh must be flagged as updatable
  26175. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26176. * @returns a new Mesh
  26177. */
  26178. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  26179. /**
  26180. * Creates a ground mesh.
  26181. * Please consider using the same method from the MeshBuilder class instead
  26182. * @param name defines the name of the mesh to create
  26183. * @param width set the width of the ground
  26184. * @param height set the height of the ground
  26185. * @param subdivisions sets the number of subdivisions per side
  26186. * @param scene defines the hosting scene
  26187. * @param updatable defines if the mesh must be flagged as updatable
  26188. * @returns a new Mesh
  26189. */
  26190. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  26191. /**
  26192. * Creates a tiled ground mesh.
  26193. * Please consider using the same method from the MeshBuilder class instead
  26194. * @param name defines the name of the mesh to create
  26195. * @param xmin set the ground minimum X coordinate
  26196. * @param zmin set the ground minimum Y coordinate
  26197. * @param xmax set the ground maximum X coordinate
  26198. * @param zmax set the ground maximum Z coordinate
  26199. * @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
  26200. * @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
  26201. * @param scene defines the hosting scene
  26202. * @param updatable defines if the mesh must be flagged as updatable
  26203. * @returns a new Mesh
  26204. */
  26205. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  26206. w: number;
  26207. h: number;
  26208. }, precision: {
  26209. w: number;
  26210. h: number;
  26211. }, scene: Scene, updatable?: boolean): Mesh;
  26212. /**
  26213. * Creates a ground mesh from a height map.
  26214. * Please consider using the same method from the MeshBuilder class instead
  26215. * @see http://doc.babylonjs.com/babylon101/height_map
  26216. * @param name defines the name of the mesh to create
  26217. * @param url sets the URL of the height map image resource
  26218. * @param width set the ground width size
  26219. * @param height set the ground height size
  26220. * @param subdivisions sets the number of subdivision per side
  26221. * @param minHeight is the minimum altitude on the ground
  26222. * @param maxHeight is the maximum altitude on the ground
  26223. * @param scene defines the hosting scene
  26224. * @param updatable defines if the mesh must be flagged as updatable
  26225. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  26226. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  26227. * @returns a new Mesh
  26228. */
  26229. 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;
  26230. /**
  26231. * Creates a tube mesh.
  26232. * The tube is a parametric shape.
  26233. * It has no predefined shape. Its final shape will depend on the input parameters.
  26234. * Please consider using the same method from the MeshBuilder class instead
  26235. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  26236. * @param name defines the name of the mesh to create
  26237. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  26238. * @param radius sets the tube radius size
  26239. * @param tessellation is the number of sides on the tubular surface
  26240. * @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
  26241. * @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
  26242. * @param scene defines the hosting scene
  26243. * @param updatable defines if the mesh must be flagged as updatable
  26244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  26245. * @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)
  26246. * @returns a new Mesh
  26247. */
  26248. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  26249. (i: number, distance: number): number;
  26250. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  26251. /**
  26252. * Creates a polyhedron mesh.
  26253. * Please consider using the same method from the MeshBuilder class instead.
  26254. * * 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
  26255. * * The parameter `size` (positive float, default 1) sets the polygon size
  26256. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26257. * * 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`
  26258. * * 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
  26259. * * 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)`)
  26260. * * 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
  26261. * * 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
  26262. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26263. * * If you create a double-sided mesh, you can choose what parts of 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
  26264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26265. * @param name defines the name of the mesh to create
  26266. * @param options defines the options used to create the mesh
  26267. * @param scene defines the hosting scene
  26268. * @returns a new Mesh
  26269. */
  26270. static CreatePolyhedron(name: string, options: {
  26271. type?: number;
  26272. size?: number;
  26273. sizeX?: number;
  26274. sizeY?: number;
  26275. sizeZ?: number;
  26276. custom?: any;
  26277. faceUV?: Vector4[];
  26278. faceColors?: Color4[];
  26279. updatable?: boolean;
  26280. sideOrientation?: number;
  26281. }, scene: Scene): Mesh;
  26282. /**
  26283. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26284. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26285. * * 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`)
  26286. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26287. * * 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
  26288. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26289. * * If you create a double-sided mesh, you can choose what parts of 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
  26290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26291. * @param name defines the name of the mesh
  26292. * @param options defines the options used to create the mesh
  26293. * @param scene defines the hosting scene
  26294. * @returns a new Mesh
  26295. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26296. */
  26297. static CreateIcoSphere(name: string, options: {
  26298. radius?: number;
  26299. flat?: boolean;
  26300. subdivisions?: number;
  26301. sideOrientation?: number;
  26302. updatable?: boolean;
  26303. }, scene: Scene): Mesh;
  26304. /**
  26305. * Creates a decal mesh.
  26306. * Please consider using the same method from the MeshBuilder class instead.
  26307. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26308. * @param name defines the name of the mesh
  26309. * @param sourceMesh defines the mesh receiving the decal
  26310. * @param position sets the position of the decal in world coordinates
  26311. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26312. * @param size sets the decal scaling
  26313. * @param angle sets the angle to rotate the decal
  26314. * @returns a new Mesh
  26315. */
  26316. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26317. /**
  26318. * Prepare internal position array for software CPU skinning
  26319. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26320. */
  26321. setPositionsForCPUSkinning(): Float32Array;
  26322. /**
  26323. * Prepare internal normal array for software CPU skinning
  26324. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26325. */
  26326. setNormalsForCPUSkinning(): Float32Array;
  26327. /**
  26328. * Updates the vertex buffer by applying transformation from the bones
  26329. * @param skeleton defines the skeleton to apply to current mesh
  26330. * @returns the current mesh
  26331. */
  26332. applySkeleton(skeleton: Skeleton): Mesh;
  26333. /**
  26334. * 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
  26335. * @param meshes defines the list of meshes to scan
  26336. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26337. */
  26338. static MinMax(meshes: AbstractMesh[]): {
  26339. min: Vector3;
  26340. max: Vector3;
  26341. };
  26342. /**
  26343. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26344. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26345. * @returns a vector3
  26346. */
  26347. static Center(meshesOrMinMaxVector: {
  26348. min: Vector3;
  26349. max: Vector3;
  26350. } | AbstractMesh[]): Vector3;
  26351. /**
  26352. * Merge the array of meshes into a single mesh for performance reasons.
  26353. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26354. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26355. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26356. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26357. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26358. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26359. * @returns a new mesh
  26360. */
  26361. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26362. /** @hidden */
  26363. addInstance(instance: InstancedMesh): void;
  26364. /** @hidden */
  26365. removeInstance(instance: InstancedMesh): void;
  26366. }
  26367. }
  26368. declare module "babylonjs/Cameras/camera" {
  26369. import { SmartArray } from "babylonjs/Misc/smartArray";
  26370. import { Observable } from "babylonjs/Misc/observable";
  26371. import { Nullable } from "babylonjs/types";
  26372. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26373. import { Scene } from "babylonjs/scene";
  26374. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26375. import { Node } from "babylonjs/node";
  26376. import { Mesh } from "babylonjs/Meshes/mesh";
  26377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26378. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26379. import { Viewport } from "babylonjs/Maths/math.viewport";
  26380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26382. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26383. import { Ray } from "babylonjs/Culling/ray";
  26384. /**
  26385. * This is the base class of all the camera used in the application.
  26386. * @see http://doc.babylonjs.com/features/cameras
  26387. */
  26388. export class Camera extends Node {
  26389. /** @hidden */
  26390. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26391. /**
  26392. * This is the default projection mode used by the cameras.
  26393. * It helps recreating a feeling of perspective and better appreciate depth.
  26394. * This is the best way to simulate real life cameras.
  26395. */
  26396. static readonly PERSPECTIVE_CAMERA: number;
  26397. /**
  26398. * This helps creating camera with an orthographic mode.
  26399. * 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.
  26400. */
  26401. static readonly ORTHOGRAPHIC_CAMERA: number;
  26402. /**
  26403. * This is the default FOV mode for perspective cameras.
  26404. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26405. */
  26406. static readonly FOVMODE_VERTICAL_FIXED: number;
  26407. /**
  26408. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26409. */
  26410. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26411. /**
  26412. * This specifies ther is no need for a camera rig.
  26413. * Basically only one eye is rendered corresponding to the camera.
  26414. */
  26415. static readonly RIG_MODE_NONE: number;
  26416. /**
  26417. * Simulates a camera Rig with one blue eye and one red eye.
  26418. * This can be use with 3d blue and red glasses.
  26419. */
  26420. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26421. /**
  26422. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26423. */
  26424. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26425. /**
  26426. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26427. */
  26428. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26429. /**
  26430. * Defines that both eyes of the camera will be rendered over under each other.
  26431. */
  26432. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26433. /**
  26434. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26435. */
  26436. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26437. /**
  26438. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26439. */
  26440. static readonly RIG_MODE_VR: number;
  26441. /**
  26442. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26443. */
  26444. static readonly RIG_MODE_WEBVR: number;
  26445. /**
  26446. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26447. */
  26448. static readonly RIG_MODE_CUSTOM: number;
  26449. /**
  26450. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26451. */
  26452. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26453. /**
  26454. * Define the input manager associated with the camera.
  26455. */
  26456. inputs: CameraInputsManager<Camera>;
  26457. /** @hidden */
  26458. _position: Vector3;
  26459. /**
  26460. * Define the current local position of the camera in the scene
  26461. */
  26462. get position(): Vector3;
  26463. set position(newPosition: Vector3);
  26464. /**
  26465. * The vector the camera should consider as up.
  26466. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26467. */
  26468. upVector: Vector3;
  26469. /**
  26470. * Define the current limit on the left side for an orthographic camera
  26471. * In scene unit
  26472. */
  26473. orthoLeft: Nullable<number>;
  26474. /**
  26475. * Define the current limit on the right side for an orthographic camera
  26476. * In scene unit
  26477. */
  26478. orthoRight: Nullable<number>;
  26479. /**
  26480. * Define the current limit on the bottom side for an orthographic camera
  26481. * In scene unit
  26482. */
  26483. orthoBottom: Nullable<number>;
  26484. /**
  26485. * Define the current limit on the top side for an orthographic camera
  26486. * In scene unit
  26487. */
  26488. orthoTop: Nullable<number>;
  26489. /**
  26490. * Field Of View is set in Radians. (default is 0.8)
  26491. */
  26492. fov: number;
  26493. /**
  26494. * Define the minimum distance the camera can see from.
  26495. * This is important to note that the depth buffer are not infinite and the closer it starts
  26496. * the more your scene might encounter depth fighting issue.
  26497. */
  26498. minZ: number;
  26499. /**
  26500. * Define the maximum distance the camera can see to.
  26501. * This is important to note that the depth buffer are not infinite and the further it end
  26502. * the more your scene might encounter depth fighting issue.
  26503. */
  26504. maxZ: number;
  26505. /**
  26506. * Define the default inertia of the camera.
  26507. * This helps giving a smooth feeling to the camera movement.
  26508. */
  26509. inertia: number;
  26510. /**
  26511. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26512. */
  26513. mode: number;
  26514. /**
  26515. * Define whether the camera is intermediate.
  26516. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26517. */
  26518. isIntermediate: boolean;
  26519. /**
  26520. * Define the viewport of the camera.
  26521. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26522. */
  26523. viewport: Viewport;
  26524. /**
  26525. * Restricts the camera to viewing objects with the same layerMask.
  26526. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26527. */
  26528. layerMask: number;
  26529. /**
  26530. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26531. */
  26532. fovMode: number;
  26533. /**
  26534. * Rig mode of the camera.
  26535. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26536. * This is normally controlled byt the camera themselves as internal use.
  26537. */
  26538. cameraRigMode: number;
  26539. /**
  26540. * Defines the distance between both "eyes" in case of a RIG
  26541. */
  26542. interaxialDistance: number;
  26543. /**
  26544. * Defines if stereoscopic rendering is done side by side or over under.
  26545. */
  26546. isStereoscopicSideBySide: boolean;
  26547. /**
  26548. * 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
  26549. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26550. * else in the scene. (Eg. security camera)
  26551. *
  26552. * 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)
  26553. */
  26554. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26555. /**
  26556. * When set, the camera will render to this render target instead of the default canvas
  26557. *
  26558. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26559. */
  26560. outputRenderTarget: Nullable<RenderTargetTexture>;
  26561. /**
  26562. * Observable triggered when the camera view matrix has changed.
  26563. */
  26564. onViewMatrixChangedObservable: Observable<Camera>;
  26565. /**
  26566. * Observable triggered when the camera Projection matrix has changed.
  26567. */
  26568. onProjectionMatrixChangedObservable: Observable<Camera>;
  26569. /**
  26570. * Observable triggered when the inputs have been processed.
  26571. */
  26572. onAfterCheckInputsObservable: Observable<Camera>;
  26573. /**
  26574. * Observable triggered when reset has been called and applied to the camera.
  26575. */
  26576. onRestoreStateObservable: Observable<Camera>;
  26577. /**
  26578. * Is this camera a part of a rig system?
  26579. */
  26580. isRigCamera: boolean;
  26581. /**
  26582. * If isRigCamera set to true this will be set with the parent camera.
  26583. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26584. */
  26585. rigParent?: Camera;
  26586. /** @hidden */
  26587. _cameraRigParams: any;
  26588. /** @hidden */
  26589. _rigCameras: Camera[];
  26590. /** @hidden */
  26591. _rigPostProcess: Nullable<PostProcess>;
  26592. protected _webvrViewMatrix: Matrix;
  26593. /** @hidden */
  26594. _skipRendering: boolean;
  26595. /** @hidden */
  26596. _projectionMatrix: Matrix;
  26597. /** @hidden */
  26598. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26599. /** @hidden */
  26600. _activeMeshes: SmartArray<AbstractMesh>;
  26601. protected _globalPosition: Vector3;
  26602. /** @hidden */
  26603. _computedViewMatrix: Matrix;
  26604. private _doNotComputeProjectionMatrix;
  26605. private _transformMatrix;
  26606. private _frustumPlanes;
  26607. private _refreshFrustumPlanes;
  26608. private _storedFov;
  26609. private _stateStored;
  26610. /**
  26611. * Instantiates a new camera object.
  26612. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26613. * @see http://doc.babylonjs.com/features/cameras
  26614. * @param name Defines the name of the camera in the scene
  26615. * @param position Defines the position of the camera
  26616. * @param scene Defines the scene the camera belongs too
  26617. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26618. */
  26619. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26620. /**
  26621. * Store current camera state (fov, position, etc..)
  26622. * @returns the camera
  26623. */
  26624. storeState(): Camera;
  26625. /**
  26626. * Restores the camera state values if it has been stored. You must call storeState() first
  26627. */
  26628. protected _restoreStateValues(): boolean;
  26629. /**
  26630. * Restored camera state. You must call storeState() first.
  26631. * @returns true if restored and false otherwise
  26632. */
  26633. restoreState(): boolean;
  26634. /**
  26635. * Gets the class name of the camera.
  26636. * @returns the class name
  26637. */
  26638. getClassName(): string;
  26639. /** @hidden */
  26640. readonly _isCamera: boolean;
  26641. /**
  26642. * Gets a string representation of the camera useful for debug purpose.
  26643. * @param fullDetails Defines that a more verboe level of logging is required
  26644. * @returns the string representation
  26645. */
  26646. toString(fullDetails?: boolean): string;
  26647. /**
  26648. * Gets the current world space position of the camera.
  26649. */
  26650. get globalPosition(): Vector3;
  26651. /**
  26652. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26653. * @returns the active meshe list
  26654. */
  26655. getActiveMeshes(): SmartArray<AbstractMesh>;
  26656. /**
  26657. * Check whether a mesh is part of the current active mesh list of the camera
  26658. * @param mesh Defines the mesh to check
  26659. * @returns true if active, false otherwise
  26660. */
  26661. isActiveMesh(mesh: Mesh): boolean;
  26662. /**
  26663. * Is this camera ready to be used/rendered
  26664. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26665. * @return true if the camera is ready
  26666. */
  26667. isReady(completeCheck?: boolean): boolean;
  26668. /** @hidden */
  26669. _initCache(): void;
  26670. /** @hidden */
  26671. _updateCache(ignoreParentClass?: boolean): void;
  26672. /** @hidden */
  26673. _isSynchronized(): boolean;
  26674. /** @hidden */
  26675. _isSynchronizedViewMatrix(): boolean;
  26676. /** @hidden */
  26677. _isSynchronizedProjectionMatrix(): boolean;
  26678. /**
  26679. * Attach the input controls to a specific dom element to get the input from.
  26680. * @param element Defines the element the controls should be listened from
  26681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26682. */
  26683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26684. /**
  26685. * Detach the current controls from the specified dom element.
  26686. * @param element Defines the element to stop listening the inputs from
  26687. */
  26688. detachControl(element: HTMLElement): void;
  26689. /**
  26690. * Update the camera state according to the different inputs gathered during the frame.
  26691. */
  26692. update(): void;
  26693. /** @hidden */
  26694. _checkInputs(): void;
  26695. /** @hidden */
  26696. get rigCameras(): Camera[];
  26697. /**
  26698. * Gets the post process used by the rig cameras
  26699. */
  26700. get rigPostProcess(): Nullable<PostProcess>;
  26701. /**
  26702. * Internal, gets the first post proces.
  26703. * @returns the first post process to be run on this camera.
  26704. */
  26705. _getFirstPostProcess(): Nullable<PostProcess>;
  26706. private _cascadePostProcessesToRigCams;
  26707. /**
  26708. * Attach a post process to the camera.
  26709. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26710. * @param postProcess The post process to attach to the camera
  26711. * @param insertAt The position of the post process in case several of them are in use in the scene
  26712. * @returns the position the post process has been inserted at
  26713. */
  26714. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26715. /**
  26716. * Detach a post process to the camera.
  26717. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26718. * @param postProcess The post process to detach from the camera
  26719. */
  26720. detachPostProcess(postProcess: PostProcess): void;
  26721. /**
  26722. * Gets the current world matrix of the camera
  26723. */
  26724. getWorldMatrix(): Matrix;
  26725. /** @hidden */
  26726. _getViewMatrix(): Matrix;
  26727. /**
  26728. * Gets the current view matrix of the camera.
  26729. * @param force forces the camera to recompute the matrix without looking at the cached state
  26730. * @returns the view matrix
  26731. */
  26732. getViewMatrix(force?: boolean): Matrix;
  26733. /**
  26734. * Freeze the projection matrix.
  26735. * It will prevent the cache check of the camera projection compute and can speed up perf
  26736. * if no parameter of the camera are meant to change
  26737. * @param projection Defines manually a projection if necessary
  26738. */
  26739. freezeProjectionMatrix(projection?: Matrix): void;
  26740. /**
  26741. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26742. */
  26743. unfreezeProjectionMatrix(): void;
  26744. /**
  26745. * Gets the current projection matrix of the camera.
  26746. * @param force forces the camera to recompute the matrix without looking at the cached state
  26747. * @returns the projection matrix
  26748. */
  26749. getProjectionMatrix(force?: boolean): Matrix;
  26750. /**
  26751. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26752. * @returns a Matrix
  26753. */
  26754. getTransformationMatrix(): Matrix;
  26755. private _updateFrustumPlanes;
  26756. /**
  26757. * Checks if a cullable object (mesh...) is in the camera frustum
  26758. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26759. * @param target The object to check
  26760. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26761. * @returns true if the object is in frustum otherwise false
  26762. */
  26763. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26764. /**
  26765. * Checks if a cullable object (mesh...) is in the camera frustum
  26766. * Unlike isInFrustum this cheks the full bounding box
  26767. * @param target The object to check
  26768. * @returns true if the object is in frustum otherwise false
  26769. */
  26770. isCompletelyInFrustum(target: ICullable): boolean;
  26771. /**
  26772. * Gets a ray in the forward direction from the camera.
  26773. * @param length Defines the length of the ray to create
  26774. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26775. * @param origin Defines the start point of the ray which defaults to the camera position
  26776. * @returns the forward ray
  26777. */
  26778. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26779. /**
  26780. * Releases resources associated with this node.
  26781. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26782. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26783. */
  26784. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26785. /** @hidden */
  26786. _isLeftCamera: boolean;
  26787. /**
  26788. * Gets the left camera of a rig setup in case of Rigged Camera
  26789. */
  26790. get isLeftCamera(): boolean;
  26791. /** @hidden */
  26792. _isRightCamera: boolean;
  26793. /**
  26794. * Gets the right camera of a rig setup in case of Rigged Camera
  26795. */
  26796. get isRightCamera(): boolean;
  26797. /**
  26798. * Gets the left camera of a rig setup in case of Rigged Camera
  26799. */
  26800. get leftCamera(): Nullable<FreeCamera>;
  26801. /**
  26802. * Gets the right camera of a rig setup in case of Rigged Camera
  26803. */
  26804. get rightCamera(): Nullable<FreeCamera>;
  26805. /**
  26806. * Gets the left camera target of a rig setup in case of Rigged Camera
  26807. * @returns the target position
  26808. */
  26809. getLeftTarget(): Nullable<Vector3>;
  26810. /**
  26811. * Gets the right camera target of a rig setup in case of Rigged Camera
  26812. * @returns the target position
  26813. */
  26814. getRightTarget(): Nullable<Vector3>;
  26815. /**
  26816. * @hidden
  26817. */
  26818. setCameraRigMode(mode: number, rigParams: any): void;
  26819. /** @hidden */
  26820. static _setStereoscopicRigMode(camera: Camera): void;
  26821. /** @hidden */
  26822. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26823. /** @hidden */
  26824. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26825. /** @hidden */
  26826. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26827. /** @hidden */
  26828. _getVRProjectionMatrix(): Matrix;
  26829. protected _updateCameraRotationMatrix(): void;
  26830. protected _updateWebVRCameraRotationMatrix(): void;
  26831. /**
  26832. * This function MUST be overwritten by the different WebVR cameras available.
  26833. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26834. * @hidden
  26835. */
  26836. _getWebVRProjectionMatrix(): Matrix;
  26837. /**
  26838. * This function MUST be overwritten by the different WebVR cameras available.
  26839. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26840. * @hidden
  26841. */
  26842. _getWebVRViewMatrix(): Matrix;
  26843. /** @hidden */
  26844. setCameraRigParameter(name: string, value: any): void;
  26845. /**
  26846. * needs to be overridden by children so sub has required properties to be copied
  26847. * @hidden
  26848. */
  26849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26850. /**
  26851. * May need to be overridden by children
  26852. * @hidden
  26853. */
  26854. _updateRigCameras(): void;
  26855. /** @hidden */
  26856. _setupInputs(): void;
  26857. /**
  26858. * Serialiaze the camera setup to a json represention
  26859. * @returns the JSON representation
  26860. */
  26861. serialize(): any;
  26862. /**
  26863. * Clones the current camera.
  26864. * @param name The cloned camera name
  26865. * @returns the cloned camera
  26866. */
  26867. clone(name: string): Camera;
  26868. /**
  26869. * Gets the direction of the camera relative to a given local axis.
  26870. * @param localAxis Defines the reference axis to provide a relative direction.
  26871. * @return the direction
  26872. */
  26873. getDirection(localAxis: Vector3): Vector3;
  26874. /**
  26875. * Returns the current camera absolute rotation
  26876. */
  26877. get absoluteRotation(): Quaternion;
  26878. /**
  26879. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26880. * @param localAxis Defines the reference axis to provide a relative direction.
  26881. * @param result Defines the vector to store the result in
  26882. */
  26883. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26884. /**
  26885. * Gets a camera constructor for a given camera type
  26886. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26887. * @param name The name of the camera the result will be able to instantiate
  26888. * @param scene The scene the result will construct the camera in
  26889. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26890. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26891. * @returns a factory method to construc the camera
  26892. */
  26893. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26894. /**
  26895. * Compute the world matrix of the camera.
  26896. * @returns the camera world matrix
  26897. */
  26898. computeWorldMatrix(): Matrix;
  26899. /**
  26900. * Parse a JSON and creates the camera from the parsed information
  26901. * @param parsedCamera The JSON to parse
  26902. * @param scene The scene to instantiate the camera in
  26903. * @returns the newly constructed camera
  26904. */
  26905. static Parse(parsedCamera: any, scene: Scene): Camera;
  26906. }
  26907. }
  26908. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26909. import { Nullable } from "babylonjs/types";
  26910. import { Scene } from "babylonjs/scene";
  26911. import { Vector4 } from "babylonjs/Maths/math.vector";
  26912. import { Mesh } from "babylonjs/Meshes/mesh";
  26913. /**
  26914. * Class containing static functions to help procedurally build meshes
  26915. */
  26916. export class DiscBuilder {
  26917. /**
  26918. * Creates a plane polygonal mesh. By default, this is a disc
  26919. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26920. * * 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
  26921. * * 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
  26922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26925. * @param name defines the name of the mesh
  26926. * @param options defines the options used to create the mesh
  26927. * @param scene defines the hosting scene
  26928. * @returns the plane polygonal mesh
  26929. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26930. */
  26931. static CreateDisc(name: string, options: {
  26932. radius?: number;
  26933. tessellation?: number;
  26934. arc?: number;
  26935. updatable?: boolean;
  26936. sideOrientation?: number;
  26937. frontUVs?: Vector4;
  26938. backUVs?: Vector4;
  26939. }, scene?: Nullable<Scene>): Mesh;
  26940. }
  26941. }
  26942. declare module "babylonjs/Materials/fresnelParameters" {
  26943. import { DeepImmutable } from "babylonjs/types";
  26944. import { Color3 } from "babylonjs/Maths/math.color";
  26945. /**
  26946. * Options to be used when creating a FresnelParameters.
  26947. */
  26948. export type IFresnelParametersCreationOptions = {
  26949. /**
  26950. * Define the color used on edges (grazing angle)
  26951. */
  26952. leftColor?: Color3;
  26953. /**
  26954. * Define the color used on center
  26955. */
  26956. rightColor?: Color3;
  26957. /**
  26958. * Define bias applied to computed fresnel term
  26959. */
  26960. bias?: number;
  26961. /**
  26962. * Defined the power exponent applied to fresnel term
  26963. */
  26964. power?: number;
  26965. /**
  26966. * Define if the fresnel effect is enable or not.
  26967. */
  26968. isEnabled?: boolean;
  26969. };
  26970. /**
  26971. * Serialized format for FresnelParameters.
  26972. */
  26973. export type IFresnelParametersSerialized = {
  26974. /**
  26975. * Define the color used on edges (grazing angle) [as an array]
  26976. */
  26977. leftColor: number[];
  26978. /**
  26979. * Define the color used on center [as an array]
  26980. */
  26981. rightColor: number[];
  26982. /**
  26983. * Define bias applied to computed fresnel term
  26984. */
  26985. bias: number;
  26986. /**
  26987. * Defined the power exponent applied to fresnel term
  26988. */
  26989. power?: number;
  26990. /**
  26991. * Define if the fresnel effect is enable or not.
  26992. */
  26993. isEnabled: boolean;
  26994. };
  26995. /**
  26996. * This represents all the required information to add a fresnel effect on a material:
  26997. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26998. */
  26999. export class FresnelParameters {
  27000. private _isEnabled;
  27001. /**
  27002. * Define if the fresnel effect is enable or not.
  27003. */
  27004. get isEnabled(): boolean;
  27005. set isEnabled(value: boolean);
  27006. /**
  27007. * Define the color used on edges (grazing angle)
  27008. */
  27009. leftColor: Color3;
  27010. /**
  27011. * Define the color used on center
  27012. */
  27013. rightColor: Color3;
  27014. /**
  27015. * Define bias applied to computed fresnel term
  27016. */
  27017. bias: number;
  27018. /**
  27019. * Defined the power exponent applied to fresnel term
  27020. */
  27021. power: number;
  27022. /**
  27023. * Creates a new FresnelParameters object.
  27024. *
  27025. * @param options provide your own settings to optionally to override defaults
  27026. */
  27027. constructor(options?: IFresnelParametersCreationOptions);
  27028. /**
  27029. * Clones the current fresnel and its valuues
  27030. * @returns a clone fresnel configuration
  27031. */
  27032. clone(): FresnelParameters;
  27033. /**
  27034. * Determines equality between FresnelParameters objects
  27035. * @param otherFresnelParameters defines the second operand
  27036. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  27037. */
  27038. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  27039. /**
  27040. * Serializes the current fresnel parameters to a JSON representation.
  27041. * @return the JSON serialization
  27042. */
  27043. serialize(): IFresnelParametersSerialized;
  27044. /**
  27045. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  27046. * @param parsedFresnelParameters Define the JSON representation
  27047. * @returns the parsed parameters
  27048. */
  27049. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  27050. }
  27051. }
  27052. declare module "babylonjs/Materials/pushMaterial" {
  27053. import { Nullable } from "babylonjs/types";
  27054. import { Scene } from "babylonjs/scene";
  27055. import { Matrix } from "babylonjs/Maths/math.vector";
  27056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27057. import { Mesh } from "babylonjs/Meshes/mesh";
  27058. import { Material } from "babylonjs/Materials/material";
  27059. import { Effect } from "babylonjs/Materials/effect";
  27060. /**
  27061. * Base class of materials working in push mode in babylon JS
  27062. * @hidden
  27063. */
  27064. export class PushMaterial extends Material {
  27065. protected _activeEffect: Effect;
  27066. protected _normalMatrix: Matrix;
  27067. /**
  27068. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27069. * This means that the material can keep using a previous shader while a new one is being compiled.
  27070. * This is mostly used when shader parallel compilation is supported (true by default)
  27071. */
  27072. allowShaderHotSwapping: boolean;
  27073. constructor(name: string, scene: Scene);
  27074. getEffect(): Effect;
  27075. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27076. /**
  27077. * Binds the given world matrix to the active effect
  27078. *
  27079. * @param world the matrix to bind
  27080. */
  27081. bindOnlyWorldMatrix(world: Matrix): void;
  27082. /**
  27083. * Binds the given normal matrix to the active effect
  27084. *
  27085. * @param normalMatrix the matrix to bind
  27086. */
  27087. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27088. bind(world: Matrix, mesh?: Mesh): void;
  27089. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27090. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27091. }
  27092. }
  27093. declare module "babylonjs/Materials/materialFlags" {
  27094. /**
  27095. * This groups all the flags used to control the materials channel.
  27096. */
  27097. export class MaterialFlags {
  27098. private static _DiffuseTextureEnabled;
  27099. /**
  27100. * Are diffuse textures enabled in the application.
  27101. */
  27102. static get DiffuseTextureEnabled(): boolean;
  27103. static set DiffuseTextureEnabled(value: boolean);
  27104. private static _AmbientTextureEnabled;
  27105. /**
  27106. * Are ambient textures enabled in the application.
  27107. */
  27108. static get AmbientTextureEnabled(): boolean;
  27109. static set AmbientTextureEnabled(value: boolean);
  27110. private static _OpacityTextureEnabled;
  27111. /**
  27112. * Are opacity textures enabled in the application.
  27113. */
  27114. static get OpacityTextureEnabled(): boolean;
  27115. static set OpacityTextureEnabled(value: boolean);
  27116. private static _ReflectionTextureEnabled;
  27117. /**
  27118. * Are reflection textures enabled in the application.
  27119. */
  27120. static get ReflectionTextureEnabled(): boolean;
  27121. static set ReflectionTextureEnabled(value: boolean);
  27122. private static _EmissiveTextureEnabled;
  27123. /**
  27124. * Are emissive textures enabled in the application.
  27125. */
  27126. static get EmissiveTextureEnabled(): boolean;
  27127. static set EmissiveTextureEnabled(value: boolean);
  27128. private static _SpecularTextureEnabled;
  27129. /**
  27130. * Are specular textures enabled in the application.
  27131. */
  27132. static get SpecularTextureEnabled(): boolean;
  27133. static set SpecularTextureEnabled(value: boolean);
  27134. private static _BumpTextureEnabled;
  27135. /**
  27136. * Are bump textures enabled in the application.
  27137. */
  27138. static get BumpTextureEnabled(): boolean;
  27139. static set BumpTextureEnabled(value: boolean);
  27140. private static _LightmapTextureEnabled;
  27141. /**
  27142. * Are lightmap textures enabled in the application.
  27143. */
  27144. static get LightmapTextureEnabled(): boolean;
  27145. static set LightmapTextureEnabled(value: boolean);
  27146. private static _RefractionTextureEnabled;
  27147. /**
  27148. * Are refraction textures enabled in the application.
  27149. */
  27150. static get RefractionTextureEnabled(): boolean;
  27151. static set RefractionTextureEnabled(value: boolean);
  27152. private static _ColorGradingTextureEnabled;
  27153. /**
  27154. * Are color grading textures enabled in the application.
  27155. */
  27156. static get ColorGradingTextureEnabled(): boolean;
  27157. static set ColorGradingTextureEnabled(value: boolean);
  27158. private static _FresnelEnabled;
  27159. /**
  27160. * Are fresnels enabled in the application.
  27161. */
  27162. static get FresnelEnabled(): boolean;
  27163. static set FresnelEnabled(value: boolean);
  27164. private static _ClearCoatTextureEnabled;
  27165. /**
  27166. * Are clear coat textures enabled in the application.
  27167. */
  27168. static get ClearCoatTextureEnabled(): boolean;
  27169. static set ClearCoatTextureEnabled(value: boolean);
  27170. private static _ClearCoatBumpTextureEnabled;
  27171. /**
  27172. * Are clear coat bump textures enabled in the application.
  27173. */
  27174. static get ClearCoatBumpTextureEnabled(): boolean;
  27175. static set ClearCoatBumpTextureEnabled(value: boolean);
  27176. private static _ClearCoatTintTextureEnabled;
  27177. /**
  27178. * Are clear coat tint textures enabled in the application.
  27179. */
  27180. static get ClearCoatTintTextureEnabled(): boolean;
  27181. static set ClearCoatTintTextureEnabled(value: boolean);
  27182. private static _SheenTextureEnabled;
  27183. /**
  27184. * Are sheen textures enabled in the application.
  27185. */
  27186. static get SheenTextureEnabled(): boolean;
  27187. static set SheenTextureEnabled(value: boolean);
  27188. private static _AnisotropicTextureEnabled;
  27189. /**
  27190. * Are anisotropic textures enabled in the application.
  27191. */
  27192. static get AnisotropicTextureEnabled(): boolean;
  27193. static set AnisotropicTextureEnabled(value: boolean);
  27194. private static _ThicknessTextureEnabled;
  27195. /**
  27196. * Are thickness textures enabled in the application.
  27197. */
  27198. static get ThicknessTextureEnabled(): boolean;
  27199. static set ThicknessTextureEnabled(value: boolean);
  27200. }
  27201. }
  27202. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27203. /** @hidden */
  27204. export var defaultFragmentDeclaration: {
  27205. name: string;
  27206. shader: string;
  27207. };
  27208. }
  27209. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27210. /** @hidden */
  27211. export var defaultUboDeclaration: {
  27212. name: string;
  27213. shader: string;
  27214. };
  27215. }
  27216. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27217. /** @hidden */
  27218. export var lightFragmentDeclaration: {
  27219. name: string;
  27220. shader: string;
  27221. };
  27222. }
  27223. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27224. /** @hidden */
  27225. export var lightUboDeclaration: {
  27226. name: string;
  27227. shader: string;
  27228. };
  27229. }
  27230. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27231. /** @hidden */
  27232. export var lightsFragmentFunctions: {
  27233. name: string;
  27234. shader: string;
  27235. };
  27236. }
  27237. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27238. /** @hidden */
  27239. export var shadowsFragmentFunctions: {
  27240. name: string;
  27241. shader: string;
  27242. };
  27243. }
  27244. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27245. /** @hidden */
  27246. export var fresnelFunction: {
  27247. name: string;
  27248. shader: string;
  27249. };
  27250. }
  27251. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27252. /** @hidden */
  27253. export var reflectionFunction: {
  27254. name: string;
  27255. shader: string;
  27256. };
  27257. }
  27258. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27259. /** @hidden */
  27260. export var bumpFragmentFunctions: {
  27261. name: string;
  27262. shader: string;
  27263. };
  27264. }
  27265. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27266. /** @hidden */
  27267. export var logDepthDeclaration: {
  27268. name: string;
  27269. shader: string;
  27270. };
  27271. }
  27272. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27273. /** @hidden */
  27274. export var bumpFragment: {
  27275. name: string;
  27276. shader: string;
  27277. };
  27278. }
  27279. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27280. /** @hidden */
  27281. export var depthPrePass: {
  27282. name: string;
  27283. shader: string;
  27284. };
  27285. }
  27286. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27287. /** @hidden */
  27288. export var lightFragment: {
  27289. name: string;
  27290. shader: string;
  27291. };
  27292. }
  27293. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27294. /** @hidden */
  27295. export var logDepthFragment: {
  27296. name: string;
  27297. shader: string;
  27298. };
  27299. }
  27300. declare module "babylonjs/Shaders/default.fragment" {
  27301. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27302. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27303. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27304. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27305. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27306. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27307. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27308. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27309. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27310. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27311. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27312. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27313. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27314. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27315. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27316. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27317. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27318. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27319. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27320. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27321. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27322. /** @hidden */
  27323. export var defaultPixelShader: {
  27324. name: string;
  27325. shader: string;
  27326. };
  27327. }
  27328. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27329. /** @hidden */
  27330. export var defaultVertexDeclaration: {
  27331. name: string;
  27332. shader: string;
  27333. };
  27334. }
  27335. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27336. /** @hidden */
  27337. export var bumpVertexDeclaration: {
  27338. name: string;
  27339. shader: string;
  27340. };
  27341. }
  27342. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27343. /** @hidden */
  27344. export var bumpVertex: {
  27345. name: string;
  27346. shader: string;
  27347. };
  27348. }
  27349. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27350. /** @hidden */
  27351. export var fogVertex: {
  27352. name: string;
  27353. shader: string;
  27354. };
  27355. }
  27356. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27357. /** @hidden */
  27358. export var shadowsVertex: {
  27359. name: string;
  27360. shader: string;
  27361. };
  27362. }
  27363. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27364. /** @hidden */
  27365. export var pointCloudVertex: {
  27366. name: string;
  27367. shader: string;
  27368. };
  27369. }
  27370. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27371. /** @hidden */
  27372. export var logDepthVertex: {
  27373. name: string;
  27374. shader: string;
  27375. };
  27376. }
  27377. declare module "babylonjs/Shaders/default.vertex" {
  27378. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27379. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27380. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27381. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27382. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27383. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27384. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27385. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27386. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27387. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27388. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27389. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27390. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27392. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27393. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27394. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27395. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27396. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27397. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27398. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27399. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27400. /** @hidden */
  27401. export var defaultVertexShader: {
  27402. name: string;
  27403. shader: string;
  27404. };
  27405. }
  27406. declare module "babylonjs/Materials/standardMaterial" {
  27407. import { SmartArray } from "babylonjs/Misc/smartArray";
  27408. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27409. import { Nullable } from "babylonjs/types";
  27410. import { Scene } from "babylonjs/scene";
  27411. import { Matrix } from "babylonjs/Maths/math.vector";
  27412. import { Color3 } from "babylonjs/Maths/math.color";
  27413. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27415. import { Mesh } from "babylonjs/Meshes/mesh";
  27416. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27417. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27418. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27419. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27420. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27422. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27423. import "babylonjs/Shaders/default.fragment";
  27424. import "babylonjs/Shaders/default.vertex";
  27425. /** @hidden */
  27426. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27427. MAINUV1: boolean;
  27428. MAINUV2: boolean;
  27429. DIFFUSE: boolean;
  27430. DIFFUSEDIRECTUV: number;
  27431. AMBIENT: boolean;
  27432. AMBIENTDIRECTUV: number;
  27433. OPACITY: boolean;
  27434. OPACITYDIRECTUV: number;
  27435. OPACITYRGB: boolean;
  27436. REFLECTION: boolean;
  27437. EMISSIVE: boolean;
  27438. EMISSIVEDIRECTUV: number;
  27439. SPECULAR: boolean;
  27440. SPECULARDIRECTUV: number;
  27441. BUMP: boolean;
  27442. BUMPDIRECTUV: number;
  27443. PARALLAX: boolean;
  27444. PARALLAXOCCLUSION: boolean;
  27445. SPECULAROVERALPHA: boolean;
  27446. CLIPPLANE: boolean;
  27447. CLIPPLANE2: boolean;
  27448. CLIPPLANE3: boolean;
  27449. CLIPPLANE4: boolean;
  27450. CLIPPLANE5: boolean;
  27451. CLIPPLANE6: boolean;
  27452. ALPHATEST: boolean;
  27453. DEPTHPREPASS: boolean;
  27454. ALPHAFROMDIFFUSE: boolean;
  27455. POINTSIZE: boolean;
  27456. FOG: boolean;
  27457. SPECULARTERM: boolean;
  27458. DIFFUSEFRESNEL: boolean;
  27459. OPACITYFRESNEL: boolean;
  27460. REFLECTIONFRESNEL: boolean;
  27461. REFRACTIONFRESNEL: boolean;
  27462. EMISSIVEFRESNEL: boolean;
  27463. FRESNEL: boolean;
  27464. NORMAL: boolean;
  27465. UV1: boolean;
  27466. UV2: boolean;
  27467. VERTEXCOLOR: boolean;
  27468. VERTEXALPHA: boolean;
  27469. NUM_BONE_INFLUENCERS: number;
  27470. BonesPerMesh: number;
  27471. BONETEXTURE: boolean;
  27472. INSTANCES: boolean;
  27473. GLOSSINESS: boolean;
  27474. ROUGHNESS: boolean;
  27475. EMISSIVEASILLUMINATION: boolean;
  27476. LINKEMISSIVEWITHDIFFUSE: boolean;
  27477. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27478. LIGHTMAP: boolean;
  27479. LIGHTMAPDIRECTUV: number;
  27480. OBJECTSPACE_NORMALMAP: boolean;
  27481. USELIGHTMAPASSHADOWMAP: boolean;
  27482. REFLECTIONMAP_3D: boolean;
  27483. REFLECTIONMAP_SPHERICAL: boolean;
  27484. REFLECTIONMAP_PLANAR: boolean;
  27485. REFLECTIONMAP_CUBIC: boolean;
  27486. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27487. REFLECTIONMAP_PROJECTION: boolean;
  27488. REFLECTIONMAP_SKYBOX: boolean;
  27489. REFLECTIONMAP_EXPLICIT: boolean;
  27490. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27491. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27492. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27493. INVERTCUBICMAP: boolean;
  27494. LOGARITHMICDEPTH: boolean;
  27495. REFRACTION: boolean;
  27496. REFRACTIONMAP_3D: boolean;
  27497. REFLECTIONOVERALPHA: boolean;
  27498. TWOSIDEDLIGHTING: boolean;
  27499. SHADOWFLOAT: boolean;
  27500. MORPHTARGETS: boolean;
  27501. MORPHTARGETS_NORMAL: boolean;
  27502. MORPHTARGETS_TANGENT: boolean;
  27503. MORPHTARGETS_UV: boolean;
  27504. NUM_MORPH_INFLUENCERS: number;
  27505. NONUNIFORMSCALING: boolean;
  27506. PREMULTIPLYALPHA: boolean;
  27507. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27508. ALPHABLEND: boolean;
  27509. IMAGEPROCESSING: boolean;
  27510. VIGNETTE: boolean;
  27511. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27512. VIGNETTEBLENDMODEOPAQUE: boolean;
  27513. TONEMAPPING: boolean;
  27514. TONEMAPPING_ACES: boolean;
  27515. CONTRAST: boolean;
  27516. COLORCURVES: boolean;
  27517. COLORGRADING: boolean;
  27518. COLORGRADING3D: boolean;
  27519. SAMPLER3DGREENDEPTH: boolean;
  27520. SAMPLER3DBGRMAP: boolean;
  27521. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27522. MULTIVIEW: boolean;
  27523. /**
  27524. * If the reflection texture on this material is in linear color space
  27525. * @hidden
  27526. */
  27527. IS_REFLECTION_LINEAR: boolean;
  27528. /**
  27529. * If the refraction texture on this material is in linear color space
  27530. * @hidden
  27531. */
  27532. IS_REFRACTION_LINEAR: boolean;
  27533. EXPOSURE: boolean;
  27534. constructor();
  27535. setReflectionMode(modeToEnable: string): void;
  27536. }
  27537. /**
  27538. * This is the default material used in Babylon. It is the best trade off between quality
  27539. * and performances.
  27540. * @see http://doc.babylonjs.com/babylon101/materials
  27541. */
  27542. export class StandardMaterial extends PushMaterial {
  27543. private _diffuseTexture;
  27544. /**
  27545. * The basic texture of the material as viewed under a light.
  27546. */
  27547. diffuseTexture: Nullable<BaseTexture>;
  27548. private _ambientTexture;
  27549. /**
  27550. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27551. */
  27552. ambientTexture: Nullable<BaseTexture>;
  27553. private _opacityTexture;
  27554. /**
  27555. * Define the transparency of the material from a texture.
  27556. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27557. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27558. */
  27559. opacityTexture: Nullable<BaseTexture>;
  27560. private _reflectionTexture;
  27561. /**
  27562. * Define the texture used to display the reflection.
  27563. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27564. */
  27565. reflectionTexture: Nullable<BaseTexture>;
  27566. private _emissiveTexture;
  27567. /**
  27568. * Define texture of the material as if self lit.
  27569. * This will be mixed in the final result even in the absence of light.
  27570. */
  27571. emissiveTexture: Nullable<BaseTexture>;
  27572. private _specularTexture;
  27573. /**
  27574. * Define how the color and intensity of the highlight given by the light in the material.
  27575. */
  27576. specularTexture: Nullable<BaseTexture>;
  27577. private _bumpTexture;
  27578. /**
  27579. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27580. * 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.
  27581. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27582. */
  27583. bumpTexture: Nullable<BaseTexture>;
  27584. private _lightmapTexture;
  27585. /**
  27586. * Complex lighting can be computationally expensive to compute at runtime.
  27587. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27588. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27589. */
  27590. lightmapTexture: Nullable<BaseTexture>;
  27591. private _refractionTexture;
  27592. /**
  27593. * Define the texture used to display the refraction.
  27594. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27595. */
  27596. refractionTexture: Nullable<BaseTexture>;
  27597. /**
  27598. * The color of the material lit by the environmental background lighting.
  27599. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27600. */
  27601. ambientColor: Color3;
  27602. /**
  27603. * The basic color of the material as viewed under a light.
  27604. */
  27605. diffuseColor: Color3;
  27606. /**
  27607. * Define how the color and intensity of the highlight given by the light in the material.
  27608. */
  27609. specularColor: Color3;
  27610. /**
  27611. * Define the color of the material as if self lit.
  27612. * This will be mixed in the final result even in the absence of light.
  27613. */
  27614. emissiveColor: Color3;
  27615. /**
  27616. * Defines how sharp are the highlights in the material.
  27617. * The bigger the value the sharper giving a more glossy feeling to the result.
  27618. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27619. */
  27620. specularPower: number;
  27621. private _useAlphaFromDiffuseTexture;
  27622. /**
  27623. * Does the transparency come from the diffuse texture alpha channel.
  27624. */
  27625. useAlphaFromDiffuseTexture: boolean;
  27626. private _useEmissiveAsIllumination;
  27627. /**
  27628. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27629. */
  27630. useEmissiveAsIllumination: boolean;
  27631. private _linkEmissiveWithDiffuse;
  27632. /**
  27633. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27634. * the emissive level when the final color is close to one.
  27635. */
  27636. linkEmissiveWithDiffuse: boolean;
  27637. private _useSpecularOverAlpha;
  27638. /**
  27639. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27640. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27641. */
  27642. useSpecularOverAlpha: boolean;
  27643. private _useReflectionOverAlpha;
  27644. /**
  27645. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27646. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27647. */
  27648. useReflectionOverAlpha: boolean;
  27649. private _disableLighting;
  27650. /**
  27651. * Does lights from the scene impacts this material.
  27652. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27653. */
  27654. disableLighting: boolean;
  27655. private _useObjectSpaceNormalMap;
  27656. /**
  27657. * Allows using an object space normal map (instead of tangent space).
  27658. */
  27659. useObjectSpaceNormalMap: boolean;
  27660. private _useParallax;
  27661. /**
  27662. * Is parallax enabled or not.
  27663. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27664. */
  27665. useParallax: boolean;
  27666. private _useParallaxOcclusion;
  27667. /**
  27668. * Is parallax occlusion enabled or not.
  27669. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27670. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27671. */
  27672. useParallaxOcclusion: boolean;
  27673. /**
  27674. * 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.
  27675. */
  27676. parallaxScaleBias: number;
  27677. private _roughness;
  27678. /**
  27679. * Helps to define how blurry the reflections should appears in the material.
  27680. */
  27681. roughness: number;
  27682. /**
  27683. * In case of refraction, define the value of the index of refraction.
  27684. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27685. */
  27686. indexOfRefraction: number;
  27687. /**
  27688. * Invert the refraction texture alongside the y axis.
  27689. * It can be useful with procedural textures or probe for instance.
  27690. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27691. */
  27692. invertRefractionY: boolean;
  27693. /**
  27694. * Defines the alpha limits in alpha test mode.
  27695. */
  27696. alphaCutOff: number;
  27697. private _useLightmapAsShadowmap;
  27698. /**
  27699. * In case of light mapping, define whether the map contains light or shadow informations.
  27700. */
  27701. useLightmapAsShadowmap: boolean;
  27702. private _diffuseFresnelParameters;
  27703. /**
  27704. * Define the diffuse fresnel parameters of the material.
  27705. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27706. */
  27707. diffuseFresnelParameters: FresnelParameters;
  27708. private _opacityFresnelParameters;
  27709. /**
  27710. * Define the opacity fresnel parameters of the material.
  27711. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27712. */
  27713. opacityFresnelParameters: FresnelParameters;
  27714. private _reflectionFresnelParameters;
  27715. /**
  27716. * Define the reflection fresnel parameters of the material.
  27717. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27718. */
  27719. reflectionFresnelParameters: FresnelParameters;
  27720. private _refractionFresnelParameters;
  27721. /**
  27722. * Define the refraction fresnel parameters of the material.
  27723. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27724. */
  27725. refractionFresnelParameters: FresnelParameters;
  27726. private _emissiveFresnelParameters;
  27727. /**
  27728. * Define the emissive fresnel parameters of the material.
  27729. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27730. */
  27731. emissiveFresnelParameters: FresnelParameters;
  27732. private _useReflectionFresnelFromSpecular;
  27733. /**
  27734. * If true automatically deducts the fresnels values from the material specularity.
  27735. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27736. */
  27737. useReflectionFresnelFromSpecular: boolean;
  27738. private _useGlossinessFromSpecularMapAlpha;
  27739. /**
  27740. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27741. */
  27742. useGlossinessFromSpecularMapAlpha: boolean;
  27743. private _maxSimultaneousLights;
  27744. /**
  27745. * Defines the maximum number of lights that can be used in the material
  27746. */
  27747. maxSimultaneousLights: number;
  27748. private _invertNormalMapX;
  27749. /**
  27750. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27751. */
  27752. invertNormalMapX: boolean;
  27753. private _invertNormalMapY;
  27754. /**
  27755. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27756. */
  27757. invertNormalMapY: boolean;
  27758. private _twoSidedLighting;
  27759. /**
  27760. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27761. */
  27762. twoSidedLighting: boolean;
  27763. /**
  27764. * Default configuration related to image processing available in the standard Material.
  27765. */
  27766. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27767. /**
  27768. * Gets the image processing configuration used either in this material.
  27769. */
  27770. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27771. /**
  27772. * Sets the Default image processing configuration used either in the this material.
  27773. *
  27774. * If sets to null, the scene one is in use.
  27775. */
  27776. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27777. /**
  27778. * Keep track of the image processing observer to allow dispose and replace.
  27779. */
  27780. private _imageProcessingObserver;
  27781. /**
  27782. * Attaches a new image processing configuration to the Standard Material.
  27783. * @param configuration
  27784. */
  27785. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27786. /**
  27787. * Gets wether the color curves effect is enabled.
  27788. */
  27789. get cameraColorCurvesEnabled(): boolean;
  27790. /**
  27791. * Sets wether the color curves effect is enabled.
  27792. */
  27793. set cameraColorCurvesEnabled(value: boolean);
  27794. /**
  27795. * Gets wether the color grading effect is enabled.
  27796. */
  27797. get cameraColorGradingEnabled(): boolean;
  27798. /**
  27799. * Gets wether the color grading effect is enabled.
  27800. */
  27801. set cameraColorGradingEnabled(value: boolean);
  27802. /**
  27803. * Gets wether tonemapping is enabled or not.
  27804. */
  27805. get cameraToneMappingEnabled(): boolean;
  27806. /**
  27807. * Sets wether tonemapping is enabled or not
  27808. */
  27809. set cameraToneMappingEnabled(value: boolean);
  27810. /**
  27811. * The camera exposure used on this material.
  27812. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27813. * This corresponds to a photographic exposure.
  27814. */
  27815. get cameraExposure(): number;
  27816. /**
  27817. * The camera exposure used on this material.
  27818. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27819. * This corresponds to a photographic exposure.
  27820. */
  27821. set cameraExposure(value: number);
  27822. /**
  27823. * Gets The camera contrast used on this material.
  27824. */
  27825. get cameraContrast(): number;
  27826. /**
  27827. * Sets The camera contrast used on this material.
  27828. */
  27829. set cameraContrast(value: number);
  27830. /**
  27831. * Gets the Color Grading 2D Lookup Texture.
  27832. */
  27833. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27834. /**
  27835. * Sets the Color Grading 2D Lookup Texture.
  27836. */
  27837. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27838. /**
  27839. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27840. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27841. * 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;
  27842. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27843. */
  27844. get cameraColorCurves(): Nullable<ColorCurves>;
  27845. /**
  27846. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27847. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27848. * 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;
  27849. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27850. */
  27851. set cameraColorCurves(value: Nullable<ColorCurves>);
  27852. /**
  27853. * Custom callback helping to override the default shader used in the material.
  27854. */
  27855. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27856. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27857. protected _worldViewProjectionMatrix: Matrix;
  27858. protected _globalAmbientColor: Color3;
  27859. protected _useLogarithmicDepth: boolean;
  27860. protected _rebuildInParallel: boolean;
  27861. /**
  27862. * Instantiates a new standard material.
  27863. * This is the default material used in Babylon. It is the best trade off between quality
  27864. * and performances.
  27865. * @see http://doc.babylonjs.com/babylon101/materials
  27866. * @param name Define the name of the material in the scene
  27867. * @param scene Define the scene the material belong to
  27868. */
  27869. constructor(name: string, scene: Scene);
  27870. /**
  27871. * Gets a boolean indicating that current material needs to register RTT
  27872. */
  27873. get hasRenderTargetTextures(): boolean;
  27874. /**
  27875. * Gets the current class name of the material e.g. "StandardMaterial"
  27876. * Mainly use in serialization.
  27877. * @returns the class name
  27878. */
  27879. getClassName(): string;
  27880. /**
  27881. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27882. * You can try switching to logarithmic depth.
  27883. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27884. */
  27885. get useLogarithmicDepth(): boolean;
  27886. set useLogarithmicDepth(value: boolean);
  27887. /**
  27888. * Specifies if the material will require alpha blending
  27889. * @returns a boolean specifying if alpha blending is needed
  27890. */
  27891. needAlphaBlending(): boolean;
  27892. /**
  27893. * Specifies if this material should be rendered in alpha test mode
  27894. * @returns a boolean specifying if an alpha test is needed.
  27895. */
  27896. needAlphaTesting(): boolean;
  27897. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27898. /**
  27899. * Get the texture used for alpha test purpose.
  27900. * @returns the diffuse texture in case of the standard material.
  27901. */
  27902. getAlphaTestTexture(): Nullable<BaseTexture>;
  27903. /**
  27904. * Get if the submesh is ready to be used and all its information available.
  27905. * Child classes can use it to update shaders
  27906. * @param mesh defines the mesh to check
  27907. * @param subMesh defines which submesh to check
  27908. * @param useInstances specifies that instances should be used
  27909. * @returns a boolean indicating that the submesh is ready or not
  27910. */
  27911. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27912. /**
  27913. * Builds the material UBO layouts.
  27914. * Used internally during the effect preparation.
  27915. */
  27916. buildUniformLayout(): void;
  27917. /**
  27918. * Unbinds the material from the mesh
  27919. */
  27920. unbind(): void;
  27921. /**
  27922. * Binds the submesh to this material by preparing the effect and shader to draw
  27923. * @param world defines the world transformation matrix
  27924. * @param mesh defines the mesh containing the submesh
  27925. * @param subMesh defines the submesh to bind the material to
  27926. */
  27927. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27928. /**
  27929. * Get the list of animatables in the material.
  27930. * @returns the list of animatables object used in the material
  27931. */
  27932. getAnimatables(): IAnimatable[];
  27933. /**
  27934. * Gets the active textures from the material
  27935. * @returns an array of textures
  27936. */
  27937. getActiveTextures(): BaseTexture[];
  27938. /**
  27939. * Specifies if the material uses a texture
  27940. * @param texture defines the texture to check against the material
  27941. * @returns a boolean specifying if the material uses the texture
  27942. */
  27943. hasTexture(texture: BaseTexture): boolean;
  27944. /**
  27945. * Disposes the material
  27946. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27947. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27948. */
  27949. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27950. /**
  27951. * Makes a duplicate of the material, and gives it a new name
  27952. * @param name defines the new name for the duplicated material
  27953. * @returns the cloned material
  27954. */
  27955. clone(name: string): StandardMaterial;
  27956. /**
  27957. * Serializes this material in a JSON representation
  27958. * @returns the serialized material object
  27959. */
  27960. serialize(): any;
  27961. /**
  27962. * Creates a standard material from parsed material data
  27963. * @param source defines the JSON representation of the material
  27964. * @param scene defines the hosting scene
  27965. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27966. * @returns a new standard material
  27967. */
  27968. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27969. /**
  27970. * Are diffuse textures enabled in the application.
  27971. */
  27972. static get DiffuseTextureEnabled(): boolean;
  27973. static set DiffuseTextureEnabled(value: boolean);
  27974. /**
  27975. * Are ambient textures enabled in the application.
  27976. */
  27977. static get AmbientTextureEnabled(): boolean;
  27978. static set AmbientTextureEnabled(value: boolean);
  27979. /**
  27980. * Are opacity textures enabled in the application.
  27981. */
  27982. static get OpacityTextureEnabled(): boolean;
  27983. static set OpacityTextureEnabled(value: boolean);
  27984. /**
  27985. * Are reflection textures enabled in the application.
  27986. */
  27987. static get ReflectionTextureEnabled(): boolean;
  27988. static set ReflectionTextureEnabled(value: boolean);
  27989. /**
  27990. * Are emissive textures enabled in the application.
  27991. */
  27992. static get EmissiveTextureEnabled(): boolean;
  27993. static set EmissiveTextureEnabled(value: boolean);
  27994. /**
  27995. * Are specular textures enabled in the application.
  27996. */
  27997. static get SpecularTextureEnabled(): boolean;
  27998. static set SpecularTextureEnabled(value: boolean);
  27999. /**
  28000. * Are bump textures enabled in the application.
  28001. */
  28002. static get BumpTextureEnabled(): boolean;
  28003. static set BumpTextureEnabled(value: boolean);
  28004. /**
  28005. * Are lightmap textures enabled in the application.
  28006. */
  28007. static get LightmapTextureEnabled(): boolean;
  28008. static set LightmapTextureEnabled(value: boolean);
  28009. /**
  28010. * Are refraction textures enabled in the application.
  28011. */
  28012. static get RefractionTextureEnabled(): boolean;
  28013. static set RefractionTextureEnabled(value: boolean);
  28014. /**
  28015. * Are color grading textures enabled in the application.
  28016. */
  28017. static get ColorGradingTextureEnabled(): boolean;
  28018. static set ColorGradingTextureEnabled(value: boolean);
  28019. /**
  28020. * Are fresnels enabled in the application.
  28021. */
  28022. static get FresnelEnabled(): boolean;
  28023. static set FresnelEnabled(value: boolean);
  28024. }
  28025. }
  28026. declare module "babylonjs/Particles/solidParticleSystem" {
  28027. import { Nullable } from "babylonjs/types";
  28028. import { Vector3 } from "babylonjs/Maths/math.vector";
  28029. import { Mesh } from "babylonjs/Meshes/mesh";
  28030. import { Scene, IDisposable } from "babylonjs/scene";
  28031. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  28032. import { Material } from "babylonjs/Materials/material";
  28033. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28034. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28035. /**
  28036. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28037. *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.
  28038. * The SPS is also a particle system. It provides some methods to manage the particles.
  28039. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28040. *
  28041. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28042. */
  28043. export class SolidParticleSystem implements IDisposable {
  28044. /**
  28045. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28046. * Example : var p = SPS.particles[i];
  28047. */
  28048. particles: SolidParticle[];
  28049. /**
  28050. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28051. */
  28052. nbParticles: number;
  28053. /**
  28054. * If the particles must ever face the camera (default false). Useful for planar particles.
  28055. */
  28056. billboard: boolean;
  28057. /**
  28058. * Recompute normals when adding a shape
  28059. */
  28060. recomputeNormals: boolean;
  28061. /**
  28062. * This a counter ofr your own usage. It's not set by any SPS functions.
  28063. */
  28064. counter: number;
  28065. /**
  28066. * The SPS name. This name is also given to the underlying mesh.
  28067. */
  28068. name: string;
  28069. /**
  28070. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28071. */
  28072. mesh: Mesh;
  28073. /**
  28074. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28075. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28076. */
  28077. vars: any;
  28078. /**
  28079. * This array is populated when the SPS is set as 'pickable'.
  28080. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28081. * Each element of this array is an object `{idx: int, faceId: int}`.
  28082. * `idx` is the picked particle index in the `SPS.particles` array
  28083. * `faceId` is the picked face index counted within this particle.
  28084. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28085. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28086. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28087. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28088. */
  28089. pickedParticles: {
  28090. idx: number;
  28091. faceId: number;
  28092. }[];
  28093. /**
  28094. * This array is populated when the SPS is set as 'pickable'
  28095. * Each key of this array is a submesh index.
  28096. * Each element of this array is a second array defined like this :
  28097. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28098. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28099. * `idx` is the picked particle index in the `SPS.particles` array
  28100. * `faceId` is the picked face index counted within this particle.
  28101. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28102. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28103. */
  28104. pickedBySubMesh: {
  28105. idx: number;
  28106. faceId: number;
  28107. }[][];
  28108. /**
  28109. * This array is populated when `enableDepthSort` is set to true.
  28110. * Each element of this array is an instance of the class DepthSortedParticle.
  28111. */
  28112. depthSortedParticles: DepthSortedParticle[];
  28113. /**
  28114. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28115. * @hidden
  28116. */
  28117. _bSphereOnly: boolean;
  28118. /**
  28119. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28120. * @hidden
  28121. */
  28122. _bSphereRadiusFactor: number;
  28123. private _scene;
  28124. private _positions;
  28125. private _indices;
  28126. private _normals;
  28127. private _colors;
  28128. private _uvs;
  28129. private _indices32;
  28130. private _positions32;
  28131. private _normals32;
  28132. private _fixedNormal32;
  28133. private _colors32;
  28134. private _uvs32;
  28135. private _index;
  28136. private _updatable;
  28137. private _pickable;
  28138. private _isVisibilityBoxLocked;
  28139. private _alwaysVisible;
  28140. private _depthSort;
  28141. private _expandable;
  28142. private _shapeCounter;
  28143. private _copy;
  28144. private _color;
  28145. private _computeParticleColor;
  28146. private _computeParticleTexture;
  28147. private _computeParticleRotation;
  28148. private _computeParticleVertex;
  28149. private _computeBoundingBox;
  28150. private _depthSortParticles;
  28151. private _camera;
  28152. private _mustUnrotateFixedNormals;
  28153. private _particlesIntersect;
  28154. private _needs32Bits;
  28155. private _isNotBuilt;
  28156. private _lastParticleId;
  28157. private _idxOfId;
  28158. private _multimaterialEnabled;
  28159. private _useModelMaterial;
  28160. private _indicesByMaterial;
  28161. private _materialIndexes;
  28162. private _depthSortFunction;
  28163. private _materialSortFunction;
  28164. private _materials;
  28165. private _multimaterial;
  28166. private _materialIndexesById;
  28167. private _defaultMaterial;
  28168. private _autoUpdateSubMeshes;
  28169. /**
  28170. * Creates a SPS (Solid Particle System) object.
  28171. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28172. * @param scene (Scene) is the scene in which the SPS is added.
  28173. * @param options defines the options of the sps e.g.
  28174. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28175. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28176. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28177. * * 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.
  28178. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28179. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28180. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28181. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28182. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28183. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28184. */
  28185. constructor(name: string, scene: Scene, options?: {
  28186. updatable?: boolean;
  28187. isPickable?: boolean;
  28188. enableDepthSort?: boolean;
  28189. particleIntersection?: boolean;
  28190. boundingSphereOnly?: boolean;
  28191. bSphereRadiusFactor?: number;
  28192. expandable?: boolean;
  28193. useModelMaterial?: boolean;
  28194. enableMultiMaterial?: boolean;
  28195. });
  28196. /**
  28197. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28198. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28199. * @returns the created mesh
  28200. */
  28201. buildMesh(): Mesh;
  28202. /**
  28203. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28204. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28205. * Thus the particles generated from `digest()` have their property `position` set yet.
  28206. * @param mesh ( Mesh ) is the mesh to be digested
  28207. * @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
  28208. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28209. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28210. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28211. * @returns the current SPS
  28212. */
  28213. digest(mesh: Mesh, options?: {
  28214. facetNb?: number;
  28215. number?: number;
  28216. delta?: number;
  28217. storage?: [];
  28218. }): SolidParticleSystem;
  28219. /**
  28220. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28221. * @hidden
  28222. */
  28223. private _unrotateFixedNormals;
  28224. /**
  28225. * Resets the temporary working copy particle
  28226. * @hidden
  28227. */
  28228. private _resetCopy;
  28229. /**
  28230. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28231. * @param p the current index in the positions array to be updated
  28232. * @param ind the current index in the indices array
  28233. * @param shape a Vector3 array, the shape geometry
  28234. * @param positions the positions array to be updated
  28235. * @param meshInd the shape indices array
  28236. * @param indices the indices array to be updated
  28237. * @param meshUV the shape uv array
  28238. * @param uvs the uv array to be updated
  28239. * @param meshCol the shape color array
  28240. * @param colors the color array to be updated
  28241. * @param meshNor the shape normals array
  28242. * @param normals the normals array to be updated
  28243. * @param idx the particle index
  28244. * @param idxInShape the particle index in its shape
  28245. * @param options the addShape() method passed options
  28246. * @model the particle model
  28247. * @hidden
  28248. */
  28249. private _meshBuilder;
  28250. /**
  28251. * Returns a shape Vector3 array from positions float array
  28252. * @param positions float array
  28253. * @returns a vector3 array
  28254. * @hidden
  28255. */
  28256. private _posToShape;
  28257. /**
  28258. * Returns a shapeUV array from a float uvs (array deep copy)
  28259. * @param uvs as a float array
  28260. * @returns a shapeUV array
  28261. * @hidden
  28262. */
  28263. private _uvsToShapeUV;
  28264. /**
  28265. * Adds a new particle object in the particles array
  28266. * @param idx particle index in particles array
  28267. * @param id particle id
  28268. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28269. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28270. * @param model particle ModelShape object
  28271. * @param shapeId model shape identifier
  28272. * @param idxInShape index of the particle in the current model
  28273. * @param bInfo model bounding info object
  28274. * @param storage target storage array, if any
  28275. * @hidden
  28276. */
  28277. private _addParticle;
  28278. /**
  28279. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28280. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28281. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28282. * @param nb (positive integer) the number of particles to be created from this model
  28283. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28284. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28285. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28286. * @returns the number of shapes in the system
  28287. */
  28288. addShape(mesh: Mesh, nb: number, options?: {
  28289. positionFunction?: any;
  28290. vertexFunction?: any;
  28291. storage?: [];
  28292. }): number;
  28293. /**
  28294. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28295. * @hidden
  28296. */
  28297. private _rebuildParticle;
  28298. /**
  28299. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28300. * @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.
  28301. * @returns the SPS.
  28302. */
  28303. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28304. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28305. * Returns an array with the removed particles.
  28306. * 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.
  28307. * The SPS can't be empty so at least one particle needs to remain in place.
  28308. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28309. * @param start index of the first particle to remove
  28310. * @param end index of the last particle to remove (included)
  28311. * @returns an array populated with the removed particles
  28312. */
  28313. removeParticles(start: number, end: number): SolidParticle[];
  28314. /**
  28315. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28316. * @param solidParticleArray an array populated with Solid Particles objects
  28317. * @returns the SPS
  28318. */
  28319. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28320. /**
  28321. * Creates a new particle and modifies the SPS mesh geometry :
  28322. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28323. * - calls _addParticle() to populate the particle array
  28324. * factorized code from addShape() and insertParticlesFromArray()
  28325. * @param idx particle index in the particles array
  28326. * @param i particle index in its shape
  28327. * @param modelShape particle ModelShape object
  28328. * @param shape shape vertex array
  28329. * @param meshInd shape indices array
  28330. * @param meshUV shape uv array
  28331. * @param meshCol shape color array
  28332. * @param meshNor shape normals array
  28333. * @param bbInfo shape bounding info
  28334. * @param storage target particle storage
  28335. * @options addShape() passed options
  28336. * @hidden
  28337. */
  28338. private _insertNewParticle;
  28339. /**
  28340. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28341. * This method calls `updateParticle()` for each particle of the SPS.
  28342. * For an animated SPS, it is usually called within the render loop.
  28343. * 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.
  28344. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28345. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28346. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28347. * @returns the SPS.
  28348. */
  28349. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28350. /**
  28351. * Disposes the SPS.
  28352. */
  28353. dispose(): void;
  28354. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28355. * idx is the particle index in the SPS
  28356. * faceId is the picked face index counted within this particle.
  28357. * Returns null if the pickInfo can't identify a picked particle.
  28358. * @param pickingInfo (PickingInfo object)
  28359. * @returns {idx: number, faceId: number} or null
  28360. */
  28361. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28362. idx: number;
  28363. faceId: number;
  28364. }>;
  28365. /**
  28366. * Returns a SolidParticle object from its identifier : particle.id
  28367. * @param id (integer) the particle Id
  28368. * @returns the searched particle or null if not found in the SPS.
  28369. */
  28370. getParticleById(id: number): Nullable<SolidParticle>;
  28371. /**
  28372. * Returns a new array populated with the particles having the passed shapeId.
  28373. * @param shapeId (integer) the shape identifier
  28374. * @returns a new solid particle array
  28375. */
  28376. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28377. /**
  28378. * Populates the passed array "ref" with the particles having the passed shapeId.
  28379. * @param shapeId the shape identifier
  28380. * @returns the SPS
  28381. * @param ref
  28382. */
  28383. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28384. /**
  28385. * Computes the required SubMeshes according the materials assigned to the particles.
  28386. * @returns the solid particle system.
  28387. * Does nothing if called before the SPS mesh is built.
  28388. */
  28389. computeSubMeshes(): SolidParticleSystem;
  28390. /**
  28391. * Sorts the solid particles by material when MultiMaterial is enabled.
  28392. * Updates the indices32 array.
  28393. * Updates the indicesByMaterial array.
  28394. * Updates the mesh indices array.
  28395. * @returns the SPS
  28396. * @hidden
  28397. */
  28398. private _sortParticlesByMaterial;
  28399. /**
  28400. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28401. * @hidden
  28402. */
  28403. private _setMaterialIndexesById;
  28404. /**
  28405. * Returns an array with unique values of Materials from the passed array
  28406. * @param array the material array to be checked and filtered
  28407. * @hidden
  28408. */
  28409. private _filterUniqueMaterialId;
  28410. /**
  28411. * Sets a new Standard Material as _defaultMaterial if not already set.
  28412. * @hidden
  28413. */
  28414. private _setDefaultMaterial;
  28415. /**
  28416. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28417. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28418. * @returns the SPS.
  28419. */
  28420. refreshVisibleSize(): SolidParticleSystem;
  28421. /**
  28422. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28423. * @param size the size (float) of the visibility box
  28424. * note : this doesn't lock the SPS mesh bounding box.
  28425. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28426. */
  28427. setVisibilityBox(size: number): void;
  28428. /**
  28429. * Gets whether the SPS as always visible or not
  28430. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28431. */
  28432. get isAlwaysVisible(): boolean;
  28433. /**
  28434. * Sets the SPS as always visible or not
  28435. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28436. */
  28437. set isAlwaysVisible(val: boolean);
  28438. /**
  28439. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28440. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28441. */
  28442. set isVisibilityBoxLocked(val: boolean);
  28443. /**
  28444. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28445. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28446. */
  28447. get isVisibilityBoxLocked(): boolean;
  28448. /**
  28449. * Tells to `setParticles()` to compute the particle rotations or not.
  28450. * Default value : true. The SPS is faster when it's set to false.
  28451. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28452. */
  28453. set computeParticleRotation(val: boolean);
  28454. /**
  28455. * Tells to `setParticles()` to compute the particle colors or not.
  28456. * Default value : true. The SPS is faster when it's set to false.
  28457. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28458. */
  28459. set computeParticleColor(val: boolean);
  28460. set computeParticleTexture(val: boolean);
  28461. /**
  28462. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28463. * Default value : false. The SPS is faster when it's set to false.
  28464. * Note : the particle custom vertex positions aren't stored values.
  28465. */
  28466. set computeParticleVertex(val: boolean);
  28467. /**
  28468. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28469. */
  28470. set computeBoundingBox(val: boolean);
  28471. /**
  28472. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28473. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28474. * Default : `true`
  28475. */
  28476. set depthSortParticles(val: boolean);
  28477. /**
  28478. * Gets if `setParticles()` computes the particle rotations or not.
  28479. * Default value : true. The SPS is faster when it's set to false.
  28480. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28481. */
  28482. get computeParticleRotation(): boolean;
  28483. /**
  28484. * Gets if `setParticles()` computes the particle colors or not.
  28485. * Default value : true. The SPS is faster when it's set to false.
  28486. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28487. */
  28488. get computeParticleColor(): boolean;
  28489. /**
  28490. * Gets if `setParticles()` computes the particle textures or not.
  28491. * Default value : true. The SPS is faster when it's set to false.
  28492. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28493. */
  28494. get computeParticleTexture(): boolean;
  28495. /**
  28496. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28497. * Default value : false. The SPS is faster when it's set to false.
  28498. * Note : the particle custom vertex positions aren't stored values.
  28499. */
  28500. get computeParticleVertex(): boolean;
  28501. /**
  28502. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28503. */
  28504. get computeBoundingBox(): boolean;
  28505. /**
  28506. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28507. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28508. * Default : `true`
  28509. */
  28510. get depthSortParticles(): boolean;
  28511. /**
  28512. * Gets if the SPS is created as expandable at construction time.
  28513. * Default : `false`
  28514. */
  28515. get expandable(): boolean;
  28516. /**
  28517. * Gets if the SPS supports the Multi Materials
  28518. */
  28519. get multimaterialEnabled(): boolean;
  28520. /**
  28521. * Gets if the SPS uses the model materials for its own multimaterial.
  28522. */
  28523. get useModelMaterial(): boolean;
  28524. /**
  28525. * The SPS used material array.
  28526. */
  28527. get materials(): Material[];
  28528. /**
  28529. * Sets the SPS MultiMaterial from the passed materials.
  28530. * Note : the passed array is internally copied and not used then by reference.
  28531. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28532. */
  28533. setMultiMaterial(materials: Material[]): void;
  28534. /**
  28535. * The SPS computed multimaterial object
  28536. */
  28537. get multimaterial(): MultiMaterial;
  28538. set multimaterial(mm: MultiMaterial);
  28539. /**
  28540. * If the subMeshes must be updated on the next call to setParticles()
  28541. */
  28542. get autoUpdateSubMeshes(): boolean;
  28543. set autoUpdateSubMeshes(val: boolean);
  28544. /**
  28545. * This function does nothing. It may be overwritten to set all the particle first values.
  28546. * The SPS doesn't call this function, you may have to call it by your own.
  28547. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28548. */
  28549. initParticles(): void;
  28550. /**
  28551. * This function does nothing. It may be overwritten to recycle a particle.
  28552. * The SPS doesn't call this function, you may have to call it by your own.
  28553. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28554. * @param particle The particle to recycle
  28555. * @returns the recycled particle
  28556. */
  28557. recycleParticle(particle: SolidParticle): SolidParticle;
  28558. /**
  28559. * Updates a particle : this function should be overwritten by the user.
  28560. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28561. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28562. * @example : just set a particle position or velocity and recycle conditions
  28563. * @param particle The particle to update
  28564. * @returns the updated particle
  28565. */
  28566. updateParticle(particle: SolidParticle): SolidParticle;
  28567. /**
  28568. * Updates a vertex of a particle : it can be overwritten by the user.
  28569. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28570. * @param particle the current particle
  28571. * @param vertex the current index of the current particle
  28572. * @param pt the index of the current vertex in the particle shape
  28573. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28574. * @example : just set a vertex particle position
  28575. * @returns the updated vertex
  28576. */
  28577. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28578. /**
  28579. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28580. * This does nothing and may be overwritten by the user.
  28581. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28582. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28583. * @param update the boolean update value actually passed to setParticles()
  28584. */
  28585. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28586. /**
  28587. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28588. * This will be passed three parameters.
  28589. * This does nothing and may be overwritten by the user.
  28590. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28591. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28592. * @param update the boolean update value actually passed to setParticles()
  28593. */
  28594. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28595. }
  28596. }
  28597. declare module "babylonjs/Particles/solidParticle" {
  28598. import { Nullable } from "babylonjs/types";
  28599. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28600. import { Color4 } from "babylonjs/Maths/math.color";
  28601. import { Mesh } from "babylonjs/Meshes/mesh";
  28602. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28603. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28604. import { Plane } from "babylonjs/Maths/math.plane";
  28605. import { Material } from "babylonjs/Materials/material";
  28606. /**
  28607. * Represents one particle of a solid particle system.
  28608. */
  28609. export class SolidParticle {
  28610. /**
  28611. * particle global index
  28612. */
  28613. idx: number;
  28614. /**
  28615. * particle identifier
  28616. */
  28617. id: number;
  28618. /**
  28619. * The color of the particle
  28620. */
  28621. color: Nullable<Color4>;
  28622. /**
  28623. * The world space position of the particle.
  28624. */
  28625. position: Vector3;
  28626. /**
  28627. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28628. */
  28629. rotation: Vector3;
  28630. /**
  28631. * The world space rotation quaternion of the particle.
  28632. */
  28633. rotationQuaternion: Nullable<Quaternion>;
  28634. /**
  28635. * The scaling of the particle.
  28636. */
  28637. scaling: Vector3;
  28638. /**
  28639. * The uvs of the particle.
  28640. */
  28641. uvs: Vector4;
  28642. /**
  28643. * The current speed of the particle.
  28644. */
  28645. velocity: Vector3;
  28646. /**
  28647. * The pivot point in the particle local space.
  28648. */
  28649. pivot: Vector3;
  28650. /**
  28651. * Must the particle be translated from its pivot point in its local space ?
  28652. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28653. * Default : false
  28654. */
  28655. translateFromPivot: boolean;
  28656. /**
  28657. * Is the particle active or not ?
  28658. */
  28659. alive: boolean;
  28660. /**
  28661. * Is the particle visible or not ?
  28662. */
  28663. isVisible: boolean;
  28664. /**
  28665. * Index of this particle in the global "positions" array (Internal use)
  28666. * @hidden
  28667. */
  28668. _pos: number;
  28669. /**
  28670. * @hidden Index of this particle in the global "indices" array (Internal use)
  28671. */
  28672. _ind: number;
  28673. /**
  28674. * @hidden ModelShape of this particle (Internal use)
  28675. */
  28676. _model: ModelShape;
  28677. /**
  28678. * ModelShape id of this particle
  28679. */
  28680. shapeId: number;
  28681. /**
  28682. * Index of the particle in its shape id
  28683. */
  28684. idxInShape: number;
  28685. /**
  28686. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28687. */
  28688. _modelBoundingInfo: BoundingInfo;
  28689. /**
  28690. * @hidden Particle BoundingInfo object (Internal use)
  28691. */
  28692. _boundingInfo: BoundingInfo;
  28693. /**
  28694. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28695. */
  28696. _sps: SolidParticleSystem;
  28697. /**
  28698. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28699. */
  28700. _stillInvisible: boolean;
  28701. /**
  28702. * @hidden Last computed particle rotation matrix
  28703. */
  28704. _rotationMatrix: number[];
  28705. /**
  28706. * Parent particle Id, if any.
  28707. * Default null.
  28708. */
  28709. parentId: Nullable<number>;
  28710. /**
  28711. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28712. */
  28713. materialIndex: Nullable<number>;
  28714. /**
  28715. * Custom object or properties.
  28716. */
  28717. props: Nullable<any>;
  28718. /**
  28719. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28720. * The possible values are :
  28721. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28722. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28723. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28724. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28725. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28726. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28727. * */
  28728. cullingStrategy: number;
  28729. /**
  28730. * @hidden Internal global position in the SPS.
  28731. */
  28732. _globalPosition: Vector3;
  28733. /**
  28734. * Creates a Solid Particle object.
  28735. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28736. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28737. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28738. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28739. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28740. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28741. * @param shapeId (integer) is the model shape identifier in the SPS.
  28742. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28743. * @param sps defines the sps it is associated to
  28744. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28745. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28746. */
  28747. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28748. /**
  28749. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28750. * @param target the particle target
  28751. * @returns the current particle
  28752. */
  28753. copyToRef(target: SolidParticle): SolidParticle;
  28754. /**
  28755. * Legacy support, changed scale to scaling
  28756. */
  28757. get scale(): Vector3;
  28758. /**
  28759. * Legacy support, changed scale to scaling
  28760. */
  28761. set scale(scale: Vector3);
  28762. /**
  28763. * Legacy support, changed quaternion to rotationQuaternion
  28764. */
  28765. get quaternion(): Nullable<Quaternion>;
  28766. /**
  28767. * Legacy support, changed quaternion to rotationQuaternion
  28768. */
  28769. set quaternion(q: Nullable<Quaternion>);
  28770. /**
  28771. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28772. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28773. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28774. * @returns true if it intersects
  28775. */
  28776. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28777. /**
  28778. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28779. * A particle is in the frustum if its bounding box intersects the frustum
  28780. * @param frustumPlanes defines the frustum to test
  28781. * @returns true if the particle is in the frustum planes
  28782. */
  28783. isInFrustum(frustumPlanes: Plane[]): boolean;
  28784. /**
  28785. * get the rotation matrix of the particle
  28786. * @hidden
  28787. */
  28788. getRotationMatrix(m: Matrix): void;
  28789. }
  28790. /**
  28791. * Represents the shape of the model used by one particle of a solid particle system.
  28792. * SPS internal tool, don't use it manually.
  28793. */
  28794. export class ModelShape {
  28795. /**
  28796. * The shape id
  28797. * @hidden
  28798. */
  28799. shapeID: number;
  28800. /**
  28801. * flat array of model positions (internal use)
  28802. * @hidden
  28803. */
  28804. _shape: Vector3[];
  28805. /**
  28806. * flat array of model UVs (internal use)
  28807. * @hidden
  28808. */
  28809. _shapeUV: number[];
  28810. /**
  28811. * color array of the model
  28812. * @hidden
  28813. */
  28814. _shapeColors: number[];
  28815. /**
  28816. * indices array of the model
  28817. * @hidden
  28818. */
  28819. _indices: number[];
  28820. /**
  28821. * normals array of the model
  28822. * @hidden
  28823. */
  28824. _normals: number[];
  28825. /**
  28826. * length of the shape in the model indices array (internal use)
  28827. * @hidden
  28828. */
  28829. _indicesLength: number;
  28830. /**
  28831. * Custom position function (internal use)
  28832. * @hidden
  28833. */
  28834. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28835. /**
  28836. * Custom vertex function (internal use)
  28837. * @hidden
  28838. */
  28839. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28840. /**
  28841. * Model material (internal use)
  28842. * @hidden
  28843. */
  28844. _material: Nullable<Material>;
  28845. /**
  28846. * 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.
  28847. * SPS internal tool, don't use it manually.
  28848. * @hidden
  28849. */
  28850. 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>);
  28851. }
  28852. /**
  28853. * Represents a Depth Sorted Particle in the solid particle system.
  28854. * @hidden
  28855. */
  28856. export class DepthSortedParticle {
  28857. /**
  28858. * Particle index
  28859. */
  28860. idx: number;
  28861. /**
  28862. * Index of the particle in the "indices" array
  28863. */
  28864. ind: number;
  28865. /**
  28866. * Length of the particle shape in the "indices" array
  28867. */
  28868. indicesLength: number;
  28869. /**
  28870. * Squared distance from the particle to the camera
  28871. */
  28872. sqDistance: number;
  28873. /**
  28874. * Material index when used with MultiMaterials
  28875. */
  28876. materialIndex: number;
  28877. /**
  28878. * Creates a new sorted particle
  28879. * @param materialIndex
  28880. */
  28881. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28882. }
  28883. }
  28884. declare module "babylonjs/Collisions/meshCollisionData" {
  28885. import { Collider } from "babylonjs/Collisions/collider";
  28886. import { Vector3 } from "babylonjs/Maths/math.vector";
  28887. import { Nullable } from "babylonjs/types";
  28888. import { Observer } from "babylonjs/Misc/observable";
  28889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28890. /**
  28891. * @hidden
  28892. */
  28893. export class _MeshCollisionData {
  28894. _checkCollisions: boolean;
  28895. _collisionMask: number;
  28896. _collisionGroup: number;
  28897. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28898. _collider: Nullable<Collider>;
  28899. _oldPositionForCollisions: Vector3;
  28900. _diffPositionForCollisions: Vector3;
  28901. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28902. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28903. }
  28904. }
  28905. declare module "babylonjs/Meshes/abstractMesh" {
  28906. import { Observable } from "babylonjs/Misc/observable";
  28907. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28908. import { Camera } from "babylonjs/Cameras/camera";
  28909. import { Scene, IDisposable } from "babylonjs/scene";
  28910. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28911. import { Node } from "babylonjs/node";
  28912. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28913. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28914. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28915. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28916. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28917. import { Material } from "babylonjs/Materials/material";
  28918. import { Light } from "babylonjs/Lights/light";
  28919. import { Skeleton } from "babylonjs/Bones/skeleton";
  28920. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28921. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28922. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28923. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28924. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28925. import { Plane } from "babylonjs/Maths/math.plane";
  28926. import { Ray } from "babylonjs/Culling/ray";
  28927. import { Collider } from "babylonjs/Collisions/collider";
  28928. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28929. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28930. /** @hidden */
  28931. class _FacetDataStorage {
  28932. facetPositions: Vector3[];
  28933. facetNormals: Vector3[];
  28934. facetPartitioning: number[][];
  28935. facetNb: number;
  28936. partitioningSubdivisions: number;
  28937. partitioningBBoxRatio: number;
  28938. facetDataEnabled: boolean;
  28939. facetParameters: any;
  28940. bbSize: Vector3;
  28941. subDiv: {
  28942. max: number;
  28943. X: number;
  28944. Y: number;
  28945. Z: number;
  28946. };
  28947. facetDepthSort: boolean;
  28948. facetDepthSortEnabled: boolean;
  28949. depthSortedIndices: IndicesArray;
  28950. depthSortedFacets: {
  28951. ind: number;
  28952. sqDistance: number;
  28953. }[];
  28954. facetDepthSortFunction: (f1: {
  28955. ind: number;
  28956. sqDistance: number;
  28957. }, f2: {
  28958. ind: number;
  28959. sqDistance: number;
  28960. }) => number;
  28961. facetDepthSortFrom: Vector3;
  28962. facetDepthSortOrigin: Vector3;
  28963. invertedMatrix: Matrix;
  28964. }
  28965. /**
  28966. * @hidden
  28967. **/
  28968. class _InternalAbstractMeshDataInfo {
  28969. _hasVertexAlpha: boolean;
  28970. _useVertexColors: boolean;
  28971. _numBoneInfluencers: number;
  28972. _applyFog: boolean;
  28973. _receiveShadows: boolean;
  28974. _facetData: _FacetDataStorage;
  28975. _visibility: number;
  28976. _skeleton: Nullable<Skeleton>;
  28977. _layerMask: number;
  28978. _computeBonesUsingShaders: boolean;
  28979. _isActive: boolean;
  28980. _onlyForInstances: boolean;
  28981. _isActiveIntermediate: boolean;
  28982. _onlyForInstancesIntermediate: boolean;
  28983. _actAsRegularMesh: boolean;
  28984. }
  28985. /**
  28986. * Class used to store all common mesh properties
  28987. */
  28988. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28989. /** No occlusion */
  28990. static OCCLUSION_TYPE_NONE: number;
  28991. /** Occlusion set to optimisitic */
  28992. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28993. /** Occlusion set to strict */
  28994. static OCCLUSION_TYPE_STRICT: number;
  28995. /** Use an accurante occlusion algorithm */
  28996. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28997. /** Use a conservative occlusion algorithm */
  28998. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28999. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29000. * Test order :
  29001. * Is the bounding sphere outside the frustum ?
  29002. * If not, are the bounding box vertices outside the frustum ?
  29003. * It not, then the cullable object is in the frustum.
  29004. */
  29005. static readonly CULLINGSTRATEGY_STANDARD: number;
  29006. /** Culling strategy : Bounding Sphere Only.
  29007. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29008. * It's also less accurate than the standard because some not visible objects can still be selected.
  29009. * Test : is the bounding sphere outside the frustum ?
  29010. * If not, then the cullable object is in the frustum.
  29011. */
  29012. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29013. /** Culling strategy : Optimistic Inclusion.
  29014. * This in an inclusion test first, then the standard exclusion test.
  29015. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29016. * 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.
  29017. * Anyway, it's as accurate as the standard strategy.
  29018. * Test :
  29019. * Is the cullable object bounding sphere center in the frustum ?
  29020. * If not, apply the default culling strategy.
  29021. */
  29022. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29023. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29024. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29025. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29026. * 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.
  29027. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29028. * Test :
  29029. * Is the cullable object bounding sphere center in the frustum ?
  29030. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29031. */
  29032. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29033. /**
  29034. * No billboard
  29035. */
  29036. static get BILLBOARDMODE_NONE(): number;
  29037. /** Billboard on X axis */
  29038. static get BILLBOARDMODE_X(): number;
  29039. /** Billboard on Y axis */
  29040. static get BILLBOARDMODE_Y(): number;
  29041. /** Billboard on Z axis */
  29042. static get BILLBOARDMODE_Z(): number;
  29043. /** Billboard on all axes */
  29044. static get BILLBOARDMODE_ALL(): number;
  29045. /** Billboard on using position instead of orientation */
  29046. static get BILLBOARDMODE_USE_POSITION(): number;
  29047. /** @hidden */
  29048. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29049. /**
  29050. * The culling strategy to use to check whether the mesh must be rendered or not.
  29051. * This value can be changed at any time and will be used on the next render mesh selection.
  29052. * The possible values are :
  29053. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29054. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29055. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29056. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29057. * Please read each static variable documentation to get details about the culling process.
  29058. * */
  29059. cullingStrategy: number;
  29060. /**
  29061. * Gets the number of facets in the mesh
  29062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29063. */
  29064. get facetNb(): number;
  29065. /**
  29066. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29068. */
  29069. get partitioningSubdivisions(): number;
  29070. set partitioningSubdivisions(nb: number);
  29071. /**
  29072. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29073. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29075. */
  29076. get partitioningBBoxRatio(): number;
  29077. set partitioningBBoxRatio(ratio: number);
  29078. /**
  29079. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29080. * Works only for updatable meshes.
  29081. * Doesn't work with multi-materials
  29082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29083. */
  29084. get mustDepthSortFacets(): boolean;
  29085. set mustDepthSortFacets(sort: boolean);
  29086. /**
  29087. * The location (Vector3) where the facet depth sort must be computed from.
  29088. * By default, the active camera position.
  29089. * Used only when facet depth sort is enabled
  29090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29091. */
  29092. get facetDepthSortFrom(): Vector3;
  29093. set facetDepthSortFrom(location: Vector3);
  29094. /**
  29095. * gets a boolean indicating if facetData is enabled
  29096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29097. */
  29098. get isFacetDataEnabled(): boolean;
  29099. /** @hidden */
  29100. _updateNonUniformScalingState(value: boolean): boolean;
  29101. /**
  29102. * An event triggered when this mesh collides with another one
  29103. */
  29104. onCollideObservable: Observable<AbstractMesh>;
  29105. /** Set a function to call when this mesh collides with another one */
  29106. set onCollide(callback: () => void);
  29107. /**
  29108. * An event triggered when the collision's position changes
  29109. */
  29110. onCollisionPositionChangeObservable: Observable<Vector3>;
  29111. /** Set a function to call when the collision's position changes */
  29112. set onCollisionPositionChange(callback: () => void);
  29113. /**
  29114. * An event triggered when material is changed
  29115. */
  29116. onMaterialChangedObservable: Observable<AbstractMesh>;
  29117. /**
  29118. * Gets or sets the orientation for POV movement & rotation
  29119. */
  29120. definedFacingForward: boolean;
  29121. /** @hidden */
  29122. _occlusionQuery: Nullable<WebGLQuery>;
  29123. /** @hidden */
  29124. _renderingGroup: Nullable<RenderingGroup>;
  29125. /**
  29126. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29127. */
  29128. get visibility(): number;
  29129. /**
  29130. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29131. */
  29132. set visibility(value: number);
  29133. /** Gets or sets the alpha index used to sort transparent meshes
  29134. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29135. */
  29136. alphaIndex: number;
  29137. /**
  29138. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29139. */
  29140. isVisible: boolean;
  29141. /**
  29142. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29143. */
  29144. isPickable: boolean;
  29145. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29146. showSubMeshesBoundingBox: boolean;
  29147. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29148. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29149. */
  29150. isBlocker: boolean;
  29151. /**
  29152. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29153. */
  29154. enablePointerMoveEvents: boolean;
  29155. /**
  29156. * Specifies the rendering group id for this mesh (0 by default)
  29157. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29158. */
  29159. renderingGroupId: number;
  29160. private _material;
  29161. /** Gets or sets current material */
  29162. get material(): Nullable<Material>;
  29163. set material(value: Nullable<Material>);
  29164. /**
  29165. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29166. * @see http://doc.babylonjs.com/babylon101/shadows
  29167. */
  29168. get receiveShadows(): boolean;
  29169. set receiveShadows(value: boolean);
  29170. /** Defines color to use when rendering outline */
  29171. outlineColor: Color3;
  29172. /** Define width to use when rendering outline */
  29173. outlineWidth: number;
  29174. /** Defines color to use when rendering overlay */
  29175. overlayColor: Color3;
  29176. /** Defines alpha to use when rendering overlay */
  29177. overlayAlpha: number;
  29178. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29179. get hasVertexAlpha(): boolean;
  29180. set hasVertexAlpha(value: boolean);
  29181. /** 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) */
  29182. get useVertexColors(): boolean;
  29183. set useVertexColors(value: boolean);
  29184. /**
  29185. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29186. */
  29187. get computeBonesUsingShaders(): boolean;
  29188. set computeBonesUsingShaders(value: boolean);
  29189. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29190. get numBoneInfluencers(): number;
  29191. set numBoneInfluencers(value: number);
  29192. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29193. get applyFog(): boolean;
  29194. set applyFog(value: boolean);
  29195. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29196. useOctreeForRenderingSelection: boolean;
  29197. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29198. useOctreeForPicking: boolean;
  29199. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29200. useOctreeForCollisions: boolean;
  29201. /**
  29202. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29203. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29204. */
  29205. get layerMask(): number;
  29206. set layerMask(value: number);
  29207. /**
  29208. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29209. */
  29210. alwaysSelectAsActiveMesh: boolean;
  29211. /**
  29212. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29213. */
  29214. doNotSyncBoundingInfo: boolean;
  29215. /**
  29216. * Gets or sets the current action manager
  29217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29218. */
  29219. actionManager: Nullable<AbstractActionManager>;
  29220. private _meshCollisionData;
  29221. /**
  29222. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29223. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29224. */
  29225. ellipsoid: Vector3;
  29226. /**
  29227. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29228. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29229. */
  29230. ellipsoidOffset: Vector3;
  29231. /**
  29232. * Gets or sets a collision mask used to mask collisions (default is -1).
  29233. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29234. */
  29235. get collisionMask(): number;
  29236. set collisionMask(mask: number);
  29237. /**
  29238. * Gets or sets the current collision group mask (-1 by default).
  29239. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29240. */
  29241. get collisionGroup(): number;
  29242. set collisionGroup(mask: number);
  29243. /**
  29244. * Gets or sets current surrounding meshes (null by default).
  29245. *
  29246. * By default collision detection is tested against every mesh in the scene.
  29247. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29248. * meshes will be tested for the collision.
  29249. *
  29250. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29251. */
  29252. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29253. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29254. /**
  29255. * Defines edge width used when edgesRenderer is enabled
  29256. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29257. */
  29258. edgesWidth: number;
  29259. /**
  29260. * Defines edge color used when edgesRenderer is enabled
  29261. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29262. */
  29263. edgesColor: Color4;
  29264. /** @hidden */
  29265. _edgesRenderer: Nullable<IEdgesRenderer>;
  29266. /** @hidden */
  29267. _masterMesh: Nullable<AbstractMesh>;
  29268. /** @hidden */
  29269. _boundingInfo: Nullable<BoundingInfo>;
  29270. /** @hidden */
  29271. _renderId: number;
  29272. /**
  29273. * Gets or sets the list of subMeshes
  29274. * @see http://doc.babylonjs.com/how_to/multi_materials
  29275. */
  29276. subMeshes: SubMesh[];
  29277. /** @hidden */
  29278. _intersectionsInProgress: AbstractMesh[];
  29279. /** @hidden */
  29280. _unIndexed: boolean;
  29281. /** @hidden */
  29282. _lightSources: Light[];
  29283. /** Gets the list of lights affecting that mesh */
  29284. get lightSources(): Light[];
  29285. /** @hidden */
  29286. get _positions(): Nullable<Vector3[]>;
  29287. /** @hidden */
  29288. _waitingData: {
  29289. lods: Nullable<any>;
  29290. actions: Nullable<any>;
  29291. freezeWorldMatrix: Nullable<boolean>;
  29292. };
  29293. /** @hidden */
  29294. _bonesTransformMatrices: Nullable<Float32Array>;
  29295. /** @hidden */
  29296. _transformMatrixTexture: Nullable<RawTexture>;
  29297. /**
  29298. * Gets or sets a skeleton to apply skining transformations
  29299. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29300. */
  29301. set skeleton(value: Nullable<Skeleton>);
  29302. get skeleton(): Nullable<Skeleton>;
  29303. /**
  29304. * An event triggered when the mesh is rebuilt.
  29305. */
  29306. onRebuildObservable: Observable<AbstractMesh>;
  29307. /**
  29308. * Creates a new AbstractMesh
  29309. * @param name defines the name of the mesh
  29310. * @param scene defines the hosting scene
  29311. */
  29312. constructor(name: string, scene?: Nullable<Scene>);
  29313. /**
  29314. * Returns the string "AbstractMesh"
  29315. * @returns "AbstractMesh"
  29316. */
  29317. getClassName(): string;
  29318. /**
  29319. * Gets a string representation of the current mesh
  29320. * @param fullDetails defines a boolean indicating if full details must be included
  29321. * @returns a string representation of the current mesh
  29322. */
  29323. toString(fullDetails?: boolean): string;
  29324. /**
  29325. * @hidden
  29326. */
  29327. protected _getEffectiveParent(): Nullable<Node>;
  29328. /** @hidden */
  29329. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29330. /** @hidden */
  29331. _rebuild(): void;
  29332. /** @hidden */
  29333. _resyncLightSources(): void;
  29334. /** @hidden */
  29335. _resyncLightSource(light: Light): void;
  29336. /** @hidden */
  29337. _unBindEffect(): void;
  29338. /** @hidden */
  29339. _removeLightSource(light: Light, dispose: boolean): void;
  29340. private _markSubMeshesAsDirty;
  29341. /** @hidden */
  29342. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29343. /** @hidden */
  29344. _markSubMeshesAsAttributesDirty(): void;
  29345. /** @hidden */
  29346. _markSubMeshesAsMiscDirty(): void;
  29347. /**
  29348. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29349. */
  29350. get scaling(): Vector3;
  29351. set scaling(newScaling: Vector3);
  29352. /**
  29353. * Returns true if the mesh is blocked. Implemented by child classes
  29354. */
  29355. get isBlocked(): boolean;
  29356. /**
  29357. * Returns the mesh itself by default. Implemented by child classes
  29358. * @param camera defines the camera to use to pick the right LOD level
  29359. * @returns the currentAbstractMesh
  29360. */
  29361. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29362. /**
  29363. * Returns 0 by default. Implemented by child classes
  29364. * @returns an integer
  29365. */
  29366. getTotalVertices(): number;
  29367. /**
  29368. * Returns a positive integer : the total number of indices in this mesh geometry.
  29369. * @returns the numner of indices or zero if the mesh has no geometry.
  29370. */
  29371. getTotalIndices(): number;
  29372. /**
  29373. * Returns null by default. Implemented by child classes
  29374. * @returns null
  29375. */
  29376. getIndices(): Nullable<IndicesArray>;
  29377. /**
  29378. * Returns the array of the requested vertex data kind. Implemented by child classes
  29379. * @param kind defines the vertex data kind to use
  29380. * @returns null
  29381. */
  29382. getVerticesData(kind: string): Nullable<FloatArray>;
  29383. /**
  29384. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29385. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29386. * Note that a new underlying VertexBuffer object is created each call.
  29387. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29388. * @param kind defines vertex data kind:
  29389. * * VertexBuffer.PositionKind
  29390. * * VertexBuffer.UVKind
  29391. * * VertexBuffer.UV2Kind
  29392. * * VertexBuffer.UV3Kind
  29393. * * VertexBuffer.UV4Kind
  29394. * * VertexBuffer.UV5Kind
  29395. * * VertexBuffer.UV6Kind
  29396. * * VertexBuffer.ColorKind
  29397. * * VertexBuffer.MatricesIndicesKind
  29398. * * VertexBuffer.MatricesIndicesExtraKind
  29399. * * VertexBuffer.MatricesWeightsKind
  29400. * * VertexBuffer.MatricesWeightsExtraKind
  29401. * @param data defines the data source
  29402. * @param updatable defines if the data must be flagged as updatable (or static)
  29403. * @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
  29404. * @returns the current mesh
  29405. */
  29406. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29407. /**
  29408. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29409. * If the mesh has no geometry, it is simply returned as it is.
  29410. * @param kind defines vertex data kind:
  29411. * * VertexBuffer.PositionKind
  29412. * * VertexBuffer.UVKind
  29413. * * VertexBuffer.UV2Kind
  29414. * * VertexBuffer.UV3Kind
  29415. * * VertexBuffer.UV4Kind
  29416. * * VertexBuffer.UV5Kind
  29417. * * VertexBuffer.UV6Kind
  29418. * * VertexBuffer.ColorKind
  29419. * * VertexBuffer.MatricesIndicesKind
  29420. * * VertexBuffer.MatricesIndicesExtraKind
  29421. * * VertexBuffer.MatricesWeightsKind
  29422. * * VertexBuffer.MatricesWeightsExtraKind
  29423. * @param data defines the data source
  29424. * @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
  29425. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29426. * @returns the current mesh
  29427. */
  29428. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29429. /**
  29430. * Sets the mesh indices,
  29431. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29432. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29433. * @param totalVertices Defines the total number of vertices
  29434. * @returns the current mesh
  29435. */
  29436. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29437. /**
  29438. * Gets a boolean indicating if specific vertex data is present
  29439. * @param kind defines the vertex data kind to use
  29440. * @returns true is data kind is present
  29441. */
  29442. isVerticesDataPresent(kind: string): boolean;
  29443. /**
  29444. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29445. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29446. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29447. * @returns a BoundingInfo
  29448. */
  29449. getBoundingInfo(): BoundingInfo;
  29450. /**
  29451. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29452. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29453. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29454. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29455. * @returns the current mesh
  29456. */
  29457. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29458. /**
  29459. * Overwrite the current bounding info
  29460. * @param boundingInfo defines the new bounding info
  29461. * @returns the current mesh
  29462. */
  29463. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29464. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29465. get useBones(): boolean;
  29466. /** @hidden */
  29467. _preActivate(): void;
  29468. /** @hidden */
  29469. _preActivateForIntermediateRendering(renderId: number): void;
  29470. /** @hidden */
  29471. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29472. /** @hidden */
  29473. _postActivate(): void;
  29474. /** @hidden */
  29475. _freeze(): void;
  29476. /** @hidden */
  29477. _unFreeze(): void;
  29478. /**
  29479. * Gets the current world matrix
  29480. * @returns a Matrix
  29481. */
  29482. getWorldMatrix(): Matrix;
  29483. /** @hidden */
  29484. _getWorldMatrixDeterminant(): number;
  29485. /**
  29486. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29487. */
  29488. get isAnInstance(): boolean;
  29489. /**
  29490. * Gets a boolean indicating if this mesh has instances
  29491. */
  29492. get hasInstances(): boolean;
  29493. /**
  29494. * Perform relative position change from the point of view of behind the front of the mesh.
  29495. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29496. * Supports definition of mesh facing forward or backward
  29497. * @param amountRight defines the distance on the right axis
  29498. * @param amountUp defines the distance on the up axis
  29499. * @param amountForward defines the distance on the forward axis
  29500. * @returns the current mesh
  29501. */
  29502. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29503. /**
  29504. * Calculate relative position change from the point of view of behind the front of the mesh.
  29505. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29506. * Supports definition of mesh facing forward or backward
  29507. * @param amountRight defines the distance on the right axis
  29508. * @param amountUp defines the distance on the up axis
  29509. * @param amountForward defines the distance on the forward axis
  29510. * @returns the new displacement vector
  29511. */
  29512. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29513. /**
  29514. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29515. * Supports definition of mesh facing forward or backward
  29516. * @param flipBack defines the flip
  29517. * @param twirlClockwise defines the twirl
  29518. * @param tiltRight defines the tilt
  29519. * @returns the current mesh
  29520. */
  29521. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29522. /**
  29523. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29524. * Supports definition of mesh facing forward or backward.
  29525. * @param flipBack defines the flip
  29526. * @param twirlClockwise defines the twirl
  29527. * @param tiltRight defines the tilt
  29528. * @returns the new rotation vector
  29529. */
  29530. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29531. /**
  29532. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29533. * This means the mesh underlying bounding box and sphere are recomputed.
  29534. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29535. * @returns the current mesh
  29536. */
  29537. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29538. /** @hidden */
  29539. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29540. /** @hidden */
  29541. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29542. /** @hidden */
  29543. _updateBoundingInfo(): AbstractMesh;
  29544. /** @hidden */
  29545. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29546. /** @hidden */
  29547. protected _afterComputeWorldMatrix(): void;
  29548. /** @hidden */
  29549. get _effectiveMesh(): AbstractMesh;
  29550. /**
  29551. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29552. * A mesh is in the frustum if its bounding box intersects the frustum
  29553. * @param frustumPlanes defines the frustum to test
  29554. * @returns true if the mesh is in the frustum planes
  29555. */
  29556. isInFrustum(frustumPlanes: Plane[]): boolean;
  29557. /**
  29558. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29559. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29560. * @param frustumPlanes defines the frustum to test
  29561. * @returns true if the mesh is completely in the frustum planes
  29562. */
  29563. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29564. /**
  29565. * True if the mesh intersects another mesh or a SolidParticle object
  29566. * @param mesh defines a target mesh or SolidParticle to test
  29567. * @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)
  29568. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29569. * @returns true if there is an intersection
  29570. */
  29571. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29572. /**
  29573. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29574. * @param point defines the point to test
  29575. * @returns true if there is an intersection
  29576. */
  29577. intersectsPoint(point: Vector3): boolean;
  29578. /**
  29579. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29580. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29581. */
  29582. get checkCollisions(): boolean;
  29583. set checkCollisions(collisionEnabled: boolean);
  29584. /**
  29585. * Gets Collider object used to compute collisions (not physics)
  29586. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29587. */
  29588. get collider(): Nullable<Collider>;
  29589. /**
  29590. * Move the mesh using collision engine
  29591. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29592. * @param displacement defines the requested displacement vector
  29593. * @returns the current mesh
  29594. */
  29595. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29596. private _onCollisionPositionChange;
  29597. /** @hidden */
  29598. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29599. /** @hidden */
  29600. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29601. /** @hidden */
  29602. _checkCollision(collider: Collider): AbstractMesh;
  29603. /** @hidden */
  29604. _generatePointsArray(): boolean;
  29605. /**
  29606. * Checks if the passed Ray intersects with the mesh
  29607. * @param ray defines the ray to use
  29608. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29609. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29610. * @returns the picking info
  29611. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29612. */
  29613. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29614. /**
  29615. * Clones the current mesh
  29616. * @param name defines the mesh name
  29617. * @param newParent defines the new mesh parent
  29618. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29619. * @returns the new mesh
  29620. */
  29621. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29622. /**
  29623. * Disposes all the submeshes of the current meshnp
  29624. * @returns the current mesh
  29625. */
  29626. releaseSubMeshes(): AbstractMesh;
  29627. /**
  29628. * Releases resources associated with this abstract mesh.
  29629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29631. */
  29632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29633. /**
  29634. * Adds the passed mesh as a child to the current mesh
  29635. * @param mesh defines the child mesh
  29636. * @returns the current mesh
  29637. */
  29638. addChild(mesh: AbstractMesh): AbstractMesh;
  29639. /**
  29640. * Removes the passed mesh from the current mesh children list
  29641. * @param mesh defines the child mesh
  29642. * @returns the current mesh
  29643. */
  29644. removeChild(mesh: AbstractMesh): AbstractMesh;
  29645. /** @hidden */
  29646. private _initFacetData;
  29647. /**
  29648. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29649. * This method can be called within the render loop.
  29650. * 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
  29651. * @returns the current mesh
  29652. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29653. */
  29654. updateFacetData(): AbstractMesh;
  29655. /**
  29656. * Returns the facetLocalNormals array.
  29657. * The normals are expressed in the mesh local spac
  29658. * @returns an array of Vector3
  29659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29660. */
  29661. getFacetLocalNormals(): Vector3[];
  29662. /**
  29663. * Returns the facetLocalPositions array.
  29664. * The facet positions are expressed in the mesh local space
  29665. * @returns an array of Vector3
  29666. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29667. */
  29668. getFacetLocalPositions(): Vector3[];
  29669. /**
  29670. * Returns the facetLocalPartioning array
  29671. * @returns an array of array of numbers
  29672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29673. */
  29674. getFacetLocalPartitioning(): number[][];
  29675. /**
  29676. * Returns the i-th facet position in the world system.
  29677. * This method allocates a new Vector3 per call
  29678. * @param i defines the facet index
  29679. * @returns a new Vector3
  29680. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29681. */
  29682. getFacetPosition(i: number): Vector3;
  29683. /**
  29684. * Sets the reference Vector3 with the i-th facet position in the world system
  29685. * @param i defines the facet index
  29686. * @param ref defines the target vector
  29687. * @returns the current mesh
  29688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29689. */
  29690. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29691. /**
  29692. * Returns the i-th facet normal in the world system.
  29693. * This method allocates a new Vector3 per call
  29694. * @param i defines the facet index
  29695. * @returns a new Vector3
  29696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29697. */
  29698. getFacetNormal(i: number): Vector3;
  29699. /**
  29700. * Sets the reference Vector3 with the i-th facet normal in the world system
  29701. * @param i defines the facet index
  29702. * @param ref defines the target vector
  29703. * @returns the current mesh
  29704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29705. */
  29706. getFacetNormalToRef(i: number, ref: Vector3): this;
  29707. /**
  29708. * 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)
  29709. * @param x defines x coordinate
  29710. * @param y defines y coordinate
  29711. * @param z defines z coordinate
  29712. * @returns the array of facet indexes
  29713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29714. */
  29715. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29716. /**
  29717. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29718. * @param projected sets as the (x,y,z) world projection on the facet
  29719. * @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
  29720. * @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
  29721. * @param x defines x coordinate
  29722. * @param y defines y coordinate
  29723. * @param z defines z coordinate
  29724. * @returns the face index if found (or null instead)
  29725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29726. */
  29727. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29728. /**
  29729. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29730. * @param projected sets as the (x,y,z) local projection on the facet
  29731. * @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
  29732. * @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
  29733. * @param x defines x coordinate
  29734. * @param y defines y coordinate
  29735. * @param z defines z coordinate
  29736. * @returns the face index if found (or null instead)
  29737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29738. */
  29739. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29740. /**
  29741. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29742. * @returns the parameters
  29743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29744. */
  29745. getFacetDataParameters(): any;
  29746. /**
  29747. * Disables the feature FacetData and frees the related memory
  29748. * @returns the current mesh
  29749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29750. */
  29751. disableFacetData(): AbstractMesh;
  29752. /**
  29753. * Updates the AbstractMesh indices array
  29754. * @param indices defines the data source
  29755. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29756. * @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)
  29757. * @returns the current mesh
  29758. */
  29759. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29760. /**
  29761. * Creates new normals data for the mesh
  29762. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29763. * @returns the current mesh
  29764. */
  29765. createNormals(updatable: boolean): AbstractMesh;
  29766. /**
  29767. * Align the mesh with a normal
  29768. * @param normal defines the normal to use
  29769. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29770. * @returns the current mesh
  29771. */
  29772. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29773. /** @hidden */
  29774. _checkOcclusionQuery(): boolean;
  29775. /**
  29776. * Disables the mesh edge rendering mode
  29777. * @returns the currentAbstractMesh
  29778. */
  29779. disableEdgesRendering(): AbstractMesh;
  29780. /**
  29781. * Enables the edge rendering mode on the mesh.
  29782. * This mode makes the mesh edges visible
  29783. * @param epsilon defines the maximal distance between two angles to detect a face
  29784. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29785. * @returns the currentAbstractMesh
  29786. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29787. */
  29788. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29789. }
  29790. }
  29791. declare module "babylonjs/Actions/actionEvent" {
  29792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29793. import { Nullable } from "babylonjs/types";
  29794. import { Sprite } from "babylonjs/Sprites/sprite";
  29795. import { Scene } from "babylonjs/scene";
  29796. import { Vector2 } from "babylonjs/Maths/math.vector";
  29797. /**
  29798. * Interface used to define ActionEvent
  29799. */
  29800. export interface IActionEvent {
  29801. /** The mesh or sprite that triggered the action */
  29802. source: any;
  29803. /** The X mouse cursor position at the time of the event */
  29804. pointerX: number;
  29805. /** The Y mouse cursor position at the time of the event */
  29806. pointerY: number;
  29807. /** The mesh that is currently pointed at (can be null) */
  29808. meshUnderPointer: Nullable<AbstractMesh>;
  29809. /** the original (browser) event that triggered the ActionEvent */
  29810. sourceEvent?: any;
  29811. /** additional data for the event */
  29812. additionalData?: any;
  29813. }
  29814. /**
  29815. * ActionEvent is the event being sent when an action is triggered.
  29816. */
  29817. export class ActionEvent implements IActionEvent {
  29818. /** The mesh or sprite that triggered the action */
  29819. source: any;
  29820. /** The X mouse cursor position at the time of the event */
  29821. pointerX: number;
  29822. /** The Y mouse cursor position at the time of the event */
  29823. pointerY: number;
  29824. /** The mesh that is currently pointed at (can be null) */
  29825. meshUnderPointer: Nullable<AbstractMesh>;
  29826. /** the original (browser) event that triggered the ActionEvent */
  29827. sourceEvent?: any;
  29828. /** additional data for the event */
  29829. additionalData?: any;
  29830. /**
  29831. * Creates a new ActionEvent
  29832. * @param source The mesh or sprite that triggered the action
  29833. * @param pointerX The X mouse cursor position at the time of the event
  29834. * @param pointerY The Y mouse cursor position at the time of the event
  29835. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29836. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29837. * @param additionalData additional data for the event
  29838. */
  29839. constructor(
  29840. /** The mesh or sprite that triggered the action */
  29841. source: any,
  29842. /** The X mouse cursor position at the time of the event */
  29843. pointerX: number,
  29844. /** The Y mouse cursor position at the time of the event */
  29845. pointerY: number,
  29846. /** The mesh that is currently pointed at (can be null) */
  29847. meshUnderPointer: Nullable<AbstractMesh>,
  29848. /** the original (browser) event that triggered the ActionEvent */
  29849. sourceEvent?: any,
  29850. /** additional data for the event */
  29851. additionalData?: any);
  29852. /**
  29853. * Helper function to auto-create an ActionEvent from a source mesh.
  29854. * @param source The source mesh that triggered the event
  29855. * @param evt The original (browser) event
  29856. * @param additionalData additional data for the event
  29857. * @returns the new ActionEvent
  29858. */
  29859. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29860. /**
  29861. * Helper function to auto-create an ActionEvent from a source sprite
  29862. * @param source The source sprite that triggered the event
  29863. * @param scene Scene associated with the sprite
  29864. * @param evt The original (browser) event
  29865. * @param additionalData additional data for the event
  29866. * @returns the new ActionEvent
  29867. */
  29868. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29869. /**
  29870. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29871. * @param scene the scene where the event occurred
  29872. * @param evt The original (browser) event
  29873. * @returns the new ActionEvent
  29874. */
  29875. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29876. /**
  29877. * Helper function to auto-create an ActionEvent from a primitive
  29878. * @param prim defines the target primitive
  29879. * @param pointerPos defines the pointer position
  29880. * @param evt The original (browser) event
  29881. * @param additionalData additional data for the event
  29882. * @returns the new ActionEvent
  29883. */
  29884. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29885. }
  29886. }
  29887. declare module "babylonjs/Actions/abstractActionManager" {
  29888. import { IDisposable } from "babylonjs/scene";
  29889. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29890. import { IAction } from "babylonjs/Actions/action";
  29891. import { Nullable } from "babylonjs/types";
  29892. /**
  29893. * Abstract class used to decouple action Manager from scene and meshes.
  29894. * Do not instantiate.
  29895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29896. */
  29897. export abstract class AbstractActionManager implements IDisposable {
  29898. /** Gets the list of active triggers */
  29899. static Triggers: {
  29900. [key: string]: number;
  29901. };
  29902. /** Gets the cursor to use when hovering items */
  29903. hoverCursor: string;
  29904. /** Gets the list of actions */
  29905. actions: IAction[];
  29906. /**
  29907. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29908. */
  29909. isRecursive: boolean;
  29910. /**
  29911. * Releases all associated resources
  29912. */
  29913. abstract dispose(): void;
  29914. /**
  29915. * Does this action manager has pointer triggers
  29916. */
  29917. abstract get hasPointerTriggers(): boolean;
  29918. /**
  29919. * Does this action manager has pick triggers
  29920. */
  29921. abstract get hasPickTriggers(): boolean;
  29922. /**
  29923. * Process a specific trigger
  29924. * @param trigger defines the trigger to process
  29925. * @param evt defines the event details to be processed
  29926. */
  29927. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29928. /**
  29929. * Does this action manager handles actions of any of the given triggers
  29930. * @param triggers defines the triggers to be tested
  29931. * @return a boolean indicating whether one (or more) of the triggers is handled
  29932. */
  29933. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29934. /**
  29935. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29936. * speed.
  29937. * @param triggerA defines the trigger to be tested
  29938. * @param triggerB defines the trigger to be tested
  29939. * @return a boolean indicating whether one (or more) of the triggers is handled
  29940. */
  29941. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29942. /**
  29943. * Does this action manager handles actions of a given trigger
  29944. * @param trigger defines the trigger to be tested
  29945. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29946. * @return whether the trigger is handled
  29947. */
  29948. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29949. /**
  29950. * Serialize this manager to a JSON object
  29951. * @param name defines the property name to store this manager
  29952. * @returns a JSON representation of this manager
  29953. */
  29954. abstract serialize(name: string): any;
  29955. /**
  29956. * Registers an action to this action manager
  29957. * @param action defines the action to be registered
  29958. * @return the action amended (prepared) after registration
  29959. */
  29960. abstract registerAction(action: IAction): Nullable<IAction>;
  29961. /**
  29962. * Unregisters an action to this action manager
  29963. * @param action defines the action to be unregistered
  29964. * @return a boolean indicating whether the action has been unregistered
  29965. */
  29966. abstract unregisterAction(action: IAction): Boolean;
  29967. /**
  29968. * Does exist one action manager with at least one trigger
  29969. **/
  29970. static get HasTriggers(): boolean;
  29971. /**
  29972. * Does exist one action manager with at least one pick trigger
  29973. **/
  29974. static get HasPickTriggers(): boolean;
  29975. /**
  29976. * Does exist one action manager that handles actions of a given trigger
  29977. * @param trigger defines the trigger to be tested
  29978. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29979. **/
  29980. static HasSpecificTrigger(trigger: number): boolean;
  29981. }
  29982. }
  29983. declare module "babylonjs/node" {
  29984. import { Scene } from "babylonjs/scene";
  29985. import { Nullable } from "babylonjs/types";
  29986. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29987. import { Engine } from "babylonjs/Engines/engine";
  29988. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29989. import { Observable } from "babylonjs/Misc/observable";
  29990. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29991. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29992. import { Animatable } from "babylonjs/Animations/animatable";
  29993. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29994. import { Animation } from "babylonjs/Animations/animation";
  29995. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29997. /**
  29998. * Defines how a node can be built from a string name.
  29999. */
  30000. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30001. /**
  30002. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30003. */
  30004. export class Node implements IBehaviorAware<Node> {
  30005. /** @hidden */
  30006. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30007. private static _NodeConstructors;
  30008. /**
  30009. * Add a new node constructor
  30010. * @param type defines the type name of the node to construct
  30011. * @param constructorFunc defines the constructor function
  30012. */
  30013. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30014. /**
  30015. * Returns a node constructor based on type name
  30016. * @param type defines the type name
  30017. * @param name defines the new node name
  30018. * @param scene defines the hosting scene
  30019. * @param options defines optional options to transmit to constructors
  30020. * @returns the new constructor or null
  30021. */
  30022. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30023. /**
  30024. * Gets or sets the name of the node
  30025. */
  30026. name: string;
  30027. /**
  30028. * Gets or sets the id of the node
  30029. */
  30030. id: string;
  30031. /**
  30032. * Gets or sets the unique id of the node
  30033. */
  30034. uniqueId: number;
  30035. /**
  30036. * Gets or sets a string used to store user defined state for the node
  30037. */
  30038. state: string;
  30039. /**
  30040. * Gets or sets an object used to store user defined information for the node
  30041. */
  30042. metadata: any;
  30043. /**
  30044. * For internal use only. Please do not use.
  30045. */
  30046. reservedDataStore: any;
  30047. /**
  30048. * List of inspectable custom properties (used by the Inspector)
  30049. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30050. */
  30051. inspectableCustomProperties: IInspectable[];
  30052. private _doNotSerialize;
  30053. /**
  30054. * Gets or sets a boolean used to define if the node must be serialized
  30055. */
  30056. get doNotSerialize(): boolean;
  30057. set doNotSerialize(value: boolean);
  30058. /** @hidden */
  30059. _isDisposed: boolean;
  30060. /**
  30061. * Gets a list of Animations associated with the node
  30062. */
  30063. animations: import("babylonjs/Animations/animation").Animation[];
  30064. protected _ranges: {
  30065. [name: string]: Nullable<AnimationRange>;
  30066. };
  30067. /**
  30068. * Callback raised when the node is ready to be used
  30069. */
  30070. onReady: Nullable<(node: Node) => void>;
  30071. private _isEnabled;
  30072. private _isParentEnabled;
  30073. private _isReady;
  30074. /** @hidden */
  30075. _currentRenderId: number;
  30076. private _parentUpdateId;
  30077. /** @hidden */
  30078. _childUpdateId: number;
  30079. /** @hidden */
  30080. _waitingParentId: Nullable<string>;
  30081. /** @hidden */
  30082. _scene: Scene;
  30083. /** @hidden */
  30084. _cache: any;
  30085. private _parentNode;
  30086. private _children;
  30087. /** @hidden */
  30088. _worldMatrix: Matrix;
  30089. /** @hidden */
  30090. _worldMatrixDeterminant: number;
  30091. /** @hidden */
  30092. _worldMatrixDeterminantIsDirty: boolean;
  30093. /** @hidden */
  30094. private _sceneRootNodesIndex;
  30095. /**
  30096. * Gets a boolean indicating if the node has been disposed
  30097. * @returns true if the node was disposed
  30098. */
  30099. isDisposed(): boolean;
  30100. /**
  30101. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30102. * @see https://doc.babylonjs.com/how_to/parenting
  30103. */
  30104. set parent(parent: Nullable<Node>);
  30105. get parent(): Nullable<Node>;
  30106. /** @hidden */
  30107. _addToSceneRootNodes(): void;
  30108. /** @hidden */
  30109. _removeFromSceneRootNodes(): void;
  30110. private _animationPropertiesOverride;
  30111. /**
  30112. * Gets or sets the animation properties override
  30113. */
  30114. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30115. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30116. /**
  30117. * Gets a string idenfifying the name of the class
  30118. * @returns "Node" string
  30119. */
  30120. getClassName(): string;
  30121. /** @hidden */
  30122. readonly _isNode: boolean;
  30123. /**
  30124. * An event triggered when the mesh is disposed
  30125. */
  30126. onDisposeObservable: Observable<Node>;
  30127. private _onDisposeObserver;
  30128. /**
  30129. * Sets a callback that will be raised when the node will be disposed
  30130. */
  30131. set onDispose(callback: () => void);
  30132. /**
  30133. * Creates a new Node
  30134. * @param name the name and id to be given to this node
  30135. * @param scene the scene this node will be added to
  30136. */
  30137. constructor(name: string, scene?: Nullable<Scene>);
  30138. /**
  30139. * Gets the scene of the node
  30140. * @returns a scene
  30141. */
  30142. getScene(): Scene;
  30143. /**
  30144. * Gets the engine of the node
  30145. * @returns a Engine
  30146. */
  30147. getEngine(): Engine;
  30148. private _behaviors;
  30149. /**
  30150. * Attach a behavior to the node
  30151. * @see http://doc.babylonjs.com/features/behaviour
  30152. * @param behavior defines the behavior to attach
  30153. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30154. * @returns the current Node
  30155. */
  30156. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30157. /**
  30158. * Remove an attached behavior
  30159. * @see http://doc.babylonjs.com/features/behaviour
  30160. * @param behavior defines the behavior to attach
  30161. * @returns the current Node
  30162. */
  30163. removeBehavior(behavior: Behavior<Node>): Node;
  30164. /**
  30165. * Gets the list of attached behaviors
  30166. * @see http://doc.babylonjs.com/features/behaviour
  30167. */
  30168. get behaviors(): Behavior<Node>[];
  30169. /**
  30170. * Gets an attached behavior by name
  30171. * @param name defines the name of the behavior to look for
  30172. * @see http://doc.babylonjs.com/features/behaviour
  30173. * @returns null if behavior was not found else the requested behavior
  30174. */
  30175. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30176. /**
  30177. * Returns the latest update of the World matrix
  30178. * @returns a Matrix
  30179. */
  30180. getWorldMatrix(): Matrix;
  30181. /** @hidden */
  30182. _getWorldMatrixDeterminant(): number;
  30183. /**
  30184. * Returns directly the latest state of the mesh World matrix.
  30185. * A Matrix is returned.
  30186. */
  30187. get worldMatrixFromCache(): Matrix;
  30188. /** @hidden */
  30189. _initCache(): void;
  30190. /** @hidden */
  30191. updateCache(force?: boolean): void;
  30192. /** @hidden */
  30193. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30194. /** @hidden */
  30195. _updateCache(ignoreParentClass?: boolean): void;
  30196. /** @hidden */
  30197. _isSynchronized(): boolean;
  30198. /** @hidden */
  30199. _markSyncedWithParent(): void;
  30200. /** @hidden */
  30201. isSynchronizedWithParent(): boolean;
  30202. /** @hidden */
  30203. isSynchronized(): boolean;
  30204. /**
  30205. * Is this node ready to be used/rendered
  30206. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30207. * @return true if the node is ready
  30208. */
  30209. isReady(completeCheck?: boolean): boolean;
  30210. /**
  30211. * Is this node enabled?
  30212. * 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
  30213. * @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
  30214. * @return whether this node (and its parent) is enabled
  30215. */
  30216. isEnabled(checkAncestors?: boolean): boolean;
  30217. /** @hidden */
  30218. protected _syncParentEnabledState(): void;
  30219. /**
  30220. * Set the enabled state of this node
  30221. * @param value defines the new enabled state
  30222. */
  30223. setEnabled(value: boolean): void;
  30224. /**
  30225. * Is this node a descendant of the given node?
  30226. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30227. * @param ancestor defines the parent node to inspect
  30228. * @returns a boolean indicating if this node is a descendant of the given node
  30229. */
  30230. isDescendantOf(ancestor: Node): boolean;
  30231. /** @hidden */
  30232. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30233. /**
  30234. * Will return all nodes that have this node as ascendant
  30235. * @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
  30236. * @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
  30237. * @return all children nodes of all types
  30238. */
  30239. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30240. /**
  30241. * Get all child-meshes of this node
  30242. * @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)
  30243. * @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
  30244. * @returns an array of AbstractMesh
  30245. */
  30246. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30247. /**
  30248. * Get all direct children of this node
  30249. * @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
  30250. * @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)
  30251. * @returns an array of Node
  30252. */
  30253. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30254. /** @hidden */
  30255. _setReady(state: boolean): void;
  30256. /**
  30257. * Get an animation by name
  30258. * @param name defines the name of the animation to look for
  30259. * @returns null if not found else the requested animation
  30260. */
  30261. getAnimationByName(name: string): Nullable<Animation>;
  30262. /**
  30263. * Creates an animation range for this node
  30264. * @param name defines the name of the range
  30265. * @param from defines the starting key
  30266. * @param to defines the end key
  30267. */
  30268. createAnimationRange(name: string, from: number, to: number): void;
  30269. /**
  30270. * Delete a specific animation range
  30271. * @param name defines the name of the range to delete
  30272. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30273. */
  30274. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30275. /**
  30276. * Get an animation range by name
  30277. * @param name defines the name of the animation range to look for
  30278. * @returns null if not found else the requested animation range
  30279. */
  30280. getAnimationRange(name: string): Nullable<AnimationRange>;
  30281. /**
  30282. * Gets the list of all animation ranges defined on this node
  30283. * @returns an array
  30284. */
  30285. getAnimationRanges(): Nullable<AnimationRange>[];
  30286. /**
  30287. * Will start the animation sequence
  30288. * @param name defines the range frames for animation sequence
  30289. * @param loop defines if the animation should loop (false by default)
  30290. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30291. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30292. * @returns the object created for this animation. If range does not exist, it will return null
  30293. */
  30294. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30295. /**
  30296. * Serialize animation ranges into a JSON compatible object
  30297. * @returns serialization object
  30298. */
  30299. serializeAnimationRanges(): any;
  30300. /**
  30301. * Computes the world matrix of the node
  30302. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30303. * @returns the world matrix
  30304. */
  30305. computeWorldMatrix(force?: boolean): Matrix;
  30306. /**
  30307. * Releases resources associated with this node.
  30308. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30309. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30310. */
  30311. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30312. /**
  30313. * Parse animation range data from a serialization object and store them into a given node
  30314. * @param node defines where to store the animation ranges
  30315. * @param parsedNode defines the serialization object to read data from
  30316. * @param scene defines the hosting scene
  30317. */
  30318. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30319. /**
  30320. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30321. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30322. * @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
  30323. * @returns the new bounding vectors
  30324. */
  30325. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30326. min: Vector3;
  30327. max: Vector3;
  30328. };
  30329. }
  30330. }
  30331. declare module "babylonjs/Animations/animation" {
  30332. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30333. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30334. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30335. import { Nullable } from "babylonjs/types";
  30336. import { Scene } from "babylonjs/scene";
  30337. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30338. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30339. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30340. import { Node } from "babylonjs/node";
  30341. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30342. import { Size } from "babylonjs/Maths/math.size";
  30343. import { Animatable } from "babylonjs/Animations/animatable";
  30344. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30345. /**
  30346. * @hidden
  30347. */
  30348. export class _IAnimationState {
  30349. key: number;
  30350. repeatCount: number;
  30351. workValue?: any;
  30352. loopMode?: number;
  30353. offsetValue?: any;
  30354. highLimitValue?: any;
  30355. }
  30356. /**
  30357. * Class used to store any kind of animation
  30358. */
  30359. export class Animation {
  30360. /**Name of the animation */
  30361. name: string;
  30362. /**Property to animate */
  30363. targetProperty: string;
  30364. /**The frames per second of the animation */
  30365. framePerSecond: number;
  30366. /**The data type of the animation */
  30367. dataType: number;
  30368. /**The loop mode of the animation */
  30369. loopMode?: number | undefined;
  30370. /**Specifies if blending should be enabled */
  30371. enableBlending?: boolean | undefined;
  30372. /**
  30373. * Use matrix interpolation instead of using direct key value when animating matrices
  30374. */
  30375. static AllowMatricesInterpolation: boolean;
  30376. /**
  30377. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30378. */
  30379. static AllowMatrixDecomposeForInterpolation: boolean;
  30380. /**
  30381. * Stores the key frames of the animation
  30382. */
  30383. private _keys;
  30384. /**
  30385. * Stores the easing function of the animation
  30386. */
  30387. private _easingFunction;
  30388. /**
  30389. * @hidden Internal use only
  30390. */
  30391. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30392. /**
  30393. * The set of event that will be linked to this animation
  30394. */
  30395. private _events;
  30396. /**
  30397. * Stores an array of target property paths
  30398. */
  30399. targetPropertyPath: string[];
  30400. /**
  30401. * Stores the blending speed of the animation
  30402. */
  30403. blendingSpeed: number;
  30404. /**
  30405. * Stores the animation ranges for the animation
  30406. */
  30407. private _ranges;
  30408. /**
  30409. * @hidden Internal use
  30410. */
  30411. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30412. /**
  30413. * Sets up an animation
  30414. * @param property The property to animate
  30415. * @param animationType The animation type to apply
  30416. * @param framePerSecond The frames per second of the animation
  30417. * @param easingFunction The easing function used in the animation
  30418. * @returns The created animation
  30419. */
  30420. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30421. /**
  30422. * Create and start an animation on a node
  30423. * @param name defines the name of the global animation that will be run on all nodes
  30424. * @param node defines the root node where the animation will take place
  30425. * @param targetProperty defines property to animate
  30426. * @param framePerSecond defines the number of frame per second yo use
  30427. * @param totalFrame defines the number of frames in total
  30428. * @param from defines the initial value
  30429. * @param to defines the final value
  30430. * @param loopMode defines which loop mode you want to use (off by default)
  30431. * @param easingFunction defines the easing function to use (linear by default)
  30432. * @param onAnimationEnd defines the callback to call when animation end
  30433. * @returns the animatable created for this animation
  30434. */
  30435. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30436. /**
  30437. * Create and start an animation on a node and its descendants
  30438. * @param name defines the name of the global animation that will be run on all nodes
  30439. * @param node defines the root node where the animation will take place
  30440. * @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
  30441. * @param targetProperty defines property to animate
  30442. * @param framePerSecond defines the number of frame per second to use
  30443. * @param totalFrame defines the number of frames in total
  30444. * @param from defines the initial value
  30445. * @param to defines the final value
  30446. * @param loopMode defines which loop mode you want to use (off by default)
  30447. * @param easingFunction defines the easing function to use (linear by default)
  30448. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30449. * @returns the list of animatables created for all nodes
  30450. * @example https://www.babylonjs-playground.com/#MH0VLI
  30451. */
  30452. 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[]>;
  30453. /**
  30454. * Creates a new animation, merges it with the existing animations and starts it
  30455. * @param name Name of the animation
  30456. * @param node Node which contains the scene that begins the animations
  30457. * @param targetProperty Specifies which property to animate
  30458. * @param framePerSecond The frames per second of the animation
  30459. * @param totalFrame The total number of frames
  30460. * @param from The frame at the beginning of the animation
  30461. * @param to The frame at the end of the animation
  30462. * @param loopMode Specifies the loop mode of the animation
  30463. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30464. * @param onAnimationEnd Callback to run once the animation is complete
  30465. * @returns Nullable animation
  30466. */
  30467. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30468. /**
  30469. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30470. * @param sourceAnimation defines the Animation containing keyframes to convert
  30471. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30472. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30473. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30474. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30475. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30476. */
  30477. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30478. /**
  30479. * Transition property of an host to the target Value
  30480. * @param property The property to transition
  30481. * @param targetValue The target Value of the property
  30482. * @param host The object where the property to animate belongs
  30483. * @param scene Scene used to run the animation
  30484. * @param frameRate Framerate (in frame/s) to use
  30485. * @param transition The transition type we want to use
  30486. * @param duration The duration of the animation, in milliseconds
  30487. * @param onAnimationEnd Callback trigger at the end of the animation
  30488. * @returns Nullable animation
  30489. */
  30490. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30491. /**
  30492. * Return the array of runtime animations currently using this animation
  30493. */
  30494. get runtimeAnimations(): RuntimeAnimation[];
  30495. /**
  30496. * Specifies if any of the runtime animations are currently running
  30497. */
  30498. get hasRunningRuntimeAnimations(): boolean;
  30499. /**
  30500. * Initializes the animation
  30501. * @param name Name of the animation
  30502. * @param targetProperty Property to animate
  30503. * @param framePerSecond The frames per second of the animation
  30504. * @param dataType The data type of the animation
  30505. * @param loopMode The loop mode of the animation
  30506. * @param enableBlending Specifies if blending should be enabled
  30507. */
  30508. constructor(
  30509. /**Name of the animation */
  30510. name: string,
  30511. /**Property to animate */
  30512. targetProperty: string,
  30513. /**The frames per second of the animation */
  30514. framePerSecond: number,
  30515. /**The data type of the animation */
  30516. dataType: number,
  30517. /**The loop mode of the animation */
  30518. loopMode?: number | undefined,
  30519. /**Specifies if blending should be enabled */
  30520. enableBlending?: boolean | undefined);
  30521. /**
  30522. * Converts the animation to a string
  30523. * @param fullDetails support for multiple levels of logging within scene loading
  30524. * @returns String form of the animation
  30525. */
  30526. toString(fullDetails?: boolean): string;
  30527. /**
  30528. * Add an event to this animation
  30529. * @param event Event to add
  30530. */
  30531. addEvent(event: AnimationEvent): void;
  30532. /**
  30533. * Remove all events found at the given frame
  30534. * @param frame The frame to remove events from
  30535. */
  30536. removeEvents(frame: number): void;
  30537. /**
  30538. * Retrieves all the events from the animation
  30539. * @returns Events from the animation
  30540. */
  30541. getEvents(): AnimationEvent[];
  30542. /**
  30543. * Creates an animation range
  30544. * @param name Name of the animation range
  30545. * @param from Starting frame of the animation range
  30546. * @param to Ending frame of the animation
  30547. */
  30548. createRange(name: string, from: number, to: number): void;
  30549. /**
  30550. * Deletes an animation range by name
  30551. * @param name Name of the animation range to delete
  30552. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30553. */
  30554. deleteRange(name: string, deleteFrames?: boolean): void;
  30555. /**
  30556. * Gets the animation range by name, or null if not defined
  30557. * @param name Name of the animation range
  30558. * @returns Nullable animation range
  30559. */
  30560. getRange(name: string): Nullable<AnimationRange>;
  30561. /**
  30562. * Gets the key frames from the animation
  30563. * @returns The key frames of the animation
  30564. */
  30565. getKeys(): Array<IAnimationKey>;
  30566. /**
  30567. * Gets the highest frame rate of the animation
  30568. * @returns Highest frame rate of the animation
  30569. */
  30570. getHighestFrame(): number;
  30571. /**
  30572. * Gets the easing function of the animation
  30573. * @returns Easing function of the animation
  30574. */
  30575. getEasingFunction(): IEasingFunction;
  30576. /**
  30577. * Sets the easing function of the animation
  30578. * @param easingFunction A custom mathematical formula for animation
  30579. */
  30580. setEasingFunction(easingFunction: EasingFunction): void;
  30581. /**
  30582. * Interpolates a scalar linearly
  30583. * @param startValue Start value of the animation curve
  30584. * @param endValue End value of the animation curve
  30585. * @param gradient Scalar amount to interpolate
  30586. * @returns Interpolated scalar value
  30587. */
  30588. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30589. /**
  30590. * Interpolates a scalar cubically
  30591. * @param startValue Start value of the animation curve
  30592. * @param outTangent End tangent of the animation
  30593. * @param endValue End value of the animation curve
  30594. * @param inTangent Start tangent of the animation curve
  30595. * @param gradient Scalar amount to interpolate
  30596. * @returns Interpolated scalar value
  30597. */
  30598. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30599. /**
  30600. * Interpolates a quaternion using a spherical linear interpolation
  30601. * @param startValue Start value of the animation curve
  30602. * @param endValue End value of the animation curve
  30603. * @param gradient Scalar amount to interpolate
  30604. * @returns Interpolated quaternion value
  30605. */
  30606. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30607. /**
  30608. * Interpolates a quaternion cubically
  30609. * @param startValue Start value of the animation curve
  30610. * @param outTangent End tangent of the animation curve
  30611. * @param endValue End value of the animation curve
  30612. * @param inTangent Start tangent of the animation curve
  30613. * @param gradient Scalar amount to interpolate
  30614. * @returns Interpolated quaternion value
  30615. */
  30616. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30617. /**
  30618. * Interpolates a Vector3 linearl
  30619. * @param startValue Start value of the animation curve
  30620. * @param endValue End value of the animation curve
  30621. * @param gradient Scalar amount to interpolate
  30622. * @returns Interpolated scalar value
  30623. */
  30624. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30625. /**
  30626. * Interpolates a Vector3 cubically
  30627. * @param startValue Start value of the animation curve
  30628. * @param outTangent End tangent of the animation
  30629. * @param endValue End value of the animation curve
  30630. * @param inTangent Start tangent of the animation curve
  30631. * @param gradient Scalar amount to interpolate
  30632. * @returns InterpolatedVector3 value
  30633. */
  30634. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30635. /**
  30636. * Interpolates a Vector2 linearly
  30637. * @param startValue Start value of the animation curve
  30638. * @param endValue End value of the animation curve
  30639. * @param gradient Scalar amount to interpolate
  30640. * @returns Interpolated Vector2 value
  30641. */
  30642. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30643. /**
  30644. * Interpolates a Vector2 cubically
  30645. * @param startValue Start value of the animation curve
  30646. * @param outTangent End tangent of the animation
  30647. * @param endValue End value of the animation curve
  30648. * @param inTangent Start tangent of the animation curve
  30649. * @param gradient Scalar amount to interpolate
  30650. * @returns Interpolated Vector2 value
  30651. */
  30652. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30653. /**
  30654. * Interpolates a size linearly
  30655. * @param startValue Start value of the animation curve
  30656. * @param endValue End value of the animation curve
  30657. * @param gradient Scalar amount to interpolate
  30658. * @returns Interpolated Size value
  30659. */
  30660. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30661. /**
  30662. * Interpolates a Color3 linearly
  30663. * @param startValue Start value of the animation curve
  30664. * @param endValue End value of the animation curve
  30665. * @param gradient Scalar amount to interpolate
  30666. * @returns Interpolated Color3 value
  30667. */
  30668. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30669. /**
  30670. * Interpolates a Color4 linearly
  30671. * @param startValue Start value of the animation curve
  30672. * @param endValue End value of the animation curve
  30673. * @param gradient Scalar amount to interpolate
  30674. * @returns Interpolated Color3 value
  30675. */
  30676. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30677. /**
  30678. * @hidden Internal use only
  30679. */
  30680. _getKeyValue(value: any): any;
  30681. /**
  30682. * @hidden Internal use only
  30683. */
  30684. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30685. /**
  30686. * Defines the function to use to interpolate matrices
  30687. * @param startValue defines the start matrix
  30688. * @param endValue defines the end matrix
  30689. * @param gradient defines the gradient between both matrices
  30690. * @param result defines an optional target matrix where to store the interpolation
  30691. * @returns the interpolated matrix
  30692. */
  30693. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30694. /**
  30695. * Makes a copy of the animation
  30696. * @returns Cloned animation
  30697. */
  30698. clone(): Animation;
  30699. /**
  30700. * Sets the key frames of the animation
  30701. * @param values The animation key frames to set
  30702. */
  30703. setKeys(values: Array<IAnimationKey>): void;
  30704. /**
  30705. * Serializes the animation to an object
  30706. * @returns Serialized object
  30707. */
  30708. serialize(): any;
  30709. /**
  30710. * Float animation type
  30711. */
  30712. static readonly ANIMATIONTYPE_FLOAT: number;
  30713. /**
  30714. * Vector3 animation type
  30715. */
  30716. static readonly ANIMATIONTYPE_VECTOR3: number;
  30717. /**
  30718. * Quaternion animation type
  30719. */
  30720. static readonly ANIMATIONTYPE_QUATERNION: number;
  30721. /**
  30722. * Matrix animation type
  30723. */
  30724. static readonly ANIMATIONTYPE_MATRIX: number;
  30725. /**
  30726. * Color3 animation type
  30727. */
  30728. static readonly ANIMATIONTYPE_COLOR3: number;
  30729. /**
  30730. * Color3 animation type
  30731. */
  30732. static readonly ANIMATIONTYPE_COLOR4: number;
  30733. /**
  30734. * Vector2 animation type
  30735. */
  30736. static readonly ANIMATIONTYPE_VECTOR2: number;
  30737. /**
  30738. * Size animation type
  30739. */
  30740. static readonly ANIMATIONTYPE_SIZE: number;
  30741. /**
  30742. * Relative Loop Mode
  30743. */
  30744. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30745. /**
  30746. * Cycle Loop Mode
  30747. */
  30748. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30749. /**
  30750. * Constant Loop Mode
  30751. */
  30752. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30753. /** @hidden */
  30754. static _UniversalLerp(left: any, right: any, amount: number): any;
  30755. /**
  30756. * Parses an animation object and creates an animation
  30757. * @param parsedAnimation Parsed animation object
  30758. * @returns Animation object
  30759. */
  30760. static Parse(parsedAnimation: any): Animation;
  30761. /**
  30762. * Appends the serialized animations from the source animations
  30763. * @param source Source containing the animations
  30764. * @param destination Target to store the animations
  30765. */
  30766. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30767. }
  30768. }
  30769. declare module "babylonjs/Animations/animatable.interface" {
  30770. import { Nullable } from "babylonjs/types";
  30771. import { Animation } from "babylonjs/Animations/animation";
  30772. /**
  30773. * Interface containing an array of animations
  30774. */
  30775. export interface IAnimatable {
  30776. /**
  30777. * Array of animations
  30778. */
  30779. animations: Nullable<Array<Animation>>;
  30780. }
  30781. }
  30782. declare module "babylonjs/Misc/decorators" {
  30783. import { Nullable } from "babylonjs/types";
  30784. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30785. import { Scene } from "babylonjs/scene";
  30786. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30787. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30788. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30789. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30790. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30791. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30792. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30793. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30794. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30795. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30796. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30797. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30798. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30799. /**
  30800. * Decorator used to define property that can be serialized as reference to a camera
  30801. * @param sourceName defines the name of the property to decorate
  30802. */
  30803. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30804. /**
  30805. * Class used to help serialization objects
  30806. */
  30807. export class SerializationHelper {
  30808. /** @hidden */
  30809. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30810. /** @hidden */
  30811. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30812. /** @hidden */
  30813. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30814. /** @hidden */
  30815. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30816. /**
  30817. * Appends the serialized animations from the source animations
  30818. * @param source Source containing the animations
  30819. * @param destination Target to store the animations
  30820. */
  30821. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30822. /**
  30823. * Static function used to serialized a specific entity
  30824. * @param entity defines the entity to serialize
  30825. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30826. * @returns a JSON compatible object representing the serialization of the entity
  30827. */
  30828. static Serialize<T>(entity: T, serializationObject?: any): any;
  30829. /**
  30830. * Creates a new entity from a serialization data object
  30831. * @param creationFunction defines a function used to instanciated the new entity
  30832. * @param source defines the source serialization data
  30833. * @param scene defines the hosting scene
  30834. * @param rootUrl defines the root url for resources
  30835. * @returns a new entity
  30836. */
  30837. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30838. /**
  30839. * Clones an object
  30840. * @param creationFunction defines the function used to instanciate the new object
  30841. * @param source defines the source object
  30842. * @returns the cloned object
  30843. */
  30844. static Clone<T>(creationFunction: () => T, source: T): T;
  30845. /**
  30846. * Instanciates a new object based on a source one (some data will be shared between both object)
  30847. * @param creationFunction defines the function used to instanciate the new object
  30848. * @param source defines the source object
  30849. * @returns the new object
  30850. */
  30851. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30852. }
  30853. }
  30854. declare module "babylonjs/Misc/guid" {
  30855. /**
  30856. * Class used to manipulate GUIDs
  30857. */
  30858. export class GUID {
  30859. /**
  30860. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30861. * Be aware Math.random() could cause collisions, but:
  30862. * "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"
  30863. * @returns a pseudo random id
  30864. */
  30865. static RandomId(): string;
  30866. }
  30867. }
  30868. declare module "babylonjs/Materials/Textures/baseTexture" {
  30869. import { Observable } from "babylonjs/Misc/observable";
  30870. import { Nullable } from "babylonjs/types";
  30871. import { Scene } from "babylonjs/scene";
  30872. import { Matrix } from "babylonjs/Maths/math.vector";
  30873. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30874. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30875. import { ISize } from "babylonjs/Maths/math.size";
  30876. import "babylonjs/Misc/fileTools";
  30877. /**
  30878. * Base class of all the textures in babylon.
  30879. * It groups all the common properties the materials, post process, lights... might need
  30880. * in order to make a correct use of the texture.
  30881. */
  30882. export class BaseTexture implements IAnimatable {
  30883. /**
  30884. * Default anisotropic filtering level for the application.
  30885. * It is set to 4 as a good tradeoff between perf and quality.
  30886. */
  30887. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30888. /**
  30889. * Gets or sets the unique id of the texture
  30890. */
  30891. uniqueId: number;
  30892. /**
  30893. * Define the name of the texture.
  30894. */
  30895. name: string;
  30896. /**
  30897. * Gets or sets an object used to store user defined information.
  30898. */
  30899. metadata: any;
  30900. /**
  30901. * For internal use only. Please do not use.
  30902. */
  30903. reservedDataStore: any;
  30904. private _hasAlpha;
  30905. /**
  30906. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30907. */
  30908. set hasAlpha(value: boolean);
  30909. get hasAlpha(): boolean;
  30910. /**
  30911. * Defines if the alpha value should be determined via the rgb values.
  30912. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30913. */
  30914. getAlphaFromRGB: boolean;
  30915. /**
  30916. * Intensity or strength of the texture.
  30917. * It is commonly used by materials to fine tune the intensity of the texture
  30918. */
  30919. level: number;
  30920. /**
  30921. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30922. * This is part of the texture as textures usually maps to one uv set.
  30923. */
  30924. coordinatesIndex: number;
  30925. private _coordinatesMode;
  30926. /**
  30927. * How a texture is mapped.
  30928. *
  30929. * | Value | Type | Description |
  30930. * | ----- | ----------------------------------- | ----------- |
  30931. * | 0 | EXPLICIT_MODE | |
  30932. * | 1 | SPHERICAL_MODE | |
  30933. * | 2 | PLANAR_MODE | |
  30934. * | 3 | CUBIC_MODE | |
  30935. * | 4 | PROJECTION_MODE | |
  30936. * | 5 | SKYBOX_MODE | |
  30937. * | 6 | INVCUBIC_MODE | |
  30938. * | 7 | EQUIRECTANGULAR_MODE | |
  30939. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30940. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30941. */
  30942. set coordinatesMode(value: number);
  30943. get coordinatesMode(): number;
  30944. /**
  30945. * | Value | Type | Description |
  30946. * | ----- | ------------------ | ----------- |
  30947. * | 0 | CLAMP_ADDRESSMODE | |
  30948. * | 1 | WRAP_ADDRESSMODE | |
  30949. * | 2 | MIRROR_ADDRESSMODE | |
  30950. */
  30951. wrapU: number;
  30952. /**
  30953. * | Value | Type | Description |
  30954. * | ----- | ------------------ | ----------- |
  30955. * | 0 | CLAMP_ADDRESSMODE | |
  30956. * | 1 | WRAP_ADDRESSMODE | |
  30957. * | 2 | MIRROR_ADDRESSMODE | |
  30958. */
  30959. wrapV: number;
  30960. /**
  30961. * | Value | Type | Description |
  30962. * | ----- | ------------------ | ----------- |
  30963. * | 0 | CLAMP_ADDRESSMODE | |
  30964. * | 1 | WRAP_ADDRESSMODE | |
  30965. * | 2 | MIRROR_ADDRESSMODE | |
  30966. */
  30967. wrapR: number;
  30968. /**
  30969. * With compliant hardware and browser (supporting anisotropic filtering)
  30970. * this defines the level of anisotropic filtering in the texture.
  30971. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30972. */
  30973. anisotropicFilteringLevel: number;
  30974. /**
  30975. * Define if the texture is a cube texture or if false a 2d texture.
  30976. */
  30977. get isCube(): boolean;
  30978. set isCube(value: boolean);
  30979. /**
  30980. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30981. */
  30982. get is3D(): boolean;
  30983. set is3D(value: boolean);
  30984. /**
  30985. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30986. */
  30987. get is2DArray(): boolean;
  30988. set is2DArray(value: boolean);
  30989. /**
  30990. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30991. * HDR texture are usually stored in linear space.
  30992. * This only impacts the PBR and Background materials
  30993. */
  30994. gammaSpace: boolean;
  30995. /**
  30996. * Gets or sets whether or not the texture contains RGBD data.
  30997. */
  30998. get isRGBD(): boolean;
  30999. set isRGBD(value: boolean);
  31000. /**
  31001. * Is Z inverted in the texture (useful in a cube texture).
  31002. */
  31003. invertZ: boolean;
  31004. /**
  31005. * Are mip maps generated for this texture or not.
  31006. */
  31007. get noMipmap(): boolean;
  31008. /**
  31009. * @hidden
  31010. */
  31011. lodLevelInAlpha: boolean;
  31012. /**
  31013. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31014. */
  31015. get lodGenerationOffset(): number;
  31016. set lodGenerationOffset(value: number);
  31017. /**
  31018. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31019. */
  31020. get lodGenerationScale(): number;
  31021. set lodGenerationScale(value: number);
  31022. /**
  31023. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31024. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31025. * average roughness values.
  31026. */
  31027. get linearSpecularLOD(): boolean;
  31028. set linearSpecularLOD(value: boolean);
  31029. /**
  31030. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31031. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31032. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31033. */
  31034. get irradianceTexture(): Nullable<BaseTexture>;
  31035. set irradianceTexture(value: Nullable<BaseTexture>);
  31036. /**
  31037. * Define if the texture is a render target.
  31038. */
  31039. isRenderTarget: boolean;
  31040. /**
  31041. * Define the unique id of the texture in the scene.
  31042. */
  31043. get uid(): string;
  31044. /**
  31045. * Return a string representation of the texture.
  31046. * @returns the texture as a string
  31047. */
  31048. toString(): string;
  31049. /**
  31050. * Get the class name of the texture.
  31051. * @returns "BaseTexture"
  31052. */
  31053. getClassName(): string;
  31054. /**
  31055. * Define the list of animation attached to the texture.
  31056. */
  31057. animations: import("babylonjs/Animations/animation").Animation[];
  31058. /**
  31059. * An event triggered when the texture is disposed.
  31060. */
  31061. onDisposeObservable: Observable<BaseTexture>;
  31062. private _onDisposeObserver;
  31063. /**
  31064. * Callback triggered when the texture has been disposed.
  31065. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31066. */
  31067. set onDispose(callback: () => void);
  31068. /**
  31069. * Define the current state of the loading sequence when in delayed load mode.
  31070. */
  31071. delayLoadState: number;
  31072. private _scene;
  31073. /** @hidden */
  31074. _texture: Nullable<InternalTexture>;
  31075. private _uid;
  31076. /**
  31077. * Define if the texture is preventinga material to render or not.
  31078. * If not and the texture is not ready, the engine will use a default black texture instead.
  31079. */
  31080. get isBlocking(): boolean;
  31081. /**
  31082. * Instantiates a new BaseTexture.
  31083. * Base class of all the textures in babylon.
  31084. * It groups all the common properties the materials, post process, lights... might need
  31085. * in order to make a correct use of the texture.
  31086. * @param scene Define the scene the texture blongs to
  31087. */
  31088. constructor(scene: Nullable<Scene>);
  31089. /**
  31090. * Get the scene the texture belongs to.
  31091. * @returns the scene or null if undefined
  31092. */
  31093. getScene(): Nullable<Scene>;
  31094. /**
  31095. * Get the texture transform matrix used to offset tile the texture for istance.
  31096. * @returns the transformation matrix
  31097. */
  31098. getTextureMatrix(): Matrix;
  31099. /**
  31100. * Get the texture reflection matrix used to rotate/transform the reflection.
  31101. * @returns the reflection matrix
  31102. */
  31103. getReflectionTextureMatrix(): Matrix;
  31104. /**
  31105. * Get the underlying lower level texture from Babylon.
  31106. * @returns the insternal texture
  31107. */
  31108. getInternalTexture(): Nullable<InternalTexture>;
  31109. /**
  31110. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31111. * @returns true if ready or not blocking
  31112. */
  31113. isReadyOrNotBlocking(): boolean;
  31114. /**
  31115. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31116. * @returns true if fully ready
  31117. */
  31118. isReady(): boolean;
  31119. private _cachedSize;
  31120. /**
  31121. * Get the size of the texture.
  31122. * @returns the texture size.
  31123. */
  31124. getSize(): ISize;
  31125. /**
  31126. * Get the base size of the texture.
  31127. * It can be different from the size if the texture has been resized for POT for instance
  31128. * @returns the base size
  31129. */
  31130. getBaseSize(): ISize;
  31131. /**
  31132. * Update the sampling mode of the texture.
  31133. * Default is Trilinear mode.
  31134. *
  31135. * | Value | Type | Description |
  31136. * | ----- | ------------------ | ----------- |
  31137. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31138. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31139. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31140. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31141. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31142. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31143. * | 7 | NEAREST_LINEAR | |
  31144. * | 8 | NEAREST_NEAREST | |
  31145. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31146. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31147. * | 11 | LINEAR_LINEAR | |
  31148. * | 12 | LINEAR_NEAREST | |
  31149. *
  31150. * > _mag_: magnification filter (close to the viewer)
  31151. * > _min_: minification filter (far from the viewer)
  31152. * > _mip_: filter used between mip map levels
  31153. *@param samplingMode Define the new sampling mode of the texture
  31154. */
  31155. updateSamplingMode(samplingMode: number): void;
  31156. /**
  31157. * Scales the texture if is `canRescale()`
  31158. * @param ratio the resize factor we want to use to rescale
  31159. */
  31160. scale(ratio: number): void;
  31161. /**
  31162. * Get if the texture can rescale.
  31163. */
  31164. get canRescale(): boolean;
  31165. /** @hidden */
  31166. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31167. /** @hidden */
  31168. _rebuild(): void;
  31169. /**
  31170. * Triggers the load sequence in delayed load mode.
  31171. */
  31172. delayLoad(): void;
  31173. /**
  31174. * Clones the texture.
  31175. * @returns the cloned texture
  31176. */
  31177. clone(): Nullable<BaseTexture>;
  31178. /**
  31179. * Get the texture underlying type (INT, FLOAT...)
  31180. */
  31181. get textureType(): number;
  31182. /**
  31183. * Get the texture underlying format (RGB, RGBA...)
  31184. */
  31185. get textureFormat(): number;
  31186. /**
  31187. * Indicates that textures need to be re-calculated for all materials
  31188. */
  31189. protected _markAllSubMeshesAsTexturesDirty(): void;
  31190. /**
  31191. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31192. * This will returns an RGBA array buffer containing either in values (0-255) or
  31193. * float values (0-1) depending of the underlying buffer type.
  31194. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31195. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31196. * @param buffer defines a user defined buffer to fill with data (can be null)
  31197. * @returns The Array buffer containing the pixels data.
  31198. */
  31199. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31200. /**
  31201. * Release and destroy the underlying lower level texture aka internalTexture.
  31202. */
  31203. releaseInternalTexture(): void;
  31204. /** @hidden */
  31205. get _lodTextureHigh(): Nullable<BaseTexture>;
  31206. /** @hidden */
  31207. get _lodTextureMid(): Nullable<BaseTexture>;
  31208. /** @hidden */
  31209. get _lodTextureLow(): Nullable<BaseTexture>;
  31210. /**
  31211. * Dispose the texture and release its associated resources.
  31212. */
  31213. dispose(): void;
  31214. /**
  31215. * Serialize the texture into a JSON representation that can be parsed later on.
  31216. * @returns the JSON representation of the texture
  31217. */
  31218. serialize(): any;
  31219. /**
  31220. * Helper function to be called back once a list of texture contains only ready textures.
  31221. * @param textures Define the list of textures to wait for
  31222. * @param callback Define the callback triggered once the entire list will be ready
  31223. */
  31224. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31225. }
  31226. }
  31227. declare module "babylonjs/Materials/effect" {
  31228. import { Observable } from "babylonjs/Misc/observable";
  31229. import { Nullable } from "babylonjs/types";
  31230. import { IDisposable } from "babylonjs/scene";
  31231. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31232. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31233. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31234. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31235. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31236. import { Engine } from "babylonjs/Engines/engine";
  31237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31239. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31240. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31241. /**
  31242. * Options to be used when creating an effect.
  31243. */
  31244. export interface IEffectCreationOptions {
  31245. /**
  31246. * Atrributes that will be used in the shader.
  31247. */
  31248. attributes: string[];
  31249. /**
  31250. * Uniform varible names that will be set in the shader.
  31251. */
  31252. uniformsNames: string[];
  31253. /**
  31254. * Uniform buffer variable names that will be set in the shader.
  31255. */
  31256. uniformBuffersNames: string[];
  31257. /**
  31258. * Sampler texture variable names that will be set in the shader.
  31259. */
  31260. samplers: string[];
  31261. /**
  31262. * Define statements that will be set in the shader.
  31263. */
  31264. defines: any;
  31265. /**
  31266. * Possible fallbacks for this effect to improve performance when needed.
  31267. */
  31268. fallbacks: Nullable<IEffectFallbacks>;
  31269. /**
  31270. * Callback that will be called when the shader is compiled.
  31271. */
  31272. onCompiled: Nullable<(effect: Effect) => void>;
  31273. /**
  31274. * Callback that will be called if an error occurs during shader compilation.
  31275. */
  31276. onError: Nullable<(effect: Effect, errors: string) => void>;
  31277. /**
  31278. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31279. */
  31280. indexParameters?: any;
  31281. /**
  31282. * Max number of lights that can be used in the shader.
  31283. */
  31284. maxSimultaneousLights?: number;
  31285. /**
  31286. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31287. */
  31288. transformFeedbackVaryings?: Nullable<string[]>;
  31289. }
  31290. /**
  31291. * Effect containing vertex and fragment shader that can be executed on an object.
  31292. */
  31293. export class Effect implements IDisposable {
  31294. /**
  31295. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31296. */
  31297. static ShadersRepository: string;
  31298. /**
  31299. * Enable logging of the shader code when a compilation error occurs
  31300. */
  31301. static LogShaderCodeOnCompilationError: boolean;
  31302. /**
  31303. * Name of the effect.
  31304. */
  31305. name: any;
  31306. /**
  31307. * String container all the define statements that should be set on the shader.
  31308. */
  31309. defines: string;
  31310. /**
  31311. * Callback that will be called when the shader is compiled.
  31312. */
  31313. onCompiled: Nullable<(effect: Effect) => void>;
  31314. /**
  31315. * Callback that will be called if an error occurs during shader compilation.
  31316. */
  31317. onError: Nullable<(effect: Effect, errors: string) => void>;
  31318. /**
  31319. * Callback that will be called when effect is bound.
  31320. */
  31321. onBind: Nullable<(effect: Effect) => void>;
  31322. /**
  31323. * Unique ID of the effect.
  31324. */
  31325. uniqueId: number;
  31326. /**
  31327. * Observable that will be called when the shader is compiled.
  31328. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31329. */
  31330. onCompileObservable: Observable<Effect>;
  31331. /**
  31332. * Observable that will be called if an error occurs during shader compilation.
  31333. */
  31334. onErrorObservable: Observable<Effect>;
  31335. /** @hidden */
  31336. _onBindObservable: Nullable<Observable<Effect>>;
  31337. /**
  31338. * @hidden
  31339. * Specifies if the effect was previously ready
  31340. */
  31341. _wasPreviouslyReady: boolean;
  31342. /**
  31343. * Observable that will be called when effect is bound.
  31344. */
  31345. get onBindObservable(): Observable<Effect>;
  31346. /** @hidden */
  31347. _bonesComputationForcedToCPU: boolean;
  31348. private static _uniqueIdSeed;
  31349. private _engine;
  31350. private _uniformBuffersNames;
  31351. private _uniformsNames;
  31352. private _samplerList;
  31353. private _samplers;
  31354. private _isReady;
  31355. private _compilationError;
  31356. private _allFallbacksProcessed;
  31357. private _attributesNames;
  31358. private _attributes;
  31359. private _attributeLocationByName;
  31360. private _uniforms;
  31361. /**
  31362. * Key for the effect.
  31363. * @hidden
  31364. */
  31365. _key: string;
  31366. private _indexParameters;
  31367. private _fallbacks;
  31368. private _vertexSourceCode;
  31369. private _fragmentSourceCode;
  31370. private _vertexSourceCodeOverride;
  31371. private _fragmentSourceCodeOverride;
  31372. private _transformFeedbackVaryings;
  31373. /**
  31374. * Compiled shader to webGL program.
  31375. * @hidden
  31376. */
  31377. _pipelineContext: Nullable<IPipelineContext>;
  31378. private _valueCache;
  31379. private static _baseCache;
  31380. /**
  31381. * Instantiates an effect.
  31382. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31383. * @param baseName Name of the effect.
  31384. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31385. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31386. * @param samplers List of sampler variables that will be passed to the shader.
  31387. * @param engine Engine to be used to render the effect
  31388. * @param defines Define statements to be added to the shader.
  31389. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31390. * @param onCompiled Callback that will be called when the shader is compiled.
  31391. * @param onError Callback that will be called if an error occurs during shader compilation.
  31392. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31393. */
  31394. 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);
  31395. private _useFinalCode;
  31396. /**
  31397. * Unique key for this effect
  31398. */
  31399. get key(): string;
  31400. /**
  31401. * If the effect has been compiled and prepared.
  31402. * @returns if the effect is compiled and prepared.
  31403. */
  31404. isReady(): boolean;
  31405. private _isReadyInternal;
  31406. /**
  31407. * The engine the effect was initialized with.
  31408. * @returns the engine.
  31409. */
  31410. getEngine(): Engine;
  31411. /**
  31412. * The pipeline context for this effect
  31413. * @returns the associated pipeline context
  31414. */
  31415. getPipelineContext(): Nullable<IPipelineContext>;
  31416. /**
  31417. * The set of names of attribute variables for the shader.
  31418. * @returns An array of attribute names.
  31419. */
  31420. getAttributesNames(): string[];
  31421. /**
  31422. * Returns the attribute at the given index.
  31423. * @param index The index of the attribute.
  31424. * @returns The location of the attribute.
  31425. */
  31426. getAttributeLocation(index: number): number;
  31427. /**
  31428. * Returns the attribute based on the name of the variable.
  31429. * @param name of the attribute to look up.
  31430. * @returns the attribute location.
  31431. */
  31432. getAttributeLocationByName(name: string): number;
  31433. /**
  31434. * The number of attributes.
  31435. * @returns the numnber of attributes.
  31436. */
  31437. getAttributesCount(): number;
  31438. /**
  31439. * Gets the index of a uniform variable.
  31440. * @param uniformName of the uniform to look up.
  31441. * @returns the index.
  31442. */
  31443. getUniformIndex(uniformName: string): number;
  31444. /**
  31445. * Returns the attribute based on the name of the variable.
  31446. * @param uniformName of the uniform to look up.
  31447. * @returns the location of the uniform.
  31448. */
  31449. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31450. /**
  31451. * Returns an array of sampler variable names
  31452. * @returns The array of sampler variable neames.
  31453. */
  31454. getSamplers(): string[];
  31455. /**
  31456. * The error from the last compilation.
  31457. * @returns the error string.
  31458. */
  31459. getCompilationError(): string;
  31460. /**
  31461. * Gets a boolean indicating that all fallbacks were used during compilation
  31462. * @returns true if all fallbacks were used
  31463. */
  31464. allFallbacksProcessed(): boolean;
  31465. /**
  31466. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31467. * @param func The callback to be used.
  31468. */
  31469. executeWhenCompiled(func: (effect: Effect) => void): void;
  31470. private _checkIsReady;
  31471. private _loadShader;
  31472. /**
  31473. * Recompiles the webGL program
  31474. * @param vertexSourceCode The source code for the vertex shader.
  31475. * @param fragmentSourceCode The source code for the fragment shader.
  31476. * @param onCompiled Callback called when completed.
  31477. * @param onError Callback called on error.
  31478. * @hidden
  31479. */
  31480. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31481. /**
  31482. * Prepares the effect
  31483. * @hidden
  31484. */
  31485. _prepareEffect(): void;
  31486. private _getShaderCodeAndErrorLine;
  31487. private _processCompilationErrors;
  31488. /**
  31489. * Checks if the effect is supported. (Must be called after compilation)
  31490. */
  31491. get isSupported(): boolean;
  31492. /**
  31493. * Binds a texture to the engine to be used as output of the shader.
  31494. * @param channel Name of the output variable.
  31495. * @param texture Texture to bind.
  31496. * @hidden
  31497. */
  31498. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31499. /**
  31500. * Sets a texture on the engine to be used in the shader.
  31501. * @param channel Name of the sampler variable.
  31502. * @param texture Texture to set.
  31503. */
  31504. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31505. /**
  31506. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31507. * @param channel Name of the sampler variable.
  31508. * @param texture Texture to set.
  31509. */
  31510. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31511. /**
  31512. * Sets an array of textures on the engine to be used in the shader.
  31513. * @param channel Name of the variable.
  31514. * @param textures Textures to set.
  31515. */
  31516. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31517. /**
  31518. * 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)
  31519. * @param channel Name of the sampler variable.
  31520. * @param postProcess Post process to get the input texture from.
  31521. */
  31522. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31523. /**
  31524. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31525. * 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)
  31526. * @param channel Name of the sampler variable.
  31527. * @param postProcess Post process to get the output texture from.
  31528. */
  31529. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31530. /** @hidden */
  31531. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31532. /** @hidden */
  31533. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31534. /** @hidden */
  31535. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31536. /** @hidden */
  31537. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31538. /**
  31539. * Binds a buffer to a uniform.
  31540. * @param buffer Buffer to bind.
  31541. * @param name Name of the uniform variable to bind to.
  31542. */
  31543. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31544. /**
  31545. * Binds block to a uniform.
  31546. * @param blockName Name of the block to bind.
  31547. * @param index Index to bind.
  31548. */
  31549. bindUniformBlock(blockName: string, index: number): void;
  31550. /**
  31551. * Sets an interger value on a uniform variable.
  31552. * @param uniformName Name of the variable.
  31553. * @param value Value to be set.
  31554. * @returns this effect.
  31555. */
  31556. setInt(uniformName: string, value: number): Effect;
  31557. /**
  31558. * Sets an int array on a uniform variable.
  31559. * @param uniformName Name of the variable.
  31560. * @param array array to be set.
  31561. * @returns this effect.
  31562. */
  31563. setIntArray(uniformName: string, array: Int32Array): Effect;
  31564. /**
  31565. * 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)
  31566. * @param uniformName Name of the variable.
  31567. * @param array array to be set.
  31568. * @returns this effect.
  31569. */
  31570. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31571. /**
  31572. * 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)
  31573. * @param uniformName Name of the variable.
  31574. * @param array array to be set.
  31575. * @returns this effect.
  31576. */
  31577. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31578. /**
  31579. * 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)
  31580. * @param uniformName Name of the variable.
  31581. * @param array array to be set.
  31582. * @returns this effect.
  31583. */
  31584. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31585. /**
  31586. * Sets an float array on a uniform variable.
  31587. * @param uniformName Name of the variable.
  31588. * @param array array to be set.
  31589. * @returns this effect.
  31590. */
  31591. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31592. /**
  31593. * 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)
  31594. * @param uniformName Name of the variable.
  31595. * @param array array to be set.
  31596. * @returns this effect.
  31597. */
  31598. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31599. /**
  31600. * 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)
  31601. * @param uniformName Name of the variable.
  31602. * @param array array to be set.
  31603. * @returns this effect.
  31604. */
  31605. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31606. /**
  31607. * 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)
  31608. * @param uniformName Name of the variable.
  31609. * @param array array to be set.
  31610. * @returns this effect.
  31611. */
  31612. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31613. /**
  31614. * Sets an array on a uniform variable.
  31615. * @param uniformName Name of the variable.
  31616. * @param array array to be set.
  31617. * @returns this effect.
  31618. */
  31619. setArray(uniformName: string, array: number[]): Effect;
  31620. /**
  31621. * 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)
  31622. * @param uniformName Name of the variable.
  31623. * @param array array to be set.
  31624. * @returns this effect.
  31625. */
  31626. setArray2(uniformName: string, array: number[]): Effect;
  31627. /**
  31628. * 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)
  31629. * @param uniformName Name of the variable.
  31630. * @param array array to be set.
  31631. * @returns this effect.
  31632. */
  31633. setArray3(uniformName: string, array: number[]): Effect;
  31634. /**
  31635. * 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)
  31636. * @param uniformName Name of the variable.
  31637. * @param array array to be set.
  31638. * @returns this effect.
  31639. */
  31640. setArray4(uniformName: string, array: number[]): Effect;
  31641. /**
  31642. * Sets matrices on a uniform variable.
  31643. * @param uniformName Name of the variable.
  31644. * @param matrices matrices to be set.
  31645. * @returns this effect.
  31646. */
  31647. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31648. /**
  31649. * Sets matrix on a uniform variable.
  31650. * @param uniformName Name of the variable.
  31651. * @param matrix matrix to be set.
  31652. * @returns this effect.
  31653. */
  31654. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31655. /**
  31656. * 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)
  31657. * @param uniformName Name of the variable.
  31658. * @param matrix matrix to be set.
  31659. * @returns this effect.
  31660. */
  31661. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31662. /**
  31663. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31664. * @param uniformName Name of the variable.
  31665. * @param matrix matrix to be set.
  31666. * @returns this effect.
  31667. */
  31668. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31669. /**
  31670. * Sets a float on a uniform variable.
  31671. * @param uniformName Name of the variable.
  31672. * @param value value to be set.
  31673. * @returns this effect.
  31674. */
  31675. setFloat(uniformName: string, value: number): Effect;
  31676. /**
  31677. * Sets a boolean on a uniform variable.
  31678. * @param uniformName Name of the variable.
  31679. * @param bool value to be set.
  31680. * @returns this effect.
  31681. */
  31682. setBool(uniformName: string, bool: boolean): Effect;
  31683. /**
  31684. * Sets a Vector2 on a uniform variable.
  31685. * @param uniformName Name of the variable.
  31686. * @param vector2 vector2 to be set.
  31687. * @returns this effect.
  31688. */
  31689. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31690. /**
  31691. * Sets a float2 on a uniform variable.
  31692. * @param uniformName Name of the variable.
  31693. * @param x First float in float2.
  31694. * @param y Second float in float2.
  31695. * @returns this effect.
  31696. */
  31697. setFloat2(uniformName: string, x: number, y: number): Effect;
  31698. /**
  31699. * Sets a Vector3 on a uniform variable.
  31700. * @param uniformName Name of the variable.
  31701. * @param vector3 Value to be set.
  31702. * @returns this effect.
  31703. */
  31704. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31705. /**
  31706. * Sets a float3 on a uniform variable.
  31707. * @param uniformName Name of the variable.
  31708. * @param x First float in float3.
  31709. * @param y Second float in float3.
  31710. * @param z Third float in float3.
  31711. * @returns this effect.
  31712. */
  31713. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31714. /**
  31715. * Sets a Vector4 on a uniform variable.
  31716. * @param uniformName Name of the variable.
  31717. * @param vector4 Value to be set.
  31718. * @returns this effect.
  31719. */
  31720. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31721. /**
  31722. * Sets a float4 on a uniform variable.
  31723. * @param uniformName Name of the variable.
  31724. * @param x First float in float4.
  31725. * @param y Second float in float4.
  31726. * @param z Third float in float4.
  31727. * @param w Fourth float in float4.
  31728. * @returns this effect.
  31729. */
  31730. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31731. /**
  31732. * Sets a Color3 on a uniform variable.
  31733. * @param uniformName Name of the variable.
  31734. * @param color3 Value to be set.
  31735. * @returns this effect.
  31736. */
  31737. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31738. /**
  31739. * Sets a Color4 on a uniform variable.
  31740. * @param uniformName Name of the variable.
  31741. * @param color3 Value to be set.
  31742. * @param alpha Alpha value to be set.
  31743. * @returns this effect.
  31744. */
  31745. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31746. /**
  31747. * Sets a Color4 on a uniform variable
  31748. * @param uniformName defines the name of the variable
  31749. * @param color4 defines the value to be set
  31750. * @returns this effect.
  31751. */
  31752. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31753. /** Release all associated resources */
  31754. dispose(): void;
  31755. /**
  31756. * This function will add a new shader to the shader store
  31757. * @param name the name of the shader
  31758. * @param pixelShader optional pixel shader content
  31759. * @param vertexShader optional vertex shader content
  31760. */
  31761. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31762. /**
  31763. * Store of each shader (The can be looked up using effect.key)
  31764. */
  31765. static ShadersStore: {
  31766. [key: string]: string;
  31767. };
  31768. /**
  31769. * Store of each included file for a shader (The can be looked up using effect.key)
  31770. */
  31771. static IncludesShadersStore: {
  31772. [key: string]: string;
  31773. };
  31774. /**
  31775. * Resets the cache of effects.
  31776. */
  31777. static ResetCache(): void;
  31778. }
  31779. }
  31780. declare module "babylonjs/Engines/engineCapabilities" {
  31781. /**
  31782. * Interface used to describe the capabilities of the engine relatively to the current browser
  31783. */
  31784. export interface EngineCapabilities {
  31785. /** Maximum textures units per fragment shader */
  31786. maxTexturesImageUnits: number;
  31787. /** Maximum texture units per vertex shader */
  31788. maxVertexTextureImageUnits: number;
  31789. /** Maximum textures units in the entire pipeline */
  31790. maxCombinedTexturesImageUnits: number;
  31791. /** Maximum texture size */
  31792. maxTextureSize: number;
  31793. /** Maximum texture samples */
  31794. maxSamples?: number;
  31795. /** Maximum cube texture size */
  31796. maxCubemapTextureSize: number;
  31797. /** Maximum render texture size */
  31798. maxRenderTextureSize: number;
  31799. /** Maximum number of vertex attributes */
  31800. maxVertexAttribs: number;
  31801. /** Maximum number of varyings */
  31802. maxVaryingVectors: number;
  31803. /** Maximum number of uniforms per vertex shader */
  31804. maxVertexUniformVectors: number;
  31805. /** Maximum number of uniforms per fragment shader */
  31806. maxFragmentUniformVectors: number;
  31807. /** Defines if standard derivates (dx/dy) are supported */
  31808. standardDerivatives: boolean;
  31809. /** Defines if s3tc texture compression is supported */
  31810. s3tc?: WEBGL_compressed_texture_s3tc;
  31811. /** Defines if pvrtc texture compression is supported */
  31812. pvrtc: any;
  31813. /** Defines if etc1 texture compression is supported */
  31814. etc1: any;
  31815. /** Defines if etc2 texture compression is supported */
  31816. etc2: any;
  31817. /** Defines if astc texture compression is supported */
  31818. astc: any;
  31819. /** Defines if float textures are supported */
  31820. textureFloat: boolean;
  31821. /** Defines if vertex array objects are supported */
  31822. vertexArrayObject: boolean;
  31823. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31824. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31825. /** Gets the maximum level of anisotropy supported */
  31826. maxAnisotropy: number;
  31827. /** Defines if instancing is supported */
  31828. instancedArrays: boolean;
  31829. /** Defines if 32 bits indices are supported */
  31830. uintIndices: boolean;
  31831. /** Defines if high precision shaders are supported */
  31832. highPrecisionShaderSupported: boolean;
  31833. /** Defines if depth reading in the fragment shader is supported */
  31834. fragmentDepthSupported: boolean;
  31835. /** Defines if float texture linear filtering is supported*/
  31836. textureFloatLinearFiltering: boolean;
  31837. /** Defines if rendering to float textures is supported */
  31838. textureFloatRender: boolean;
  31839. /** Defines if half float textures are supported*/
  31840. textureHalfFloat: boolean;
  31841. /** Defines if half float texture linear filtering is supported*/
  31842. textureHalfFloatLinearFiltering: boolean;
  31843. /** Defines if rendering to half float textures is supported */
  31844. textureHalfFloatRender: boolean;
  31845. /** Defines if textureLOD shader command is supported */
  31846. textureLOD: boolean;
  31847. /** Defines if draw buffers extension is supported */
  31848. drawBuffersExtension: boolean;
  31849. /** Defines if depth textures are supported */
  31850. depthTextureExtension: boolean;
  31851. /** Defines if float color buffer are supported */
  31852. colorBufferFloat: boolean;
  31853. /** Gets disjoint timer query extension (null if not supported) */
  31854. timerQuery?: EXT_disjoint_timer_query;
  31855. /** Defines if timestamp can be used with timer query */
  31856. canUseTimestampForTimerQuery: boolean;
  31857. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31858. multiview?: any;
  31859. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31860. oculusMultiview?: any;
  31861. /** Function used to let the system compiles shaders in background */
  31862. parallelShaderCompile?: {
  31863. COMPLETION_STATUS_KHR: number;
  31864. };
  31865. /** Max number of texture samples for MSAA */
  31866. maxMSAASamples: number;
  31867. /** Defines if the blend min max extension is supported */
  31868. blendMinMax: boolean;
  31869. }
  31870. }
  31871. declare module "babylonjs/States/depthCullingState" {
  31872. import { Nullable } from "babylonjs/types";
  31873. /**
  31874. * @hidden
  31875. **/
  31876. export class DepthCullingState {
  31877. private _isDepthTestDirty;
  31878. private _isDepthMaskDirty;
  31879. private _isDepthFuncDirty;
  31880. private _isCullFaceDirty;
  31881. private _isCullDirty;
  31882. private _isZOffsetDirty;
  31883. private _isFrontFaceDirty;
  31884. private _depthTest;
  31885. private _depthMask;
  31886. private _depthFunc;
  31887. private _cull;
  31888. private _cullFace;
  31889. private _zOffset;
  31890. private _frontFace;
  31891. /**
  31892. * Initializes the state.
  31893. */
  31894. constructor();
  31895. get isDirty(): boolean;
  31896. get zOffset(): number;
  31897. set zOffset(value: number);
  31898. get cullFace(): Nullable<number>;
  31899. set cullFace(value: Nullable<number>);
  31900. get cull(): Nullable<boolean>;
  31901. set cull(value: Nullable<boolean>);
  31902. get depthFunc(): Nullable<number>;
  31903. set depthFunc(value: Nullable<number>);
  31904. get depthMask(): boolean;
  31905. set depthMask(value: boolean);
  31906. get depthTest(): boolean;
  31907. set depthTest(value: boolean);
  31908. get frontFace(): Nullable<number>;
  31909. set frontFace(value: Nullable<number>);
  31910. reset(): void;
  31911. apply(gl: WebGLRenderingContext): void;
  31912. }
  31913. }
  31914. declare module "babylonjs/States/stencilState" {
  31915. /**
  31916. * @hidden
  31917. **/
  31918. export class StencilState {
  31919. /** 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 */
  31920. static readonly ALWAYS: number;
  31921. /** Passed to stencilOperation to specify that stencil value must be kept */
  31922. static readonly KEEP: number;
  31923. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31924. static readonly REPLACE: number;
  31925. private _isStencilTestDirty;
  31926. private _isStencilMaskDirty;
  31927. private _isStencilFuncDirty;
  31928. private _isStencilOpDirty;
  31929. private _stencilTest;
  31930. private _stencilMask;
  31931. private _stencilFunc;
  31932. private _stencilFuncRef;
  31933. private _stencilFuncMask;
  31934. private _stencilOpStencilFail;
  31935. private _stencilOpDepthFail;
  31936. private _stencilOpStencilDepthPass;
  31937. get isDirty(): boolean;
  31938. get stencilFunc(): number;
  31939. set stencilFunc(value: number);
  31940. get stencilFuncRef(): number;
  31941. set stencilFuncRef(value: number);
  31942. get stencilFuncMask(): number;
  31943. set stencilFuncMask(value: number);
  31944. get stencilOpStencilFail(): number;
  31945. set stencilOpStencilFail(value: number);
  31946. get stencilOpDepthFail(): number;
  31947. set stencilOpDepthFail(value: number);
  31948. get stencilOpStencilDepthPass(): number;
  31949. set stencilOpStencilDepthPass(value: number);
  31950. get stencilMask(): number;
  31951. set stencilMask(value: number);
  31952. get stencilTest(): boolean;
  31953. set stencilTest(value: boolean);
  31954. constructor();
  31955. reset(): void;
  31956. apply(gl: WebGLRenderingContext): void;
  31957. }
  31958. }
  31959. declare module "babylonjs/States/alphaCullingState" {
  31960. /**
  31961. * @hidden
  31962. **/
  31963. export class AlphaState {
  31964. private _isAlphaBlendDirty;
  31965. private _isBlendFunctionParametersDirty;
  31966. private _isBlendEquationParametersDirty;
  31967. private _isBlendConstantsDirty;
  31968. private _alphaBlend;
  31969. private _blendFunctionParameters;
  31970. private _blendEquationParameters;
  31971. private _blendConstants;
  31972. /**
  31973. * Initializes the state.
  31974. */
  31975. constructor();
  31976. get isDirty(): boolean;
  31977. get alphaBlend(): boolean;
  31978. set alphaBlend(value: boolean);
  31979. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31980. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31981. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31982. reset(): void;
  31983. apply(gl: WebGLRenderingContext): void;
  31984. }
  31985. }
  31986. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31987. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31988. /** @hidden */
  31989. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31990. attributeProcessor(attribute: string): string;
  31991. varyingProcessor(varying: string, isFragment: boolean): string;
  31992. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31993. }
  31994. }
  31995. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31996. /**
  31997. * Interface for attribute information associated with buffer instanciation
  31998. */
  31999. export interface InstancingAttributeInfo {
  32000. /**
  32001. * Name of the GLSL attribute
  32002. * if attribute index is not specified, this is used to retrieve the index from the effect
  32003. */
  32004. attributeName: string;
  32005. /**
  32006. * Index/offset of the attribute in the vertex shader
  32007. * if not specified, this will be computes from the name.
  32008. */
  32009. index?: number;
  32010. /**
  32011. * size of the attribute, 1, 2, 3 or 4
  32012. */
  32013. attributeSize: number;
  32014. /**
  32015. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32016. */
  32017. offset: number;
  32018. /**
  32019. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32020. * default to 1
  32021. */
  32022. divisor?: number;
  32023. /**
  32024. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32025. * default is FLOAT
  32026. */
  32027. attributeType?: number;
  32028. /**
  32029. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32030. */
  32031. normalized?: boolean;
  32032. }
  32033. }
  32034. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32036. import { Nullable } from "babylonjs/types";
  32037. module "babylonjs/Engines/thinEngine" {
  32038. interface ThinEngine {
  32039. /**
  32040. * Update a video texture
  32041. * @param texture defines the texture to update
  32042. * @param video defines the video element to use
  32043. * @param invertY defines if data must be stored with Y axis inverted
  32044. */
  32045. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32046. }
  32047. }
  32048. }
  32049. declare module "babylonjs/Materials/Textures/videoTexture" {
  32050. import { Observable } from "babylonjs/Misc/observable";
  32051. import { Nullable } from "babylonjs/types";
  32052. import { Scene } from "babylonjs/scene";
  32053. import { Texture } from "babylonjs/Materials/Textures/texture";
  32054. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32055. /**
  32056. * Settings for finer control over video usage
  32057. */
  32058. export interface VideoTextureSettings {
  32059. /**
  32060. * Applies `autoplay` to video, if specified
  32061. */
  32062. autoPlay?: boolean;
  32063. /**
  32064. * Applies `loop` to video, if specified
  32065. */
  32066. loop?: boolean;
  32067. /**
  32068. * Automatically updates internal texture from video at every frame in the render loop
  32069. */
  32070. autoUpdateTexture: boolean;
  32071. /**
  32072. * Image src displayed during the video loading or until the user interacts with the video.
  32073. */
  32074. poster?: string;
  32075. }
  32076. /**
  32077. * If you want to display a video in your scene, this is the special texture for that.
  32078. * This special texture works similar to other textures, with the exception of a few parameters.
  32079. * @see https://doc.babylonjs.com/how_to/video_texture
  32080. */
  32081. export class VideoTexture extends Texture {
  32082. /**
  32083. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32084. */
  32085. readonly autoUpdateTexture: boolean;
  32086. /**
  32087. * The video instance used by the texture internally
  32088. */
  32089. readonly video: HTMLVideoElement;
  32090. private _onUserActionRequestedObservable;
  32091. /**
  32092. * Event triggerd when a dom action is required by the user to play the video.
  32093. * This happens due to recent changes in browser policies preventing video to auto start.
  32094. */
  32095. get onUserActionRequestedObservable(): Observable<Texture>;
  32096. private _generateMipMaps;
  32097. private _engine;
  32098. private _stillImageCaptured;
  32099. private _displayingPosterTexture;
  32100. private _settings;
  32101. private _createInternalTextureOnEvent;
  32102. private _frameId;
  32103. private _currentSrc;
  32104. /**
  32105. * Creates a video texture.
  32106. * If you want to display a video in your scene, this is the special texture for that.
  32107. * This special texture works similar to other textures, with the exception of a few parameters.
  32108. * @see https://doc.babylonjs.com/how_to/video_texture
  32109. * @param name optional name, will detect from video source, if not defined
  32110. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32111. * @param scene is obviously the current scene.
  32112. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32113. * @param invertY is false by default but can be used to invert video on Y axis
  32114. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32115. * @param settings allows finer control over video usage
  32116. */
  32117. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32118. private _getName;
  32119. private _getVideo;
  32120. private _createInternalTexture;
  32121. private reset;
  32122. /**
  32123. * @hidden Internal method to initiate `update`.
  32124. */
  32125. _rebuild(): void;
  32126. /**
  32127. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32128. */
  32129. update(): void;
  32130. /**
  32131. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32132. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32133. */
  32134. updateTexture(isVisible: boolean): void;
  32135. protected _updateInternalTexture: () => void;
  32136. /**
  32137. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32138. * @param url New url.
  32139. */
  32140. updateURL(url: string): void;
  32141. /**
  32142. * Clones the texture.
  32143. * @returns the cloned texture
  32144. */
  32145. clone(): VideoTexture;
  32146. /**
  32147. * Dispose the texture and release its associated resources.
  32148. */
  32149. dispose(): void;
  32150. /**
  32151. * Creates a video texture straight from a stream.
  32152. * @param scene Define the scene the texture should be created in
  32153. * @param stream Define the stream the texture should be created from
  32154. * @returns The created video texture as a promise
  32155. */
  32156. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32157. /**
  32158. * Creates a video texture straight from your WebCam video feed.
  32159. * @param scene Define the scene the texture should be created in
  32160. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32161. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32162. * @returns The created video texture as a promise
  32163. */
  32164. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32165. minWidth: number;
  32166. maxWidth: number;
  32167. minHeight: number;
  32168. maxHeight: number;
  32169. deviceId: string;
  32170. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32171. /**
  32172. * Creates a video texture straight from your WebCam video feed.
  32173. * @param scene Define the scene the texture should be created in
  32174. * @param onReady Define a callback to triggered once the texture will be ready
  32175. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32176. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32177. */
  32178. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32179. minWidth: number;
  32180. maxWidth: number;
  32181. minHeight: number;
  32182. maxHeight: number;
  32183. deviceId: string;
  32184. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32185. }
  32186. }
  32187. declare module "babylonjs/Engines/thinEngine" {
  32188. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32189. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32190. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32191. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32192. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32193. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32194. import { Observable } from "babylonjs/Misc/observable";
  32195. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32196. import { StencilState } from "babylonjs/States/stencilState";
  32197. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32198. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32199. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32200. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32201. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32202. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32203. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32204. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32205. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32207. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32208. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32209. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32210. import { WebRequest } from "babylonjs/Misc/webRequest";
  32211. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32212. /**
  32213. * Defines the interface used by objects working like Scene
  32214. * @hidden
  32215. */
  32216. export interface ISceneLike {
  32217. _addPendingData(data: any): void;
  32218. _removePendingData(data: any): void;
  32219. offlineProvider: IOfflineProvider;
  32220. }
  32221. /** Interface defining initialization parameters for Engine class */
  32222. export interface EngineOptions extends WebGLContextAttributes {
  32223. /**
  32224. * Defines if the engine should no exceed a specified device ratio
  32225. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32226. */
  32227. limitDeviceRatio?: number;
  32228. /**
  32229. * Defines if webvr should be enabled automatically
  32230. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32231. */
  32232. autoEnableWebVR?: boolean;
  32233. /**
  32234. * Defines if webgl2 should be turned off even if supported
  32235. * @see http://doc.babylonjs.com/features/webgl2
  32236. */
  32237. disableWebGL2Support?: boolean;
  32238. /**
  32239. * Defines if webaudio should be initialized as well
  32240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32241. */
  32242. audioEngine?: boolean;
  32243. /**
  32244. * Defines if animations should run using a deterministic lock step
  32245. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32246. */
  32247. deterministicLockstep?: boolean;
  32248. /** Defines the maximum steps to use with deterministic lock step mode */
  32249. lockstepMaxSteps?: number;
  32250. /** Defines the seconds between each deterministic lock step */
  32251. timeStep?: number;
  32252. /**
  32253. * Defines that engine should ignore context lost events
  32254. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32255. */
  32256. doNotHandleContextLost?: boolean;
  32257. /**
  32258. * Defines that engine should ignore modifying touch action attribute and style
  32259. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32260. */
  32261. doNotHandleTouchAction?: boolean;
  32262. /**
  32263. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32264. */
  32265. useHighPrecisionFloats?: boolean;
  32266. }
  32267. /**
  32268. * The base engine class (root of all engines)
  32269. */
  32270. export class ThinEngine {
  32271. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32272. static ExceptionList: ({
  32273. key: string;
  32274. capture: string;
  32275. captureConstraint: number;
  32276. targets: string[];
  32277. } | {
  32278. key: string;
  32279. capture: null;
  32280. captureConstraint: null;
  32281. targets: string[];
  32282. })[];
  32283. /** @hidden */
  32284. static _TextureLoaders: IInternalTextureLoader[];
  32285. /**
  32286. * Returns the current npm package of the sdk
  32287. */
  32288. static get NpmPackage(): string;
  32289. /**
  32290. * Returns the current version of the framework
  32291. */
  32292. static get Version(): string;
  32293. /**
  32294. * Returns a string describing the current engine
  32295. */
  32296. get description(): string;
  32297. /**
  32298. * Gets or sets the epsilon value used by collision engine
  32299. */
  32300. static CollisionsEpsilon: number;
  32301. /**
  32302. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32303. */
  32304. static get ShadersRepository(): string;
  32305. static set ShadersRepository(value: string);
  32306. /** @hidden */
  32307. _shaderProcessor: IShaderProcessor;
  32308. /**
  32309. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32310. */
  32311. forcePOTTextures: boolean;
  32312. /**
  32313. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32314. */
  32315. isFullscreen: boolean;
  32316. /**
  32317. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32318. */
  32319. cullBackFaces: boolean;
  32320. /**
  32321. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32322. */
  32323. renderEvenInBackground: boolean;
  32324. /**
  32325. * Gets or sets a boolean indicating that cache can be kept between frames
  32326. */
  32327. preventCacheWipeBetweenFrames: boolean;
  32328. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32329. validateShaderPrograms: boolean;
  32330. /**
  32331. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32332. * This can provide greater z depth for distant objects.
  32333. */
  32334. useReverseDepthBuffer: boolean;
  32335. /**
  32336. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32337. */
  32338. disableUniformBuffers: boolean;
  32339. /** @hidden */
  32340. _uniformBuffers: UniformBuffer[];
  32341. /**
  32342. * Gets a boolean indicating that the engine supports uniform buffers
  32343. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32344. */
  32345. get supportsUniformBuffers(): boolean;
  32346. /** @hidden */
  32347. _gl: WebGLRenderingContext;
  32348. /** @hidden */
  32349. _webGLVersion: number;
  32350. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32351. protected _windowIsBackground: boolean;
  32352. protected _creationOptions: EngineOptions;
  32353. protected _highPrecisionShadersAllowed: boolean;
  32354. /** @hidden */
  32355. get _shouldUseHighPrecisionShader(): boolean;
  32356. /**
  32357. * Gets a boolean indicating that only power of 2 textures are supported
  32358. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32359. */
  32360. get needPOTTextures(): boolean;
  32361. /** @hidden */
  32362. _badOS: boolean;
  32363. /** @hidden */
  32364. _badDesktopOS: boolean;
  32365. private _hardwareScalingLevel;
  32366. /** @hidden */
  32367. _caps: EngineCapabilities;
  32368. private _isStencilEnable;
  32369. private _glVersion;
  32370. private _glRenderer;
  32371. private _glVendor;
  32372. /** @hidden */
  32373. _videoTextureSupported: boolean;
  32374. protected _renderingQueueLaunched: boolean;
  32375. protected _activeRenderLoops: (() => void)[];
  32376. /**
  32377. * Observable signaled when a context lost event is raised
  32378. */
  32379. onContextLostObservable: Observable<ThinEngine>;
  32380. /**
  32381. * Observable signaled when a context restored event is raised
  32382. */
  32383. onContextRestoredObservable: Observable<ThinEngine>;
  32384. private _onContextLost;
  32385. private _onContextRestored;
  32386. protected _contextWasLost: boolean;
  32387. /** @hidden */
  32388. _doNotHandleContextLost: boolean;
  32389. /**
  32390. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32391. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32392. */
  32393. get doNotHandleContextLost(): boolean;
  32394. set doNotHandleContextLost(value: boolean);
  32395. /**
  32396. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32397. */
  32398. disableVertexArrayObjects: boolean;
  32399. /** @hidden */
  32400. protected _colorWrite: boolean;
  32401. /** @hidden */
  32402. protected _colorWriteChanged: boolean;
  32403. /** @hidden */
  32404. protected _depthCullingState: DepthCullingState;
  32405. /** @hidden */
  32406. protected _stencilState: StencilState;
  32407. /** @hidden */
  32408. _alphaState: AlphaState;
  32409. /** @hidden */
  32410. _alphaMode: number;
  32411. /** @hidden */
  32412. _alphaEquation: number;
  32413. /** @hidden */
  32414. _internalTexturesCache: InternalTexture[];
  32415. /** @hidden */
  32416. protected _activeChannel: number;
  32417. private _currentTextureChannel;
  32418. /** @hidden */
  32419. protected _boundTexturesCache: {
  32420. [key: string]: Nullable<InternalTexture>;
  32421. };
  32422. /** @hidden */
  32423. protected _currentEffect: Nullable<Effect>;
  32424. /** @hidden */
  32425. protected _currentProgram: Nullable<WebGLProgram>;
  32426. private _compiledEffects;
  32427. private _vertexAttribArraysEnabled;
  32428. /** @hidden */
  32429. protected _cachedViewport: Nullable<IViewportLike>;
  32430. private _cachedVertexArrayObject;
  32431. /** @hidden */
  32432. protected _cachedVertexBuffers: any;
  32433. /** @hidden */
  32434. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32435. /** @hidden */
  32436. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32437. /** @hidden */
  32438. _currentRenderTarget: Nullable<InternalTexture>;
  32439. private _uintIndicesCurrentlySet;
  32440. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32441. /** @hidden */
  32442. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32443. private _currentBufferPointers;
  32444. private _currentInstanceLocations;
  32445. private _currentInstanceBuffers;
  32446. private _textureUnits;
  32447. /** @hidden */
  32448. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32449. /** @hidden */
  32450. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32451. /** @hidden */
  32452. _boundRenderFunction: any;
  32453. private _vaoRecordInProgress;
  32454. private _mustWipeVertexAttributes;
  32455. private _emptyTexture;
  32456. private _emptyCubeTexture;
  32457. private _emptyTexture3D;
  32458. private _emptyTexture2DArray;
  32459. /** @hidden */
  32460. _frameHandler: number;
  32461. private _nextFreeTextureSlots;
  32462. private _maxSimultaneousTextures;
  32463. private _activeRequests;
  32464. /** @hidden */
  32465. _transformTextureUrl: Nullable<(url: string) => string>;
  32466. protected get _supportsHardwareTextureRescaling(): boolean;
  32467. private _framebufferDimensionsObject;
  32468. /**
  32469. * sets the object from which width and height will be taken from when getting render width and height
  32470. * Will fallback to the gl object
  32471. * @param dimensions the framebuffer width and height that will be used.
  32472. */
  32473. set framebufferDimensionsObject(dimensions: Nullable<{
  32474. framebufferWidth: number;
  32475. framebufferHeight: number;
  32476. }>);
  32477. /**
  32478. * Gets the current viewport
  32479. */
  32480. get currentViewport(): Nullable<IViewportLike>;
  32481. /**
  32482. * Gets the default empty texture
  32483. */
  32484. get emptyTexture(): InternalTexture;
  32485. /**
  32486. * Gets the default empty 3D texture
  32487. */
  32488. get emptyTexture3D(): InternalTexture;
  32489. /**
  32490. * Gets the default empty 2D array texture
  32491. */
  32492. get emptyTexture2DArray(): InternalTexture;
  32493. /**
  32494. * Gets the default empty cube texture
  32495. */
  32496. get emptyCubeTexture(): InternalTexture;
  32497. /**
  32498. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32499. */
  32500. readonly premultipliedAlpha: boolean;
  32501. /**
  32502. * Observable event triggered before each texture is initialized
  32503. */
  32504. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32505. /**
  32506. * Creates a new engine
  32507. * @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
  32508. * @param antialias defines enable antialiasing (default: false)
  32509. * @param options defines further options to be sent to the getContext() function
  32510. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32511. */
  32512. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32513. private _rebuildInternalTextures;
  32514. private _rebuildEffects;
  32515. /**
  32516. * Gets a boolean indicating if all created effects are ready
  32517. * @returns true if all effects are ready
  32518. */
  32519. areAllEffectsReady(): boolean;
  32520. protected _rebuildBuffers(): void;
  32521. protected _initGLContext(): void;
  32522. /**
  32523. * Gets version of the current webGL context
  32524. */
  32525. get webGLVersion(): number;
  32526. /**
  32527. * Gets a string idenfifying the name of the class
  32528. * @returns "Engine" string
  32529. */
  32530. getClassName(): string;
  32531. /**
  32532. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32533. */
  32534. get isStencilEnable(): boolean;
  32535. /** @hidden */
  32536. _prepareWorkingCanvas(): void;
  32537. /**
  32538. * Reset the texture cache to empty state
  32539. */
  32540. resetTextureCache(): void;
  32541. /**
  32542. * Gets an object containing information about the current webGL context
  32543. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32544. */
  32545. getGlInfo(): {
  32546. vendor: string;
  32547. renderer: string;
  32548. version: string;
  32549. };
  32550. /**
  32551. * Defines the hardware scaling level.
  32552. * By default the hardware scaling level is computed from the window device ratio.
  32553. * 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.
  32554. * @param level defines the level to use
  32555. */
  32556. setHardwareScalingLevel(level: number): void;
  32557. /**
  32558. * Gets the current hardware scaling level.
  32559. * By default the hardware scaling level is computed from the window device ratio.
  32560. * 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.
  32561. * @returns a number indicating the current hardware scaling level
  32562. */
  32563. getHardwareScalingLevel(): number;
  32564. /**
  32565. * Gets the list of loaded textures
  32566. * @returns an array containing all loaded textures
  32567. */
  32568. getLoadedTexturesCache(): InternalTexture[];
  32569. /**
  32570. * Gets the object containing all engine capabilities
  32571. * @returns the EngineCapabilities object
  32572. */
  32573. getCaps(): EngineCapabilities;
  32574. /**
  32575. * stop executing a render loop function and remove it from the execution array
  32576. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32577. */
  32578. stopRenderLoop(renderFunction?: () => void): void;
  32579. /** @hidden */
  32580. _renderLoop(): void;
  32581. /**
  32582. * Gets the HTML canvas attached with the current webGL context
  32583. * @returns a HTML canvas
  32584. */
  32585. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32586. /**
  32587. * Gets host window
  32588. * @returns the host window object
  32589. */
  32590. getHostWindow(): Nullable<Window>;
  32591. /**
  32592. * Gets the current render width
  32593. * @param useScreen defines if screen size must be used (or the current render target if any)
  32594. * @returns a number defining the current render width
  32595. */
  32596. getRenderWidth(useScreen?: boolean): number;
  32597. /**
  32598. * Gets the current render height
  32599. * @param useScreen defines if screen size must be used (or the current render target if any)
  32600. * @returns a number defining the current render height
  32601. */
  32602. getRenderHeight(useScreen?: boolean): number;
  32603. /**
  32604. * Can be used to override the current requestAnimationFrame requester.
  32605. * @hidden
  32606. */
  32607. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32608. /**
  32609. * Register and execute a render loop. The engine can have more than one render function
  32610. * @param renderFunction defines the function to continuously execute
  32611. */
  32612. runRenderLoop(renderFunction: () => void): void;
  32613. /**
  32614. * Clear the current render buffer or the current render target (if any is set up)
  32615. * @param color defines the color to use
  32616. * @param backBuffer defines if the back buffer must be cleared
  32617. * @param depth defines if the depth buffer must be cleared
  32618. * @param stencil defines if the stencil buffer must be cleared
  32619. */
  32620. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32621. private _viewportCached;
  32622. /** @hidden */
  32623. _viewport(x: number, y: number, width: number, height: number): void;
  32624. /**
  32625. * Set the WebGL's viewport
  32626. * @param viewport defines the viewport element to be used
  32627. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32628. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32629. */
  32630. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32631. /**
  32632. * Begin a new frame
  32633. */
  32634. beginFrame(): void;
  32635. /**
  32636. * Enf the current frame
  32637. */
  32638. endFrame(): void;
  32639. /**
  32640. * Resize the view according to the canvas' size
  32641. */
  32642. resize(): void;
  32643. /**
  32644. * Force a specific size of the canvas
  32645. * @param width defines the new canvas' width
  32646. * @param height defines the new canvas' height
  32647. */
  32648. setSize(width: number, height: number): void;
  32649. /**
  32650. * Binds the frame buffer to the specified texture.
  32651. * @param texture The texture to render to or null for the default canvas
  32652. * @param faceIndex The face of the texture to render to in case of cube texture
  32653. * @param requiredWidth The width of the target to render to
  32654. * @param requiredHeight The height of the target to render to
  32655. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32656. * @param lodLevel defines the lod level to bind to the frame buffer
  32657. * @param layer defines the 2d array index to bind to frame buffer to
  32658. */
  32659. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32660. /** @hidden */
  32661. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32662. /**
  32663. * Unbind the current render target texture from the webGL context
  32664. * @param texture defines the render target texture to unbind
  32665. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32666. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32667. */
  32668. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32669. /**
  32670. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32671. */
  32672. flushFramebuffer(): void;
  32673. /**
  32674. * Unbind the current render target and bind the default framebuffer
  32675. */
  32676. restoreDefaultFramebuffer(): void;
  32677. /** @hidden */
  32678. protected _resetVertexBufferBinding(): void;
  32679. /**
  32680. * Creates a vertex buffer
  32681. * @param data the data for the vertex buffer
  32682. * @returns the new WebGL static buffer
  32683. */
  32684. createVertexBuffer(data: DataArray): DataBuffer;
  32685. private _createVertexBuffer;
  32686. /**
  32687. * Creates a dynamic vertex buffer
  32688. * @param data the data for the dynamic vertex buffer
  32689. * @returns the new WebGL dynamic buffer
  32690. */
  32691. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32692. protected _resetIndexBufferBinding(): void;
  32693. /**
  32694. * Creates a new index buffer
  32695. * @param indices defines the content of the index buffer
  32696. * @param updatable defines if the index buffer must be updatable
  32697. * @returns a new webGL buffer
  32698. */
  32699. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32700. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32701. /**
  32702. * Bind a webGL buffer to the webGL context
  32703. * @param buffer defines the buffer to bind
  32704. */
  32705. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32706. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32707. private bindBuffer;
  32708. /**
  32709. * update the bound buffer with the given data
  32710. * @param data defines the data to update
  32711. */
  32712. updateArrayBuffer(data: Float32Array): void;
  32713. private _vertexAttribPointer;
  32714. /** @hidden */
  32715. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32716. private _bindVertexBuffersAttributes;
  32717. /**
  32718. * Records a vertex array object
  32719. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32720. * @param vertexBuffers defines the list of vertex buffers to store
  32721. * @param indexBuffer defines the index buffer to store
  32722. * @param effect defines the effect to store
  32723. * @returns the new vertex array object
  32724. */
  32725. recordVertexArrayObject(vertexBuffers: {
  32726. [key: string]: VertexBuffer;
  32727. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32728. /**
  32729. * Bind a specific vertex array object
  32730. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32731. * @param vertexArrayObject defines the vertex array object to bind
  32732. * @param indexBuffer defines the index buffer to bind
  32733. */
  32734. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32735. /**
  32736. * Bind webGl buffers directly to the webGL context
  32737. * @param vertexBuffer defines the vertex buffer to bind
  32738. * @param indexBuffer defines the index buffer to bind
  32739. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32740. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32741. * @param effect defines the effect associated with the vertex buffer
  32742. */
  32743. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32744. private _unbindVertexArrayObject;
  32745. /**
  32746. * Bind a list of vertex buffers to the webGL context
  32747. * @param vertexBuffers defines the list of vertex buffers to bind
  32748. * @param indexBuffer defines the index buffer to bind
  32749. * @param effect defines the effect associated with the vertex buffers
  32750. */
  32751. bindBuffers(vertexBuffers: {
  32752. [key: string]: Nullable<VertexBuffer>;
  32753. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32754. /**
  32755. * Unbind all instance attributes
  32756. */
  32757. unbindInstanceAttributes(): void;
  32758. /**
  32759. * Release and free the memory of a vertex array object
  32760. * @param vao defines the vertex array object to delete
  32761. */
  32762. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32763. /** @hidden */
  32764. _releaseBuffer(buffer: DataBuffer): boolean;
  32765. protected _deleteBuffer(buffer: DataBuffer): void;
  32766. /**
  32767. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32768. * @param instancesBuffer defines the webGL buffer to update and bind
  32769. * @param data defines the data to store in the buffer
  32770. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32771. */
  32772. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32773. /**
  32774. * Bind the content of a webGL buffer used with instantiation
  32775. * @param instancesBuffer defines the webGL buffer to bind
  32776. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32777. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32778. */
  32779. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32780. /**
  32781. * Disable the instance attribute corresponding to the name in parameter
  32782. * @param name defines the name of the attribute to disable
  32783. */
  32784. disableInstanceAttributeByName(name: string): void;
  32785. /**
  32786. * Disable the instance attribute corresponding to the location in parameter
  32787. * @param attributeLocation defines the attribute location of the attribute to disable
  32788. */
  32789. disableInstanceAttribute(attributeLocation: number): void;
  32790. /**
  32791. * Disable the attribute corresponding to the location in parameter
  32792. * @param attributeLocation defines the attribute location of the attribute to disable
  32793. */
  32794. disableAttributeByIndex(attributeLocation: number): void;
  32795. /**
  32796. * Send a draw order
  32797. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32798. * @param indexStart defines the starting index
  32799. * @param indexCount defines the number of index to draw
  32800. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32801. */
  32802. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32803. /**
  32804. * Draw a list of points
  32805. * @param verticesStart defines the index of first vertex to draw
  32806. * @param verticesCount defines the count of vertices to draw
  32807. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32808. */
  32809. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32810. /**
  32811. * Draw a list of unindexed primitives
  32812. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32813. * @param verticesStart defines the index of first vertex to draw
  32814. * @param verticesCount defines the count of vertices to draw
  32815. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32816. */
  32817. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32818. /**
  32819. * Draw a list of indexed primitives
  32820. * @param fillMode defines the primitive to use
  32821. * @param indexStart defines the starting index
  32822. * @param indexCount defines the number of index to draw
  32823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32824. */
  32825. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32826. /**
  32827. * Draw a list of unindexed primitives
  32828. * @param fillMode defines the primitive to use
  32829. * @param verticesStart defines the index of first vertex to draw
  32830. * @param verticesCount defines the count of vertices to draw
  32831. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32832. */
  32833. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32834. private _drawMode;
  32835. /** @hidden */
  32836. protected _reportDrawCall(): void;
  32837. /** @hidden */
  32838. _releaseEffect(effect: Effect): void;
  32839. /** @hidden */
  32840. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32841. /**
  32842. * Create a new effect (used to store vertex/fragment shaders)
  32843. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32844. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32845. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32846. * @param samplers defines an array of string used to represent textures
  32847. * @param defines defines the string containing the defines to use to compile the shaders
  32848. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32849. * @param onCompiled defines a function to call when the effect creation is successful
  32850. * @param onError defines a function to call when the effect creation has failed
  32851. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32852. * @returns the new Effect
  32853. */
  32854. 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;
  32855. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32856. private _compileShader;
  32857. private _compileRawShader;
  32858. /** @hidden */
  32859. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32860. /**
  32861. * Directly creates a webGL program
  32862. * @param pipelineContext defines the pipeline context to attach to
  32863. * @param vertexCode defines the vertex shader code to use
  32864. * @param fragmentCode defines the fragment shader code to use
  32865. * @param context defines the webGL context to use (if not set, the current one will be used)
  32866. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32867. * @returns the new webGL program
  32868. */
  32869. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32870. /**
  32871. * Creates a webGL program
  32872. * @param pipelineContext defines the pipeline context to attach to
  32873. * @param vertexCode defines the vertex shader code to use
  32874. * @param fragmentCode defines the fragment shader code to use
  32875. * @param defines defines the string containing the defines to use to compile the shaders
  32876. * @param context defines the webGL context to use (if not set, the current one will be used)
  32877. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32878. * @returns the new webGL program
  32879. */
  32880. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32881. /**
  32882. * Creates a new pipeline context
  32883. * @returns the new pipeline
  32884. */
  32885. createPipelineContext(): IPipelineContext;
  32886. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32887. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32888. /** @hidden */
  32889. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32890. /** @hidden */
  32891. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32892. /** @hidden */
  32893. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32894. /**
  32895. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32896. * @param pipelineContext defines the pipeline context to use
  32897. * @param uniformsNames defines the list of uniform names
  32898. * @returns an array of webGL uniform locations
  32899. */
  32900. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32901. /**
  32902. * Gets the lsit of active attributes for a given webGL program
  32903. * @param pipelineContext defines the pipeline context to use
  32904. * @param attributesNames defines the list of attribute names to get
  32905. * @returns an array of indices indicating the offset of each attribute
  32906. */
  32907. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32908. /**
  32909. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32910. * @param effect defines the effect to activate
  32911. */
  32912. enableEffect(effect: Nullable<Effect>): void;
  32913. /**
  32914. * Set the value of an uniform to a number (int)
  32915. * @param uniform defines the webGL uniform location where to store the value
  32916. * @param value defines the int number to store
  32917. */
  32918. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32919. /**
  32920. * Set the value of an uniform to an array of int32
  32921. * @param uniform defines the webGL uniform location where to store the value
  32922. * @param array defines the array of int32 to store
  32923. */
  32924. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32925. /**
  32926. * Set the value of an uniform to an array of int32 (stored as vec2)
  32927. * @param uniform defines the webGL uniform location where to store the value
  32928. * @param array defines the array of int32 to store
  32929. */
  32930. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32931. /**
  32932. * Set the value of an uniform to an array of int32 (stored as vec3)
  32933. * @param uniform defines the webGL uniform location where to store the value
  32934. * @param array defines the array of int32 to store
  32935. */
  32936. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32937. /**
  32938. * Set the value of an uniform to an array of int32 (stored as vec4)
  32939. * @param uniform defines the webGL uniform location where to store the value
  32940. * @param array defines the array of int32 to store
  32941. */
  32942. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32943. /**
  32944. * Set the value of an uniform to an array of number
  32945. * @param uniform defines the webGL uniform location where to store the value
  32946. * @param array defines the array of number to store
  32947. */
  32948. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32949. /**
  32950. * Set the value of an uniform to an array of number (stored as vec2)
  32951. * @param uniform defines the webGL uniform location where to store the value
  32952. * @param array defines the array of number to store
  32953. */
  32954. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32955. /**
  32956. * Set the value of an uniform to an array of number (stored as vec3)
  32957. * @param uniform defines the webGL uniform location where to store the value
  32958. * @param array defines the array of number to store
  32959. */
  32960. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32961. /**
  32962. * Set the value of an uniform to an array of number (stored as vec4)
  32963. * @param uniform defines the webGL uniform location where to store the value
  32964. * @param array defines the array of number to store
  32965. */
  32966. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32967. /**
  32968. * Set the value of an uniform to an array of float32 (stored as matrices)
  32969. * @param uniform defines the webGL uniform location where to store the value
  32970. * @param matrices defines the array of float32 to store
  32971. */
  32972. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32973. /**
  32974. * Set the value of an uniform to a matrix (3x3)
  32975. * @param uniform defines the webGL uniform location where to store the value
  32976. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32977. */
  32978. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32979. /**
  32980. * Set the value of an uniform to a matrix (2x2)
  32981. * @param uniform defines the webGL uniform location where to store the value
  32982. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32983. */
  32984. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32985. /**
  32986. * Set the value of an uniform to a number (float)
  32987. * @param uniform defines the webGL uniform location where to store the value
  32988. * @param value defines the float number to store
  32989. */
  32990. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32991. /**
  32992. * Set the value of an uniform to a vec2
  32993. * @param uniform defines the webGL uniform location where to store the value
  32994. * @param x defines the 1st component of the value
  32995. * @param y defines the 2nd component of the value
  32996. */
  32997. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32998. /**
  32999. * Set the value of an uniform to a vec3
  33000. * @param uniform defines the webGL uniform location where to store the value
  33001. * @param x defines the 1st component of the value
  33002. * @param y defines the 2nd component of the value
  33003. * @param z defines the 3rd component of the value
  33004. */
  33005. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33006. /**
  33007. * Set the value of an uniform to a vec4
  33008. * @param uniform defines the webGL uniform location where to store the value
  33009. * @param x defines the 1st component of the value
  33010. * @param y defines the 2nd component of the value
  33011. * @param z defines the 3rd component of the value
  33012. * @param w defines the 4th component of the value
  33013. */
  33014. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33015. /**
  33016. * Apply all cached states (depth, culling, stencil and alpha)
  33017. */
  33018. applyStates(): void;
  33019. /**
  33020. * Enable or disable color writing
  33021. * @param enable defines the state to set
  33022. */
  33023. setColorWrite(enable: boolean): void;
  33024. /**
  33025. * Gets a boolean indicating if color writing is enabled
  33026. * @returns the current color writing state
  33027. */
  33028. getColorWrite(): boolean;
  33029. /**
  33030. * Gets the depth culling state manager
  33031. */
  33032. get depthCullingState(): DepthCullingState;
  33033. /**
  33034. * Gets the alpha state manager
  33035. */
  33036. get alphaState(): AlphaState;
  33037. /**
  33038. * Gets the stencil state manager
  33039. */
  33040. get stencilState(): StencilState;
  33041. /**
  33042. * Clears the list of texture accessible through engine.
  33043. * This can help preventing texture load conflict due to name collision.
  33044. */
  33045. clearInternalTexturesCache(): void;
  33046. /**
  33047. * Force the entire cache to be cleared
  33048. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33049. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33050. */
  33051. wipeCaches(bruteForce?: boolean): void;
  33052. /** @hidden */
  33053. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33054. min: number;
  33055. mag: number;
  33056. };
  33057. /** @hidden */
  33058. _createTexture(): WebGLTexture;
  33059. /**
  33060. * Usually called from Texture.ts.
  33061. * Passed information to create a WebGLTexture
  33062. * @param url defines a value which contains one of the following:
  33063. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33064. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33065. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33066. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33067. * @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)
  33068. * @param scene needed for loading to the correct scene
  33069. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33070. * @param onLoad optional callback to be called upon successful completion
  33071. * @param onError optional callback to be called upon failure
  33072. * @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
  33073. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33074. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33075. * @param forcedExtension defines the extension to use to pick the right loader
  33076. * @param mimeType defines an optional mime type
  33077. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33078. */
  33079. 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;
  33080. /**
  33081. * Loads an image as an HTMLImageElement.
  33082. * @param input url string, ArrayBuffer, or Blob to load
  33083. * @param onLoad callback called when the image successfully loads
  33084. * @param onError callback called when the image fails to load
  33085. * @param offlineProvider offline provider for caching
  33086. * @param mimeType optional mime type
  33087. * @returns the HTMLImageElement of the loaded image
  33088. * @hidden
  33089. */
  33090. 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>;
  33091. /**
  33092. * @hidden
  33093. */
  33094. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33095. /**
  33096. * Creates a raw texture
  33097. * @param data defines the data to store in the texture
  33098. * @param width defines the width of the texture
  33099. * @param height defines the height of the texture
  33100. * @param format defines the format of the data
  33101. * @param generateMipMaps defines if the engine should generate the mip levels
  33102. * @param invertY defines if data must be stored with Y axis inverted
  33103. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  33104. * @param compression defines the compression used (null by default)
  33105. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  33106. * @returns the raw texture inside an InternalTexture
  33107. */
  33108. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  33109. /**
  33110. * Creates a new raw cube texture
  33111. * @param data defines the array of data to use to create each face
  33112. * @param size defines the size of the textures
  33113. * @param format defines the format of the data
  33114. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33115. * @param generateMipMaps defines if the engine should generate the mip levels
  33116. * @param invertY defines if data must be stored with Y axis inverted
  33117. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33118. * @param compression defines the compression used (null by default)
  33119. * @returns the cube texture as an InternalTexture
  33120. */
  33121. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  33122. /**
  33123. * Creates a new raw 3D texture
  33124. * @param data defines the data used to create the texture
  33125. * @param width defines the width of the texture
  33126. * @param height defines the height of the texture
  33127. * @param depth defines the depth of the texture
  33128. * @param format defines the format of the texture
  33129. * @param generateMipMaps defines if the engine must generate mip levels
  33130. * @param invertY defines if data must be stored with Y axis inverted
  33131. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33132. * @param compression defines the compressed used (can be null)
  33133. * @param textureType defines the compressed used (can be null)
  33134. * @returns a new raw 3D texture (stored in an InternalTexture)
  33135. */
  33136. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33137. /**
  33138. * Creates a new raw 2D array texture
  33139. * @param data defines the data used to create the texture
  33140. * @param width defines the width of the texture
  33141. * @param height defines the height of the texture
  33142. * @param depth defines the number of layers of the texture
  33143. * @param format defines the format of the texture
  33144. * @param generateMipMaps defines if the engine must generate mip levels
  33145. * @param invertY defines if data must be stored with Y axis inverted
  33146. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33147. * @param compression defines the compressed used (can be null)
  33148. * @param textureType defines the compressed used (can be null)
  33149. * @returns a new raw 2D array texture (stored in an InternalTexture)
  33150. */
  33151. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33152. private _unpackFlipYCached;
  33153. /**
  33154. * In case you are sharing the context with other applications, it might
  33155. * be interested to not cache the unpack flip y state to ensure a consistent
  33156. * value would be set.
  33157. */
  33158. enableUnpackFlipYCached: boolean;
  33159. /** @hidden */
  33160. _unpackFlipY(value: boolean): void;
  33161. /** @hidden */
  33162. _getUnpackAlignement(): number;
  33163. private _getTextureTarget;
  33164. /**
  33165. * Update the sampling mode of a given texture
  33166. * @param samplingMode defines the required sampling mode
  33167. * @param texture defines the texture to update
  33168. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33169. */
  33170. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33171. /**
  33172. * Update the sampling mode of a given texture
  33173. * @param texture defines the texture to update
  33174. * @param wrapU defines the texture wrap mode of the u coordinates
  33175. * @param wrapV defines the texture wrap mode of the v coordinates
  33176. * @param wrapR defines the texture wrap mode of the r coordinates
  33177. */
  33178. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33179. /** @hidden */
  33180. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33181. width: number;
  33182. height: number;
  33183. layers?: number;
  33184. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33185. /** @hidden */
  33186. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33187. /** @hidden */
  33188. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33189. /**
  33190. * Update a portion of an internal texture
  33191. * @param texture defines the texture to update
  33192. * @param imageData defines the data to store into the texture
  33193. * @param xOffset defines the x coordinates of the update rectangle
  33194. * @param yOffset defines the y coordinates of the update rectangle
  33195. * @param width defines the width of the update rectangle
  33196. * @param height defines the height of the update rectangle
  33197. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33198. * @param lod defines the lod level to update (0 by default)
  33199. */
  33200. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33201. /** @hidden */
  33202. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33203. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33204. private _prepareWebGLTexture;
  33205. /** @hidden */
  33206. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33207. private _getDepthStencilBuffer;
  33208. /** @hidden */
  33209. _releaseFramebufferObjects(texture: InternalTexture): void;
  33210. /** @hidden */
  33211. _releaseTexture(texture: InternalTexture): void;
  33212. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33213. protected _setProgram(program: WebGLProgram): void;
  33214. protected _boundUniforms: {
  33215. [key: number]: WebGLUniformLocation;
  33216. };
  33217. /**
  33218. * Binds an effect to the webGL context
  33219. * @param effect defines the effect to bind
  33220. */
  33221. bindSamplers(effect: Effect): void;
  33222. private _activateCurrentTexture;
  33223. /** @hidden */
  33224. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33225. /** @hidden */
  33226. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33227. /**
  33228. * Unbind all textures from the webGL context
  33229. */
  33230. unbindAllTextures(): void;
  33231. /**
  33232. * Sets a texture to the according uniform.
  33233. * @param channel The texture channel
  33234. * @param uniform The uniform to set
  33235. * @param texture The texture to apply
  33236. */
  33237. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33238. private _bindSamplerUniformToChannel;
  33239. private _getTextureWrapMode;
  33240. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33241. /**
  33242. * Sets an array of texture to the webGL context
  33243. * @param channel defines the channel where the texture array must be set
  33244. * @param uniform defines the associated uniform location
  33245. * @param textures defines the array of textures to bind
  33246. */
  33247. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33248. /** @hidden */
  33249. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33250. private _setTextureParameterFloat;
  33251. private _setTextureParameterInteger;
  33252. /**
  33253. * Unbind all vertex attributes from the webGL context
  33254. */
  33255. unbindAllAttributes(): void;
  33256. /**
  33257. * 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
  33258. */
  33259. releaseEffects(): void;
  33260. /**
  33261. * Dispose and release all associated resources
  33262. */
  33263. dispose(): void;
  33264. /**
  33265. * Attach a new callback raised when context lost event is fired
  33266. * @param callback defines the callback to call
  33267. */
  33268. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33269. /**
  33270. * Attach a new callback raised when context restored event is fired
  33271. * @param callback defines the callback to call
  33272. */
  33273. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33274. /**
  33275. * Get the current error code of the webGL context
  33276. * @returns the error code
  33277. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33278. */
  33279. getError(): number;
  33280. private _canRenderToFloatFramebuffer;
  33281. private _canRenderToHalfFloatFramebuffer;
  33282. private _canRenderToFramebuffer;
  33283. /** @hidden */
  33284. _getWebGLTextureType(type: number): number;
  33285. /** @hidden */
  33286. _getInternalFormat(format: number): number;
  33287. /** @hidden */
  33288. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33289. /** @hidden */
  33290. _getRGBAMultiSampleBufferFormat(type: number): number;
  33291. /** @hidden */
  33292. _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;
  33293. /**
  33294. * Loads a file from a url
  33295. * @param url url to load
  33296. * @param onSuccess callback called when the file successfully loads
  33297. * @param onProgress callback called while file is loading (if the server supports this mode)
  33298. * @param offlineProvider defines the offline provider for caching
  33299. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33300. * @param onError callback called when the file fails to load
  33301. * @returns a file request object
  33302. * @hidden
  33303. */
  33304. 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;
  33305. /**
  33306. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33307. * @param x defines the x coordinate of the rectangle where pixels must be read
  33308. * @param y defines the y coordinate of the rectangle where pixels must be read
  33309. * @param width defines the width of the rectangle where pixels must be read
  33310. * @param height defines the height of the rectangle where pixels must be read
  33311. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33312. * @returns a Uint8Array containing RGBA colors
  33313. */
  33314. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33315. private static _isSupported;
  33316. /**
  33317. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33318. * @returns true if the engine can be created
  33319. * @ignorenaming
  33320. */
  33321. static isSupported(): boolean;
  33322. /**
  33323. * Find the next highest power of two.
  33324. * @param x Number to start search from.
  33325. * @return Next highest power of two.
  33326. */
  33327. static CeilingPOT(x: number): number;
  33328. /**
  33329. * Find the next lowest power of two.
  33330. * @param x Number to start search from.
  33331. * @return Next lowest power of two.
  33332. */
  33333. static FloorPOT(x: number): number;
  33334. /**
  33335. * Find the nearest power of two.
  33336. * @param x Number to start search from.
  33337. * @return Next nearest power of two.
  33338. */
  33339. static NearestPOT(x: number): number;
  33340. /**
  33341. * Get the closest exponent of two
  33342. * @param value defines the value to approximate
  33343. * @param max defines the maximum value to return
  33344. * @param mode defines how to define the closest value
  33345. * @returns closest exponent of two of the given value
  33346. */
  33347. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33348. /**
  33349. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33350. * @param func - the function to be called
  33351. * @param requester - the object that will request the next frame. Falls back to window.
  33352. * @returns frame number
  33353. */
  33354. static QueueNewFrame(func: () => void, requester?: any): number;
  33355. /**
  33356. * Gets host document
  33357. * @returns the host document object
  33358. */
  33359. getHostDocument(): Nullable<Document>;
  33360. }
  33361. }
  33362. declare module "babylonjs/Maths/sphericalPolynomial" {
  33363. import { Vector3 } from "babylonjs/Maths/math.vector";
  33364. import { Color3 } from "babylonjs/Maths/math.color";
  33365. /**
  33366. * Class representing spherical harmonics coefficients to the 3rd degree
  33367. */
  33368. export class SphericalHarmonics {
  33369. /**
  33370. * Defines whether or not the harmonics have been prescaled for rendering.
  33371. */
  33372. preScaled: boolean;
  33373. /**
  33374. * The l0,0 coefficients of the spherical harmonics
  33375. */
  33376. l00: Vector3;
  33377. /**
  33378. * The l1,-1 coefficients of the spherical harmonics
  33379. */
  33380. l1_1: Vector3;
  33381. /**
  33382. * The l1,0 coefficients of the spherical harmonics
  33383. */
  33384. l10: Vector3;
  33385. /**
  33386. * The l1,1 coefficients of the spherical harmonics
  33387. */
  33388. l11: Vector3;
  33389. /**
  33390. * The l2,-2 coefficients of the spherical harmonics
  33391. */
  33392. l2_2: Vector3;
  33393. /**
  33394. * The l2,-1 coefficients of the spherical harmonics
  33395. */
  33396. l2_1: Vector3;
  33397. /**
  33398. * The l2,0 coefficients of the spherical harmonics
  33399. */
  33400. l20: Vector3;
  33401. /**
  33402. * The l2,1 coefficients of the spherical harmonics
  33403. */
  33404. l21: Vector3;
  33405. /**
  33406. * The l2,2 coefficients of the spherical harmonics
  33407. */
  33408. l22: Vector3;
  33409. /**
  33410. * Adds a light to the spherical harmonics
  33411. * @param direction the direction of the light
  33412. * @param color the color of the light
  33413. * @param deltaSolidAngle the delta solid angle of the light
  33414. */
  33415. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33416. /**
  33417. * Scales the spherical harmonics by the given amount
  33418. * @param scale the amount to scale
  33419. */
  33420. scaleInPlace(scale: number): void;
  33421. /**
  33422. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33423. *
  33424. * ```
  33425. * E_lm = A_l * L_lm
  33426. * ```
  33427. *
  33428. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33429. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33430. * the scaling factors are given in equation 9.
  33431. */
  33432. convertIncidentRadianceToIrradiance(): void;
  33433. /**
  33434. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33435. *
  33436. * ```
  33437. * L = (1/pi) * E * rho
  33438. * ```
  33439. *
  33440. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33441. */
  33442. convertIrradianceToLambertianRadiance(): void;
  33443. /**
  33444. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33445. * required operations at run time.
  33446. *
  33447. * This is simply done by scaling back the SH with Ylm constants parameter.
  33448. * The trigonometric part being applied by the shader at run time.
  33449. */
  33450. preScaleForRendering(): void;
  33451. /**
  33452. * Constructs a spherical harmonics from an array.
  33453. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33454. * @returns the spherical harmonics
  33455. */
  33456. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33457. /**
  33458. * Gets the spherical harmonics from polynomial
  33459. * @param polynomial the spherical polynomial
  33460. * @returns the spherical harmonics
  33461. */
  33462. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33463. }
  33464. /**
  33465. * Class representing spherical polynomial coefficients to the 3rd degree
  33466. */
  33467. export class SphericalPolynomial {
  33468. private _harmonics;
  33469. /**
  33470. * The spherical harmonics used to create the polynomials.
  33471. */
  33472. get preScaledHarmonics(): SphericalHarmonics;
  33473. /**
  33474. * The x coefficients of the spherical polynomial
  33475. */
  33476. x: Vector3;
  33477. /**
  33478. * The y coefficients of the spherical polynomial
  33479. */
  33480. y: Vector3;
  33481. /**
  33482. * The z coefficients of the spherical polynomial
  33483. */
  33484. z: Vector3;
  33485. /**
  33486. * The xx coefficients of the spherical polynomial
  33487. */
  33488. xx: Vector3;
  33489. /**
  33490. * The yy coefficients of the spherical polynomial
  33491. */
  33492. yy: Vector3;
  33493. /**
  33494. * The zz coefficients of the spherical polynomial
  33495. */
  33496. zz: Vector3;
  33497. /**
  33498. * The xy coefficients of the spherical polynomial
  33499. */
  33500. xy: Vector3;
  33501. /**
  33502. * The yz coefficients of the spherical polynomial
  33503. */
  33504. yz: Vector3;
  33505. /**
  33506. * The zx coefficients of the spherical polynomial
  33507. */
  33508. zx: Vector3;
  33509. /**
  33510. * Adds an ambient color to the spherical polynomial
  33511. * @param color the color to add
  33512. */
  33513. addAmbient(color: Color3): void;
  33514. /**
  33515. * Scales the spherical polynomial by the given amount
  33516. * @param scale the amount to scale
  33517. */
  33518. scaleInPlace(scale: number): void;
  33519. /**
  33520. * Gets the spherical polynomial from harmonics
  33521. * @param harmonics the spherical harmonics
  33522. * @returns the spherical polynomial
  33523. */
  33524. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33525. /**
  33526. * Constructs a spherical polynomial from an array.
  33527. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33528. * @returns the spherical polynomial
  33529. */
  33530. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33531. }
  33532. }
  33533. declare module "babylonjs/Materials/Textures/internalTexture" {
  33534. import { Observable } from "babylonjs/Misc/observable";
  33535. import { Nullable, int } from "babylonjs/types";
  33536. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33537. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33538. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33539. /**
  33540. * Defines the source of the internal texture
  33541. */
  33542. export enum InternalTextureSource {
  33543. /**
  33544. * The source of the texture data is unknown
  33545. */
  33546. Unknown = 0,
  33547. /**
  33548. * Texture data comes from an URL
  33549. */
  33550. Url = 1,
  33551. /**
  33552. * Texture data is only used for temporary storage
  33553. */
  33554. Temp = 2,
  33555. /**
  33556. * Texture data comes from raw data (ArrayBuffer)
  33557. */
  33558. Raw = 3,
  33559. /**
  33560. * Texture content is dynamic (video or dynamic texture)
  33561. */
  33562. Dynamic = 4,
  33563. /**
  33564. * Texture content is generated by rendering to it
  33565. */
  33566. RenderTarget = 5,
  33567. /**
  33568. * Texture content is part of a multi render target process
  33569. */
  33570. MultiRenderTarget = 6,
  33571. /**
  33572. * Texture data comes from a cube data file
  33573. */
  33574. Cube = 7,
  33575. /**
  33576. * Texture data comes from a raw cube data
  33577. */
  33578. CubeRaw = 8,
  33579. /**
  33580. * Texture data come from a prefiltered cube data file
  33581. */
  33582. CubePrefiltered = 9,
  33583. /**
  33584. * Texture content is raw 3D data
  33585. */
  33586. Raw3D = 10,
  33587. /**
  33588. * Texture content is raw 2D array data
  33589. */
  33590. Raw2DArray = 11,
  33591. /**
  33592. * Texture content is a depth texture
  33593. */
  33594. Depth = 12,
  33595. /**
  33596. * Texture data comes from a raw cube data encoded with RGBD
  33597. */
  33598. CubeRawRGBD = 13
  33599. }
  33600. /**
  33601. * Class used to store data associated with WebGL texture data for the engine
  33602. * This class should not be used directly
  33603. */
  33604. export class InternalTexture {
  33605. /** @hidden */
  33606. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33607. /**
  33608. * Defines if the texture is ready
  33609. */
  33610. isReady: boolean;
  33611. /**
  33612. * Defines if the texture is a cube texture
  33613. */
  33614. isCube: boolean;
  33615. /**
  33616. * Defines if the texture contains 3D data
  33617. */
  33618. is3D: boolean;
  33619. /**
  33620. * Defines if the texture contains 2D array data
  33621. */
  33622. is2DArray: boolean;
  33623. /**
  33624. * Defines if the texture contains multiview data
  33625. */
  33626. isMultiview: boolean;
  33627. /**
  33628. * Gets the URL used to load this texture
  33629. */
  33630. url: string;
  33631. /**
  33632. * Gets the sampling mode of the texture
  33633. */
  33634. samplingMode: number;
  33635. /**
  33636. * Gets a boolean indicating if the texture needs mipmaps generation
  33637. */
  33638. generateMipMaps: boolean;
  33639. /**
  33640. * Gets the number of samples used by the texture (WebGL2+ only)
  33641. */
  33642. samples: number;
  33643. /**
  33644. * Gets the type of the texture (int, float...)
  33645. */
  33646. type: number;
  33647. /**
  33648. * Gets the format of the texture (RGB, RGBA...)
  33649. */
  33650. format: number;
  33651. /**
  33652. * Observable called when the texture is loaded
  33653. */
  33654. onLoadedObservable: Observable<InternalTexture>;
  33655. /**
  33656. * Gets the width of the texture
  33657. */
  33658. width: number;
  33659. /**
  33660. * Gets the height of the texture
  33661. */
  33662. height: number;
  33663. /**
  33664. * Gets the depth of the texture
  33665. */
  33666. depth: number;
  33667. /**
  33668. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33669. */
  33670. baseWidth: number;
  33671. /**
  33672. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33673. */
  33674. baseHeight: number;
  33675. /**
  33676. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33677. */
  33678. baseDepth: number;
  33679. /**
  33680. * Gets a boolean indicating if the texture is inverted on Y axis
  33681. */
  33682. invertY: boolean;
  33683. /** @hidden */
  33684. _invertVScale: boolean;
  33685. /** @hidden */
  33686. _associatedChannel: number;
  33687. /** @hidden */
  33688. _source: InternalTextureSource;
  33689. /** @hidden */
  33690. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33691. /** @hidden */
  33692. _bufferView: Nullable<ArrayBufferView>;
  33693. /** @hidden */
  33694. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33695. /** @hidden */
  33696. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33697. /** @hidden */
  33698. _size: number;
  33699. /** @hidden */
  33700. _extension: string;
  33701. /** @hidden */
  33702. _files: Nullable<string[]>;
  33703. /** @hidden */
  33704. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33705. /** @hidden */
  33706. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33707. /** @hidden */
  33708. _framebuffer: Nullable<WebGLFramebuffer>;
  33709. /** @hidden */
  33710. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33711. /** @hidden */
  33712. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33713. /** @hidden */
  33714. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33715. /** @hidden */
  33716. _attachments: Nullable<number[]>;
  33717. /** @hidden */
  33718. _cachedCoordinatesMode: Nullable<number>;
  33719. /** @hidden */
  33720. _cachedWrapU: Nullable<number>;
  33721. /** @hidden */
  33722. _cachedWrapV: Nullable<number>;
  33723. /** @hidden */
  33724. _cachedWrapR: Nullable<number>;
  33725. /** @hidden */
  33726. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33727. /** @hidden */
  33728. _isDisabled: boolean;
  33729. /** @hidden */
  33730. _compression: Nullable<string>;
  33731. /** @hidden */
  33732. _generateStencilBuffer: boolean;
  33733. /** @hidden */
  33734. _generateDepthBuffer: boolean;
  33735. /** @hidden */
  33736. _comparisonFunction: number;
  33737. /** @hidden */
  33738. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33739. /** @hidden */
  33740. _lodGenerationScale: number;
  33741. /** @hidden */
  33742. _lodGenerationOffset: number;
  33743. /** @hidden */
  33744. _depthStencilTexture: Nullable<InternalTexture>;
  33745. /** @hidden */
  33746. _colorTextureArray: Nullable<WebGLTexture>;
  33747. /** @hidden */
  33748. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33749. /** @hidden */
  33750. _lodTextureHigh: Nullable<BaseTexture>;
  33751. /** @hidden */
  33752. _lodTextureMid: Nullable<BaseTexture>;
  33753. /** @hidden */
  33754. _lodTextureLow: Nullable<BaseTexture>;
  33755. /** @hidden */
  33756. _isRGBD: boolean;
  33757. /** @hidden */
  33758. _linearSpecularLOD: boolean;
  33759. /** @hidden */
  33760. _irradianceTexture: Nullable<BaseTexture>;
  33761. /** @hidden */
  33762. _webGLTexture: Nullable<WebGLTexture>;
  33763. /** @hidden */
  33764. _references: number;
  33765. private _engine;
  33766. /**
  33767. * Gets the Engine the texture belongs to.
  33768. * @returns The babylon engine
  33769. */
  33770. getEngine(): ThinEngine;
  33771. /**
  33772. * Gets the data source type of the texture
  33773. */
  33774. get source(): InternalTextureSource;
  33775. /**
  33776. * Creates a new InternalTexture
  33777. * @param engine defines the engine to use
  33778. * @param source defines the type of data that will be used
  33779. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33780. */
  33781. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33782. /**
  33783. * Increments the number of references (ie. the number of Texture that point to it)
  33784. */
  33785. incrementReferences(): void;
  33786. /**
  33787. * Change the size of the texture (not the size of the content)
  33788. * @param width defines the new width
  33789. * @param height defines the new height
  33790. * @param depth defines the new depth (1 by default)
  33791. */
  33792. updateSize(width: int, height: int, depth?: int): void;
  33793. /** @hidden */
  33794. _rebuild(): void;
  33795. /** @hidden */
  33796. _swapAndDie(target: InternalTexture): void;
  33797. /**
  33798. * Dispose the current allocated resources
  33799. */
  33800. dispose(): void;
  33801. }
  33802. }
  33803. declare module "babylonjs/Audio/analyser" {
  33804. import { Scene } from "babylonjs/scene";
  33805. /**
  33806. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33808. */
  33809. export class Analyser {
  33810. /**
  33811. * Gets or sets the smoothing
  33812. * @ignorenaming
  33813. */
  33814. SMOOTHING: number;
  33815. /**
  33816. * Gets or sets the FFT table size
  33817. * @ignorenaming
  33818. */
  33819. FFT_SIZE: number;
  33820. /**
  33821. * Gets or sets the bar graph amplitude
  33822. * @ignorenaming
  33823. */
  33824. BARGRAPHAMPLITUDE: number;
  33825. /**
  33826. * Gets or sets the position of the debug canvas
  33827. * @ignorenaming
  33828. */
  33829. DEBUGCANVASPOS: {
  33830. x: number;
  33831. y: number;
  33832. };
  33833. /**
  33834. * Gets or sets the debug canvas size
  33835. * @ignorenaming
  33836. */
  33837. DEBUGCANVASSIZE: {
  33838. width: number;
  33839. height: number;
  33840. };
  33841. private _byteFreqs;
  33842. private _byteTime;
  33843. private _floatFreqs;
  33844. private _webAudioAnalyser;
  33845. private _debugCanvas;
  33846. private _debugCanvasContext;
  33847. private _scene;
  33848. private _registerFunc;
  33849. private _audioEngine;
  33850. /**
  33851. * Creates a new analyser
  33852. * @param scene defines hosting scene
  33853. */
  33854. constructor(scene: Scene);
  33855. /**
  33856. * Get the number of data values you will have to play with for the visualization
  33857. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33858. * @returns a number
  33859. */
  33860. getFrequencyBinCount(): number;
  33861. /**
  33862. * Gets the current frequency data as a byte array
  33863. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33864. * @returns a Uint8Array
  33865. */
  33866. getByteFrequencyData(): Uint8Array;
  33867. /**
  33868. * Gets the current waveform as a byte array
  33869. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33870. * @returns a Uint8Array
  33871. */
  33872. getByteTimeDomainData(): Uint8Array;
  33873. /**
  33874. * Gets the current frequency data as a float array
  33875. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33876. * @returns a Float32Array
  33877. */
  33878. getFloatFrequencyData(): Float32Array;
  33879. /**
  33880. * Renders the debug canvas
  33881. */
  33882. drawDebugCanvas(): void;
  33883. /**
  33884. * Stops rendering the debug canvas and removes it
  33885. */
  33886. stopDebugCanvas(): void;
  33887. /**
  33888. * Connects two audio nodes
  33889. * @param inputAudioNode defines first node to connect
  33890. * @param outputAudioNode defines second node to connect
  33891. */
  33892. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33893. /**
  33894. * Releases all associated resources
  33895. */
  33896. dispose(): void;
  33897. }
  33898. }
  33899. declare module "babylonjs/Audio/audioEngine" {
  33900. import { IDisposable } from "babylonjs/scene";
  33901. import { Analyser } from "babylonjs/Audio/analyser";
  33902. import { Nullable } from "babylonjs/types";
  33903. import { Observable } from "babylonjs/Misc/observable";
  33904. /**
  33905. * This represents an audio engine and it is responsible
  33906. * to play, synchronize and analyse sounds throughout the application.
  33907. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33908. */
  33909. export interface IAudioEngine extends IDisposable {
  33910. /**
  33911. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33912. */
  33913. readonly canUseWebAudio: boolean;
  33914. /**
  33915. * Gets the current AudioContext if available.
  33916. */
  33917. readonly audioContext: Nullable<AudioContext>;
  33918. /**
  33919. * The master gain node defines the global audio volume of your audio engine.
  33920. */
  33921. readonly masterGain: GainNode;
  33922. /**
  33923. * Gets whether or not mp3 are supported by your browser.
  33924. */
  33925. readonly isMP3supported: boolean;
  33926. /**
  33927. * Gets whether or not ogg are supported by your browser.
  33928. */
  33929. readonly isOGGsupported: boolean;
  33930. /**
  33931. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33932. * @ignoreNaming
  33933. */
  33934. WarnedWebAudioUnsupported: boolean;
  33935. /**
  33936. * Defines if the audio engine relies on a custom unlocked button.
  33937. * In this case, the embedded button will not be displayed.
  33938. */
  33939. useCustomUnlockedButton: boolean;
  33940. /**
  33941. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33942. */
  33943. readonly unlocked: boolean;
  33944. /**
  33945. * Event raised when audio has been unlocked on the browser.
  33946. */
  33947. onAudioUnlockedObservable: Observable<AudioEngine>;
  33948. /**
  33949. * Event raised when audio has been locked on the browser.
  33950. */
  33951. onAudioLockedObservable: Observable<AudioEngine>;
  33952. /**
  33953. * Flags the audio engine in Locked state.
  33954. * This happens due to new browser policies preventing audio to autoplay.
  33955. */
  33956. lock(): void;
  33957. /**
  33958. * Unlocks the audio engine once a user action has been done on the dom.
  33959. * This is helpful to resume play once browser policies have been satisfied.
  33960. */
  33961. unlock(): void;
  33962. /**
  33963. * Gets the global volume sets on the master gain.
  33964. * @returns the global volume if set or -1 otherwise
  33965. */
  33966. getGlobalVolume(): number;
  33967. /**
  33968. * Sets the global volume of your experience (sets on the master gain).
  33969. * @param newVolume Defines the new global volume of the application
  33970. */
  33971. setGlobalVolume(newVolume: number): void;
  33972. /**
  33973. * Connect the audio engine to an audio analyser allowing some amazing
  33974. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33976. * @param analyser The analyser to connect to the engine
  33977. */
  33978. connectToAnalyser(analyser: Analyser): void;
  33979. }
  33980. /**
  33981. * This represents the default audio engine used in babylon.
  33982. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33984. */
  33985. export class AudioEngine implements IAudioEngine {
  33986. private _audioContext;
  33987. private _audioContextInitialized;
  33988. private _muteButton;
  33989. private _hostElement;
  33990. /**
  33991. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33992. */
  33993. canUseWebAudio: boolean;
  33994. /**
  33995. * The master gain node defines the global audio volume of your audio engine.
  33996. */
  33997. masterGain: GainNode;
  33998. /**
  33999. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34000. * @ignoreNaming
  34001. */
  34002. WarnedWebAudioUnsupported: boolean;
  34003. /**
  34004. * Gets whether or not mp3 are supported by your browser.
  34005. */
  34006. isMP3supported: boolean;
  34007. /**
  34008. * Gets whether or not ogg are supported by your browser.
  34009. */
  34010. isOGGsupported: boolean;
  34011. /**
  34012. * Gets whether audio has been unlocked on the device.
  34013. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34014. * a user interaction has happened.
  34015. */
  34016. unlocked: boolean;
  34017. /**
  34018. * Defines if the audio engine relies on a custom unlocked button.
  34019. * In this case, the embedded button will not be displayed.
  34020. */
  34021. useCustomUnlockedButton: boolean;
  34022. /**
  34023. * Event raised when audio has been unlocked on the browser.
  34024. */
  34025. onAudioUnlockedObservable: Observable<AudioEngine>;
  34026. /**
  34027. * Event raised when audio has been locked on the browser.
  34028. */
  34029. onAudioLockedObservable: Observable<AudioEngine>;
  34030. /**
  34031. * Gets the current AudioContext if available.
  34032. */
  34033. get audioContext(): Nullable<AudioContext>;
  34034. private _connectedAnalyser;
  34035. /**
  34036. * Instantiates a new audio engine.
  34037. *
  34038. * There should be only one per page as some browsers restrict the number
  34039. * of audio contexts you can create.
  34040. * @param hostElement defines the host element where to display the mute icon if necessary
  34041. */
  34042. constructor(hostElement?: Nullable<HTMLElement>);
  34043. /**
  34044. * Flags the audio engine in Locked state.
  34045. * This happens due to new browser policies preventing audio to autoplay.
  34046. */
  34047. lock(): void;
  34048. /**
  34049. * Unlocks the audio engine once a user action has been done on the dom.
  34050. * This is helpful to resume play once browser policies have been satisfied.
  34051. */
  34052. unlock(): void;
  34053. private _resumeAudioContext;
  34054. private _initializeAudioContext;
  34055. private _tryToRun;
  34056. private _triggerRunningState;
  34057. private _triggerSuspendedState;
  34058. private _displayMuteButton;
  34059. private _moveButtonToTopLeft;
  34060. private _onResize;
  34061. private _hideMuteButton;
  34062. /**
  34063. * Destroy and release the resources associated with the audio ccontext.
  34064. */
  34065. dispose(): void;
  34066. /**
  34067. * Gets the global volume sets on the master gain.
  34068. * @returns the global volume if set or -1 otherwise
  34069. */
  34070. getGlobalVolume(): number;
  34071. /**
  34072. * Sets the global volume of your experience (sets on the master gain).
  34073. * @param newVolume Defines the new global volume of the application
  34074. */
  34075. setGlobalVolume(newVolume: number): void;
  34076. /**
  34077. * Connect the audio engine to an audio analyser allowing some amazing
  34078. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34079. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34080. * @param analyser The analyser to connect to the engine
  34081. */
  34082. connectToAnalyser(analyser: Analyser): void;
  34083. }
  34084. }
  34085. declare module "babylonjs/Loading/loadingScreen" {
  34086. /**
  34087. * Interface used to present a loading screen while loading a scene
  34088. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34089. */
  34090. export interface ILoadingScreen {
  34091. /**
  34092. * Function called to display the loading screen
  34093. */
  34094. displayLoadingUI: () => void;
  34095. /**
  34096. * Function called to hide the loading screen
  34097. */
  34098. hideLoadingUI: () => void;
  34099. /**
  34100. * Gets or sets the color to use for the background
  34101. */
  34102. loadingUIBackgroundColor: string;
  34103. /**
  34104. * Gets or sets the text to display while loading
  34105. */
  34106. loadingUIText: string;
  34107. }
  34108. /**
  34109. * Class used for the default loading screen
  34110. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34111. */
  34112. export class DefaultLoadingScreen implements ILoadingScreen {
  34113. private _renderingCanvas;
  34114. private _loadingText;
  34115. private _loadingDivBackgroundColor;
  34116. private _loadingDiv;
  34117. private _loadingTextDiv;
  34118. /** Gets or sets the logo url to use for the default loading screen */
  34119. static DefaultLogoUrl: string;
  34120. /** Gets or sets the spinner url to use for the default loading screen */
  34121. static DefaultSpinnerUrl: string;
  34122. /**
  34123. * Creates a new default loading screen
  34124. * @param _renderingCanvas defines the canvas used to render the scene
  34125. * @param _loadingText defines the default text to display
  34126. * @param _loadingDivBackgroundColor defines the default background color
  34127. */
  34128. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34129. /**
  34130. * Function called to display the loading screen
  34131. */
  34132. displayLoadingUI(): void;
  34133. /**
  34134. * Function called to hide the loading screen
  34135. */
  34136. hideLoadingUI(): void;
  34137. /**
  34138. * Gets or sets the text to display while loading
  34139. */
  34140. set loadingUIText(text: string);
  34141. get loadingUIText(): string;
  34142. /**
  34143. * Gets or sets the color to use for the background
  34144. */
  34145. get loadingUIBackgroundColor(): string;
  34146. set loadingUIBackgroundColor(color: string);
  34147. private _resizeLoadingUI;
  34148. }
  34149. }
  34150. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34151. /**
  34152. * Interface for any object that can request an animation frame
  34153. */
  34154. export interface ICustomAnimationFrameRequester {
  34155. /**
  34156. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34157. */
  34158. renderFunction?: Function;
  34159. /**
  34160. * Called to request the next frame to render to
  34161. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34162. */
  34163. requestAnimationFrame: Function;
  34164. /**
  34165. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34166. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34167. */
  34168. requestID?: number;
  34169. }
  34170. }
  34171. declare module "babylonjs/Misc/performanceMonitor" {
  34172. /**
  34173. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34174. */
  34175. export class PerformanceMonitor {
  34176. private _enabled;
  34177. private _rollingFrameTime;
  34178. private _lastFrameTimeMs;
  34179. /**
  34180. * constructor
  34181. * @param frameSampleSize The number of samples required to saturate the sliding window
  34182. */
  34183. constructor(frameSampleSize?: number);
  34184. /**
  34185. * Samples current frame
  34186. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34187. */
  34188. sampleFrame(timeMs?: number): void;
  34189. /**
  34190. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34191. */
  34192. get averageFrameTime(): number;
  34193. /**
  34194. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34195. */
  34196. get averageFrameTimeVariance(): number;
  34197. /**
  34198. * Returns the frame time of the most recent frame
  34199. */
  34200. get instantaneousFrameTime(): number;
  34201. /**
  34202. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34203. */
  34204. get averageFPS(): number;
  34205. /**
  34206. * Returns the average framerate in frames per second using the most recent frame time
  34207. */
  34208. get instantaneousFPS(): number;
  34209. /**
  34210. * Returns true if enough samples have been taken to completely fill the sliding window
  34211. */
  34212. get isSaturated(): boolean;
  34213. /**
  34214. * Enables contributions to the sliding window sample set
  34215. */
  34216. enable(): void;
  34217. /**
  34218. * Disables contributions to the sliding window sample set
  34219. * Samples will not be interpolated over the disabled period
  34220. */
  34221. disable(): void;
  34222. /**
  34223. * Returns true if sampling is enabled
  34224. */
  34225. get isEnabled(): boolean;
  34226. /**
  34227. * Resets performance monitor
  34228. */
  34229. reset(): void;
  34230. }
  34231. /**
  34232. * RollingAverage
  34233. *
  34234. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34235. */
  34236. export class RollingAverage {
  34237. /**
  34238. * Current average
  34239. */
  34240. average: number;
  34241. /**
  34242. * Current variance
  34243. */
  34244. variance: number;
  34245. protected _samples: Array<number>;
  34246. protected _sampleCount: number;
  34247. protected _pos: number;
  34248. protected _m2: number;
  34249. /**
  34250. * constructor
  34251. * @param length The number of samples required to saturate the sliding window
  34252. */
  34253. constructor(length: number);
  34254. /**
  34255. * Adds a sample to the sample set
  34256. * @param v The sample value
  34257. */
  34258. add(v: number): void;
  34259. /**
  34260. * Returns previously added values or null if outside of history or outside the sliding window domain
  34261. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34262. * @return Value previously recorded with add() or null if outside of range
  34263. */
  34264. history(i: number): number;
  34265. /**
  34266. * Returns true if enough samples have been taken to completely fill the sliding window
  34267. * @return true if sample-set saturated
  34268. */
  34269. isSaturated(): boolean;
  34270. /**
  34271. * Resets the rolling average (equivalent to 0 samples taken so far)
  34272. */
  34273. reset(): void;
  34274. /**
  34275. * Wraps a value around the sample range boundaries
  34276. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34277. * @return Wrapped position in sample range
  34278. */
  34279. protected _wrapPosition(i: number): number;
  34280. }
  34281. }
  34282. declare module "babylonjs/Misc/perfCounter" {
  34283. /**
  34284. * This class is used to track a performance counter which is number based.
  34285. * The user has access to many properties which give statistics of different nature.
  34286. *
  34287. * The implementer can track two kinds of Performance Counter: time and count.
  34288. * 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.
  34289. * 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.
  34290. */
  34291. export class PerfCounter {
  34292. /**
  34293. * Gets or sets a global boolean to turn on and off all the counters
  34294. */
  34295. static Enabled: boolean;
  34296. /**
  34297. * Returns the smallest value ever
  34298. */
  34299. get min(): number;
  34300. /**
  34301. * Returns the biggest value ever
  34302. */
  34303. get max(): number;
  34304. /**
  34305. * Returns the average value since the performance counter is running
  34306. */
  34307. get average(): number;
  34308. /**
  34309. * Returns the average value of the last second the counter was monitored
  34310. */
  34311. get lastSecAverage(): number;
  34312. /**
  34313. * Returns the current value
  34314. */
  34315. get current(): number;
  34316. /**
  34317. * Gets the accumulated total
  34318. */
  34319. get total(): number;
  34320. /**
  34321. * Gets the total value count
  34322. */
  34323. get count(): number;
  34324. /**
  34325. * Creates a new counter
  34326. */
  34327. constructor();
  34328. /**
  34329. * Call this method to start monitoring a new frame.
  34330. * 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.
  34331. */
  34332. fetchNewFrame(): void;
  34333. /**
  34334. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34335. * @param newCount the count value to add to the monitored count
  34336. * @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.
  34337. */
  34338. addCount(newCount: number, fetchResult: boolean): void;
  34339. /**
  34340. * Start monitoring this performance counter
  34341. */
  34342. beginMonitoring(): void;
  34343. /**
  34344. * Compute the time lapsed since the previous beginMonitoring() call.
  34345. * @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
  34346. */
  34347. endMonitoring(newFrame?: boolean): void;
  34348. private _fetchResult;
  34349. private _startMonitoringTime;
  34350. private _min;
  34351. private _max;
  34352. private _average;
  34353. private _current;
  34354. private _totalValueCount;
  34355. private _totalAccumulated;
  34356. private _lastSecAverage;
  34357. private _lastSecAccumulated;
  34358. private _lastSecTime;
  34359. private _lastSecValueCount;
  34360. }
  34361. }
  34362. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34363. module "babylonjs/Engines/thinEngine" {
  34364. interface ThinEngine {
  34365. /**
  34366. * Sets alpha constants used by some alpha blending modes
  34367. * @param r defines the red component
  34368. * @param g defines the green component
  34369. * @param b defines the blue component
  34370. * @param a defines the alpha component
  34371. */
  34372. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34373. /**
  34374. * Sets the current alpha mode
  34375. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34376. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34377. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34378. */
  34379. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34380. /**
  34381. * Gets the current alpha mode
  34382. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34383. * @returns the current alpha mode
  34384. */
  34385. getAlphaMode(): number;
  34386. /**
  34387. * Sets the current alpha equation
  34388. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34389. */
  34390. setAlphaEquation(equation: number): void;
  34391. /**
  34392. * Gets the current alpha equation.
  34393. * @returns the current alpha equation
  34394. */
  34395. getAlphaEquation(): number;
  34396. }
  34397. }
  34398. }
  34399. declare module "babylonjs/Engines/engine" {
  34400. import { Observable } from "babylonjs/Misc/observable";
  34401. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34402. import { Scene } from "babylonjs/scene";
  34403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34404. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34405. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34406. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34407. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34408. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34409. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34410. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34411. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34412. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34413. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34414. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34415. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34416. import "babylonjs/Engines/Extensions/engine.alpha";
  34417. import { Material } from "babylonjs/Materials/material";
  34418. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34419. /**
  34420. * Defines the interface used by display changed events
  34421. */
  34422. export interface IDisplayChangedEventArgs {
  34423. /** Gets the vrDisplay object (if any) */
  34424. vrDisplay: Nullable<any>;
  34425. /** Gets a boolean indicating if webVR is supported */
  34426. vrSupported: boolean;
  34427. }
  34428. /**
  34429. * Defines the interface used by objects containing a viewport (like a camera)
  34430. */
  34431. interface IViewportOwnerLike {
  34432. /**
  34433. * Gets or sets the viewport
  34434. */
  34435. viewport: IViewportLike;
  34436. }
  34437. /**
  34438. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34439. */
  34440. export class Engine extends ThinEngine {
  34441. /** Defines that alpha blending is disabled */
  34442. static readonly ALPHA_DISABLE: number;
  34443. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34444. static readonly ALPHA_ADD: number;
  34445. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34446. static readonly ALPHA_COMBINE: number;
  34447. /** Defines that alpha blending to DEST - SRC * DEST */
  34448. static readonly ALPHA_SUBTRACT: number;
  34449. /** Defines that alpha blending to SRC * DEST */
  34450. static readonly ALPHA_MULTIPLY: number;
  34451. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34452. static readonly ALPHA_MAXIMIZED: number;
  34453. /** Defines that alpha blending to SRC + DEST */
  34454. static readonly ALPHA_ONEONE: number;
  34455. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34456. static readonly ALPHA_PREMULTIPLIED: number;
  34457. /**
  34458. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34459. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34460. */
  34461. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34462. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34463. static readonly ALPHA_INTERPOLATE: number;
  34464. /**
  34465. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34466. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34467. */
  34468. static readonly ALPHA_SCREENMODE: number;
  34469. /** Defines that the ressource is not delayed*/
  34470. static readonly DELAYLOADSTATE_NONE: number;
  34471. /** Defines that the ressource was successfully delay loaded */
  34472. static readonly DELAYLOADSTATE_LOADED: number;
  34473. /** Defines that the ressource is currently delay loading */
  34474. static readonly DELAYLOADSTATE_LOADING: number;
  34475. /** Defines that the ressource is delayed and has not started loading */
  34476. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34477. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34478. static readonly NEVER: number;
  34479. /** 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 */
  34480. static readonly ALWAYS: number;
  34481. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34482. static readonly LESS: number;
  34483. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34484. static readonly EQUAL: number;
  34485. /** 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 */
  34486. static readonly LEQUAL: number;
  34487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34488. static readonly GREATER: number;
  34489. /** 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 */
  34490. static readonly GEQUAL: number;
  34491. /** 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 */
  34492. static readonly NOTEQUAL: number;
  34493. /** Passed to stencilOperation to specify that stencil value must be kept */
  34494. static readonly KEEP: number;
  34495. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34496. static readonly REPLACE: number;
  34497. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34498. static readonly INCR: number;
  34499. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34500. static readonly DECR: number;
  34501. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34502. static readonly INVERT: number;
  34503. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34504. static readonly INCR_WRAP: number;
  34505. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34506. static readonly DECR_WRAP: number;
  34507. /** Texture is not repeating outside of 0..1 UVs */
  34508. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34509. /** Texture is repeating outside of 0..1 UVs */
  34510. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34511. /** Texture is repeating and mirrored */
  34512. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34513. /** ALPHA */
  34514. static readonly TEXTUREFORMAT_ALPHA: number;
  34515. /** LUMINANCE */
  34516. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34517. /** LUMINANCE_ALPHA */
  34518. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34519. /** RGB */
  34520. static readonly TEXTUREFORMAT_RGB: number;
  34521. /** RGBA */
  34522. static readonly TEXTUREFORMAT_RGBA: number;
  34523. /** RED */
  34524. static readonly TEXTUREFORMAT_RED: number;
  34525. /** RED (2nd reference) */
  34526. static readonly TEXTUREFORMAT_R: number;
  34527. /** RG */
  34528. static readonly TEXTUREFORMAT_RG: number;
  34529. /** RED_INTEGER */
  34530. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34531. /** RED_INTEGER (2nd reference) */
  34532. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34533. /** RG_INTEGER */
  34534. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34535. /** RGB_INTEGER */
  34536. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34537. /** RGBA_INTEGER */
  34538. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34539. /** UNSIGNED_BYTE */
  34540. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34541. /** UNSIGNED_BYTE (2nd reference) */
  34542. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34543. /** FLOAT */
  34544. static readonly TEXTURETYPE_FLOAT: number;
  34545. /** HALF_FLOAT */
  34546. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34547. /** BYTE */
  34548. static readonly TEXTURETYPE_BYTE: number;
  34549. /** SHORT */
  34550. static readonly TEXTURETYPE_SHORT: number;
  34551. /** UNSIGNED_SHORT */
  34552. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34553. /** INT */
  34554. static readonly TEXTURETYPE_INT: number;
  34555. /** UNSIGNED_INT */
  34556. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34557. /** UNSIGNED_SHORT_4_4_4_4 */
  34558. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34559. /** UNSIGNED_SHORT_5_5_5_1 */
  34560. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34561. /** UNSIGNED_SHORT_5_6_5 */
  34562. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34563. /** UNSIGNED_INT_2_10_10_10_REV */
  34564. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34565. /** UNSIGNED_INT_24_8 */
  34566. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34567. /** UNSIGNED_INT_10F_11F_11F_REV */
  34568. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34569. /** UNSIGNED_INT_5_9_9_9_REV */
  34570. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34571. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34572. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34573. /** nearest is mag = nearest and min = nearest and mip = linear */
  34574. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34575. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34576. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34577. /** Trilinear is mag = linear and min = linear and mip = linear */
  34578. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34579. /** nearest is mag = nearest and min = nearest and mip = linear */
  34580. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34581. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34582. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34583. /** Trilinear is mag = linear and min = linear and mip = linear */
  34584. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34585. /** mag = nearest and min = nearest and mip = nearest */
  34586. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34587. /** mag = nearest and min = linear and mip = nearest */
  34588. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34589. /** mag = nearest and min = linear and mip = linear */
  34590. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34591. /** mag = nearest and min = linear and mip = none */
  34592. static readonly TEXTURE_NEAREST_LINEAR: number;
  34593. /** mag = nearest and min = nearest and mip = none */
  34594. static readonly TEXTURE_NEAREST_NEAREST: number;
  34595. /** mag = linear and min = nearest and mip = nearest */
  34596. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34597. /** mag = linear and min = nearest and mip = linear */
  34598. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34599. /** mag = linear and min = linear and mip = none */
  34600. static readonly TEXTURE_LINEAR_LINEAR: number;
  34601. /** mag = linear and min = nearest and mip = none */
  34602. static readonly TEXTURE_LINEAR_NEAREST: number;
  34603. /** Explicit coordinates mode */
  34604. static readonly TEXTURE_EXPLICIT_MODE: number;
  34605. /** Spherical coordinates mode */
  34606. static readonly TEXTURE_SPHERICAL_MODE: number;
  34607. /** Planar coordinates mode */
  34608. static readonly TEXTURE_PLANAR_MODE: number;
  34609. /** Cubic coordinates mode */
  34610. static readonly TEXTURE_CUBIC_MODE: number;
  34611. /** Projection coordinates mode */
  34612. static readonly TEXTURE_PROJECTION_MODE: number;
  34613. /** Skybox coordinates mode */
  34614. static readonly TEXTURE_SKYBOX_MODE: number;
  34615. /** Inverse Cubic coordinates mode */
  34616. static readonly TEXTURE_INVCUBIC_MODE: number;
  34617. /** Equirectangular coordinates mode */
  34618. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34619. /** Equirectangular Fixed coordinates mode */
  34620. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34621. /** Equirectangular Fixed Mirrored coordinates mode */
  34622. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34623. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34624. static readonly SCALEMODE_FLOOR: number;
  34625. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34626. static readonly SCALEMODE_NEAREST: number;
  34627. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34628. static readonly SCALEMODE_CEILING: number;
  34629. /**
  34630. * Returns the current npm package of the sdk
  34631. */
  34632. static get NpmPackage(): string;
  34633. /**
  34634. * Returns the current version of the framework
  34635. */
  34636. static get Version(): string;
  34637. /** Gets the list of created engines */
  34638. static get Instances(): Engine[];
  34639. /**
  34640. * Gets the latest created engine
  34641. */
  34642. static get LastCreatedEngine(): Nullable<Engine>;
  34643. /**
  34644. * Gets the latest created scene
  34645. */
  34646. static get LastCreatedScene(): Nullable<Scene>;
  34647. /**
  34648. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34649. * @param flag defines which part of the materials must be marked as dirty
  34650. * @param predicate defines a predicate used to filter which materials should be affected
  34651. */
  34652. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34653. /**
  34654. * Method called to create the default loading screen.
  34655. * This can be overriden in your own app.
  34656. * @param canvas The rendering canvas element
  34657. * @returns The loading screen
  34658. */
  34659. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34660. /**
  34661. * Method called to create the default rescale post process on each engine.
  34662. */
  34663. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34664. /**
  34665. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34666. **/
  34667. enableOfflineSupport: boolean;
  34668. /**
  34669. * 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)
  34670. **/
  34671. disableManifestCheck: boolean;
  34672. /**
  34673. * Gets the list of created scenes
  34674. */
  34675. scenes: Scene[];
  34676. /**
  34677. * Event raised when a new scene is created
  34678. */
  34679. onNewSceneAddedObservable: Observable<Scene>;
  34680. /**
  34681. * Gets the list of created postprocesses
  34682. */
  34683. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34684. /**
  34685. * Gets a boolean indicating if the pointer is currently locked
  34686. */
  34687. isPointerLock: boolean;
  34688. /**
  34689. * Observable event triggered each time the rendering canvas is resized
  34690. */
  34691. onResizeObservable: Observable<Engine>;
  34692. /**
  34693. * Observable event triggered each time the canvas loses focus
  34694. */
  34695. onCanvasBlurObservable: Observable<Engine>;
  34696. /**
  34697. * Observable event triggered each time the canvas gains focus
  34698. */
  34699. onCanvasFocusObservable: Observable<Engine>;
  34700. /**
  34701. * Observable event triggered each time the canvas receives pointerout event
  34702. */
  34703. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34704. /**
  34705. * Observable raised when the engine begins a new frame
  34706. */
  34707. onBeginFrameObservable: Observable<Engine>;
  34708. /**
  34709. * If set, will be used to request the next animation frame for the render loop
  34710. */
  34711. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34712. /**
  34713. * Observable raised when the engine ends the current frame
  34714. */
  34715. onEndFrameObservable: Observable<Engine>;
  34716. /**
  34717. * Observable raised when the engine is about to compile a shader
  34718. */
  34719. onBeforeShaderCompilationObservable: Observable<Engine>;
  34720. /**
  34721. * Observable raised when the engine has jsut compiled a shader
  34722. */
  34723. onAfterShaderCompilationObservable: Observable<Engine>;
  34724. /**
  34725. * Gets the audio engine
  34726. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34727. * @ignorenaming
  34728. */
  34729. static audioEngine: IAudioEngine;
  34730. /**
  34731. * Default AudioEngine factory responsible of creating the Audio Engine.
  34732. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34733. */
  34734. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34735. /**
  34736. * Default offline support factory responsible of creating a tool used to store data locally.
  34737. * By default, this will create a Database object if the workload has been embedded.
  34738. */
  34739. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34740. private _loadingScreen;
  34741. private _pointerLockRequested;
  34742. private _dummyFramebuffer;
  34743. private _rescalePostProcess;
  34744. private _deterministicLockstep;
  34745. private _lockstepMaxSteps;
  34746. private _timeStep;
  34747. protected get _supportsHardwareTextureRescaling(): boolean;
  34748. private _fps;
  34749. private _deltaTime;
  34750. /** @hidden */
  34751. _drawCalls: PerfCounter;
  34752. /** 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 */
  34753. canvasTabIndex: number;
  34754. /**
  34755. * Turn this value on if you want to pause FPS computation when in background
  34756. */
  34757. disablePerformanceMonitorInBackground: boolean;
  34758. private _performanceMonitor;
  34759. /**
  34760. * Gets the performance monitor attached to this engine
  34761. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34762. */
  34763. get performanceMonitor(): PerformanceMonitor;
  34764. private _onFocus;
  34765. private _onBlur;
  34766. private _onCanvasPointerOut;
  34767. private _onCanvasBlur;
  34768. private _onCanvasFocus;
  34769. private _onFullscreenChange;
  34770. private _onPointerLockChange;
  34771. /**
  34772. * Gets the HTML element used to attach event listeners
  34773. * @returns a HTML element
  34774. */
  34775. getInputElement(): Nullable<HTMLElement>;
  34776. /**
  34777. * Creates a new engine
  34778. * @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
  34779. * @param antialias defines enable antialiasing (default: false)
  34780. * @param options defines further options to be sent to the getContext() function
  34781. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34782. */
  34783. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34784. /**
  34785. * Gets current aspect ratio
  34786. * @param viewportOwner defines the camera to use to get the aspect ratio
  34787. * @param useScreen defines if screen size must be used (or the current render target if any)
  34788. * @returns a number defining the aspect ratio
  34789. */
  34790. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34791. /**
  34792. * Gets current screen aspect ratio
  34793. * @returns a number defining the aspect ratio
  34794. */
  34795. getScreenAspectRatio(): number;
  34796. /**
  34797. * Gets the client rect of the HTML canvas attached with the current webGL context
  34798. * @returns a client rectanglee
  34799. */
  34800. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34801. /**
  34802. * Gets the client rect of the HTML element used for events
  34803. * @returns a client rectanglee
  34804. */
  34805. getInputElementClientRect(): Nullable<ClientRect>;
  34806. /**
  34807. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34808. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34809. * @returns true if engine is in deterministic lock step mode
  34810. */
  34811. isDeterministicLockStep(): boolean;
  34812. /**
  34813. * Gets the max steps when engine is running in deterministic lock step
  34814. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34815. * @returns the max steps
  34816. */
  34817. getLockstepMaxSteps(): number;
  34818. /**
  34819. * Returns the time in ms between steps when using deterministic lock step.
  34820. * @returns time step in (ms)
  34821. */
  34822. getTimeStep(): number;
  34823. /**
  34824. * Force the mipmap generation for the given render target texture
  34825. * @param texture defines the render target texture to use
  34826. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34827. */
  34828. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34829. /** States */
  34830. /**
  34831. * Set various states to the webGL context
  34832. * @param culling defines backface culling state
  34833. * @param zOffset defines the value to apply to zOffset (0 by default)
  34834. * @param force defines if states must be applied even if cache is up to date
  34835. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34836. */
  34837. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34838. /**
  34839. * Set the z offset to apply to current rendering
  34840. * @param value defines the offset to apply
  34841. */
  34842. setZOffset(value: number): void;
  34843. /**
  34844. * Gets the current value of the zOffset
  34845. * @returns the current zOffset state
  34846. */
  34847. getZOffset(): number;
  34848. /**
  34849. * Enable or disable depth buffering
  34850. * @param enable defines the state to set
  34851. */
  34852. setDepthBuffer(enable: boolean): void;
  34853. /**
  34854. * Gets a boolean indicating if depth writing is enabled
  34855. * @returns the current depth writing state
  34856. */
  34857. getDepthWrite(): boolean;
  34858. /**
  34859. * Enable or disable depth writing
  34860. * @param enable defines the state to set
  34861. */
  34862. setDepthWrite(enable: boolean): void;
  34863. /**
  34864. * Gets a boolean indicating if stencil buffer is enabled
  34865. * @returns the current stencil buffer state
  34866. */
  34867. getStencilBuffer(): boolean;
  34868. /**
  34869. * Enable or disable the stencil buffer
  34870. * @param enable defines if the stencil buffer must be enabled or disabled
  34871. */
  34872. setStencilBuffer(enable: boolean): void;
  34873. /**
  34874. * Gets the current stencil mask
  34875. * @returns a number defining the new stencil mask to use
  34876. */
  34877. getStencilMask(): number;
  34878. /**
  34879. * Sets the current stencil mask
  34880. * @param mask defines the new stencil mask to use
  34881. */
  34882. setStencilMask(mask: number): void;
  34883. /**
  34884. * Gets the current stencil function
  34885. * @returns a number defining the stencil function to use
  34886. */
  34887. getStencilFunction(): number;
  34888. /**
  34889. * Gets the current stencil reference value
  34890. * @returns a number defining the stencil reference value to use
  34891. */
  34892. getStencilFunctionReference(): number;
  34893. /**
  34894. * Gets the current stencil mask
  34895. * @returns a number defining the stencil mask to use
  34896. */
  34897. getStencilFunctionMask(): number;
  34898. /**
  34899. * Sets the current stencil function
  34900. * @param stencilFunc defines the new stencil function to use
  34901. */
  34902. setStencilFunction(stencilFunc: number): void;
  34903. /**
  34904. * Sets the current stencil reference
  34905. * @param reference defines the new stencil reference to use
  34906. */
  34907. setStencilFunctionReference(reference: number): void;
  34908. /**
  34909. * Sets the current stencil mask
  34910. * @param mask defines the new stencil mask to use
  34911. */
  34912. setStencilFunctionMask(mask: number): void;
  34913. /**
  34914. * Gets the current stencil operation when stencil fails
  34915. * @returns a number defining stencil operation to use when stencil fails
  34916. */
  34917. getStencilOperationFail(): number;
  34918. /**
  34919. * Gets the current stencil operation when depth fails
  34920. * @returns a number defining stencil operation to use when depth fails
  34921. */
  34922. getStencilOperationDepthFail(): number;
  34923. /**
  34924. * Gets the current stencil operation when stencil passes
  34925. * @returns a number defining stencil operation to use when stencil passes
  34926. */
  34927. getStencilOperationPass(): number;
  34928. /**
  34929. * Sets the stencil operation to use when stencil fails
  34930. * @param operation defines the stencil operation to use when stencil fails
  34931. */
  34932. setStencilOperationFail(operation: number): void;
  34933. /**
  34934. * Sets the stencil operation to use when depth fails
  34935. * @param operation defines the stencil operation to use when depth fails
  34936. */
  34937. setStencilOperationDepthFail(operation: number): void;
  34938. /**
  34939. * Sets the stencil operation to use when stencil passes
  34940. * @param operation defines the stencil operation to use when stencil passes
  34941. */
  34942. setStencilOperationPass(operation: number): void;
  34943. /**
  34944. * Sets a boolean indicating if the dithering state is enabled or disabled
  34945. * @param value defines the dithering state
  34946. */
  34947. setDitheringState(value: boolean): void;
  34948. /**
  34949. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34950. * @param value defines the rasterizer state
  34951. */
  34952. setRasterizerState(value: boolean): void;
  34953. /**
  34954. * Gets the current depth function
  34955. * @returns a number defining the depth function
  34956. */
  34957. getDepthFunction(): Nullable<number>;
  34958. /**
  34959. * Sets the current depth function
  34960. * @param depthFunc defines the function to use
  34961. */
  34962. setDepthFunction(depthFunc: number): void;
  34963. /**
  34964. * Sets the current depth function to GREATER
  34965. */
  34966. setDepthFunctionToGreater(): void;
  34967. /**
  34968. * Sets the current depth function to GEQUAL
  34969. */
  34970. setDepthFunctionToGreaterOrEqual(): void;
  34971. /**
  34972. * Sets the current depth function to LESS
  34973. */
  34974. setDepthFunctionToLess(): void;
  34975. /**
  34976. * Sets the current depth function to LEQUAL
  34977. */
  34978. setDepthFunctionToLessOrEqual(): void;
  34979. private _cachedStencilBuffer;
  34980. private _cachedStencilFunction;
  34981. private _cachedStencilMask;
  34982. private _cachedStencilOperationPass;
  34983. private _cachedStencilOperationFail;
  34984. private _cachedStencilOperationDepthFail;
  34985. private _cachedStencilReference;
  34986. /**
  34987. * Caches the the state of the stencil buffer
  34988. */
  34989. cacheStencilState(): void;
  34990. /**
  34991. * Restores the state of the stencil buffer
  34992. */
  34993. restoreStencilState(): void;
  34994. /**
  34995. * Directly set the WebGL Viewport
  34996. * @param x defines the x coordinate of the viewport (in screen space)
  34997. * @param y defines the y coordinate of the viewport (in screen space)
  34998. * @param width defines the width of the viewport (in screen space)
  34999. * @param height defines the height of the viewport (in screen space)
  35000. * @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
  35001. */
  35002. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35003. /**
  35004. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35005. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35006. * @param y defines the y-coordinate of the corner of the clear rectangle
  35007. * @param width defines the width of the clear rectangle
  35008. * @param height defines the height of the clear rectangle
  35009. * @param clearColor defines the clear color
  35010. */
  35011. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35012. /**
  35013. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35014. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35015. * @param y defines the y-coordinate of the corner of the clear rectangle
  35016. * @param width defines the width of the clear rectangle
  35017. * @param height defines the height of the clear rectangle
  35018. */
  35019. enableScissor(x: number, y: number, width: number, height: number): void;
  35020. /**
  35021. * Disable previously set scissor test rectangle
  35022. */
  35023. disableScissor(): void;
  35024. protected _reportDrawCall(): void;
  35025. /**
  35026. * Initializes a webVR display and starts listening to display change events
  35027. * The onVRDisplayChangedObservable will be notified upon these changes
  35028. * @returns The onVRDisplayChangedObservable
  35029. */
  35030. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35031. /** @hidden */
  35032. _prepareVRComponent(): void;
  35033. /** @hidden */
  35034. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35035. /** @hidden */
  35036. _submitVRFrame(): void;
  35037. /**
  35038. * Call this function to leave webVR mode
  35039. * Will do nothing if webVR is not supported or if there is no webVR device
  35040. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35041. */
  35042. disableVR(): void;
  35043. /**
  35044. * Gets a boolean indicating that the system is in VR mode and is presenting
  35045. * @returns true if VR mode is engaged
  35046. */
  35047. isVRPresenting(): boolean;
  35048. /** @hidden */
  35049. _requestVRFrame(): void;
  35050. /** @hidden */
  35051. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35052. /**
  35053. * Gets the source code of the vertex shader associated with a specific webGL program
  35054. * @param program defines the program to use
  35055. * @returns a string containing the source code of the vertex shader associated with the program
  35056. */
  35057. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35058. /**
  35059. * Gets the source code of the fragment shader associated with a specific webGL program
  35060. * @param program defines the program to use
  35061. * @returns a string containing the source code of the fragment shader associated with the program
  35062. */
  35063. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35064. /**
  35065. * Sets a depth stencil texture from a render target to the according uniform.
  35066. * @param channel The texture channel
  35067. * @param uniform The uniform to set
  35068. * @param texture The render target texture containing the depth stencil texture to apply
  35069. */
  35070. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35071. /**
  35072. * Sets a texture to the webGL context from a postprocess
  35073. * @param channel defines the channel to use
  35074. * @param postProcess defines the source postprocess
  35075. */
  35076. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35077. /**
  35078. * Binds the output of the passed in post process to the texture channel specified
  35079. * @param channel The channel the texture should be bound to
  35080. * @param postProcess The post process which's output should be bound
  35081. */
  35082. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35083. /** @hidden */
  35084. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  35085. protected _rebuildBuffers(): void;
  35086. /** @hidden */
  35087. _renderFrame(): void;
  35088. _renderLoop(): void;
  35089. /** @hidden */
  35090. _renderViews(): boolean;
  35091. /**
  35092. * Toggle full screen mode
  35093. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35094. */
  35095. switchFullscreen(requestPointerLock: boolean): void;
  35096. /**
  35097. * Enters full screen mode
  35098. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35099. */
  35100. enterFullscreen(requestPointerLock: boolean): void;
  35101. /**
  35102. * Exits full screen mode
  35103. */
  35104. exitFullscreen(): void;
  35105. /**
  35106. * Enters Pointerlock mode
  35107. */
  35108. enterPointerlock(): void;
  35109. /**
  35110. * Exits Pointerlock mode
  35111. */
  35112. exitPointerlock(): void;
  35113. /**
  35114. * Begin a new frame
  35115. */
  35116. beginFrame(): void;
  35117. /**
  35118. * Enf the current frame
  35119. */
  35120. endFrame(): void;
  35121. resize(): void;
  35122. /**
  35123. * Force a specific size of the canvas
  35124. * @param width defines the new canvas' width
  35125. * @param height defines the new canvas' height
  35126. */
  35127. setSize(width: number, height: number): void;
  35128. /**
  35129. * Updates a dynamic vertex buffer.
  35130. * @param vertexBuffer the vertex buffer to update
  35131. * @param data the data used to update the vertex buffer
  35132. * @param byteOffset the byte offset of the data
  35133. * @param byteLength the byte length of the data
  35134. */
  35135. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35136. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35137. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35138. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35139. _releaseTexture(texture: InternalTexture): void;
  35140. /**
  35141. * @hidden
  35142. * Rescales a texture
  35143. * @param source input texutre
  35144. * @param destination destination texture
  35145. * @param scene scene to use to render the resize
  35146. * @param internalFormat format to use when resizing
  35147. * @param onComplete callback to be called when resize has completed
  35148. */
  35149. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35150. /**
  35151. * Gets the current framerate
  35152. * @returns a number representing the framerate
  35153. */
  35154. getFps(): number;
  35155. /**
  35156. * Gets the time spent between current and previous frame
  35157. * @returns a number representing the delta time in ms
  35158. */
  35159. getDeltaTime(): number;
  35160. private _measureFps;
  35161. /** @hidden */
  35162. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35163. /**
  35164. * Update a dynamic index buffer
  35165. * @param indexBuffer defines the target index buffer
  35166. * @param indices defines the data to update
  35167. * @param offset defines the offset in the target index buffer where update should start
  35168. */
  35169. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35170. /**
  35171. * Updates the sample count of a render target texture
  35172. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35173. * @param texture defines the texture to update
  35174. * @param samples defines the sample count to set
  35175. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35176. */
  35177. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35178. /**
  35179. * Updates a depth texture Comparison Mode and Function.
  35180. * If the comparison Function is equal to 0, the mode will be set to none.
  35181. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35182. * @param texture The texture to set the comparison function for
  35183. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35184. */
  35185. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35186. /**
  35187. * Creates a webGL buffer to use with instanciation
  35188. * @param capacity defines the size of the buffer
  35189. * @returns the webGL buffer
  35190. */
  35191. createInstancesBuffer(capacity: number): DataBuffer;
  35192. /**
  35193. * Delete a webGL buffer used with instanciation
  35194. * @param buffer defines the webGL buffer to delete
  35195. */
  35196. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35197. private _clientWaitAsync;
  35198. /** @hidden */
  35199. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35200. /** @hidden */
  35201. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35202. dispose(): void;
  35203. private _disableTouchAction;
  35204. /**
  35205. * Display the loading screen
  35206. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35207. */
  35208. displayLoadingUI(): void;
  35209. /**
  35210. * Hide the loading screen
  35211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35212. */
  35213. hideLoadingUI(): void;
  35214. /**
  35215. * Gets the current loading screen object
  35216. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35217. */
  35218. get loadingScreen(): ILoadingScreen;
  35219. /**
  35220. * Sets the current loading screen object
  35221. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35222. */
  35223. set loadingScreen(loadingScreen: ILoadingScreen);
  35224. /**
  35225. * Sets the current loading screen text
  35226. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35227. */
  35228. set loadingUIText(text: string);
  35229. /**
  35230. * Sets the current loading screen background color
  35231. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35232. */
  35233. set loadingUIBackgroundColor(color: string);
  35234. /** Pointerlock and fullscreen */
  35235. /**
  35236. * Ask the browser to promote the current element to pointerlock mode
  35237. * @param element defines the DOM element to promote
  35238. */
  35239. static _RequestPointerlock(element: HTMLElement): void;
  35240. /**
  35241. * Asks the browser to exit pointerlock mode
  35242. */
  35243. static _ExitPointerlock(): void;
  35244. /**
  35245. * Ask the browser to promote the current element to fullscreen rendering mode
  35246. * @param element defines the DOM element to promote
  35247. */
  35248. static _RequestFullscreen(element: HTMLElement): void;
  35249. /**
  35250. * Asks the browser to exit fullscreen mode
  35251. */
  35252. static _ExitFullscreen(): void;
  35253. }
  35254. }
  35255. declare module "babylonjs/Engines/engineStore" {
  35256. import { Nullable } from "babylonjs/types";
  35257. import { Engine } from "babylonjs/Engines/engine";
  35258. import { Scene } from "babylonjs/scene";
  35259. /**
  35260. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35261. * during the life time of the application.
  35262. */
  35263. export class EngineStore {
  35264. /** Gets the list of created engines */
  35265. static Instances: import("babylonjs/Engines/engine").Engine[];
  35266. /** @hidden */
  35267. static _LastCreatedScene: Nullable<Scene>;
  35268. /**
  35269. * Gets the latest created engine
  35270. */
  35271. static get LastCreatedEngine(): Nullable<Engine>;
  35272. /**
  35273. * Gets the latest created scene
  35274. */
  35275. static get LastCreatedScene(): Nullable<Scene>;
  35276. /**
  35277. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35278. * @ignorenaming
  35279. */
  35280. static UseFallbackTexture: boolean;
  35281. /**
  35282. * Texture content used if a texture cannot loaded
  35283. * @ignorenaming
  35284. */
  35285. static FallbackTexture: string;
  35286. }
  35287. }
  35288. declare module "babylonjs/Misc/promise" {
  35289. /**
  35290. * Helper class that provides a small promise polyfill
  35291. */
  35292. export class PromisePolyfill {
  35293. /**
  35294. * Static function used to check if the polyfill is required
  35295. * If this is the case then the function will inject the polyfill to window.Promise
  35296. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35297. */
  35298. static Apply(force?: boolean): void;
  35299. }
  35300. }
  35301. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35302. /**
  35303. * Interface for screenshot methods with describe argument called `size` as object with options
  35304. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35305. */
  35306. export interface IScreenshotSize {
  35307. /**
  35308. * number in pixels for canvas height
  35309. */
  35310. height?: number;
  35311. /**
  35312. * multiplier allowing render at a higher or lower resolution
  35313. * If value is defined then height and width will be ignored and taken from camera
  35314. */
  35315. precision?: number;
  35316. /**
  35317. * number in pixels for canvas width
  35318. */
  35319. width?: number;
  35320. }
  35321. }
  35322. declare module "babylonjs/Misc/tools" {
  35323. import { Nullable, float } from "babylonjs/types";
  35324. import { DomManagement } from "babylonjs/Misc/domManagement";
  35325. import { WebRequest } from "babylonjs/Misc/webRequest";
  35326. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35327. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35328. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35329. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35330. import { Camera } from "babylonjs/Cameras/camera";
  35331. import { Engine } from "babylonjs/Engines/engine";
  35332. interface IColor4Like {
  35333. r: float;
  35334. g: float;
  35335. b: float;
  35336. a: float;
  35337. }
  35338. /**
  35339. * Class containing a set of static utilities functions
  35340. */
  35341. export class Tools {
  35342. /**
  35343. * Gets or sets the base URL to use to load assets
  35344. */
  35345. static get BaseUrl(): string;
  35346. static set BaseUrl(value: string);
  35347. /**
  35348. * Enable/Disable Custom HTTP Request Headers globally.
  35349. * default = false
  35350. * @see CustomRequestHeaders
  35351. */
  35352. static UseCustomRequestHeaders: boolean;
  35353. /**
  35354. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35355. * i.e. when loading files, where the server/service expects an Authorization header
  35356. */
  35357. static CustomRequestHeaders: {
  35358. [key: string]: string;
  35359. };
  35360. /**
  35361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35362. */
  35363. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35364. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35365. /**
  35366. * Default behaviour for cors in the application.
  35367. * It can be a string if the expected behavior is identical in the entire app.
  35368. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35369. */
  35370. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35371. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35372. /**
  35373. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35374. * @ignorenaming
  35375. */
  35376. static get UseFallbackTexture(): boolean;
  35377. static set UseFallbackTexture(value: boolean);
  35378. /**
  35379. * Use this object to register external classes like custom textures or material
  35380. * to allow the laoders to instantiate them
  35381. */
  35382. static get RegisteredExternalClasses(): {
  35383. [key: string]: Object;
  35384. };
  35385. static set RegisteredExternalClasses(classes: {
  35386. [key: string]: Object;
  35387. });
  35388. /**
  35389. * Texture content used if a texture cannot loaded
  35390. * @ignorenaming
  35391. */
  35392. static get fallbackTexture(): string;
  35393. static set fallbackTexture(value: string);
  35394. /**
  35395. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35396. * @param u defines the coordinate on X axis
  35397. * @param v defines the coordinate on Y axis
  35398. * @param width defines the width of the source data
  35399. * @param height defines the height of the source data
  35400. * @param pixels defines the source byte array
  35401. * @param color defines the output color
  35402. */
  35403. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35404. /**
  35405. * Interpolates between a and b via alpha
  35406. * @param a The lower value (returned when alpha = 0)
  35407. * @param b The upper value (returned when alpha = 1)
  35408. * @param alpha The interpolation-factor
  35409. * @return The mixed value
  35410. */
  35411. static Mix(a: number, b: number, alpha: number): number;
  35412. /**
  35413. * Tries to instantiate a new object from a given class name
  35414. * @param className defines the class name to instantiate
  35415. * @returns the new object or null if the system was not able to do the instantiation
  35416. */
  35417. static Instantiate(className: string): any;
  35418. /**
  35419. * Provides a slice function that will work even on IE
  35420. * @param data defines the array to slice
  35421. * @param start defines the start of the data (optional)
  35422. * @param end defines the end of the data (optional)
  35423. * @returns the new sliced array
  35424. */
  35425. static Slice<T>(data: T, start?: number, end?: number): T;
  35426. /**
  35427. * Polyfill for setImmediate
  35428. * @param action defines the action to execute after the current execution block
  35429. */
  35430. static SetImmediate(action: () => void): void;
  35431. /**
  35432. * Function indicating if a number is an exponent of 2
  35433. * @param value defines the value to test
  35434. * @returns true if the value is an exponent of 2
  35435. */
  35436. static IsExponentOfTwo(value: number): boolean;
  35437. private static _tmpFloatArray;
  35438. /**
  35439. * Returns the nearest 32-bit single precision float representation of a Number
  35440. * @param value A Number. If the parameter is of a different type, it will get converted
  35441. * to a number or to NaN if it cannot be converted
  35442. * @returns number
  35443. */
  35444. static FloatRound(value: number): number;
  35445. /**
  35446. * Extracts the filename from a path
  35447. * @param path defines the path to use
  35448. * @returns the filename
  35449. */
  35450. static GetFilename(path: string): string;
  35451. /**
  35452. * Extracts the "folder" part of a path (everything before the filename).
  35453. * @param uri The URI to extract the info from
  35454. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35455. * @returns The "folder" part of the path
  35456. */
  35457. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35458. /**
  35459. * Extracts text content from a DOM element hierarchy
  35460. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35461. */
  35462. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35463. /**
  35464. * Convert an angle in radians to degrees
  35465. * @param angle defines the angle to convert
  35466. * @returns the angle in degrees
  35467. */
  35468. static ToDegrees(angle: number): number;
  35469. /**
  35470. * Convert an angle in degrees to radians
  35471. * @param angle defines the angle to convert
  35472. * @returns the angle in radians
  35473. */
  35474. static ToRadians(angle: number): number;
  35475. /**
  35476. * Returns an array if obj is not an array
  35477. * @param obj defines the object to evaluate as an array
  35478. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35479. * @returns either obj directly if obj is an array or a new array containing obj
  35480. */
  35481. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35482. /**
  35483. * Gets the pointer prefix to use
  35484. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35485. */
  35486. static GetPointerPrefix(): string;
  35487. /**
  35488. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35489. * @param url define the url we are trying
  35490. * @param element define the dom element where to configure the cors policy
  35491. */
  35492. static SetCorsBehavior(url: string | string[], element: {
  35493. crossOrigin: string | null;
  35494. }): void;
  35495. /**
  35496. * Removes unwanted characters from an url
  35497. * @param url defines the url to clean
  35498. * @returns the cleaned url
  35499. */
  35500. static CleanUrl(url: string): string;
  35501. /**
  35502. * Gets or sets a function used to pre-process url before using them to load assets
  35503. */
  35504. static get PreprocessUrl(): (url: string) => string;
  35505. static set PreprocessUrl(processor: (url: string) => string);
  35506. /**
  35507. * Loads an image as an HTMLImageElement.
  35508. * @param input url string, ArrayBuffer, or Blob to load
  35509. * @param onLoad callback called when the image successfully loads
  35510. * @param onError callback called when the image fails to load
  35511. * @param offlineProvider offline provider for caching
  35512. * @param mimeType optional mime type
  35513. * @returns the HTMLImageElement of the loaded image
  35514. */
  35515. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35516. /**
  35517. * Loads a file from a url
  35518. * @param url url string, ArrayBuffer, or Blob to load
  35519. * @param onSuccess callback called when the file successfully loads
  35520. * @param onProgress callback called while file is loading (if the server supports this mode)
  35521. * @param offlineProvider defines the offline provider for caching
  35522. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35523. * @param onError callback called when the file fails to load
  35524. * @returns a file request object
  35525. */
  35526. 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;
  35527. /**
  35528. * Loads a file from a url
  35529. * @param url the file url to load
  35530. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35531. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35532. */
  35533. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35534. /**
  35535. * Load a script (identified by an url). When the url returns, the
  35536. * content of this file is added into a new script element, attached to the DOM (body element)
  35537. * @param scriptUrl defines the url of the script to laod
  35538. * @param onSuccess defines the callback called when the script is loaded
  35539. * @param onError defines the callback to call if an error occurs
  35540. * @param scriptId defines the id of the script element
  35541. */
  35542. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35543. /**
  35544. * Load an asynchronous script (identified by an url). When the url returns, the
  35545. * content of this file is added into a new script element, attached to the DOM (body element)
  35546. * @param scriptUrl defines the url of the script to laod
  35547. * @param scriptId defines the id of the script element
  35548. * @returns a promise request object
  35549. */
  35550. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35551. /**
  35552. * Loads a file from a blob
  35553. * @param fileToLoad defines the blob to use
  35554. * @param callback defines the callback to call when data is loaded
  35555. * @param progressCallback defines the callback to call during loading process
  35556. * @returns a file request object
  35557. */
  35558. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35559. /**
  35560. * Reads a file from a File object
  35561. * @param file defines the file to load
  35562. * @param onSuccess defines the callback to call when data is loaded
  35563. * @param onProgress defines the callback to call during loading process
  35564. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35565. * @param onError defines the callback to call when an error occurs
  35566. * @returns a file request object
  35567. */
  35568. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35569. /**
  35570. * Creates a data url from a given string content
  35571. * @param content defines the content to convert
  35572. * @returns the new data url link
  35573. */
  35574. static FileAsURL(content: string): string;
  35575. /**
  35576. * Format the given number to a specific decimal format
  35577. * @param value defines the number to format
  35578. * @param decimals defines the number of decimals to use
  35579. * @returns the formatted string
  35580. */
  35581. static Format(value: number, decimals?: number): string;
  35582. /**
  35583. * Tries to copy an object by duplicating every property
  35584. * @param source defines the source object
  35585. * @param destination defines the target object
  35586. * @param doNotCopyList defines a list of properties to avoid
  35587. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35588. */
  35589. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35590. /**
  35591. * Gets a boolean indicating if the given object has no own property
  35592. * @param obj defines the object to test
  35593. * @returns true if object has no own property
  35594. */
  35595. static IsEmpty(obj: any): boolean;
  35596. /**
  35597. * Function used to register events at window level
  35598. * @param windowElement defines the Window object to use
  35599. * @param events defines the events to register
  35600. */
  35601. static RegisterTopRootEvents(windowElement: Window, events: {
  35602. name: string;
  35603. handler: Nullable<(e: FocusEvent) => any>;
  35604. }[]): void;
  35605. /**
  35606. * Function used to unregister events from window level
  35607. * @param windowElement defines the Window object to use
  35608. * @param events defines the events to unregister
  35609. */
  35610. static UnregisterTopRootEvents(windowElement: Window, events: {
  35611. name: string;
  35612. handler: Nullable<(e: FocusEvent) => any>;
  35613. }[]): void;
  35614. /**
  35615. * @ignore
  35616. */
  35617. static _ScreenshotCanvas: HTMLCanvasElement;
  35618. /**
  35619. * Dumps the current bound framebuffer
  35620. * @param width defines the rendering width
  35621. * @param height defines the rendering height
  35622. * @param engine defines the hosting engine
  35623. * @param successCallback defines the callback triggered once the data are available
  35624. * @param mimeType defines the mime type of the result
  35625. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35626. */
  35627. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35628. /**
  35629. * Converts the canvas data to blob.
  35630. * This acts as a polyfill for browsers not supporting the to blob function.
  35631. * @param canvas Defines the canvas to extract the data from
  35632. * @param successCallback Defines the callback triggered once the data are available
  35633. * @param mimeType Defines the mime type of the result
  35634. */
  35635. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35636. /**
  35637. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35638. * @param successCallback defines the callback triggered once the data are available
  35639. * @param mimeType defines the mime type of the result
  35640. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35641. */
  35642. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35643. /**
  35644. * Downloads a blob in the browser
  35645. * @param blob defines the blob to download
  35646. * @param fileName defines the name of the downloaded file
  35647. */
  35648. static Download(blob: Blob, fileName: string): void;
  35649. /**
  35650. * Captures a screenshot of the current rendering
  35651. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35652. * @param engine defines the rendering engine
  35653. * @param camera defines the source camera
  35654. * @param size This parameter can be set to a single number or to an object with the
  35655. * following (optional) properties: precision, width, height. If a single number is passed,
  35656. * it will be used for both width and height. If an object is passed, the screenshot size
  35657. * will be derived from the parameters. The precision property is a multiplier allowing
  35658. * rendering at a higher or lower resolution
  35659. * @param successCallback defines the callback receives a single parameter which contains the
  35660. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35661. * src parameter of an <img> to display it
  35662. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35663. * Check your browser for supported MIME types
  35664. */
  35665. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35666. /**
  35667. * Captures a screenshot of the current rendering
  35668. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35669. * @param engine defines the rendering engine
  35670. * @param camera defines the source camera
  35671. * @param size This parameter can be set to a single number or to an object with the
  35672. * following (optional) properties: precision, width, height. If a single number is passed,
  35673. * it will be used for both width and height. If an object is passed, the screenshot size
  35674. * will be derived from the parameters. The precision property is a multiplier allowing
  35675. * rendering at a higher or lower resolution
  35676. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35677. * Check your browser for supported MIME types
  35678. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35679. * to the src parameter of an <img> to display it
  35680. */
  35681. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35682. /**
  35683. * Generates an image screenshot from the specified camera.
  35684. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35685. * @param engine The engine to use for rendering
  35686. * @param camera The camera to use for rendering
  35687. * @param size This parameter can be set to a single number or to an object with the
  35688. * following (optional) properties: precision, width, height. If a single number is passed,
  35689. * it will be used for both width and height. If an object is passed, the screenshot size
  35690. * will be derived from the parameters. The precision property is a multiplier allowing
  35691. * rendering at a higher or lower resolution
  35692. * @param successCallback The callback receives a single parameter which contains the
  35693. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35694. * src parameter of an <img> to display it
  35695. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35696. * Check your browser for supported MIME types
  35697. * @param samples Texture samples (default: 1)
  35698. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35699. * @param fileName A name for for the downloaded file.
  35700. */
  35701. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35702. /**
  35703. * Generates an image screenshot from the specified camera.
  35704. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35705. * @param engine The engine to use for rendering
  35706. * @param camera The camera to use for rendering
  35707. * @param size This parameter can be set to a single number or to an object with the
  35708. * following (optional) properties: precision, width, height. If a single number is passed,
  35709. * it will be used for both width and height. If an object is passed, the screenshot size
  35710. * will be derived from the parameters. The precision property is a multiplier allowing
  35711. * rendering at a higher or lower resolution
  35712. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35713. * Check your browser for supported MIME types
  35714. * @param samples Texture samples (default: 1)
  35715. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35716. * @param fileName A name for for the downloaded file.
  35717. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35718. * to the src parameter of an <img> to display it
  35719. */
  35720. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35721. /**
  35722. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35723. * Be aware Math.random() could cause collisions, but:
  35724. * "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"
  35725. * @returns a pseudo random id
  35726. */
  35727. static RandomId(): string;
  35728. /**
  35729. * Test if the given uri is a base64 string
  35730. * @param uri The uri to test
  35731. * @return True if the uri is a base64 string or false otherwise
  35732. */
  35733. static IsBase64(uri: string): boolean;
  35734. /**
  35735. * Decode the given base64 uri.
  35736. * @param uri The uri to decode
  35737. * @return The decoded base64 data.
  35738. */
  35739. static DecodeBase64(uri: string): ArrayBuffer;
  35740. /**
  35741. * Gets the absolute url.
  35742. * @param url the input url
  35743. * @return the absolute url
  35744. */
  35745. static GetAbsoluteUrl(url: string): string;
  35746. /**
  35747. * No log
  35748. */
  35749. static readonly NoneLogLevel: number;
  35750. /**
  35751. * Only message logs
  35752. */
  35753. static readonly MessageLogLevel: number;
  35754. /**
  35755. * Only warning logs
  35756. */
  35757. static readonly WarningLogLevel: number;
  35758. /**
  35759. * Only error logs
  35760. */
  35761. static readonly ErrorLogLevel: number;
  35762. /**
  35763. * All logs
  35764. */
  35765. static readonly AllLogLevel: number;
  35766. /**
  35767. * Gets a value indicating the number of loading errors
  35768. * @ignorenaming
  35769. */
  35770. static get errorsCount(): number;
  35771. /**
  35772. * Callback called when a new log is added
  35773. */
  35774. static OnNewCacheEntry: (entry: string) => void;
  35775. /**
  35776. * Log a message to the console
  35777. * @param message defines the message to log
  35778. */
  35779. static Log(message: string): void;
  35780. /**
  35781. * Write a warning message to the console
  35782. * @param message defines the message to log
  35783. */
  35784. static Warn(message: string): void;
  35785. /**
  35786. * Write an error message to the console
  35787. * @param message defines the message to log
  35788. */
  35789. static Error(message: string): void;
  35790. /**
  35791. * Gets current log cache (list of logs)
  35792. */
  35793. static get LogCache(): string;
  35794. /**
  35795. * Clears the log cache
  35796. */
  35797. static ClearLogCache(): void;
  35798. /**
  35799. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35800. */
  35801. static set LogLevels(level: number);
  35802. /**
  35803. * Checks if the window object exists
  35804. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35805. */
  35806. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35807. /**
  35808. * No performance log
  35809. */
  35810. static readonly PerformanceNoneLogLevel: number;
  35811. /**
  35812. * Use user marks to log performance
  35813. */
  35814. static readonly PerformanceUserMarkLogLevel: number;
  35815. /**
  35816. * Log performance to the console
  35817. */
  35818. static readonly PerformanceConsoleLogLevel: number;
  35819. private static _performance;
  35820. /**
  35821. * Sets the current performance log level
  35822. */
  35823. static set PerformanceLogLevel(level: number);
  35824. private static _StartPerformanceCounterDisabled;
  35825. private static _EndPerformanceCounterDisabled;
  35826. private static _StartUserMark;
  35827. private static _EndUserMark;
  35828. private static _StartPerformanceConsole;
  35829. private static _EndPerformanceConsole;
  35830. /**
  35831. * Starts a performance counter
  35832. */
  35833. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35834. /**
  35835. * Ends a specific performance coutner
  35836. */
  35837. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35838. /**
  35839. * Gets either window.performance.now() if supported or Date.now() else
  35840. */
  35841. static get Now(): number;
  35842. /**
  35843. * This method will return the name of the class used to create the instance of the given object.
  35844. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35845. * @param object the object to get the class name from
  35846. * @param isType defines if the object is actually a type
  35847. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35848. */
  35849. static GetClassName(object: any, isType?: boolean): string;
  35850. /**
  35851. * Gets the first element of an array satisfying a given predicate
  35852. * @param array defines the array to browse
  35853. * @param predicate defines the predicate to use
  35854. * @returns null if not found or the element
  35855. */
  35856. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35857. /**
  35858. * This method will return the name of the full name of the class, including its owning module (if any).
  35859. * 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).
  35860. * @param object the object to get the class name from
  35861. * @param isType defines if the object is actually a type
  35862. * @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.
  35863. * @ignorenaming
  35864. */
  35865. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35866. /**
  35867. * Returns a promise that resolves after the given amount of time.
  35868. * @param delay Number of milliseconds to delay
  35869. * @returns Promise that resolves after the given amount of time
  35870. */
  35871. static DelayAsync(delay: number): Promise<void>;
  35872. /**
  35873. * Utility function to detect if the current user agent is Safari
  35874. * @returns whether or not the current user agent is safari
  35875. */
  35876. static IsSafari(): boolean;
  35877. }
  35878. /**
  35879. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35880. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35881. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35882. * @param name The name of the class, case should be preserved
  35883. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35884. */
  35885. export function className(name: string, module?: string): (target: Object) => void;
  35886. /**
  35887. * An implementation of a loop for asynchronous functions.
  35888. */
  35889. export class AsyncLoop {
  35890. /**
  35891. * Defines the number of iterations for the loop
  35892. */
  35893. iterations: number;
  35894. /**
  35895. * Defines the current index of the loop.
  35896. */
  35897. index: number;
  35898. private _done;
  35899. private _fn;
  35900. private _successCallback;
  35901. /**
  35902. * Constructor.
  35903. * @param iterations the number of iterations.
  35904. * @param func the function to run each iteration
  35905. * @param successCallback the callback that will be called upon succesful execution
  35906. * @param offset starting offset.
  35907. */
  35908. constructor(
  35909. /**
  35910. * Defines the number of iterations for the loop
  35911. */
  35912. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35913. /**
  35914. * Execute the next iteration. Must be called after the last iteration was finished.
  35915. */
  35916. executeNext(): void;
  35917. /**
  35918. * Break the loop and run the success callback.
  35919. */
  35920. breakLoop(): void;
  35921. /**
  35922. * Create and run an async loop.
  35923. * @param iterations the number of iterations.
  35924. * @param fn the function to run each iteration
  35925. * @param successCallback the callback that will be called upon succesful execution
  35926. * @param offset starting offset.
  35927. * @returns the created async loop object
  35928. */
  35929. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35930. /**
  35931. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35932. * @param iterations total number of iterations
  35933. * @param syncedIterations number of synchronous iterations in each async iteration.
  35934. * @param fn the function to call each iteration.
  35935. * @param callback a success call back that will be called when iterating stops.
  35936. * @param breakFunction a break condition (optional)
  35937. * @param timeout timeout settings for the setTimeout function. default - 0.
  35938. * @returns the created async loop object
  35939. */
  35940. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35941. }
  35942. }
  35943. declare module "babylonjs/Misc/stringDictionary" {
  35944. import { Nullable } from "babylonjs/types";
  35945. /**
  35946. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35947. * The underlying implementation relies on an associative array to ensure the best performances.
  35948. * The value can be anything including 'null' but except 'undefined'
  35949. */
  35950. export class StringDictionary<T> {
  35951. /**
  35952. * This will clear this dictionary and copy the content from the 'source' one.
  35953. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35954. * @param source the dictionary to take the content from and copy to this dictionary
  35955. */
  35956. copyFrom(source: StringDictionary<T>): void;
  35957. /**
  35958. * Get a value based from its key
  35959. * @param key the given key to get the matching value from
  35960. * @return the value if found, otherwise undefined is returned
  35961. */
  35962. get(key: string): T | undefined;
  35963. /**
  35964. * Get a value from its key or add it if it doesn't exist.
  35965. * This method will ensure you that a given key/data will be present in the dictionary.
  35966. * @param key the given key to get the matching value from
  35967. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35968. * The factory will only be invoked if there's no data for the given key.
  35969. * @return the value corresponding to the key.
  35970. */
  35971. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35972. /**
  35973. * Get a value from its key if present in the dictionary otherwise add it
  35974. * @param key the key to get the value from
  35975. * @param val if there's no such key/value pair in the dictionary add it with this value
  35976. * @return the value corresponding to the key
  35977. */
  35978. getOrAdd(key: string, val: T): T;
  35979. /**
  35980. * Check if there's a given key in the dictionary
  35981. * @param key the key to check for
  35982. * @return true if the key is present, false otherwise
  35983. */
  35984. contains(key: string): boolean;
  35985. /**
  35986. * Add a new key and its corresponding value
  35987. * @param key the key to add
  35988. * @param value the value corresponding to the key
  35989. * @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
  35990. */
  35991. add(key: string, value: T): boolean;
  35992. /**
  35993. * Update a specific value associated to a key
  35994. * @param key defines the key to use
  35995. * @param value defines the value to store
  35996. * @returns true if the value was updated (or false if the key was not found)
  35997. */
  35998. set(key: string, value: T): boolean;
  35999. /**
  36000. * Get the element of the given key and remove it from the dictionary
  36001. * @param key defines the key to search
  36002. * @returns the value associated with the key or null if not found
  36003. */
  36004. getAndRemove(key: string): Nullable<T>;
  36005. /**
  36006. * Remove a key/value from the dictionary.
  36007. * @param key the key to remove
  36008. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36009. */
  36010. remove(key: string): boolean;
  36011. /**
  36012. * Clear the whole content of the dictionary
  36013. */
  36014. clear(): void;
  36015. /**
  36016. * Gets the current count
  36017. */
  36018. get count(): number;
  36019. /**
  36020. * Execute a callback on each key/val of the dictionary.
  36021. * Note that you can remove any element in this dictionary in the callback implementation
  36022. * @param callback the callback to execute on a given key/value pair
  36023. */
  36024. forEach(callback: (key: string, val: T) => void): void;
  36025. /**
  36026. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36027. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36028. * Note that you can remove any element in this dictionary in the callback implementation
  36029. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36030. * @returns the first item
  36031. */
  36032. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36033. private _count;
  36034. private _data;
  36035. }
  36036. }
  36037. declare module "babylonjs/Collisions/collisionCoordinator" {
  36038. import { Nullable } from "babylonjs/types";
  36039. import { Scene } from "babylonjs/scene";
  36040. import { Vector3 } from "babylonjs/Maths/math.vector";
  36041. import { Collider } from "babylonjs/Collisions/collider";
  36042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36043. /** @hidden */
  36044. export interface ICollisionCoordinator {
  36045. createCollider(): Collider;
  36046. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36047. init(scene: Scene): void;
  36048. }
  36049. /** @hidden */
  36050. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36051. private _scene;
  36052. private _scaledPosition;
  36053. private _scaledVelocity;
  36054. private _finalPosition;
  36055. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36056. createCollider(): Collider;
  36057. init(scene: Scene): void;
  36058. private _collideWithWorld;
  36059. }
  36060. }
  36061. declare module "babylonjs/Inputs/scene.inputManager" {
  36062. import { Nullable } from "babylonjs/types";
  36063. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36064. import { Vector2 } from "babylonjs/Maths/math.vector";
  36065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36066. import { Scene } from "babylonjs/scene";
  36067. /**
  36068. * Class used to manage all inputs for the scene.
  36069. */
  36070. export class InputManager {
  36071. /** The distance in pixel that you have to move to prevent some events */
  36072. static DragMovementThreshold: number;
  36073. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36074. static LongPressDelay: number;
  36075. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36076. static DoubleClickDelay: number;
  36077. /** If you need to check double click without raising a single click at first click, enable this flag */
  36078. static ExclusiveDoubleClickMode: boolean;
  36079. private _wheelEventName;
  36080. private _onPointerMove;
  36081. private _onPointerDown;
  36082. private _onPointerUp;
  36083. private _initClickEvent;
  36084. private _initActionManager;
  36085. private _delayedSimpleClick;
  36086. private _delayedSimpleClickTimeout;
  36087. private _previousDelayedSimpleClickTimeout;
  36088. private _meshPickProceed;
  36089. private _previousButtonPressed;
  36090. private _currentPickResult;
  36091. private _previousPickResult;
  36092. private _totalPointersPressed;
  36093. private _doubleClickOccured;
  36094. private _pointerOverMesh;
  36095. private _pickedDownMesh;
  36096. private _pickedUpMesh;
  36097. private _pointerX;
  36098. private _pointerY;
  36099. private _unTranslatedPointerX;
  36100. private _unTranslatedPointerY;
  36101. private _startingPointerPosition;
  36102. private _previousStartingPointerPosition;
  36103. private _startingPointerTime;
  36104. private _previousStartingPointerTime;
  36105. private _pointerCaptures;
  36106. private _onKeyDown;
  36107. private _onKeyUp;
  36108. private _onCanvasFocusObserver;
  36109. private _onCanvasBlurObserver;
  36110. private _scene;
  36111. /**
  36112. * Creates a new InputManager
  36113. * @param scene defines the hosting scene
  36114. */
  36115. constructor(scene: Scene);
  36116. /**
  36117. * Gets the mesh that is currently under the pointer
  36118. */
  36119. get meshUnderPointer(): Nullable<AbstractMesh>;
  36120. /**
  36121. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36122. */
  36123. get unTranslatedPointer(): Vector2;
  36124. /**
  36125. * Gets or sets the current on-screen X position of the pointer
  36126. */
  36127. get pointerX(): number;
  36128. set pointerX(value: number);
  36129. /**
  36130. * Gets or sets the current on-screen Y position of the pointer
  36131. */
  36132. get pointerY(): number;
  36133. set pointerY(value: number);
  36134. private _updatePointerPosition;
  36135. private _processPointerMove;
  36136. private _setRayOnPointerInfo;
  36137. private _checkPrePointerObservable;
  36138. /**
  36139. * Use this method to simulate a pointer move on a mesh
  36140. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36141. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36142. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36143. */
  36144. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36145. /**
  36146. * Use this method to simulate a pointer down on a mesh
  36147. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36148. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36149. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36150. */
  36151. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36152. private _processPointerDown;
  36153. /** @hidden */
  36154. _isPointerSwiping(): boolean;
  36155. /**
  36156. * Use this method to simulate a pointer up on a mesh
  36157. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36158. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36159. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36160. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36161. */
  36162. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36163. private _processPointerUp;
  36164. /**
  36165. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36166. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36167. * @returns true if the pointer was captured
  36168. */
  36169. isPointerCaptured(pointerId?: number): boolean;
  36170. /**
  36171. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36172. * @param attachUp defines if you want to attach events to pointerup
  36173. * @param attachDown defines if you want to attach events to pointerdown
  36174. * @param attachMove defines if you want to attach events to pointermove
  36175. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36176. */
  36177. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36178. /**
  36179. * Detaches all event handlers
  36180. */
  36181. detachControl(): void;
  36182. /**
  36183. * Force the value of meshUnderPointer
  36184. * @param mesh defines the mesh to use
  36185. */
  36186. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36187. /**
  36188. * Gets the mesh under the pointer
  36189. * @returns a Mesh or null if no mesh is under the pointer
  36190. */
  36191. getPointerOverMesh(): Nullable<AbstractMesh>;
  36192. }
  36193. }
  36194. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36195. /**
  36196. * Helper class used to generate session unique ID
  36197. */
  36198. export class UniqueIdGenerator {
  36199. private static _UniqueIdCounter;
  36200. /**
  36201. * Gets an unique (relatively to the current scene) Id
  36202. */
  36203. static get UniqueId(): number;
  36204. }
  36205. }
  36206. declare module "babylonjs/Animations/animationGroup" {
  36207. import { Animatable } from "babylonjs/Animations/animatable";
  36208. import { Animation } from "babylonjs/Animations/animation";
  36209. import { Scene, IDisposable } from "babylonjs/scene";
  36210. import { Observable } from "babylonjs/Misc/observable";
  36211. import { Nullable } from "babylonjs/types";
  36212. import "babylonjs/Animations/animatable";
  36213. /**
  36214. * This class defines the direct association between an animation and a target
  36215. */
  36216. export class TargetedAnimation {
  36217. /**
  36218. * Animation to perform
  36219. */
  36220. animation: Animation;
  36221. /**
  36222. * Target to animate
  36223. */
  36224. target: any;
  36225. /**
  36226. * Serialize the object
  36227. * @returns the JSON object representing the current entity
  36228. */
  36229. serialize(): any;
  36230. }
  36231. /**
  36232. * Use this class to create coordinated animations on multiple targets
  36233. */
  36234. export class AnimationGroup implements IDisposable {
  36235. /** The name of the animation group */
  36236. name: string;
  36237. private _scene;
  36238. private _targetedAnimations;
  36239. private _animatables;
  36240. private _from;
  36241. private _to;
  36242. private _isStarted;
  36243. private _isPaused;
  36244. private _speedRatio;
  36245. private _loopAnimation;
  36246. private _isAdditive;
  36247. /**
  36248. * Gets or sets the unique id of the node
  36249. */
  36250. uniqueId: number;
  36251. /**
  36252. * This observable will notify when one animation have ended
  36253. */
  36254. onAnimationEndObservable: Observable<TargetedAnimation>;
  36255. /**
  36256. * Observer raised when one animation loops
  36257. */
  36258. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36259. /**
  36260. * Observer raised when all animations have looped
  36261. */
  36262. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36263. /**
  36264. * This observable will notify when all animations have ended.
  36265. */
  36266. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36267. /**
  36268. * This observable will notify when all animations have paused.
  36269. */
  36270. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36271. /**
  36272. * This observable will notify when all animations are playing.
  36273. */
  36274. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36275. /**
  36276. * Gets the first frame
  36277. */
  36278. get from(): number;
  36279. /**
  36280. * Gets the last frame
  36281. */
  36282. get to(): number;
  36283. /**
  36284. * Define if the animations are started
  36285. */
  36286. get isStarted(): boolean;
  36287. /**
  36288. * Gets a value indicating that the current group is playing
  36289. */
  36290. get isPlaying(): boolean;
  36291. /**
  36292. * Gets or sets the speed ratio to use for all animations
  36293. */
  36294. get speedRatio(): number;
  36295. /**
  36296. * Gets or sets the speed ratio to use for all animations
  36297. */
  36298. set speedRatio(value: number);
  36299. /**
  36300. * Gets or sets if all animations should loop or not
  36301. */
  36302. get loopAnimation(): boolean;
  36303. set loopAnimation(value: boolean);
  36304. /**
  36305. * Gets or sets if all animations should be evaluated additively
  36306. */
  36307. get isAdditive(): boolean;
  36308. set isAdditive(value: boolean);
  36309. /**
  36310. * Gets the targeted animations for this animation group
  36311. */
  36312. get targetedAnimations(): Array<TargetedAnimation>;
  36313. /**
  36314. * returning the list of animatables controlled by this animation group.
  36315. */
  36316. get animatables(): Array<Animatable>;
  36317. /**
  36318. * Instantiates a new Animation Group.
  36319. * This helps managing several animations at once.
  36320. * @see http://doc.babylonjs.com/how_to/group
  36321. * @param name Defines the name of the group
  36322. * @param scene Defines the scene the group belongs to
  36323. */
  36324. constructor(
  36325. /** The name of the animation group */
  36326. name: string, scene?: Nullable<Scene>);
  36327. /**
  36328. * Add an animation (with its target) in the group
  36329. * @param animation defines the animation we want to add
  36330. * @param target defines the target of the animation
  36331. * @returns the TargetedAnimation object
  36332. */
  36333. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36334. /**
  36335. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36336. * It can add constant keys at begin or end
  36337. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36338. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36339. * @returns the animation group
  36340. */
  36341. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36342. private _animationLoopCount;
  36343. private _animationLoopFlags;
  36344. private _processLoop;
  36345. /**
  36346. * Start all animations on given targets
  36347. * @param loop defines if animations must loop
  36348. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36349. * @param from defines the from key (optional)
  36350. * @param to defines the to key (optional)
  36351. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36352. * @returns the current animation group
  36353. */
  36354. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36355. /**
  36356. * Pause all animations
  36357. * @returns the animation group
  36358. */
  36359. pause(): AnimationGroup;
  36360. /**
  36361. * Play all animations to initial state
  36362. * This function will start() the animations if they were not started or will restart() them if they were paused
  36363. * @param loop defines if animations must loop
  36364. * @returns the animation group
  36365. */
  36366. play(loop?: boolean): AnimationGroup;
  36367. /**
  36368. * Reset all animations to initial state
  36369. * @returns the animation group
  36370. */
  36371. reset(): AnimationGroup;
  36372. /**
  36373. * Restart animations from key 0
  36374. * @returns the animation group
  36375. */
  36376. restart(): AnimationGroup;
  36377. /**
  36378. * Stop all animations
  36379. * @returns the animation group
  36380. */
  36381. stop(): AnimationGroup;
  36382. /**
  36383. * Set animation weight for all animatables
  36384. * @param weight defines the weight to use
  36385. * @return the animationGroup
  36386. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36387. */
  36388. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36389. /**
  36390. * Synchronize and normalize all animatables with a source animatable
  36391. * @param root defines the root animatable to synchronize with
  36392. * @return the animationGroup
  36393. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36394. */
  36395. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36396. /**
  36397. * Goes to a specific frame in this animation group
  36398. * @param frame the frame number to go to
  36399. * @return the animationGroup
  36400. */
  36401. goToFrame(frame: number): AnimationGroup;
  36402. /**
  36403. * Dispose all associated resources
  36404. */
  36405. dispose(): void;
  36406. private _checkAnimationGroupEnded;
  36407. /**
  36408. * Clone the current animation group and returns a copy
  36409. * @param newName defines the name of the new group
  36410. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36411. * @returns the new aniamtion group
  36412. */
  36413. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36414. /**
  36415. * Serializes the animationGroup to an object
  36416. * @returns Serialized object
  36417. */
  36418. serialize(): any;
  36419. /**
  36420. * Returns a new AnimationGroup object parsed from the source provided.
  36421. * @param parsedAnimationGroup defines the source
  36422. * @param scene defines the scene that will receive the animationGroup
  36423. * @returns a new AnimationGroup
  36424. */
  36425. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36426. /**
  36427. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36428. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36429. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36430. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36431. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36432. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36433. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36434. */
  36435. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36436. /**
  36437. * Returns the string "AnimationGroup"
  36438. * @returns "AnimationGroup"
  36439. */
  36440. getClassName(): string;
  36441. /**
  36442. * Creates a detailled string about the object
  36443. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36444. * @returns a string representing the object
  36445. */
  36446. toString(fullDetails?: boolean): string;
  36447. }
  36448. }
  36449. declare module "babylonjs/scene" {
  36450. import { Nullable } from "babylonjs/types";
  36451. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36452. import { Observable } from "babylonjs/Misc/observable";
  36453. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36454. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36455. import { Geometry } from "babylonjs/Meshes/geometry";
  36456. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36457. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36459. import { Mesh } from "babylonjs/Meshes/mesh";
  36460. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36461. import { Bone } from "babylonjs/Bones/bone";
  36462. import { Skeleton } from "babylonjs/Bones/skeleton";
  36463. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36464. import { Camera } from "babylonjs/Cameras/camera";
  36465. import { AbstractScene } from "babylonjs/abstractScene";
  36466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36467. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36468. import { Material } from "babylonjs/Materials/material";
  36469. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36470. import { Effect } from "babylonjs/Materials/effect";
  36471. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36472. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36473. import { Light } from "babylonjs/Lights/light";
  36474. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36475. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36476. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36477. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36478. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36479. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36480. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36481. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36482. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36483. import { Engine } from "babylonjs/Engines/engine";
  36484. import { Node } from "babylonjs/node";
  36485. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36486. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36487. import { WebRequest } from "babylonjs/Misc/webRequest";
  36488. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36489. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36490. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36491. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36492. import { Plane } from "babylonjs/Maths/math.plane";
  36493. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36494. import { Ray } from "babylonjs/Culling/ray";
  36495. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36496. import { Animation } from "babylonjs/Animations/animation";
  36497. import { Animatable } from "babylonjs/Animations/animatable";
  36498. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36499. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36500. import { Collider } from "babylonjs/Collisions/collider";
  36501. /**
  36502. * Define an interface for all classes that will hold resources
  36503. */
  36504. export interface IDisposable {
  36505. /**
  36506. * Releases all held resources
  36507. */
  36508. dispose(): void;
  36509. }
  36510. /** Interface defining initialization parameters for Scene class */
  36511. export interface SceneOptions {
  36512. /**
  36513. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36514. * It will improve performance when the number of geometries becomes important.
  36515. */
  36516. useGeometryUniqueIdsMap?: boolean;
  36517. /**
  36518. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36519. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36520. */
  36521. useMaterialMeshMap?: boolean;
  36522. /**
  36523. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36524. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36525. */
  36526. useClonedMeshMap?: boolean;
  36527. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36528. virtual?: boolean;
  36529. }
  36530. /**
  36531. * Represents a scene to be rendered by the engine.
  36532. * @see http://doc.babylonjs.com/features/scene
  36533. */
  36534. export class Scene extends AbstractScene implements IAnimatable {
  36535. /** The fog is deactivated */
  36536. static readonly FOGMODE_NONE: number;
  36537. /** The fog density is following an exponential function */
  36538. static readonly FOGMODE_EXP: number;
  36539. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36540. static readonly FOGMODE_EXP2: number;
  36541. /** The fog density is following a linear function. */
  36542. static readonly FOGMODE_LINEAR: number;
  36543. /**
  36544. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36545. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36546. */
  36547. static MinDeltaTime: number;
  36548. /**
  36549. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36550. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36551. */
  36552. static MaxDeltaTime: number;
  36553. /**
  36554. * Factory used to create the default material.
  36555. * @param name The name of the material to create
  36556. * @param scene The scene to create the material for
  36557. * @returns The default material
  36558. */
  36559. static DefaultMaterialFactory(scene: Scene): Material;
  36560. /**
  36561. * Factory used to create the a collision coordinator.
  36562. * @returns The collision coordinator
  36563. */
  36564. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36565. /** @hidden */
  36566. _inputManager: InputManager;
  36567. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36568. cameraToUseForPointers: Nullable<Camera>;
  36569. /** @hidden */
  36570. readonly _isScene: boolean;
  36571. /** @hidden */
  36572. _blockEntityCollection: boolean;
  36573. /**
  36574. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36575. */
  36576. autoClear: boolean;
  36577. /**
  36578. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36579. */
  36580. autoClearDepthAndStencil: boolean;
  36581. /**
  36582. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36583. */
  36584. clearColor: Color4;
  36585. /**
  36586. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36587. */
  36588. ambientColor: Color3;
  36589. /**
  36590. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36591. * It should only be one of the following (if not the default embedded one):
  36592. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36593. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36594. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36595. * The material properties need to be setup according to the type of texture in use.
  36596. */
  36597. environmentBRDFTexture: BaseTexture;
  36598. /** @hidden */
  36599. protected _environmentTexture: Nullable<BaseTexture>;
  36600. /**
  36601. * Texture used in all pbr material as the reflection texture.
  36602. * As in the majority of the scene they are the same (exception for multi room and so on),
  36603. * this is easier to reference from here than from all the materials.
  36604. */
  36605. get environmentTexture(): Nullable<BaseTexture>;
  36606. /**
  36607. * Texture used in all pbr material as the reflection texture.
  36608. * As in the majority of the scene they are the same (exception for multi room and so on),
  36609. * this is easier to set here than in all the materials.
  36610. */
  36611. set environmentTexture(value: Nullable<BaseTexture>);
  36612. /** @hidden */
  36613. protected _environmentIntensity: number;
  36614. /**
  36615. * Intensity of the environment in all pbr material.
  36616. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36617. * As in the majority of the scene they are the same (exception for multi room and so on),
  36618. * this is easier to reference from here than from all the materials.
  36619. */
  36620. get environmentIntensity(): number;
  36621. /**
  36622. * Intensity of the environment in all pbr material.
  36623. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36624. * As in the majority of the scene they are the same (exception for multi room and so on),
  36625. * this is easier to set here than in all the materials.
  36626. */
  36627. set environmentIntensity(value: number);
  36628. /** @hidden */
  36629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36630. /**
  36631. * Default image processing configuration used either in the rendering
  36632. * Forward main pass or through the imageProcessingPostProcess if present.
  36633. * As in the majority of the scene they are the same (exception for multi camera),
  36634. * this is easier to reference from here than from all the materials and post process.
  36635. *
  36636. * No setter as we it is a shared configuration, you can set the values instead.
  36637. */
  36638. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36639. private _forceWireframe;
  36640. /**
  36641. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36642. */
  36643. set forceWireframe(value: boolean);
  36644. get forceWireframe(): boolean;
  36645. private _skipFrustumClipping;
  36646. /**
  36647. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36648. */
  36649. set skipFrustumClipping(value: boolean);
  36650. get skipFrustumClipping(): boolean;
  36651. private _forcePointsCloud;
  36652. /**
  36653. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36654. */
  36655. set forcePointsCloud(value: boolean);
  36656. get forcePointsCloud(): boolean;
  36657. /**
  36658. * Gets or sets the active clipplane 1
  36659. */
  36660. clipPlane: Nullable<Plane>;
  36661. /**
  36662. * Gets or sets the active clipplane 2
  36663. */
  36664. clipPlane2: Nullable<Plane>;
  36665. /**
  36666. * Gets or sets the active clipplane 3
  36667. */
  36668. clipPlane3: Nullable<Plane>;
  36669. /**
  36670. * Gets or sets the active clipplane 4
  36671. */
  36672. clipPlane4: Nullable<Plane>;
  36673. /**
  36674. * Gets or sets the active clipplane 5
  36675. */
  36676. clipPlane5: Nullable<Plane>;
  36677. /**
  36678. * Gets or sets the active clipplane 6
  36679. */
  36680. clipPlane6: Nullable<Plane>;
  36681. /**
  36682. * Gets or sets a boolean indicating if animations are enabled
  36683. */
  36684. animationsEnabled: boolean;
  36685. private _animationPropertiesOverride;
  36686. /**
  36687. * Gets or sets the animation properties override
  36688. */
  36689. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36690. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36691. /**
  36692. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36693. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36694. */
  36695. useConstantAnimationDeltaTime: boolean;
  36696. /**
  36697. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36698. * Please note that it requires to run a ray cast through the scene on every frame
  36699. */
  36700. constantlyUpdateMeshUnderPointer: boolean;
  36701. /**
  36702. * Defines the HTML cursor to use when hovering over interactive elements
  36703. */
  36704. hoverCursor: string;
  36705. /**
  36706. * Defines the HTML default cursor to use (empty by default)
  36707. */
  36708. defaultCursor: string;
  36709. /**
  36710. * Defines whether cursors are handled by the scene.
  36711. */
  36712. doNotHandleCursors: boolean;
  36713. /**
  36714. * This is used to call preventDefault() on pointer down
  36715. * in order to block unwanted artifacts like system double clicks
  36716. */
  36717. preventDefaultOnPointerDown: boolean;
  36718. /**
  36719. * This is used to call preventDefault() on pointer up
  36720. * in order to block unwanted artifacts like system double clicks
  36721. */
  36722. preventDefaultOnPointerUp: boolean;
  36723. /**
  36724. * Gets or sets user defined metadata
  36725. */
  36726. metadata: any;
  36727. /**
  36728. * For internal use only. Please do not use.
  36729. */
  36730. reservedDataStore: any;
  36731. /**
  36732. * Gets the name of the plugin used to load this scene (null by default)
  36733. */
  36734. loadingPluginName: string;
  36735. /**
  36736. * Use this array to add regular expressions used to disable offline support for specific urls
  36737. */
  36738. disableOfflineSupportExceptionRules: RegExp[];
  36739. /**
  36740. * An event triggered when the scene is disposed.
  36741. */
  36742. onDisposeObservable: Observable<Scene>;
  36743. private _onDisposeObserver;
  36744. /** Sets a function to be executed when this scene is disposed. */
  36745. set onDispose(callback: () => void);
  36746. /**
  36747. * An event triggered before rendering the scene (right after animations and physics)
  36748. */
  36749. onBeforeRenderObservable: Observable<Scene>;
  36750. private _onBeforeRenderObserver;
  36751. /** Sets a function to be executed before rendering this scene */
  36752. set beforeRender(callback: Nullable<() => void>);
  36753. /**
  36754. * An event triggered after rendering the scene
  36755. */
  36756. onAfterRenderObservable: Observable<Scene>;
  36757. /**
  36758. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36759. */
  36760. onAfterRenderCameraObservable: Observable<Camera>;
  36761. private _onAfterRenderObserver;
  36762. /** Sets a function to be executed after rendering this scene */
  36763. set afterRender(callback: Nullable<() => void>);
  36764. /**
  36765. * An event triggered before animating the scene
  36766. */
  36767. onBeforeAnimationsObservable: Observable<Scene>;
  36768. /**
  36769. * An event triggered after animations processing
  36770. */
  36771. onAfterAnimationsObservable: Observable<Scene>;
  36772. /**
  36773. * An event triggered before draw calls are ready to be sent
  36774. */
  36775. onBeforeDrawPhaseObservable: Observable<Scene>;
  36776. /**
  36777. * An event triggered after draw calls have been sent
  36778. */
  36779. onAfterDrawPhaseObservable: Observable<Scene>;
  36780. /**
  36781. * An event triggered when the scene is ready
  36782. */
  36783. onReadyObservable: Observable<Scene>;
  36784. /**
  36785. * An event triggered before rendering a camera
  36786. */
  36787. onBeforeCameraRenderObservable: Observable<Camera>;
  36788. private _onBeforeCameraRenderObserver;
  36789. /** Sets a function to be executed before rendering a camera*/
  36790. set beforeCameraRender(callback: () => void);
  36791. /**
  36792. * An event triggered after rendering a camera
  36793. */
  36794. onAfterCameraRenderObservable: Observable<Camera>;
  36795. private _onAfterCameraRenderObserver;
  36796. /** Sets a function to be executed after rendering a camera*/
  36797. set afterCameraRender(callback: () => void);
  36798. /**
  36799. * An event triggered when active meshes evaluation is about to start
  36800. */
  36801. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36802. /**
  36803. * An event triggered when active meshes evaluation is done
  36804. */
  36805. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36806. /**
  36807. * An event triggered when particles rendering is about to start
  36808. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36809. */
  36810. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36811. /**
  36812. * An event triggered when particles rendering is done
  36813. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36814. */
  36815. onAfterParticlesRenderingObservable: Observable<Scene>;
  36816. /**
  36817. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36818. */
  36819. onDataLoadedObservable: Observable<Scene>;
  36820. /**
  36821. * An event triggered when a camera is created
  36822. */
  36823. onNewCameraAddedObservable: Observable<Camera>;
  36824. /**
  36825. * An event triggered when a camera is removed
  36826. */
  36827. onCameraRemovedObservable: Observable<Camera>;
  36828. /**
  36829. * An event triggered when a light is created
  36830. */
  36831. onNewLightAddedObservable: Observable<Light>;
  36832. /**
  36833. * An event triggered when a light is removed
  36834. */
  36835. onLightRemovedObservable: Observable<Light>;
  36836. /**
  36837. * An event triggered when a geometry is created
  36838. */
  36839. onNewGeometryAddedObservable: Observable<Geometry>;
  36840. /**
  36841. * An event triggered when a geometry is removed
  36842. */
  36843. onGeometryRemovedObservable: Observable<Geometry>;
  36844. /**
  36845. * An event triggered when a transform node is created
  36846. */
  36847. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36848. /**
  36849. * An event triggered when a transform node is removed
  36850. */
  36851. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36852. /**
  36853. * An event triggered when a mesh is created
  36854. */
  36855. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36856. /**
  36857. * An event triggered when a mesh is removed
  36858. */
  36859. onMeshRemovedObservable: Observable<AbstractMesh>;
  36860. /**
  36861. * An event triggered when a skeleton is created
  36862. */
  36863. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36864. /**
  36865. * An event triggered when a skeleton is removed
  36866. */
  36867. onSkeletonRemovedObservable: Observable<Skeleton>;
  36868. /**
  36869. * An event triggered when a material is created
  36870. */
  36871. onNewMaterialAddedObservable: Observable<Material>;
  36872. /**
  36873. * An event triggered when a material is removed
  36874. */
  36875. onMaterialRemovedObservable: Observable<Material>;
  36876. /**
  36877. * An event triggered when a texture is created
  36878. */
  36879. onNewTextureAddedObservable: Observable<BaseTexture>;
  36880. /**
  36881. * An event triggered when a texture is removed
  36882. */
  36883. onTextureRemovedObservable: Observable<BaseTexture>;
  36884. /**
  36885. * An event triggered when render targets are about to be rendered
  36886. * Can happen multiple times per frame.
  36887. */
  36888. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36889. /**
  36890. * An event triggered when render targets were rendered.
  36891. * Can happen multiple times per frame.
  36892. */
  36893. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36894. /**
  36895. * An event triggered before calculating deterministic simulation step
  36896. */
  36897. onBeforeStepObservable: Observable<Scene>;
  36898. /**
  36899. * An event triggered after calculating deterministic simulation step
  36900. */
  36901. onAfterStepObservable: Observable<Scene>;
  36902. /**
  36903. * An event triggered when the activeCamera property is updated
  36904. */
  36905. onActiveCameraChanged: Observable<Scene>;
  36906. /**
  36907. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36908. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36909. * 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)
  36910. */
  36911. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36912. /**
  36913. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36914. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36915. * 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)
  36916. */
  36917. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36918. /**
  36919. * This Observable will when a mesh has been imported into the scene.
  36920. */
  36921. onMeshImportedObservable: Observable<AbstractMesh>;
  36922. /**
  36923. * This Observable will when an animation file has been imported into the scene.
  36924. */
  36925. onAnimationFileImportedObservable: Observable<Scene>;
  36926. /**
  36927. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36928. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36929. */
  36930. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36931. /** @hidden */
  36932. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36933. /**
  36934. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36935. */
  36936. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36937. /**
  36938. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36939. */
  36940. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36941. /**
  36942. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36943. */
  36944. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36945. /** Callback called when a pointer move is detected */
  36946. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36947. /** Callback called when a pointer down is detected */
  36948. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36949. /** Callback called when a pointer up is detected */
  36950. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36951. /** Callback called when a pointer pick is detected */
  36952. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36953. /**
  36954. * 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).
  36955. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36956. */
  36957. onPrePointerObservable: Observable<PointerInfoPre>;
  36958. /**
  36959. * Observable event triggered each time an input event is received from the rendering canvas
  36960. */
  36961. onPointerObservable: Observable<PointerInfo>;
  36962. /**
  36963. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36964. */
  36965. get unTranslatedPointer(): Vector2;
  36966. /**
  36967. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36968. */
  36969. static get DragMovementThreshold(): number;
  36970. static set DragMovementThreshold(value: number);
  36971. /**
  36972. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36973. */
  36974. static get LongPressDelay(): number;
  36975. static set LongPressDelay(value: number);
  36976. /**
  36977. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36978. */
  36979. static get DoubleClickDelay(): number;
  36980. static set DoubleClickDelay(value: number);
  36981. /** If you need to check double click without raising a single click at first click, enable this flag */
  36982. static get ExclusiveDoubleClickMode(): boolean;
  36983. static set ExclusiveDoubleClickMode(value: boolean);
  36984. /** @hidden */
  36985. _mirroredCameraPosition: Nullable<Vector3>;
  36986. /**
  36987. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36988. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36989. */
  36990. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36991. /**
  36992. * Observable event triggered each time an keyboard event is received from the hosting window
  36993. */
  36994. onKeyboardObservable: Observable<KeyboardInfo>;
  36995. private _useRightHandedSystem;
  36996. /**
  36997. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36998. */
  36999. set useRightHandedSystem(value: boolean);
  37000. get useRightHandedSystem(): boolean;
  37001. private _timeAccumulator;
  37002. private _currentStepId;
  37003. private _currentInternalStep;
  37004. /**
  37005. * Sets the step Id used by deterministic lock step
  37006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37007. * @param newStepId defines the step Id
  37008. */
  37009. setStepId(newStepId: number): void;
  37010. /**
  37011. * Gets the step Id used by deterministic lock step
  37012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37013. * @returns the step Id
  37014. */
  37015. getStepId(): number;
  37016. /**
  37017. * Gets the internal step used by deterministic lock step
  37018. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37019. * @returns the internal step
  37020. */
  37021. getInternalStep(): number;
  37022. private _fogEnabled;
  37023. /**
  37024. * Gets or sets a boolean indicating if fog is enabled on this scene
  37025. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37026. * (Default is true)
  37027. */
  37028. set fogEnabled(value: boolean);
  37029. get fogEnabled(): boolean;
  37030. private _fogMode;
  37031. /**
  37032. * Gets or sets the fog mode to use
  37033. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37034. * | mode | value |
  37035. * | --- | --- |
  37036. * | FOGMODE_NONE | 0 |
  37037. * | FOGMODE_EXP | 1 |
  37038. * | FOGMODE_EXP2 | 2 |
  37039. * | FOGMODE_LINEAR | 3 |
  37040. */
  37041. set fogMode(value: number);
  37042. get fogMode(): number;
  37043. /**
  37044. * Gets or sets the fog color to use
  37045. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37046. * (Default is Color3(0.2, 0.2, 0.3))
  37047. */
  37048. fogColor: Color3;
  37049. /**
  37050. * Gets or sets the fog density to use
  37051. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37052. * (Default is 0.1)
  37053. */
  37054. fogDensity: number;
  37055. /**
  37056. * Gets or sets the fog start distance to use
  37057. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37058. * (Default is 0)
  37059. */
  37060. fogStart: number;
  37061. /**
  37062. * Gets or sets the fog end distance to use
  37063. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37064. * (Default is 1000)
  37065. */
  37066. fogEnd: number;
  37067. private _shadowsEnabled;
  37068. /**
  37069. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37070. */
  37071. set shadowsEnabled(value: boolean);
  37072. get shadowsEnabled(): boolean;
  37073. private _lightsEnabled;
  37074. /**
  37075. * Gets or sets a boolean indicating if lights are enabled on this scene
  37076. */
  37077. set lightsEnabled(value: boolean);
  37078. get lightsEnabled(): boolean;
  37079. /** All of the active cameras added to this scene. */
  37080. activeCameras: Camera[];
  37081. /** @hidden */
  37082. _activeCamera: Nullable<Camera>;
  37083. /** Gets or sets the current active camera */
  37084. get activeCamera(): Nullable<Camera>;
  37085. set activeCamera(value: Nullable<Camera>);
  37086. private _defaultMaterial;
  37087. /** The default material used on meshes when no material is affected */
  37088. get defaultMaterial(): Material;
  37089. /** The default material used on meshes when no material is affected */
  37090. set defaultMaterial(value: Material);
  37091. private _texturesEnabled;
  37092. /**
  37093. * Gets or sets a boolean indicating if textures are enabled on this scene
  37094. */
  37095. set texturesEnabled(value: boolean);
  37096. get texturesEnabled(): boolean;
  37097. /**
  37098. * Gets or sets a boolean indicating if particles are enabled on this scene
  37099. */
  37100. particlesEnabled: boolean;
  37101. /**
  37102. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37103. */
  37104. spritesEnabled: boolean;
  37105. private _skeletonsEnabled;
  37106. /**
  37107. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37108. */
  37109. set skeletonsEnabled(value: boolean);
  37110. get skeletonsEnabled(): boolean;
  37111. /**
  37112. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37113. */
  37114. lensFlaresEnabled: boolean;
  37115. /**
  37116. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37117. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37118. */
  37119. collisionsEnabled: boolean;
  37120. private _collisionCoordinator;
  37121. /** @hidden */
  37122. get collisionCoordinator(): ICollisionCoordinator;
  37123. /**
  37124. * Defines the gravity applied to this scene (used only for collisions)
  37125. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37126. */
  37127. gravity: Vector3;
  37128. /**
  37129. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37130. */
  37131. postProcessesEnabled: boolean;
  37132. /**
  37133. * The list of postprocesses added to the scene
  37134. */
  37135. postProcesses: PostProcess[];
  37136. /**
  37137. * Gets the current postprocess manager
  37138. */
  37139. postProcessManager: PostProcessManager;
  37140. /**
  37141. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37142. */
  37143. renderTargetsEnabled: boolean;
  37144. /**
  37145. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37146. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37147. */
  37148. dumpNextRenderTargets: boolean;
  37149. /**
  37150. * The list of user defined render targets added to the scene
  37151. */
  37152. customRenderTargets: RenderTargetTexture[];
  37153. /**
  37154. * Defines if texture loading must be delayed
  37155. * If true, textures will only be loaded when they need to be rendered
  37156. */
  37157. useDelayedTextureLoading: boolean;
  37158. /**
  37159. * Gets the list of meshes imported to the scene through SceneLoader
  37160. */
  37161. importedMeshesFiles: String[];
  37162. /**
  37163. * Gets or sets a boolean indicating if probes are enabled on this scene
  37164. */
  37165. probesEnabled: boolean;
  37166. /**
  37167. * Gets or sets the current offline provider to use to store scene data
  37168. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37169. */
  37170. offlineProvider: IOfflineProvider;
  37171. /**
  37172. * Gets or sets the action manager associated with the scene
  37173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37174. */
  37175. actionManager: AbstractActionManager;
  37176. private _meshesForIntersections;
  37177. /**
  37178. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37179. */
  37180. proceduralTexturesEnabled: boolean;
  37181. private _engine;
  37182. private _totalVertices;
  37183. /** @hidden */
  37184. _activeIndices: PerfCounter;
  37185. /** @hidden */
  37186. _activeParticles: PerfCounter;
  37187. /** @hidden */
  37188. _activeBones: PerfCounter;
  37189. private _animationRatio;
  37190. /** @hidden */
  37191. _animationTimeLast: number;
  37192. /** @hidden */
  37193. _animationTime: number;
  37194. /**
  37195. * Gets or sets a general scale for animation speed
  37196. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37197. */
  37198. animationTimeScale: number;
  37199. /** @hidden */
  37200. _cachedMaterial: Nullable<Material>;
  37201. /** @hidden */
  37202. _cachedEffect: Nullable<Effect>;
  37203. /** @hidden */
  37204. _cachedVisibility: Nullable<number>;
  37205. private _renderId;
  37206. private _frameId;
  37207. private _executeWhenReadyTimeoutId;
  37208. private _intermediateRendering;
  37209. private _viewUpdateFlag;
  37210. private _projectionUpdateFlag;
  37211. /** @hidden */
  37212. _toBeDisposed: Nullable<IDisposable>[];
  37213. private _activeRequests;
  37214. /** @hidden */
  37215. _pendingData: any[];
  37216. private _isDisposed;
  37217. /**
  37218. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37219. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37220. */
  37221. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37222. private _activeMeshes;
  37223. private _processedMaterials;
  37224. private _renderTargets;
  37225. /** @hidden */
  37226. _activeParticleSystems: SmartArray<IParticleSystem>;
  37227. private _activeSkeletons;
  37228. private _softwareSkinnedMeshes;
  37229. private _renderingManager;
  37230. /** @hidden */
  37231. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37232. private _transformMatrix;
  37233. private _sceneUbo;
  37234. /** @hidden */
  37235. _viewMatrix: Matrix;
  37236. private _projectionMatrix;
  37237. /** @hidden */
  37238. _forcedViewPosition: Nullable<Vector3>;
  37239. /** @hidden */
  37240. _frustumPlanes: Plane[];
  37241. /**
  37242. * Gets the list of frustum planes (built from the active camera)
  37243. */
  37244. get frustumPlanes(): Plane[];
  37245. /**
  37246. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37247. * This is useful if there are more lights that the maximum simulteanous authorized
  37248. */
  37249. requireLightSorting: boolean;
  37250. /** @hidden */
  37251. readonly useMaterialMeshMap: boolean;
  37252. /** @hidden */
  37253. readonly useClonedMeshMap: boolean;
  37254. private _externalData;
  37255. private _uid;
  37256. /**
  37257. * @hidden
  37258. * Backing store of defined scene components.
  37259. */
  37260. _components: ISceneComponent[];
  37261. /**
  37262. * @hidden
  37263. * Backing store of defined scene components.
  37264. */
  37265. _serializableComponents: ISceneSerializableComponent[];
  37266. /**
  37267. * List of components to register on the next registration step.
  37268. */
  37269. private _transientComponents;
  37270. /**
  37271. * Registers the transient components if needed.
  37272. */
  37273. private _registerTransientComponents;
  37274. /**
  37275. * @hidden
  37276. * Add a component to the scene.
  37277. * Note that the ccomponent could be registered on th next frame if this is called after
  37278. * the register component stage.
  37279. * @param component Defines the component to add to the scene
  37280. */
  37281. _addComponent(component: ISceneComponent): void;
  37282. /**
  37283. * @hidden
  37284. * Gets a component from the scene.
  37285. * @param name defines the name of the component to retrieve
  37286. * @returns the component or null if not present
  37287. */
  37288. _getComponent(name: string): Nullable<ISceneComponent>;
  37289. /**
  37290. * @hidden
  37291. * Defines the actions happening before camera updates.
  37292. */
  37293. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37294. /**
  37295. * @hidden
  37296. * Defines the actions happening before clear the canvas.
  37297. */
  37298. _beforeClearStage: Stage<SimpleStageAction>;
  37299. /**
  37300. * @hidden
  37301. * Defines the actions when collecting render targets for the frame.
  37302. */
  37303. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37304. /**
  37305. * @hidden
  37306. * Defines the actions happening for one camera in the frame.
  37307. */
  37308. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37309. /**
  37310. * @hidden
  37311. * Defines the actions happening during the per mesh ready checks.
  37312. */
  37313. _isReadyForMeshStage: Stage<MeshStageAction>;
  37314. /**
  37315. * @hidden
  37316. * Defines the actions happening before evaluate active mesh checks.
  37317. */
  37318. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37319. /**
  37320. * @hidden
  37321. * Defines the actions happening during the evaluate sub mesh checks.
  37322. */
  37323. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37324. /**
  37325. * @hidden
  37326. * Defines the actions happening during the active mesh stage.
  37327. */
  37328. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37329. /**
  37330. * @hidden
  37331. * Defines the actions happening during the per camera render target step.
  37332. */
  37333. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37334. /**
  37335. * @hidden
  37336. * Defines the actions happening just before the active camera is drawing.
  37337. */
  37338. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37339. /**
  37340. * @hidden
  37341. * Defines the actions happening just before a render target is drawing.
  37342. */
  37343. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37344. /**
  37345. * @hidden
  37346. * Defines the actions happening just before a rendering group is drawing.
  37347. */
  37348. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37349. /**
  37350. * @hidden
  37351. * Defines the actions happening just before a mesh is drawing.
  37352. */
  37353. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37354. /**
  37355. * @hidden
  37356. * Defines the actions happening just after a mesh has been drawn.
  37357. */
  37358. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37359. /**
  37360. * @hidden
  37361. * Defines the actions happening just after a rendering group has been drawn.
  37362. */
  37363. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37364. /**
  37365. * @hidden
  37366. * Defines the actions happening just after the active camera has been drawn.
  37367. */
  37368. _afterCameraDrawStage: Stage<CameraStageAction>;
  37369. /**
  37370. * @hidden
  37371. * Defines the actions happening just after a render target has been drawn.
  37372. */
  37373. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37374. /**
  37375. * @hidden
  37376. * Defines the actions happening just after rendering all cameras and computing intersections.
  37377. */
  37378. _afterRenderStage: Stage<SimpleStageAction>;
  37379. /**
  37380. * @hidden
  37381. * Defines the actions happening when a pointer move event happens.
  37382. */
  37383. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37384. /**
  37385. * @hidden
  37386. * Defines the actions happening when a pointer down event happens.
  37387. */
  37388. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37389. /**
  37390. * @hidden
  37391. * Defines the actions happening when a pointer up event happens.
  37392. */
  37393. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37394. /**
  37395. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37396. */
  37397. private geometriesByUniqueId;
  37398. /**
  37399. * Creates a new Scene
  37400. * @param engine defines the engine to use to render this scene
  37401. * @param options defines the scene options
  37402. */
  37403. constructor(engine: Engine, options?: SceneOptions);
  37404. /**
  37405. * Gets a string idenfifying the name of the class
  37406. * @returns "Scene" string
  37407. */
  37408. getClassName(): string;
  37409. private _defaultMeshCandidates;
  37410. /**
  37411. * @hidden
  37412. */
  37413. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37414. private _defaultSubMeshCandidates;
  37415. /**
  37416. * @hidden
  37417. */
  37418. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37419. /**
  37420. * Sets the default candidate providers for the scene.
  37421. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37422. * and getCollidingSubMeshCandidates to their default function
  37423. */
  37424. setDefaultCandidateProviders(): void;
  37425. /**
  37426. * Gets the mesh that is currently under the pointer
  37427. */
  37428. get meshUnderPointer(): Nullable<AbstractMesh>;
  37429. /**
  37430. * Gets or sets the current on-screen X position of the pointer
  37431. */
  37432. get pointerX(): number;
  37433. set pointerX(value: number);
  37434. /**
  37435. * Gets or sets the current on-screen Y position of the pointer
  37436. */
  37437. get pointerY(): number;
  37438. set pointerY(value: number);
  37439. /**
  37440. * Gets the cached material (ie. the latest rendered one)
  37441. * @returns the cached material
  37442. */
  37443. getCachedMaterial(): Nullable<Material>;
  37444. /**
  37445. * Gets the cached effect (ie. the latest rendered one)
  37446. * @returns the cached effect
  37447. */
  37448. getCachedEffect(): Nullable<Effect>;
  37449. /**
  37450. * Gets the cached visibility state (ie. the latest rendered one)
  37451. * @returns the cached visibility state
  37452. */
  37453. getCachedVisibility(): Nullable<number>;
  37454. /**
  37455. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37456. * @param material defines the current material
  37457. * @param effect defines the current effect
  37458. * @param visibility defines the current visibility state
  37459. * @returns true if one parameter is not cached
  37460. */
  37461. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37462. /**
  37463. * Gets the engine associated with the scene
  37464. * @returns an Engine
  37465. */
  37466. getEngine(): Engine;
  37467. /**
  37468. * Gets the total number of vertices rendered per frame
  37469. * @returns the total number of vertices rendered per frame
  37470. */
  37471. getTotalVertices(): number;
  37472. /**
  37473. * Gets the performance counter for total vertices
  37474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37475. */
  37476. get totalVerticesPerfCounter(): PerfCounter;
  37477. /**
  37478. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37479. * @returns the total number of active indices rendered per frame
  37480. */
  37481. getActiveIndices(): number;
  37482. /**
  37483. * Gets the performance counter for active indices
  37484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37485. */
  37486. get totalActiveIndicesPerfCounter(): PerfCounter;
  37487. /**
  37488. * Gets the total number of active particles rendered per frame
  37489. * @returns the total number of active particles rendered per frame
  37490. */
  37491. getActiveParticles(): number;
  37492. /**
  37493. * Gets the performance counter for active particles
  37494. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37495. */
  37496. get activeParticlesPerfCounter(): PerfCounter;
  37497. /**
  37498. * Gets the total number of active bones rendered per frame
  37499. * @returns the total number of active bones rendered per frame
  37500. */
  37501. getActiveBones(): number;
  37502. /**
  37503. * Gets the performance counter for active bones
  37504. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37505. */
  37506. get activeBonesPerfCounter(): PerfCounter;
  37507. /**
  37508. * Gets the array of active meshes
  37509. * @returns an array of AbstractMesh
  37510. */
  37511. getActiveMeshes(): SmartArray<AbstractMesh>;
  37512. /**
  37513. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37514. * @returns a number
  37515. */
  37516. getAnimationRatio(): number;
  37517. /**
  37518. * Gets an unique Id for the current render phase
  37519. * @returns a number
  37520. */
  37521. getRenderId(): number;
  37522. /**
  37523. * Gets an unique Id for the current frame
  37524. * @returns a number
  37525. */
  37526. getFrameId(): number;
  37527. /** Call this function if you want to manually increment the render Id*/
  37528. incrementRenderId(): void;
  37529. private _createUbo;
  37530. /**
  37531. * Use this method to simulate a pointer move on a mesh
  37532. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37533. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37534. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37535. * @returns the current scene
  37536. */
  37537. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37538. /**
  37539. * Use this method to simulate a pointer down on a mesh
  37540. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37541. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37542. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37543. * @returns the current scene
  37544. */
  37545. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37546. /**
  37547. * Use this method to simulate a pointer up on a mesh
  37548. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37549. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37550. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37551. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37552. * @returns the current scene
  37553. */
  37554. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37555. /**
  37556. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37557. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37558. * @returns true if the pointer was captured
  37559. */
  37560. isPointerCaptured(pointerId?: number): boolean;
  37561. /**
  37562. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37563. * @param attachUp defines if you want to attach events to pointerup
  37564. * @param attachDown defines if you want to attach events to pointerdown
  37565. * @param attachMove defines if you want to attach events to pointermove
  37566. */
  37567. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37568. /** Detaches all event handlers*/
  37569. detachControl(): void;
  37570. /**
  37571. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37572. * Delay loaded resources are not taking in account
  37573. * @return true if all required resources are ready
  37574. */
  37575. isReady(): boolean;
  37576. /** Resets all cached information relative to material (including effect and visibility) */
  37577. resetCachedMaterial(): void;
  37578. /**
  37579. * Registers a function to be called before every frame render
  37580. * @param func defines the function to register
  37581. */
  37582. registerBeforeRender(func: () => void): void;
  37583. /**
  37584. * Unregisters a function called before every frame render
  37585. * @param func defines the function to unregister
  37586. */
  37587. unregisterBeforeRender(func: () => void): void;
  37588. /**
  37589. * Registers a function to be called after every frame render
  37590. * @param func defines the function to register
  37591. */
  37592. registerAfterRender(func: () => void): void;
  37593. /**
  37594. * Unregisters a function called after every frame render
  37595. * @param func defines the function to unregister
  37596. */
  37597. unregisterAfterRender(func: () => void): void;
  37598. private _executeOnceBeforeRender;
  37599. /**
  37600. * The provided function will run before render once and will be disposed afterwards.
  37601. * A timeout delay can be provided so that the function will be executed in N ms.
  37602. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37603. * @param func The function to be executed.
  37604. * @param timeout optional delay in ms
  37605. */
  37606. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37607. /** @hidden */
  37608. _addPendingData(data: any): void;
  37609. /** @hidden */
  37610. _removePendingData(data: any): void;
  37611. /**
  37612. * Returns the number of items waiting to be loaded
  37613. * @returns the number of items waiting to be loaded
  37614. */
  37615. getWaitingItemsCount(): number;
  37616. /**
  37617. * Returns a boolean indicating if the scene is still loading data
  37618. */
  37619. get isLoading(): boolean;
  37620. /**
  37621. * Registers a function to be executed when the scene is ready
  37622. * @param {Function} func - the function to be executed
  37623. */
  37624. executeWhenReady(func: () => void): void;
  37625. /**
  37626. * Returns a promise that resolves when the scene is ready
  37627. * @returns A promise that resolves when the scene is ready
  37628. */
  37629. whenReadyAsync(): Promise<void>;
  37630. /** @hidden */
  37631. _checkIsReady(): void;
  37632. /**
  37633. * Gets all animatable attached to the scene
  37634. */
  37635. get animatables(): Animatable[];
  37636. /**
  37637. * Resets the last animation time frame.
  37638. * Useful to override when animations start running when loading a scene for the first time.
  37639. */
  37640. resetLastAnimationTimeFrame(): void;
  37641. /**
  37642. * Gets the current view matrix
  37643. * @returns a Matrix
  37644. */
  37645. getViewMatrix(): Matrix;
  37646. /**
  37647. * Gets the current projection matrix
  37648. * @returns a Matrix
  37649. */
  37650. getProjectionMatrix(): Matrix;
  37651. /**
  37652. * Gets the current transform matrix
  37653. * @returns a Matrix made of View * Projection
  37654. */
  37655. getTransformMatrix(): Matrix;
  37656. /**
  37657. * Sets the current transform matrix
  37658. * @param viewL defines the View matrix to use
  37659. * @param projectionL defines the Projection matrix to use
  37660. * @param viewR defines the right View matrix to use (if provided)
  37661. * @param projectionR defines the right Projection matrix to use (if provided)
  37662. */
  37663. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37664. /**
  37665. * Gets the uniform buffer used to store scene data
  37666. * @returns a UniformBuffer
  37667. */
  37668. getSceneUniformBuffer(): UniformBuffer;
  37669. /**
  37670. * Gets an unique (relatively to the current scene) Id
  37671. * @returns an unique number for the scene
  37672. */
  37673. getUniqueId(): number;
  37674. /**
  37675. * Add a mesh to the list of scene's meshes
  37676. * @param newMesh defines the mesh to add
  37677. * @param recursive if all child meshes should also be added to the scene
  37678. */
  37679. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37680. /**
  37681. * Remove a mesh for the list of scene's meshes
  37682. * @param toRemove defines the mesh to remove
  37683. * @param recursive if all child meshes should also be removed from the scene
  37684. * @returns the index where the mesh was in the mesh list
  37685. */
  37686. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37687. /**
  37688. * Add a transform node to the list of scene's transform nodes
  37689. * @param newTransformNode defines the transform node to add
  37690. */
  37691. addTransformNode(newTransformNode: TransformNode): void;
  37692. /**
  37693. * Remove a transform node for the list of scene's transform nodes
  37694. * @param toRemove defines the transform node to remove
  37695. * @returns the index where the transform node was in the transform node list
  37696. */
  37697. removeTransformNode(toRemove: TransformNode): number;
  37698. /**
  37699. * Remove a skeleton for the list of scene's skeletons
  37700. * @param toRemove defines the skeleton to remove
  37701. * @returns the index where the skeleton was in the skeleton list
  37702. */
  37703. removeSkeleton(toRemove: Skeleton): number;
  37704. /**
  37705. * Remove a morph target for the list of scene's morph targets
  37706. * @param toRemove defines the morph target to remove
  37707. * @returns the index where the morph target was in the morph target list
  37708. */
  37709. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37710. /**
  37711. * Remove a light for the list of scene's lights
  37712. * @param toRemove defines the light to remove
  37713. * @returns the index where the light was in the light list
  37714. */
  37715. removeLight(toRemove: Light): number;
  37716. /**
  37717. * Remove a camera for the list of scene's cameras
  37718. * @param toRemove defines the camera to remove
  37719. * @returns the index where the camera was in the camera list
  37720. */
  37721. removeCamera(toRemove: Camera): number;
  37722. /**
  37723. * Remove a particle system for the list of scene's particle systems
  37724. * @param toRemove defines the particle system to remove
  37725. * @returns the index where the particle system was in the particle system list
  37726. */
  37727. removeParticleSystem(toRemove: IParticleSystem): number;
  37728. /**
  37729. * Remove a animation for the list of scene's animations
  37730. * @param toRemove defines the animation to remove
  37731. * @returns the index where the animation was in the animation list
  37732. */
  37733. removeAnimation(toRemove: Animation): number;
  37734. /**
  37735. * Will stop the animation of the given target
  37736. * @param target - the target
  37737. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37738. * @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)
  37739. */
  37740. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37741. /**
  37742. * Removes the given animation group from this scene.
  37743. * @param toRemove The animation group to remove
  37744. * @returns The index of the removed animation group
  37745. */
  37746. removeAnimationGroup(toRemove: AnimationGroup): number;
  37747. /**
  37748. * Removes the given multi-material from this scene.
  37749. * @param toRemove The multi-material to remove
  37750. * @returns The index of the removed multi-material
  37751. */
  37752. removeMultiMaterial(toRemove: MultiMaterial): number;
  37753. /**
  37754. * Removes the given material from this scene.
  37755. * @param toRemove The material to remove
  37756. * @returns The index of the removed material
  37757. */
  37758. removeMaterial(toRemove: Material): number;
  37759. /**
  37760. * Removes the given action manager from this scene.
  37761. * @param toRemove The action manager to remove
  37762. * @returns The index of the removed action manager
  37763. */
  37764. removeActionManager(toRemove: AbstractActionManager): number;
  37765. /**
  37766. * Removes the given texture from this scene.
  37767. * @param toRemove The texture to remove
  37768. * @returns The index of the removed texture
  37769. */
  37770. removeTexture(toRemove: BaseTexture): number;
  37771. /**
  37772. * Adds the given light to this scene
  37773. * @param newLight The light to add
  37774. */
  37775. addLight(newLight: Light): void;
  37776. /**
  37777. * Sorts the list list based on light priorities
  37778. */
  37779. sortLightsByPriority(): void;
  37780. /**
  37781. * Adds the given camera to this scene
  37782. * @param newCamera The camera to add
  37783. */
  37784. addCamera(newCamera: Camera): void;
  37785. /**
  37786. * Adds the given skeleton to this scene
  37787. * @param newSkeleton The skeleton to add
  37788. */
  37789. addSkeleton(newSkeleton: Skeleton): void;
  37790. /**
  37791. * Adds the given particle system to this scene
  37792. * @param newParticleSystem The particle system to add
  37793. */
  37794. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37795. /**
  37796. * Adds the given animation to this scene
  37797. * @param newAnimation The animation to add
  37798. */
  37799. addAnimation(newAnimation: Animation): void;
  37800. /**
  37801. * Adds the given animation group to this scene.
  37802. * @param newAnimationGroup The animation group to add
  37803. */
  37804. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37805. /**
  37806. * Adds the given multi-material to this scene
  37807. * @param newMultiMaterial The multi-material to add
  37808. */
  37809. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37810. /**
  37811. * Adds the given material to this scene
  37812. * @param newMaterial The material to add
  37813. */
  37814. addMaterial(newMaterial: Material): void;
  37815. /**
  37816. * Adds the given morph target to this scene
  37817. * @param newMorphTargetManager The morph target to add
  37818. */
  37819. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37820. /**
  37821. * Adds the given geometry to this scene
  37822. * @param newGeometry The geometry to add
  37823. */
  37824. addGeometry(newGeometry: Geometry): void;
  37825. /**
  37826. * Adds the given action manager to this scene
  37827. * @param newActionManager The action manager to add
  37828. */
  37829. addActionManager(newActionManager: AbstractActionManager): void;
  37830. /**
  37831. * Adds the given texture to this scene.
  37832. * @param newTexture The texture to add
  37833. */
  37834. addTexture(newTexture: BaseTexture): void;
  37835. /**
  37836. * Switch active camera
  37837. * @param newCamera defines the new active camera
  37838. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37839. */
  37840. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37841. /**
  37842. * sets the active camera of the scene using its ID
  37843. * @param id defines the camera's ID
  37844. * @return the new active camera or null if none found.
  37845. */
  37846. setActiveCameraByID(id: string): Nullable<Camera>;
  37847. /**
  37848. * sets the active camera of the scene using its name
  37849. * @param name defines the camera's name
  37850. * @returns the new active camera or null if none found.
  37851. */
  37852. setActiveCameraByName(name: string): Nullable<Camera>;
  37853. /**
  37854. * get an animation group using its name
  37855. * @param name defines the material's name
  37856. * @return the animation group or null if none found.
  37857. */
  37858. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37859. /**
  37860. * Get a material using its unique id
  37861. * @param uniqueId defines the material's unique id
  37862. * @return the material or null if none found.
  37863. */
  37864. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37865. /**
  37866. * get a material using its id
  37867. * @param id defines the material's ID
  37868. * @return the material or null if none found.
  37869. */
  37870. getMaterialByID(id: string): Nullable<Material>;
  37871. /**
  37872. * Gets a the last added material using a given id
  37873. * @param id defines the material's ID
  37874. * @return the last material with the given id or null if none found.
  37875. */
  37876. getLastMaterialByID(id: string): Nullable<Material>;
  37877. /**
  37878. * Gets a material using its name
  37879. * @param name defines the material's name
  37880. * @return the material or null if none found.
  37881. */
  37882. getMaterialByName(name: string): Nullable<Material>;
  37883. /**
  37884. * Get a texture using its unique id
  37885. * @param uniqueId defines the texture's unique id
  37886. * @return the texture or null if none found.
  37887. */
  37888. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37889. /**
  37890. * Gets a camera using its id
  37891. * @param id defines the id to look for
  37892. * @returns the camera or null if not found
  37893. */
  37894. getCameraByID(id: string): Nullable<Camera>;
  37895. /**
  37896. * Gets a camera using its unique id
  37897. * @param uniqueId defines the unique id to look for
  37898. * @returns the camera or null if not found
  37899. */
  37900. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37901. /**
  37902. * Gets a camera using its name
  37903. * @param name defines the camera's name
  37904. * @return the camera or null if none found.
  37905. */
  37906. getCameraByName(name: string): Nullable<Camera>;
  37907. /**
  37908. * Gets a bone using its id
  37909. * @param id defines the bone's id
  37910. * @return the bone or null if not found
  37911. */
  37912. getBoneByID(id: string): Nullable<Bone>;
  37913. /**
  37914. * Gets a bone using its id
  37915. * @param name defines the bone's name
  37916. * @return the bone or null if not found
  37917. */
  37918. getBoneByName(name: string): Nullable<Bone>;
  37919. /**
  37920. * Gets a light node using its name
  37921. * @param name defines the the light's name
  37922. * @return the light or null if none found.
  37923. */
  37924. getLightByName(name: string): Nullable<Light>;
  37925. /**
  37926. * Gets a light node using its id
  37927. * @param id defines the light's id
  37928. * @return the light or null if none found.
  37929. */
  37930. getLightByID(id: string): Nullable<Light>;
  37931. /**
  37932. * Gets a light node using its scene-generated unique ID
  37933. * @param uniqueId defines the light's unique id
  37934. * @return the light or null if none found.
  37935. */
  37936. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37937. /**
  37938. * Gets a particle system by id
  37939. * @param id defines the particle system id
  37940. * @return the corresponding system or null if none found
  37941. */
  37942. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37943. /**
  37944. * Gets a geometry using its ID
  37945. * @param id defines the geometry's id
  37946. * @return the geometry or null if none found.
  37947. */
  37948. getGeometryByID(id: string): Nullable<Geometry>;
  37949. private _getGeometryByUniqueID;
  37950. /**
  37951. * Add a new geometry to this scene
  37952. * @param geometry defines the geometry to be added to the scene.
  37953. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37954. * @return a boolean defining if the geometry was added or not
  37955. */
  37956. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37957. /**
  37958. * Removes an existing geometry
  37959. * @param geometry defines the geometry to be removed from the scene
  37960. * @return a boolean defining if the geometry was removed or not
  37961. */
  37962. removeGeometry(geometry: Geometry): boolean;
  37963. /**
  37964. * Gets the list of geometries attached to the scene
  37965. * @returns an array of Geometry
  37966. */
  37967. getGeometries(): Geometry[];
  37968. /**
  37969. * Gets the first added mesh found of a given ID
  37970. * @param id defines the id to search for
  37971. * @return the mesh found or null if not found at all
  37972. */
  37973. getMeshByID(id: string): Nullable<AbstractMesh>;
  37974. /**
  37975. * Gets a list of meshes using their id
  37976. * @param id defines the id to search for
  37977. * @returns a list of meshes
  37978. */
  37979. getMeshesByID(id: string): Array<AbstractMesh>;
  37980. /**
  37981. * Gets the first added transform node found of a given ID
  37982. * @param id defines the id to search for
  37983. * @return the found transform node or null if not found at all.
  37984. */
  37985. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37986. /**
  37987. * Gets a transform node with its auto-generated unique id
  37988. * @param uniqueId efines the unique id to search for
  37989. * @return the found transform node or null if not found at all.
  37990. */
  37991. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37992. /**
  37993. * Gets a list of transform nodes using their id
  37994. * @param id defines the id to search for
  37995. * @returns a list of transform nodes
  37996. */
  37997. getTransformNodesByID(id: string): Array<TransformNode>;
  37998. /**
  37999. * Gets a mesh with its auto-generated unique id
  38000. * @param uniqueId defines the unique id to search for
  38001. * @return the found mesh or null if not found at all.
  38002. */
  38003. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38004. /**
  38005. * Gets a the last added mesh using a given id
  38006. * @param id defines the id to search for
  38007. * @return the found mesh or null if not found at all.
  38008. */
  38009. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38010. /**
  38011. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38012. * @param id defines the id to search for
  38013. * @return the found node or null if not found at all
  38014. */
  38015. getLastEntryByID(id: string): Nullable<Node>;
  38016. /**
  38017. * Gets a node (Mesh, Camera, Light) using a given id
  38018. * @param id defines the id to search for
  38019. * @return the found node or null if not found at all
  38020. */
  38021. getNodeByID(id: string): Nullable<Node>;
  38022. /**
  38023. * Gets a node (Mesh, Camera, Light) using a given name
  38024. * @param name defines the name to search for
  38025. * @return the found node or null if not found at all.
  38026. */
  38027. getNodeByName(name: string): Nullable<Node>;
  38028. /**
  38029. * Gets a mesh using a given name
  38030. * @param name defines the name to search for
  38031. * @return the found mesh or null if not found at all.
  38032. */
  38033. getMeshByName(name: string): Nullable<AbstractMesh>;
  38034. /**
  38035. * Gets a transform node using a given name
  38036. * @param name defines the name to search for
  38037. * @return the found transform node or null if not found at all.
  38038. */
  38039. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38040. /**
  38041. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38042. * @param id defines the id to search for
  38043. * @return the found skeleton or null if not found at all.
  38044. */
  38045. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38046. /**
  38047. * Gets a skeleton using a given auto generated unique id
  38048. * @param uniqueId defines the unique id to search for
  38049. * @return the found skeleton or null if not found at all.
  38050. */
  38051. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38052. /**
  38053. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38054. * @param id defines the id to search for
  38055. * @return the found skeleton or null if not found at all.
  38056. */
  38057. getSkeletonById(id: string): Nullable<Skeleton>;
  38058. /**
  38059. * Gets a skeleton using a given name
  38060. * @param name defines the name to search for
  38061. * @return the found skeleton or null if not found at all.
  38062. */
  38063. getSkeletonByName(name: string): Nullable<Skeleton>;
  38064. /**
  38065. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38066. * @param id defines the id to search for
  38067. * @return the found morph target manager or null if not found at all.
  38068. */
  38069. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38070. /**
  38071. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38072. * @param id defines the id to search for
  38073. * @return the found morph target or null if not found at all.
  38074. */
  38075. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38076. /**
  38077. * Gets a boolean indicating if the given mesh is active
  38078. * @param mesh defines the mesh to look for
  38079. * @returns true if the mesh is in the active list
  38080. */
  38081. isActiveMesh(mesh: AbstractMesh): boolean;
  38082. /**
  38083. * Return a unique id as a string which can serve as an identifier for the scene
  38084. */
  38085. get uid(): string;
  38086. /**
  38087. * Add an externaly attached data from its key.
  38088. * This method call will fail and return false, if such key already exists.
  38089. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38090. * @param key the unique key that identifies the data
  38091. * @param data the data object to associate to the key for this Engine instance
  38092. * @return true if no such key were already present and the data was added successfully, false otherwise
  38093. */
  38094. addExternalData<T>(key: string, data: T): boolean;
  38095. /**
  38096. * Get an externaly attached data from its key
  38097. * @param key the unique key that identifies the data
  38098. * @return the associated data, if present (can be null), or undefined if not present
  38099. */
  38100. getExternalData<T>(key: string): Nullable<T>;
  38101. /**
  38102. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38103. * @param key the unique key that identifies the data
  38104. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38105. * @return the associated data, can be null if the factory returned null.
  38106. */
  38107. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38108. /**
  38109. * Remove an externaly attached data from the Engine instance
  38110. * @param key the unique key that identifies the data
  38111. * @return true if the data was successfully removed, false if it doesn't exist
  38112. */
  38113. removeExternalData(key: string): boolean;
  38114. private _evaluateSubMesh;
  38115. /**
  38116. * Clear the processed materials smart array preventing retention point in material dispose.
  38117. */
  38118. freeProcessedMaterials(): void;
  38119. private _preventFreeActiveMeshesAndRenderingGroups;
  38120. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38121. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38122. * when disposing several meshes in a row or a hierarchy of meshes.
  38123. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38124. */
  38125. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38126. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38127. /**
  38128. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38129. */
  38130. freeActiveMeshes(): void;
  38131. /**
  38132. * Clear the info related to rendering groups preventing retention points during dispose.
  38133. */
  38134. freeRenderingGroups(): void;
  38135. /** @hidden */
  38136. _isInIntermediateRendering(): boolean;
  38137. /**
  38138. * Lambda returning the list of potentially active meshes.
  38139. */
  38140. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38141. /**
  38142. * Lambda returning the list of potentially active sub meshes.
  38143. */
  38144. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38145. /**
  38146. * Lambda returning the list of potentially intersecting sub meshes.
  38147. */
  38148. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38149. /**
  38150. * Lambda returning the list of potentially colliding sub meshes.
  38151. */
  38152. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38153. private _activeMeshesFrozen;
  38154. private _skipEvaluateActiveMeshesCompletely;
  38155. /**
  38156. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38157. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38158. * @returns the current scene
  38159. */
  38160. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38161. /**
  38162. * Use this function to restart evaluating active meshes on every frame
  38163. * @returns the current scene
  38164. */
  38165. unfreezeActiveMeshes(): Scene;
  38166. private _evaluateActiveMeshes;
  38167. private _activeMesh;
  38168. /**
  38169. * Update the transform matrix to update from the current active camera
  38170. * @param force defines a boolean used to force the update even if cache is up to date
  38171. */
  38172. updateTransformMatrix(force?: boolean): void;
  38173. private _bindFrameBuffer;
  38174. /** @hidden */
  38175. _allowPostProcessClearColor: boolean;
  38176. /** @hidden */
  38177. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38178. private _processSubCameras;
  38179. private _checkIntersections;
  38180. /** @hidden */
  38181. _advancePhysicsEngineStep(step: number): void;
  38182. /**
  38183. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38184. */
  38185. getDeterministicFrameTime: () => number;
  38186. /** @hidden */
  38187. _animate(): void;
  38188. /** Execute all animations (for a frame) */
  38189. animate(): void;
  38190. /**
  38191. * Render the scene
  38192. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38193. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38194. */
  38195. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38196. /**
  38197. * Freeze all materials
  38198. * A frozen material will not be updatable but should be faster to render
  38199. */
  38200. freezeMaterials(): void;
  38201. /**
  38202. * Unfreeze all materials
  38203. * A frozen material will not be updatable but should be faster to render
  38204. */
  38205. unfreezeMaterials(): void;
  38206. /**
  38207. * Releases all held ressources
  38208. */
  38209. dispose(): void;
  38210. /**
  38211. * Gets if the scene is already disposed
  38212. */
  38213. get isDisposed(): boolean;
  38214. /**
  38215. * Call this function to reduce memory footprint of the scene.
  38216. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38217. */
  38218. clearCachedVertexData(): void;
  38219. /**
  38220. * This function will remove the local cached buffer data from texture.
  38221. * It will save memory but will prevent the texture from being rebuilt
  38222. */
  38223. cleanCachedTextureBuffer(): void;
  38224. /**
  38225. * Get the world extend vectors with an optional filter
  38226. *
  38227. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38228. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38229. */
  38230. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38231. min: Vector3;
  38232. max: Vector3;
  38233. };
  38234. /**
  38235. * Creates a ray that can be used to pick in the scene
  38236. * @param x defines the x coordinate of the origin (on-screen)
  38237. * @param y defines the y coordinate of the origin (on-screen)
  38238. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38239. * @param camera defines the camera to use for the picking
  38240. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38241. * @returns a Ray
  38242. */
  38243. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38244. /**
  38245. * Creates a ray that can be used to pick in the scene
  38246. * @param x defines the x coordinate of the origin (on-screen)
  38247. * @param y defines the y coordinate of the origin (on-screen)
  38248. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38249. * @param result defines the ray where to store the picking ray
  38250. * @param camera defines the camera to use for the picking
  38251. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38252. * @returns the current scene
  38253. */
  38254. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38255. /**
  38256. * Creates a ray that can be used to pick in the scene
  38257. * @param x defines the x coordinate of the origin (on-screen)
  38258. * @param y defines the y coordinate of the origin (on-screen)
  38259. * @param camera defines the camera to use for the picking
  38260. * @returns a Ray
  38261. */
  38262. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38263. /**
  38264. * Creates a ray that can be used to pick in the scene
  38265. * @param x defines the x coordinate of the origin (on-screen)
  38266. * @param y defines the y coordinate of the origin (on-screen)
  38267. * @param result defines the ray where to store the picking ray
  38268. * @param camera defines the camera to use for the picking
  38269. * @returns the current scene
  38270. */
  38271. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38272. /** Launch a ray to try to pick a mesh in the scene
  38273. * @param x position on screen
  38274. * @param y position on screen
  38275. * @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
  38276. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38277. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38278. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38279. * @returns a PickingInfo
  38280. */
  38281. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38282. /** Use the given ray to pick a mesh in the scene
  38283. * @param ray The ray to use to pick meshes
  38284. * @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
  38285. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38286. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38287. * @returns a PickingInfo
  38288. */
  38289. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38290. /**
  38291. * Launch a ray to try to pick a mesh in the scene
  38292. * @param x X position on screen
  38293. * @param y Y position on screen
  38294. * @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
  38295. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38296. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38297. * @returns an array of PickingInfo
  38298. */
  38299. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38300. /**
  38301. * Launch a ray to try to pick a mesh in the scene
  38302. * @param ray Ray to use
  38303. * @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
  38304. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38305. * @returns an array of PickingInfo
  38306. */
  38307. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38308. /**
  38309. * Force the value of meshUnderPointer
  38310. * @param mesh defines the mesh to use
  38311. */
  38312. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38313. /**
  38314. * Gets the mesh under the pointer
  38315. * @returns a Mesh or null if no mesh is under the pointer
  38316. */
  38317. getPointerOverMesh(): Nullable<AbstractMesh>;
  38318. /** @hidden */
  38319. _rebuildGeometries(): void;
  38320. /** @hidden */
  38321. _rebuildTextures(): void;
  38322. private _getByTags;
  38323. /**
  38324. * Get a list of meshes by tags
  38325. * @param tagsQuery defines the tags query to use
  38326. * @param forEach defines a predicate used to filter results
  38327. * @returns an array of Mesh
  38328. */
  38329. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38330. /**
  38331. * Get a list of cameras by tags
  38332. * @param tagsQuery defines the tags query to use
  38333. * @param forEach defines a predicate used to filter results
  38334. * @returns an array of Camera
  38335. */
  38336. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38337. /**
  38338. * Get a list of lights by tags
  38339. * @param tagsQuery defines the tags query to use
  38340. * @param forEach defines a predicate used to filter results
  38341. * @returns an array of Light
  38342. */
  38343. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38344. /**
  38345. * Get a list of materials by tags
  38346. * @param tagsQuery defines the tags query to use
  38347. * @param forEach defines a predicate used to filter results
  38348. * @returns an array of Material
  38349. */
  38350. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38351. /**
  38352. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38353. * This allowed control for front to back rendering or reversly depending of the special needs.
  38354. *
  38355. * @param renderingGroupId The rendering group id corresponding to its index
  38356. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38357. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38358. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38359. */
  38360. 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;
  38361. /**
  38362. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38363. *
  38364. * @param renderingGroupId The rendering group id corresponding to its index
  38365. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38366. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38367. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38368. */
  38369. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38370. /**
  38371. * Gets the current auto clear configuration for one rendering group of the rendering
  38372. * manager.
  38373. * @param index the rendering group index to get the information for
  38374. * @returns The auto clear setup for the requested rendering group
  38375. */
  38376. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38377. private _blockMaterialDirtyMechanism;
  38378. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38379. get blockMaterialDirtyMechanism(): boolean;
  38380. set blockMaterialDirtyMechanism(value: boolean);
  38381. /**
  38382. * Will flag all materials as dirty to trigger new shader compilation
  38383. * @param flag defines the flag used to specify which material part must be marked as dirty
  38384. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38385. */
  38386. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38387. /** @hidden */
  38388. _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;
  38389. /** @hidden */
  38390. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38391. /** @hidden */
  38392. _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;
  38393. /** @hidden */
  38394. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38395. /** @hidden */
  38396. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38397. /** @hidden */
  38398. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38399. }
  38400. }
  38401. declare module "babylonjs/assetContainer" {
  38402. import { AbstractScene } from "babylonjs/abstractScene";
  38403. import { Scene } from "babylonjs/scene";
  38404. import { Mesh } from "babylonjs/Meshes/mesh";
  38405. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38406. import { Skeleton } from "babylonjs/Bones/skeleton";
  38407. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38408. import { Animatable } from "babylonjs/Animations/animatable";
  38409. import { Nullable } from "babylonjs/types";
  38410. import { Node } from "babylonjs/node";
  38411. /**
  38412. * Set of assets to keep when moving a scene into an asset container.
  38413. */
  38414. export class KeepAssets extends AbstractScene {
  38415. }
  38416. /**
  38417. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38418. */
  38419. export class InstantiatedEntries {
  38420. /**
  38421. * List of new root nodes (eg. nodes with no parent)
  38422. */
  38423. rootNodes: TransformNode[];
  38424. /**
  38425. * List of new skeletons
  38426. */
  38427. skeletons: Skeleton[];
  38428. /**
  38429. * List of new animation groups
  38430. */
  38431. animationGroups: AnimationGroup[];
  38432. }
  38433. /**
  38434. * Container with a set of assets that can be added or removed from a scene.
  38435. */
  38436. export class AssetContainer extends AbstractScene {
  38437. private _wasAddedToScene;
  38438. /**
  38439. * The scene the AssetContainer belongs to.
  38440. */
  38441. scene: Scene;
  38442. /**
  38443. * Instantiates an AssetContainer.
  38444. * @param scene The scene the AssetContainer belongs to.
  38445. */
  38446. constructor(scene: Scene);
  38447. /**
  38448. * Instantiate or clone all meshes and add the new ones to the scene.
  38449. * Skeletons and animation groups will all be cloned
  38450. * @param nameFunction defines an optional function used to get new names for clones
  38451. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38452. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38453. */
  38454. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38455. /**
  38456. * Adds all the assets from the container to the scene.
  38457. */
  38458. addAllToScene(): void;
  38459. /**
  38460. * Removes all the assets in the container from the scene
  38461. */
  38462. removeAllFromScene(): void;
  38463. /**
  38464. * Disposes all the assets in the container
  38465. */
  38466. dispose(): void;
  38467. private _moveAssets;
  38468. /**
  38469. * Removes all the assets contained in the scene and adds them to the container.
  38470. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38471. */
  38472. moveAllFromScene(keepAssets?: KeepAssets): void;
  38473. /**
  38474. * 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.
  38475. * @returns the root mesh
  38476. */
  38477. createRootMesh(): Mesh;
  38478. /**
  38479. * Merge animations from this asset container into a scene
  38480. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38481. * @param animatables set of animatables to retarget to a node from the scene
  38482. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38483. */
  38484. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38485. }
  38486. }
  38487. declare module "babylonjs/abstractScene" {
  38488. import { Scene } from "babylonjs/scene";
  38489. import { Nullable } from "babylonjs/types";
  38490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38491. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38492. import { Geometry } from "babylonjs/Meshes/geometry";
  38493. import { Skeleton } from "babylonjs/Bones/skeleton";
  38494. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38495. import { AssetContainer } from "babylonjs/assetContainer";
  38496. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38497. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38498. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38499. import { Material } from "babylonjs/Materials/material";
  38500. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38501. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38502. import { Camera } from "babylonjs/Cameras/camera";
  38503. import { Light } from "babylonjs/Lights/light";
  38504. import { Node } from "babylonjs/node";
  38505. import { Animation } from "babylonjs/Animations/animation";
  38506. /**
  38507. * Defines how the parser contract is defined.
  38508. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38509. */
  38510. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38511. /**
  38512. * Defines how the individual parser contract is defined.
  38513. * These parser can parse an individual asset
  38514. */
  38515. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38516. /**
  38517. * Base class of the scene acting as a container for the different elements composing a scene.
  38518. * This class is dynamically extended by the different components of the scene increasing
  38519. * flexibility and reducing coupling
  38520. */
  38521. export abstract class AbstractScene {
  38522. /**
  38523. * Stores the list of available parsers in the application.
  38524. */
  38525. private static _BabylonFileParsers;
  38526. /**
  38527. * Stores the list of available individual parsers in the application.
  38528. */
  38529. private static _IndividualBabylonFileParsers;
  38530. /**
  38531. * Adds a parser in the list of available ones
  38532. * @param name Defines the name of the parser
  38533. * @param parser Defines the parser to add
  38534. */
  38535. static AddParser(name: string, parser: BabylonFileParser): void;
  38536. /**
  38537. * Gets a general parser from the list of avaialble ones
  38538. * @param name Defines the name of the parser
  38539. * @returns the requested parser or null
  38540. */
  38541. static GetParser(name: string): Nullable<BabylonFileParser>;
  38542. /**
  38543. * Adds n individual parser in the list of available ones
  38544. * @param name Defines the name of the parser
  38545. * @param parser Defines the parser to add
  38546. */
  38547. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38548. /**
  38549. * Gets an individual parser from the list of avaialble ones
  38550. * @param name Defines the name of the parser
  38551. * @returns the requested parser or null
  38552. */
  38553. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38554. /**
  38555. * Parser json data and populate both a scene and its associated container object
  38556. * @param jsonData Defines the data to parse
  38557. * @param scene Defines the scene to parse the data for
  38558. * @param container Defines the container attached to the parsing sequence
  38559. * @param rootUrl Defines the root url of the data
  38560. */
  38561. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38562. /**
  38563. * Gets the list of root nodes (ie. nodes with no parent)
  38564. */
  38565. rootNodes: Node[];
  38566. /** All of the cameras added to this scene
  38567. * @see http://doc.babylonjs.com/babylon101/cameras
  38568. */
  38569. cameras: Camera[];
  38570. /**
  38571. * All of the lights added to this scene
  38572. * @see http://doc.babylonjs.com/babylon101/lights
  38573. */
  38574. lights: Light[];
  38575. /**
  38576. * All of the (abstract) meshes added to this scene
  38577. */
  38578. meshes: AbstractMesh[];
  38579. /**
  38580. * The list of skeletons added to the scene
  38581. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38582. */
  38583. skeletons: Skeleton[];
  38584. /**
  38585. * All of the particle systems added to this scene
  38586. * @see http://doc.babylonjs.com/babylon101/particles
  38587. */
  38588. particleSystems: IParticleSystem[];
  38589. /**
  38590. * Gets a list of Animations associated with the scene
  38591. */
  38592. animations: Animation[];
  38593. /**
  38594. * All of the animation groups added to this scene
  38595. * @see http://doc.babylonjs.com/how_to/group
  38596. */
  38597. animationGroups: AnimationGroup[];
  38598. /**
  38599. * All of the multi-materials added to this scene
  38600. * @see http://doc.babylonjs.com/how_to/multi_materials
  38601. */
  38602. multiMaterials: MultiMaterial[];
  38603. /**
  38604. * All of the materials added to this scene
  38605. * In the context of a Scene, it is not supposed to be modified manually.
  38606. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38607. * Note also that the order of the Material within the array is not significant and might change.
  38608. * @see http://doc.babylonjs.com/babylon101/materials
  38609. */
  38610. materials: Material[];
  38611. /**
  38612. * The list of morph target managers added to the scene
  38613. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38614. */
  38615. morphTargetManagers: MorphTargetManager[];
  38616. /**
  38617. * The list of geometries used in the scene.
  38618. */
  38619. geometries: Geometry[];
  38620. /**
  38621. * All of the tranform nodes added to this scene
  38622. * In the context of a Scene, it is not supposed to be modified manually.
  38623. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38624. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38625. * @see http://doc.babylonjs.com/how_to/transformnode
  38626. */
  38627. transformNodes: TransformNode[];
  38628. /**
  38629. * ActionManagers available on the scene.
  38630. */
  38631. actionManagers: AbstractActionManager[];
  38632. /**
  38633. * Textures to keep.
  38634. */
  38635. textures: BaseTexture[];
  38636. /**
  38637. * Environment texture for the scene
  38638. */
  38639. environmentTexture: Nullable<BaseTexture>;
  38640. /**
  38641. * @returns all meshes, lights, cameras, transformNodes and bones
  38642. */
  38643. getNodes(): Array<Node>;
  38644. }
  38645. }
  38646. declare module "babylonjs/Audio/sound" {
  38647. import { Observable } from "babylonjs/Misc/observable";
  38648. import { Vector3 } from "babylonjs/Maths/math.vector";
  38649. import { Nullable } from "babylonjs/types";
  38650. import { Scene } from "babylonjs/scene";
  38651. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38652. /**
  38653. * Interface used to define options for Sound class
  38654. */
  38655. export interface ISoundOptions {
  38656. /**
  38657. * Does the sound autoplay once loaded.
  38658. */
  38659. autoplay?: boolean;
  38660. /**
  38661. * Does the sound loop after it finishes playing once.
  38662. */
  38663. loop?: boolean;
  38664. /**
  38665. * Sound's volume
  38666. */
  38667. volume?: number;
  38668. /**
  38669. * Is it a spatial sound?
  38670. */
  38671. spatialSound?: boolean;
  38672. /**
  38673. * Maximum distance to hear that sound
  38674. */
  38675. maxDistance?: number;
  38676. /**
  38677. * Uses user defined attenuation function
  38678. */
  38679. useCustomAttenuation?: boolean;
  38680. /**
  38681. * Define the roll off factor of spatial sounds.
  38682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38683. */
  38684. rolloffFactor?: number;
  38685. /**
  38686. * Define the reference distance the sound should be heard perfectly.
  38687. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38688. */
  38689. refDistance?: number;
  38690. /**
  38691. * Define the distance attenuation model the sound will follow.
  38692. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38693. */
  38694. distanceModel?: string;
  38695. /**
  38696. * Defines the playback speed (1 by default)
  38697. */
  38698. playbackRate?: number;
  38699. /**
  38700. * Defines if the sound is from a streaming source
  38701. */
  38702. streaming?: boolean;
  38703. /**
  38704. * Defines an optional length (in seconds) inside the sound file
  38705. */
  38706. length?: number;
  38707. /**
  38708. * Defines an optional offset (in seconds) inside the sound file
  38709. */
  38710. offset?: number;
  38711. /**
  38712. * If true, URLs will not be required to state the audio file codec to use.
  38713. */
  38714. skipCodecCheck?: boolean;
  38715. }
  38716. /**
  38717. * Defines a sound that can be played in the application.
  38718. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38720. */
  38721. export class Sound {
  38722. /**
  38723. * The name of the sound in the scene.
  38724. */
  38725. name: string;
  38726. /**
  38727. * Does the sound autoplay once loaded.
  38728. */
  38729. autoplay: boolean;
  38730. /**
  38731. * Does the sound loop after it finishes playing once.
  38732. */
  38733. loop: boolean;
  38734. /**
  38735. * Does the sound use a custom attenuation curve to simulate the falloff
  38736. * happening when the source gets further away from the camera.
  38737. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38738. */
  38739. useCustomAttenuation: boolean;
  38740. /**
  38741. * The sound track id this sound belongs to.
  38742. */
  38743. soundTrackId: number;
  38744. /**
  38745. * Is this sound currently played.
  38746. */
  38747. isPlaying: boolean;
  38748. /**
  38749. * Is this sound currently paused.
  38750. */
  38751. isPaused: boolean;
  38752. /**
  38753. * Does this sound enables spatial sound.
  38754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38755. */
  38756. spatialSound: boolean;
  38757. /**
  38758. * Define the reference distance the sound should be heard perfectly.
  38759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38760. */
  38761. refDistance: number;
  38762. /**
  38763. * Define the roll off factor of spatial sounds.
  38764. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38765. */
  38766. rolloffFactor: number;
  38767. /**
  38768. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38769. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38770. */
  38771. maxDistance: number;
  38772. /**
  38773. * Define the distance attenuation model the sound will follow.
  38774. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38775. */
  38776. distanceModel: string;
  38777. /**
  38778. * @hidden
  38779. * Back Compat
  38780. **/
  38781. onended: () => any;
  38782. /**
  38783. * Observable event when the current playing sound finishes.
  38784. */
  38785. onEndedObservable: Observable<Sound>;
  38786. private _panningModel;
  38787. private _playbackRate;
  38788. private _streaming;
  38789. private _startTime;
  38790. private _startOffset;
  38791. private _position;
  38792. /** @hidden */
  38793. _positionInEmitterSpace: boolean;
  38794. private _localDirection;
  38795. private _volume;
  38796. private _isReadyToPlay;
  38797. private _isDirectional;
  38798. private _readyToPlayCallback;
  38799. private _audioBuffer;
  38800. private _soundSource;
  38801. private _streamingSource;
  38802. private _soundPanner;
  38803. private _soundGain;
  38804. private _inputAudioNode;
  38805. private _outputAudioNode;
  38806. private _coneInnerAngle;
  38807. private _coneOuterAngle;
  38808. private _coneOuterGain;
  38809. private _scene;
  38810. private _connectedTransformNode;
  38811. private _customAttenuationFunction;
  38812. private _registerFunc;
  38813. private _isOutputConnected;
  38814. private _htmlAudioElement;
  38815. private _urlType;
  38816. private _length?;
  38817. private _offset?;
  38818. /** @hidden */
  38819. static _SceneComponentInitialization: (scene: Scene) => void;
  38820. /**
  38821. * Create a sound and attach it to a scene
  38822. * @param name Name of your sound
  38823. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38824. * @param scene defines the scene the sound belongs to
  38825. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38826. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38827. */
  38828. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38829. /**
  38830. * Release the sound and its associated resources
  38831. */
  38832. dispose(): void;
  38833. /**
  38834. * Gets if the sounds is ready to be played or not.
  38835. * @returns true if ready, otherwise false
  38836. */
  38837. isReady(): boolean;
  38838. private _soundLoaded;
  38839. /**
  38840. * Sets the data of the sound from an audiobuffer
  38841. * @param audioBuffer The audioBuffer containing the data
  38842. */
  38843. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38844. /**
  38845. * Updates the current sounds options such as maxdistance, loop...
  38846. * @param options A JSON object containing values named as the object properties
  38847. */
  38848. updateOptions(options: ISoundOptions): void;
  38849. private _createSpatialParameters;
  38850. private _updateSpatialParameters;
  38851. /**
  38852. * Switch the panning model to HRTF:
  38853. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38855. */
  38856. switchPanningModelToHRTF(): void;
  38857. /**
  38858. * Switch the panning model to Equal Power:
  38859. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38861. */
  38862. switchPanningModelToEqualPower(): void;
  38863. private _switchPanningModel;
  38864. /**
  38865. * Connect this sound to a sound track audio node like gain...
  38866. * @param soundTrackAudioNode the sound track audio node to connect to
  38867. */
  38868. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38869. /**
  38870. * Transform this sound into a directional source
  38871. * @param coneInnerAngle Size of the inner cone in degree
  38872. * @param coneOuterAngle Size of the outer cone in degree
  38873. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38874. */
  38875. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38876. /**
  38877. * Gets or sets the inner angle for the directional cone.
  38878. */
  38879. get directionalConeInnerAngle(): number;
  38880. /**
  38881. * Gets or sets the inner angle for the directional cone.
  38882. */
  38883. set directionalConeInnerAngle(value: number);
  38884. /**
  38885. * Gets or sets the outer angle for the directional cone.
  38886. */
  38887. get directionalConeOuterAngle(): number;
  38888. /**
  38889. * Gets or sets the outer angle for the directional cone.
  38890. */
  38891. set directionalConeOuterAngle(value: number);
  38892. /**
  38893. * Sets the position of the emitter if spatial sound is enabled
  38894. * @param newPosition Defines the new posisiton
  38895. */
  38896. setPosition(newPosition: Vector3): void;
  38897. /**
  38898. * Sets the local direction of the emitter if spatial sound is enabled
  38899. * @param newLocalDirection Defines the new local direction
  38900. */
  38901. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38902. private _updateDirection;
  38903. /** @hidden */
  38904. updateDistanceFromListener(): void;
  38905. /**
  38906. * Sets a new custom attenuation function for the sound.
  38907. * @param callback Defines the function used for the attenuation
  38908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38909. */
  38910. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38911. /**
  38912. * Play the sound
  38913. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38914. * @param offset (optional) Start the sound at a specific time in seconds
  38915. * @param length (optional) Sound duration (in seconds)
  38916. */
  38917. play(time?: number, offset?: number, length?: number): void;
  38918. private _onended;
  38919. /**
  38920. * Stop the sound
  38921. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38922. */
  38923. stop(time?: number): void;
  38924. /**
  38925. * Put the sound in pause
  38926. */
  38927. pause(): void;
  38928. /**
  38929. * Sets a dedicated volume for this sounds
  38930. * @param newVolume Define the new volume of the sound
  38931. * @param time Define time for gradual change to new volume
  38932. */
  38933. setVolume(newVolume: number, time?: number): void;
  38934. /**
  38935. * Set the sound play back rate
  38936. * @param newPlaybackRate Define the playback rate the sound should be played at
  38937. */
  38938. setPlaybackRate(newPlaybackRate: number): void;
  38939. /**
  38940. * Gets the volume of the sound.
  38941. * @returns the volume of the sound
  38942. */
  38943. getVolume(): number;
  38944. /**
  38945. * Attach the sound to a dedicated mesh
  38946. * @param transformNode The transform node to connect the sound with
  38947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38948. */
  38949. attachToMesh(transformNode: TransformNode): void;
  38950. /**
  38951. * Detach the sound from the previously attached mesh
  38952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38953. */
  38954. detachFromMesh(): void;
  38955. private _onRegisterAfterWorldMatrixUpdate;
  38956. /**
  38957. * Clone the current sound in the scene.
  38958. * @returns the new sound clone
  38959. */
  38960. clone(): Nullable<Sound>;
  38961. /**
  38962. * Gets the current underlying audio buffer containing the data
  38963. * @returns the audio buffer
  38964. */
  38965. getAudioBuffer(): Nullable<AudioBuffer>;
  38966. /**
  38967. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38968. * @returns the source node
  38969. */
  38970. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38971. /**
  38972. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38973. * @returns the gain node
  38974. */
  38975. getSoundGain(): Nullable<GainNode>;
  38976. /**
  38977. * Serializes the Sound in a JSON representation
  38978. * @returns the JSON representation of the sound
  38979. */
  38980. serialize(): any;
  38981. /**
  38982. * Parse a JSON representation of a sound to innstantiate in a given scene
  38983. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38984. * @param scene Define the scene the new parsed sound should be created in
  38985. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38986. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38987. * @returns the newly parsed sound
  38988. */
  38989. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38990. }
  38991. }
  38992. declare module "babylonjs/Actions/directAudioActions" {
  38993. import { Action } from "babylonjs/Actions/action";
  38994. import { Condition } from "babylonjs/Actions/condition";
  38995. import { Sound } from "babylonjs/Audio/sound";
  38996. /**
  38997. * This defines an action helpful to play a defined sound on a triggered action.
  38998. */
  38999. export class PlaySoundAction extends Action {
  39000. private _sound;
  39001. /**
  39002. * Instantiate the action
  39003. * @param triggerOptions defines the trigger options
  39004. * @param sound defines the sound to play
  39005. * @param condition defines the trigger related conditions
  39006. */
  39007. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39008. /** @hidden */
  39009. _prepare(): void;
  39010. /**
  39011. * Execute the action and play the sound.
  39012. */
  39013. execute(): void;
  39014. /**
  39015. * Serializes the actions and its related information.
  39016. * @param parent defines the object to serialize in
  39017. * @returns the serialized object
  39018. */
  39019. serialize(parent: any): any;
  39020. }
  39021. /**
  39022. * This defines an action helpful to stop a defined sound on a triggered action.
  39023. */
  39024. export class StopSoundAction extends Action {
  39025. private _sound;
  39026. /**
  39027. * Instantiate the action
  39028. * @param triggerOptions defines the trigger options
  39029. * @param sound defines the sound to stop
  39030. * @param condition defines the trigger related conditions
  39031. */
  39032. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39033. /** @hidden */
  39034. _prepare(): void;
  39035. /**
  39036. * Execute the action and stop the sound.
  39037. */
  39038. execute(): void;
  39039. /**
  39040. * Serializes the actions and its related information.
  39041. * @param parent defines the object to serialize in
  39042. * @returns the serialized object
  39043. */
  39044. serialize(parent: any): any;
  39045. }
  39046. }
  39047. declare module "babylonjs/Actions/interpolateValueAction" {
  39048. import { Action } from "babylonjs/Actions/action";
  39049. import { Condition } from "babylonjs/Actions/condition";
  39050. import { Observable } from "babylonjs/Misc/observable";
  39051. /**
  39052. * This defines an action responsible to change the value of a property
  39053. * by interpolating between its current value and the newly set one once triggered.
  39054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39055. */
  39056. export class InterpolateValueAction extends Action {
  39057. /**
  39058. * Defines the path of the property where the value should be interpolated
  39059. */
  39060. propertyPath: string;
  39061. /**
  39062. * Defines the target value at the end of the interpolation.
  39063. */
  39064. value: any;
  39065. /**
  39066. * Defines the time it will take for the property to interpolate to the value.
  39067. */
  39068. duration: number;
  39069. /**
  39070. * Defines if the other scene animations should be stopped when the action has been triggered
  39071. */
  39072. stopOtherAnimations?: boolean;
  39073. /**
  39074. * Defines a callback raised once the interpolation animation has been done.
  39075. */
  39076. onInterpolationDone?: () => void;
  39077. /**
  39078. * Observable triggered once the interpolation animation has been done.
  39079. */
  39080. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39081. private _target;
  39082. private _effectiveTarget;
  39083. private _property;
  39084. /**
  39085. * Instantiate the action
  39086. * @param triggerOptions defines the trigger options
  39087. * @param target defines the object containing the value to interpolate
  39088. * @param propertyPath defines the path to the property in the target object
  39089. * @param value defines the target value at the end of the interpolation
  39090. * @param duration deines the time it will take for the property to interpolate to the value.
  39091. * @param condition defines the trigger related conditions
  39092. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39093. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39094. */
  39095. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39096. /** @hidden */
  39097. _prepare(): void;
  39098. /**
  39099. * Execute the action starts the value interpolation.
  39100. */
  39101. execute(): void;
  39102. /**
  39103. * Serializes the actions and its related information.
  39104. * @param parent defines the object to serialize in
  39105. * @returns the serialized object
  39106. */
  39107. serialize(parent: any): any;
  39108. }
  39109. }
  39110. declare module "babylonjs/Actions/index" {
  39111. export * from "babylonjs/Actions/abstractActionManager";
  39112. export * from "babylonjs/Actions/action";
  39113. export * from "babylonjs/Actions/actionEvent";
  39114. export * from "babylonjs/Actions/actionManager";
  39115. export * from "babylonjs/Actions/condition";
  39116. export * from "babylonjs/Actions/directActions";
  39117. export * from "babylonjs/Actions/directAudioActions";
  39118. export * from "babylonjs/Actions/interpolateValueAction";
  39119. }
  39120. declare module "babylonjs/Animations/index" {
  39121. export * from "babylonjs/Animations/animatable";
  39122. export * from "babylonjs/Animations/animation";
  39123. export * from "babylonjs/Animations/animationGroup";
  39124. export * from "babylonjs/Animations/animationPropertiesOverride";
  39125. export * from "babylonjs/Animations/easing";
  39126. export * from "babylonjs/Animations/runtimeAnimation";
  39127. export * from "babylonjs/Animations/animationEvent";
  39128. export * from "babylonjs/Animations/animationGroup";
  39129. export * from "babylonjs/Animations/animationKey";
  39130. export * from "babylonjs/Animations/animationRange";
  39131. export * from "babylonjs/Animations/animatable.interface";
  39132. }
  39133. declare module "babylonjs/Audio/soundTrack" {
  39134. import { Sound } from "babylonjs/Audio/sound";
  39135. import { Analyser } from "babylonjs/Audio/analyser";
  39136. import { Scene } from "babylonjs/scene";
  39137. /**
  39138. * Options allowed during the creation of a sound track.
  39139. */
  39140. export interface ISoundTrackOptions {
  39141. /**
  39142. * The volume the sound track should take during creation
  39143. */
  39144. volume?: number;
  39145. /**
  39146. * Define if the sound track is the main sound track of the scene
  39147. */
  39148. mainTrack?: boolean;
  39149. }
  39150. /**
  39151. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39152. * It will be also used in a future release to apply effects on a specific track.
  39153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39154. */
  39155. export class SoundTrack {
  39156. /**
  39157. * The unique identifier of the sound track in the scene.
  39158. */
  39159. id: number;
  39160. /**
  39161. * The list of sounds included in the sound track.
  39162. */
  39163. soundCollection: Array<Sound>;
  39164. private _outputAudioNode;
  39165. private _scene;
  39166. private _connectedAnalyser;
  39167. private _options;
  39168. private _isInitialized;
  39169. /**
  39170. * Creates a new sound track.
  39171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39172. * @param scene Define the scene the sound track belongs to
  39173. * @param options
  39174. */
  39175. constructor(scene: Scene, options?: ISoundTrackOptions);
  39176. private _initializeSoundTrackAudioGraph;
  39177. /**
  39178. * Release the sound track and its associated resources
  39179. */
  39180. dispose(): void;
  39181. /**
  39182. * Adds a sound to this sound track
  39183. * @param sound define the cound to add
  39184. * @ignoreNaming
  39185. */
  39186. AddSound(sound: Sound): void;
  39187. /**
  39188. * Removes a sound to this sound track
  39189. * @param sound define the cound to remove
  39190. * @ignoreNaming
  39191. */
  39192. RemoveSound(sound: Sound): void;
  39193. /**
  39194. * Set a global volume for the full sound track.
  39195. * @param newVolume Define the new volume of the sound track
  39196. */
  39197. setVolume(newVolume: number): void;
  39198. /**
  39199. * Switch the panning model to HRTF:
  39200. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39201. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39202. */
  39203. switchPanningModelToHRTF(): void;
  39204. /**
  39205. * Switch the panning model to Equal Power:
  39206. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39208. */
  39209. switchPanningModelToEqualPower(): void;
  39210. /**
  39211. * Connect the sound track to an audio analyser allowing some amazing
  39212. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39213. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39214. * @param analyser The analyser to connect to the engine
  39215. */
  39216. connectToAnalyser(analyser: Analyser): void;
  39217. }
  39218. }
  39219. declare module "babylonjs/Audio/audioSceneComponent" {
  39220. import { Sound } from "babylonjs/Audio/sound";
  39221. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39222. import { Nullable } from "babylonjs/types";
  39223. import { Vector3 } from "babylonjs/Maths/math.vector";
  39224. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39225. import { Scene } from "babylonjs/scene";
  39226. import { AbstractScene } from "babylonjs/abstractScene";
  39227. import "babylonjs/Audio/audioEngine";
  39228. module "babylonjs/abstractScene" {
  39229. interface AbstractScene {
  39230. /**
  39231. * The list of sounds used in the scene.
  39232. */
  39233. sounds: Nullable<Array<Sound>>;
  39234. }
  39235. }
  39236. module "babylonjs/scene" {
  39237. interface Scene {
  39238. /**
  39239. * @hidden
  39240. * Backing field
  39241. */
  39242. _mainSoundTrack: SoundTrack;
  39243. /**
  39244. * The main sound track played by the scene.
  39245. * It cotains your primary collection of sounds.
  39246. */
  39247. mainSoundTrack: SoundTrack;
  39248. /**
  39249. * The list of sound tracks added to the scene
  39250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39251. */
  39252. soundTracks: Nullable<Array<SoundTrack>>;
  39253. /**
  39254. * Gets a sound using a given name
  39255. * @param name defines the name to search for
  39256. * @return the found sound or null if not found at all.
  39257. */
  39258. getSoundByName(name: string): Nullable<Sound>;
  39259. /**
  39260. * Gets or sets if audio support is enabled
  39261. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39262. */
  39263. audioEnabled: boolean;
  39264. /**
  39265. * Gets or sets if audio will be output to headphones
  39266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39267. */
  39268. headphone: boolean;
  39269. /**
  39270. * Gets or sets custom audio listener position provider
  39271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39272. */
  39273. audioListenerPositionProvider: Nullable<() => Vector3>;
  39274. /**
  39275. * Gets or sets a refresh rate when using 3D audio positioning
  39276. */
  39277. audioPositioningRefreshRate: number;
  39278. }
  39279. }
  39280. /**
  39281. * Defines the sound scene component responsible to manage any sounds
  39282. * in a given scene.
  39283. */
  39284. export class AudioSceneComponent implements ISceneSerializableComponent {
  39285. /**
  39286. * The component name helpfull to identify the component in the list of scene components.
  39287. */
  39288. readonly name: string;
  39289. /**
  39290. * The scene the component belongs to.
  39291. */
  39292. scene: Scene;
  39293. private _audioEnabled;
  39294. /**
  39295. * Gets whether audio is enabled or not.
  39296. * Please use related enable/disable method to switch state.
  39297. */
  39298. get audioEnabled(): boolean;
  39299. private _headphone;
  39300. /**
  39301. * Gets whether audio is outputing to headphone or not.
  39302. * Please use the according Switch methods to change output.
  39303. */
  39304. get headphone(): boolean;
  39305. /**
  39306. * Gets or sets a refresh rate when using 3D audio positioning
  39307. */
  39308. audioPositioningRefreshRate: number;
  39309. private _audioListenerPositionProvider;
  39310. /**
  39311. * Gets the current audio listener position provider
  39312. */
  39313. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39314. /**
  39315. * Sets a custom listener position for all sounds in the scene
  39316. * By default, this is the position of the first active camera
  39317. */
  39318. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39319. /**
  39320. * Creates a new instance of the component for the given scene
  39321. * @param scene Defines the scene to register the component in
  39322. */
  39323. constructor(scene: Scene);
  39324. /**
  39325. * Registers the component in a given scene
  39326. */
  39327. register(): void;
  39328. /**
  39329. * Rebuilds the elements related to this component in case of
  39330. * context lost for instance.
  39331. */
  39332. rebuild(): void;
  39333. /**
  39334. * Serializes the component data to the specified json object
  39335. * @param serializationObject The object to serialize to
  39336. */
  39337. serialize(serializationObject: any): void;
  39338. /**
  39339. * Adds all the elements from the container to the scene
  39340. * @param container the container holding the elements
  39341. */
  39342. addFromContainer(container: AbstractScene): void;
  39343. /**
  39344. * Removes all the elements in the container from the scene
  39345. * @param container contains the elements to remove
  39346. * @param dispose if the removed element should be disposed (default: false)
  39347. */
  39348. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39349. /**
  39350. * Disposes the component and the associated ressources.
  39351. */
  39352. dispose(): void;
  39353. /**
  39354. * Disables audio in the associated scene.
  39355. */
  39356. disableAudio(): void;
  39357. /**
  39358. * Enables audio in the associated scene.
  39359. */
  39360. enableAudio(): void;
  39361. /**
  39362. * Switch audio to headphone output.
  39363. */
  39364. switchAudioModeForHeadphones(): void;
  39365. /**
  39366. * Switch audio to normal speakers.
  39367. */
  39368. switchAudioModeForNormalSpeakers(): void;
  39369. private _cachedCameraDirection;
  39370. private _cachedCameraPosition;
  39371. private _lastCheck;
  39372. private _afterRender;
  39373. }
  39374. }
  39375. declare module "babylonjs/Audio/weightedsound" {
  39376. import { Sound } from "babylonjs/Audio/sound";
  39377. /**
  39378. * Wraps one or more Sound objects and selects one with random weight for playback.
  39379. */
  39380. export class WeightedSound {
  39381. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39382. loop: boolean;
  39383. private _coneInnerAngle;
  39384. private _coneOuterAngle;
  39385. private _volume;
  39386. /** A Sound is currently playing. */
  39387. isPlaying: boolean;
  39388. /** A Sound is currently paused. */
  39389. isPaused: boolean;
  39390. private _sounds;
  39391. private _weights;
  39392. private _currentIndex?;
  39393. /**
  39394. * Creates a new WeightedSound from the list of sounds given.
  39395. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39396. * @param sounds Array of Sounds that will be selected from.
  39397. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39398. */
  39399. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39400. /**
  39401. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39402. */
  39403. get directionalConeInnerAngle(): number;
  39404. /**
  39405. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39406. */
  39407. set directionalConeInnerAngle(value: number);
  39408. /**
  39409. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39410. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39411. */
  39412. get directionalConeOuterAngle(): number;
  39413. /**
  39414. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39415. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39416. */
  39417. set directionalConeOuterAngle(value: number);
  39418. /**
  39419. * Playback volume.
  39420. */
  39421. get volume(): number;
  39422. /**
  39423. * Playback volume.
  39424. */
  39425. set volume(value: number);
  39426. private _onended;
  39427. /**
  39428. * Suspend playback
  39429. */
  39430. pause(): void;
  39431. /**
  39432. * Stop playback
  39433. */
  39434. stop(): void;
  39435. /**
  39436. * Start playback.
  39437. * @param startOffset Position the clip head at a specific time in seconds.
  39438. */
  39439. play(startOffset?: number): void;
  39440. }
  39441. }
  39442. declare module "babylonjs/Audio/index" {
  39443. export * from "babylonjs/Audio/analyser";
  39444. export * from "babylonjs/Audio/audioEngine";
  39445. export * from "babylonjs/Audio/audioSceneComponent";
  39446. export * from "babylonjs/Audio/sound";
  39447. export * from "babylonjs/Audio/soundTrack";
  39448. export * from "babylonjs/Audio/weightedsound";
  39449. }
  39450. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39451. import { Behavior } from "babylonjs/Behaviors/behavior";
  39452. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39453. import { BackEase } from "babylonjs/Animations/easing";
  39454. /**
  39455. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39456. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39457. */
  39458. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39459. /**
  39460. * Gets the name of the behavior.
  39461. */
  39462. get name(): string;
  39463. /**
  39464. * The easing function used by animations
  39465. */
  39466. static EasingFunction: BackEase;
  39467. /**
  39468. * The easing mode used by animations
  39469. */
  39470. static EasingMode: number;
  39471. /**
  39472. * The duration of the animation, in milliseconds
  39473. */
  39474. transitionDuration: number;
  39475. /**
  39476. * Length of the distance animated by the transition when lower radius is reached
  39477. */
  39478. lowerRadiusTransitionRange: number;
  39479. /**
  39480. * Length of the distance animated by the transition when upper radius is reached
  39481. */
  39482. upperRadiusTransitionRange: number;
  39483. private _autoTransitionRange;
  39484. /**
  39485. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39486. */
  39487. get autoTransitionRange(): boolean;
  39488. /**
  39489. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39490. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39491. */
  39492. set autoTransitionRange(value: boolean);
  39493. private _attachedCamera;
  39494. private _onAfterCheckInputsObserver;
  39495. private _onMeshTargetChangedObserver;
  39496. /**
  39497. * Initializes the behavior.
  39498. */
  39499. init(): void;
  39500. /**
  39501. * Attaches the behavior to its arc rotate camera.
  39502. * @param camera Defines the camera to attach the behavior to
  39503. */
  39504. attach(camera: ArcRotateCamera): void;
  39505. /**
  39506. * Detaches the behavior from its current arc rotate camera.
  39507. */
  39508. detach(): void;
  39509. private _radiusIsAnimating;
  39510. private _radiusBounceTransition;
  39511. private _animatables;
  39512. private _cachedWheelPrecision;
  39513. /**
  39514. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39515. * @param radiusLimit The limit to check against.
  39516. * @return Bool to indicate if at limit.
  39517. */
  39518. private _isRadiusAtLimit;
  39519. /**
  39520. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39521. * @param radiusDelta The delta by which to animate to. Can be negative.
  39522. */
  39523. private _applyBoundRadiusAnimation;
  39524. /**
  39525. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39526. */
  39527. protected _clearAnimationLocks(): void;
  39528. /**
  39529. * Stops and removes all animations that have been applied to the camera
  39530. */
  39531. stopAllAnimations(): void;
  39532. }
  39533. }
  39534. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39535. import { Behavior } from "babylonjs/Behaviors/behavior";
  39536. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39537. import { ExponentialEase } from "babylonjs/Animations/easing";
  39538. import { Nullable } from "babylonjs/types";
  39539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39540. import { Vector3 } from "babylonjs/Maths/math.vector";
  39541. /**
  39542. * 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.
  39543. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39544. */
  39545. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39546. /**
  39547. * Gets the name of the behavior.
  39548. */
  39549. get name(): string;
  39550. private _mode;
  39551. private _radiusScale;
  39552. private _positionScale;
  39553. private _defaultElevation;
  39554. private _elevationReturnTime;
  39555. private _elevationReturnWaitTime;
  39556. private _zoomStopsAnimation;
  39557. private _framingTime;
  39558. /**
  39559. * The easing function used by animations
  39560. */
  39561. static EasingFunction: ExponentialEase;
  39562. /**
  39563. * The easing mode used by animations
  39564. */
  39565. static EasingMode: number;
  39566. /**
  39567. * Sets the current mode used by the behavior
  39568. */
  39569. set mode(mode: number);
  39570. /**
  39571. * Gets current mode used by the behavior.
  39572. */
  39573. get mode(): number;
  39574. /**
  39575. * Sets the scale applied to the radius (1 by default)
  39576. */
  39577. set radiusScale(radius: number);
  39578. /**
  39579. * Gets the scale applied to the radius
  39580. */
  39581. get radiusScale(): number;
  39582. /**
  39583. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39584. */
  39585. set positionScale(scale: number);
  39586. /**
  39587. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39588. */
  39589. get positionScale(): number;
  39590. /**
  39591. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39592. * behaviour is triggered, in radians.
  39593. */
  39594. set defaultElevation(elevation: number);
  39595. /**
  39596. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39597. * behaviour is triggered, in radians.
  39598. */
  39599. get defaultElevation(): number;
  39600. /**
  39601. * Sets the time (in milliseconds) taken to return to the default beta position.
  39602. * Negative value indicates camera should not return to default.
  39603. */
  39604. set elevationReturnTime(speed: number);
  39605. /**
  39606. * Gets the time (in milliseconds) taken to return to the default beta position.
  39607. * Negative value indicates camera should not return to default.
  39608. */
  39609. get elevationReturnTime(): number;
  39610. /**
  39611. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39612. */
  39613. set elevationReturnWaitTime(time: number);
  39614. /**
  39615. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39616. */
  39617. get elevationReturnWaitTime(): number;
  39618. /**
  39619. * Sets the flag that indicates if user zooming should stop animation.
  39620. */
  39621. set zoomStopsAnimation(flag: boolean);
  39622. /**
  39623. * Gets the flag that indicates if user zooming should stop animation.
  39624. */
  39625. get zoomStopsAnimation(): boolean;
  39626. /**
  39627. * Sets the transition time when framing the mesh, in milliseconds
  39628. */
  39629. set framingTime(time: number);
  39630. /**
  39631. * Gets the transition time when framing the mesh, in milliseconds
  39632. */
  39633. get framingTime(): number;
  39634. /**
  39635. * Define if the behavior should automatically change the configured
  39636. * camera limits and sensibilities.
  39637. */
  39638. autoCorrectCameraLimitsAndSensibility: boolean;
  39639. private _onPrePointerObservableObserver;
  39640. private _onAfterCheckInputsObserver;
  39641. private _onMeshTargetChangedObserver;
  39642. private _attachedCamera;
  39643. private _isPointerDown;
  39644. private _lastInteractionTime;
  39645. /**
  39646. * Initializes the behavior.
  39647. */
  39648. init(): void;
  39649. /**
  39650. * Attaches the behavior to its arc rotate camera.
  39651. * @param camera Defines the camera to attach the behavior to
  39652. */
  39653. attach(camera: ArcRotateCamera): void;
  39654. /**
  39655. * Detaches the behavior from its current arc rotate camera.
  39656. */
  39657. detach(): void;
  39658. private _animatables;
  39659. private _betaIsAnimating;
  39660. private _betaTransition;
  39661. private _radiusTransition;
  39662. private _vectorTransition;
  39663. /**
  39664. * Targets the given mesh and updates zoom level accordingly.
  39665. * @param mesh The mesh to target.
  39666. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39667. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39668. */
  39669. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39670. /**
  39671. * Targets the given mesh with its children and updates zoom level accordingly.
  39672. * @param mesh The mesh to target.
  39673. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39674. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39675. */
  39676. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39677. /**
  39678. * Targets the given meshes with their children and updates zoom level accordingly.
  39679. * @param meshes The mesh to target.
  39680. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39681. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39682. */
  39683. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39684. /**
  39685. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39686. * @param minimumWorld Determines the smaller position of the bounding box extend
  39687. * @param maximumWorld Determines the bigger position of the bounding box extend
  39688. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39689. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39690. */
  39691. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39692. /**
  39693. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39694. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39695. * frustum width.
  39696. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39697. * to fully enclose the mesh in the viewing frustum.
  39698. */
  39699. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39700. /**
  39701. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39702. * is automatically returned to its default position (expected to be above ground plane).
  39703. */
  39704. private _maintainCameraAboveGround;
  39705. /**
  39706. * Returns the frustum slope based on the canvas ratio and camera FOV
  39707. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39708. */
  39709. private _getFrustumSlope;
  39710. /**
  39711. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39712. */
  39713. private _clearAnimationLocks;
  39714. /**
  39715. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39716. */
  39717. private _applyUserInteraction;
  39718. /**
  39719. * Stops and removes all animations that have been applied to the camera
  39720. */
  39721. stopAllAnimations(): void;
  39722. /**
  39723. * Gets a value indicating if the user is moving the camera
  39724. */
  39725. get isUserIsMoving(): boolean;
  39726. /**
  39727. * The camera can move all the way towards the mesh.
  39728. */
  39729. static IgnoreBoundsSizeMode: number;
  39730. /**
  39731. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39732. */
  39733. static FitFrustumSidesMode: number;
  39734. }
  39735. }
  39736. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39737. import { Nullable } from "babylonjs/types";
  39738. import { Camera } from "babylonjs/Cameras/camera";
  39739. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39740. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39741. /**
  39742. * Base class for Camera Pointer Inputs.
  39743. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39744. * for example usage.
  39745. */
  39746. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39747. /**
  39748. * Defines the camera the input is attached to.
  39749. */
  39750. abstract camera: Camera;
  39751. /**
  39752. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39753. */
  39754. protected _altKey: boolean;
  39755. protected _ctrlKey: boolean;
  39756. protected _metaKey: boolean;
  39757. protected _shiftKey: boolean;
  39758. /**
  39759. * Which mouse buttons were pressed at time of last mouse event.
  39760. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39761. */
  39762. protected _buttonsPressed: number;
  39763. /**
  39764. * Defines the buttons associated with the input to handle camera move.
  39765. */
  39766. buttons: number[];
  39767. /**
  39768. * Attach the input controls to a specific dom element to get the input from.
  39769. * @param element Defines the element the controls should be listened from
  39770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39771. */
  39772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39773. /**
  39774. * Detach the current controls from the specified dom element.
  39775. * @param element Defines the element to stop listening the inputs from
  39776. */
  39777. detachControl(element: Nullable<HTMLElement>): void;
  39778. /**
  39779. * Gets the class name of the current input.
  39780. * @returns the class name
  39781. */
  39782. getClassName(): string;
  39783. /**
  39784. * Get the friendly name associated with the input class.
  39785. * @returns the input friendly name
  39786. */
  39787. getSimpleName(): string;
  39788. /**
  39789. * Called on pointer POINTERDOUBLETAP event.
  39790. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39791. */
  39792. protected onDoubleTap(type: string): void;
  39793. /**
  39794. * Called on pointer POINTERMOVE event if only a single touch is active.
  39795. * Override this method to provide functionality.
  39796. */
  39797. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39798. /**
  39799. * Called on pointer POINTERMOVE event if multiple touches are active.
  39800. * Override this method to provide functionality.
  39801. */
  39802. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39803. /**
  39804. * Called on JS contextmenu event.
  39805. * Override this method to provide functionality.
  39806. */
  39807. protected onContextMenu(evt: PointerEvent): void;
  39808. /**
  39809. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39810. * press.
  39811. * Override this method to provide functionality.
  39812. */
  39813. protected onButtonDown(evt: PointerEvent): void;
  39814. /**
  39815. * Called each time a new POINTERUP event occurs. Ie, for each button
  39816. * release.
  39817. * Override this method to provide functionality.
  39818. */
  39819. protected onButtonUp(evt: PointerEvent): void;
  39820. /**
  39821. * Called when window becomes inactive.
  39822. * Override this method to provide functionality.
  39823. */
  39824. protected onLostFocus(): void;
  39825. private _pointerInput;
  39826. private _observer;
  39827. private _onLostFocus;
  39828. private pointA;
  39829. private pointB;
  39830. }
  39831. }
  39832. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39833. import { Nullable } from "babylonjs/types";
  39834. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39835. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39836. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39837. /**
  39838. * Manage the pointers inputs to control an arc rotate camera.
  39839. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39840. */
  39841. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39842. /**
  39843. * Defines the camera the input is attached to.
  39844. */
  39845. camera: ArcRotateCamera;
  39846. /**
  39847. * Gets the class name of the current input.
  39848. * @returns the class name
  39849. */
  39850. getClassName(): string;
  39851. /**
  39852. * Defines the buttons associated with the input to handle camera move.
  39853. */
  39854. buttons: number[];
  39855. /**
  39856. * Defines the pointer angular sensibility along the X axis or how fast is
  39857. * the camera rotating.
  39858. */
  39859. angularSensibilityX: number;
  39860. /**
  39861. * Defines the pointer angular sensibility along the Y axis or how fast is
  39862. * the camera rotating.
  39863. */
  39864. angularSensibilityY: number;
  39865. /**
  39866. * Defines the pointer pinch precision or how fast is the camera zooming.
  39867. */
  39868. pinchPrecision: number;
  39869. /**
  39870. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39871. * from 0.
  39872. * It defines the percentage of current camera.radius to use as delta when
  39873. * pinch zoom is used.
  39874. */
  39875. pinchDeltaPercentage: number;
  39876. /**
  39877. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39878. * that any object in the plane at the camera's target point will scale
  39879. * perfectly with finger motion.
  39880. * Overrides pinchDeltaPercentage and pinchPrecision.
  39881. */
  39882. useNaturalPinchZoom: boolean;
  39883. /**
  39884. * Defines the pointer panning sensibility or how fast is the camera moving.
  39885. */
  39886. panningSensibility: number;
  39887. /**
  39888. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39889. */
  39890. multiTouchPanning: boolean;
  39891. /**
  39892. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39893. * zoom (pinch) through multitouch.
  39894. */
  39895. multiTouchPanAndZoom: boolean;
  39896. /**
  39897. * Revers pinch action direction.
  39898. */
  39899. pinchInwards: boolean;
  39900. private _isPanClick;
  39901. private _twoFingerActivityCount;
  39902. private _isPinching;
  39903. /**
  39904. * Called on pointer POINTERMOVE event if only a single touch is active.
  39905. */
  39906. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39907. /**
  39908. * Called on pointer POINTERDOUBLETAP event.
  39909. */
  39910. protected onDoubleTap(type: string): void;
  39911. /**
  39912. * Called on pointer POINTERMOVE event if multiple touches are active.
  39913. */
  39914. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39915. /**
  39916. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39917. * press.
  39918. */
  39919. protected onButtonDown(evt: PointerEvent): void;
  39920. /**
  39921. * Called each time a new POINTERUP event occurs. Ie, for each button
  39922. * release.
  39923. */
  39924. protected onButtonUp(evt: PointerEvent): void;
  39925. /**
  39926. * Called when window becomes inactive.
  39927. */
  39928. protected onLostFocus(): void;
  39929. }
  39930. }
  39931. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39932. import { Nullable } from "babylonjs/types";
  39933. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39934. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39935. /**
  39936. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39937. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39938. */
  39939. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39940. /**
  39941. * Defines the camera the input is attached to.
  39942. */
  39943. camera: ArcRotateCamera;
  39944. /**
  39945. * Defines the list of key codes associated with the up action (increase alpha)
  39946. */
  39947. keysUp: number[];
  39948. /**
  39949. * Defines the list of key codes associated with the down action (decrease alpha)
  39950. */
  39951. keysDown: number[];
  39952. /**
  39953. * Defines the list of key codes associated with the left action (increase beta)
  39954. */
  39955. keysLeft: number[];
  39956. /**
  39957. * Defines the list of key codes associated with the right action (decrease beta)
  39958. */
  39959. keysRight: number[];
  39960. /**
  39961. * Defines the list of key codes associated with the reset action.
  39962. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39963. */
  39964. keysReset: number[];
  39965. /**
  39966. * Defines the panning sensibility of the inputs.
  39967. * (How fast is the camera panning)
  39968. */
  39969. panningSensibility: number;
  39970. /**
  39971. * Defines the zooming sensibility of the inputs.
  39972. * (How fast is the camera zooming)
  39973. */
  39974. zoomingSensibility: number;
  39975. /**
  39976. * Defines whether maintaining the alt key down switch the movement mode from
  39977. * orientation to zoom.
  39978. */
  39979. useAltToZoom: boolean;
  39980. /**
  39981. * Rotation speed of the camera
  39982. */
  39983. angularSpeed: number;
  39984. private _keys;
  39985. private _ctrlPressed;
  39986. private _altPressed;
  39987. private _onCanvasBlurObserver;
  39988. private _onKeyboardObserver;
  39989. private _engine;
  39990. private _scene;
  39991. /**
  39992. * Attach the input controls to a specific dom element to get the input from.
  39993. * @param element Defines the element the controls should be listened from
  39994. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39995. */
  39996. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39997. /**
  39998. * Detach the current controls from the specified dom element.
  39999. * @param element Defines the element to stop listening the inputs from
  40000. */
  40001. detachControl(element: Nullable<HTMLElement>): void;
  40002. /**
  40003. * Update the current camera state depending on the inputs that have been used this frame.
  40004. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40005. */
  40006. checkInputs(): void;
  40007. /**
  40008. * Gets the class name of the current intput.
  40009. * @returns the class name
  40010. */
  40011. getClassName(): string;
  40012. /**
  40013. * Get the friendly name associated with the input class.
  40014. * @returns the input friendly name
  40015. */
  40016. getSimpleName(): string;
  40017. }
  40018. }
  40019. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40020. import { Nullable } from "babylonjs/types";
  40021. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40022. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40023. /**
  40024. * Manage the mouse wheel inputs to control an arc rotate camera.
  40025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40026. */
  40027. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40028. /**
  40029. * Defines the camera the input is attached to.
  40030. */
  40031. camera: ArcRotateCamera;
  40032. /**
  40033. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40034. */
  40035. wheelPrecision: number;
  40036. /**
  40037. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40038. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40039. */
  40040. wheelDeltaPercentage: number;
  40041. private _wheel;
  40042. private _observer;
  40043. private computeDeltaFromMouseWheelLegacyEvent;
  40044. /**
  40045. * Attach the input controls to a specific dom element to get the input from.
  40046. * @param element Defines the element the controls should be listened from
  40047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40048. */
  40049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40050. /**
  40051. * Detach the current controls from the specified dom element.
  40052. * @param element Defines the element to stop listening the inputs from
  40053. */
  40054. detachControl(element: Nullable<HTMLElement>): void;
  40055. /**
  40056. * Gets the class name of the current intput.
  40057. * @returns the class name
  40058. */
  40059. getClassName(): string;
  40060. /**
  40061. * Get the friendly name associated with the input class.
  40062. * @returns the input friendly name
  40063. */
  40064. getSimpleName(): string;
  40065. }
  40066. }
  40067. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40068. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40069. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40070. /**
  40071. * Default Inputs manager for the ArcRotateCamera.
  40072. * It groups all the default supported inputs for ease of use.
  40073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40074. */
  40075. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40076. /**
  40077. * Instantiates a new ArcRotateCameraInputsManager.
  40078. * @param camera Defines the camera the inputs belong to
  40079. */
  40080. constructor(camera: ArcRotateCamera);
  40081. /**
  40082. * Add mouse wheel input support to the input manager.
  40083. * @returns the current input manager
  40084. */
  40085. addMouseWheel(): ArcRotateCameraInputsManager;
  40086. /**
  40087. * Add pointers input support to the input manager.
  40088. * @returns the current input manager
  40089. */
  40090. addPointers(): ArcRotateCameraInputsManager;
  40091. /**
  40092. * Add keyboard input support to the input manager.
  40093. * @returns the current input manager
  40094. */
  40095. addKeyboard(): ArcRotateCameraInputsManager;
  40096. }
  40097. }
  40098. declare module "babylonjs/Cameras/arcRotateCamera" {
  40099. import { Observable } from "babylonjs/Misc/observable";
  40100. import { Nullable } from "babylonjs/types";
  40101. import { Scene } from "babylonjs/scene";
  40102. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40104. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40105. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40106. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40107. import { Camera } from "babylonjs/Cameras/camera";
  40108. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40109. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40110. import { Collider } from "babylonjs/Collisions/collider";
  40111. /**
  40112. * This represents an orbital type of camera.
  40113. *
  40114. * 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.
  40115. * 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.
  40116. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40117. */
  40118. export class ArcRotateCamera extends TargetCamera {
  40119. /**
  40120. * Defines the rotation angle of the camera along the longitudinal axis.
  40121. */
  40122. alpha: number;
  40123. /**
  40124. * Defines the rotation angle of the camera along the latitudinal axis.
  40125. */
  40126. beta: number;
  40127. /**
  40128. * Defines the radius of the camera from it s target point.
  40129. */
  40130. radius: number;
  40131. protected _target: Vector3;
  40132. protected _targetHost: Nullable<AbstractMesh>;
  40133. /**
  40134. * Defines the target point of the camera.
  40135. * The camera looks towards it form the radius distance.
  40136. */
  40137. get target(): Vector3;
  40138. set target(value: Vector3);
  40139. /**
  40140. * Define the current local position of the camera in the scene
  40141. */
  40142. get position(): Vector3;
  40143. set position(newPosition: Vector3);
  40144. protected _upVector: Vector3;
  40145. protected _upToYMatrix: Matrix;
  40146. protected _YToUpMatrix: Matrix;
  40147. /**
  40148. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40149. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40150. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40151. */
  40152. set upVector(vec: Vector3);
  40153. get upVector(): Vector3;
  40154. /**
  40155. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40156. */
  40157. setMatUp(): void;
  40158. /**
  40159. * Current inertia value on the longitudinal axis.
  40160. * The bigger this number the longer it will take for the camera to stop.
  40161. */
  40162. inertialAlphaOffset: number;
  40163. /**
  40164. * Current inertia value on the latitudinal axis.
  40165. * The bigger this number the longer it will take for the camera to stop.
  40166. */
  40167. inertialBetaOffset: number;
  40168. /**
  40169. * Current inertia value on the radius axis.
  40170. * The bigger this number the longer it will take for the camera to stop.
  40171. */
  40172. inertialRadiusOffset: number;
  40173. /**
  40174. * Minimum allowed angle on the longitudinal axis.
  40175. * This can help limiting how the Camera is able to move in the scene.
  40176. */
  40177. lowerAlphaLimit: Nullable<number>;
  40178. /**
  40179. * Maximum allowed angle on the longitudinal axis.
  40180. * This can help limiting how the Camera is able to move in the scene.
  40181. */
  40182. upperAlphaLimit: Nullable<number>;
  40183. /**
  40184. * Minimum allowed angle on the latitudinal axis.
  40185. * This can help limiting how the Camera is able to move in the scene.
  40186. */
  40187. lowerBetaLimit: number;
  40188. /**
  40189. * Maximum allowed angle on the latitudinal axis.
  40190. * This can help limiting how the Camera is able to move in the scene.
  40191. */
  40192. upperBetaLimit: number;
  40193. /**
  40194. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40195. * This can help limiting how the Camera is able to move in the scene.
  40196. */
  40197. lowerRadiusLimit: Nullable<number>;
  40198. /**
  40199. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40200. * This can help limiting how the Camera is able to move in the scene.
  40201. */
  40202. upperRadiusLimit: Nullable<number>;
  40203. /**
  40204. * Defines the current inertia value used during panning of the camera along the X axis.
  40205. */
  40206. inertialPanningX: number;
  40207. /**
  40208. * Defines the current inertia value used during panning of the camera along the Y axis.
  40209. */
  40210. inertialPanningY: number;
  40211. /**
  40212. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40213. * Basically if your fingers moves away from more than this distance you will be considered
  40214. * in pinch mode.
  40215. */
  40216. pinchToPanMaxDistance: number;
  40217. /**
  40218. * Defines the maximum distance the camera can pan.
  40219. * This could help keeping the cammera always in your scene.
  40220. */
  40221. panningDistanceLimit: Nullable<number>;
  40222. /**
  40223. * Defines the target of the camera before paning.
  40224. */
  40225. panningOriginTarget: Vector3;
  40226. /**
  40227. * Defines the value of the inertia used during panning.
  40228. * 0 would mean stop inertia and one would mean no decelleration at all.
  40229. */
  40230. panningInertia: number;
  40231. /**
  40232. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40233. */
  40234. get angularSensibilityX(): number;
  40235. set angularSensibilityX(value: number);
  40236. /**
  40237. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40238. */
  40239. get angularSensibilityY(): number;
  40240. set angularSensibilityY(value: number);
  40241. /**
  40242. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40243. */
  40244. get pinchPrecision(): number;
  40245. set pinchPrecision(value: number);
  40246. /**
  40247. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40248. * It will be used instead of pinchDeltaPrecision if different from 0.
  40249. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40250. */
  40251. get pinchDeltaPercentage(): number;
  40252. set pinchDeltaPercentage(value: number);
  40253. /**
  40254. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40255. * and pinch delta percentage.
  40256. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40257. * that any object in the plane at the camera's target point will scale
  40258. * perfectly with finger motion.
  40259. */
  40260. get useNaturalPinchZoom(): boolean;
  40261. set useNaturalPinchZoom(value: boolean);
  40262. /**
  40263. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40264. */
  40265. get panningSensibility(): number;
  40266. set panningSensibility(value: number);
  40267. /**
  40268. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40269. */
  40270. get keysUp(): number[];
  40271. set keysUp(value: number[]);
  40272. /**
  40273. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40274. */
  40275. get keysDown(): number[];
  40276. set keysDown(value: number[]);
  40277. /**
  40278. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40279. */
  40280. get keysLeft(): number[];
  40281. set keysLeft(value: number[]);
  40282. /**
  40283. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40284. */
  40285. get keysRight(): number[];
  40286. set keysRight(value: number[]);
  40287. /**
  40288. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40289. */
  40290. get wheelPrecision(): number;
  40291. set wheelPrecision(value: number);
  40292. /**
  40293. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40294. * It will be used instead of pinchDeltaPrecision if different from 0.
  40295. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40296. */
  40297. get wheelDeltaPercentage(): number;
  40298. set wheelDeltaPercentage(value: number);
  40299. /**
  40300. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40301. */
  40302. zoomOnFactor: number;
  40303. /**
  40304. * Defines a screen offset for the camera position.
  40305. */
  40306. targetScreenOffset: Vector2;
  40307. /**
  40308. * Allows the camera to be completely reversed.
  40309. * If false the camera can not arrive upside down.
  40310. */
  40311. allowUpsideDown: boolean;
  40312. /**
  40313. * Define if double tap/click is used to restore the previously saved state of the camera.
  40314. */
  40315. useInputToRestoreState: boolean;
  40316. /** @hidden */
  40317. _viewMatrix: Matrix;
  40318. /** @hidden */
  40319. _useCtrlForPanning: boolean;
  40320. /** @hidden */
  40321. _panningMouseButton: number;
  40322. /**
  40323. * Defines the input associated to the camera.
  40324. */
  40325. inputs: ArcRotateCameraInputsManager;
  40326. /** @hidden */
  40327. _reset: () => void;
  40328. /**
  40329. * Defines the allowed panning axis.
  40330. */
  40331. panningAxis: Vector3;
  40332. protected _localDirection: Vector3;
  40333. protected _transformedDirection: Vector3;
  40334. private _bouncingBehavior;
  40335. /**
  40336. * Gets the bouncing behavior of the camera if it has been enabled.
  40337. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40338. */
  40339. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40340. /**
  40341. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40342. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40343. */
  40344. get useBouncingBehavior(): boolean;
  40345. set useBouncingBehavior(value: boolean);
  40346. private _framingBehavior;
  40347. /**
  40348. * Gets the framing behavior of the camera if it has been enabled.
  40349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40350. */
  40351. get framingBehavior(): Nullable<FramingBehavior>;
  40352. /**
  40353. * Defines if the framing behavior of the camera is enabled on the camera.
  40354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40355. */
  40356. get useFramingBehavior(): boolean;
  40357. set useFramingBehavior(value: boolean);
  40358. private _autoRotationBehavior;
  40359. /**
  40360. * Gets the auto rotation behavior of the camera if it has been enabled.
  40361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40362. */
  40363. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40364. /**
  40365. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40367. */
  40368. get useAutoRotationBehavior(): boolean;
  40369. set useAutoRotationBehavior(value: boolean);
  40370. /**
  40371. * Observable triggered when the mesh target has been changed on the camera.
  40372. */
  40373. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40374. /**
  40375. * Event raised when the camera is colliding with a mesh.
  40376. */
  40377. onCollide: (collidedMesh: AbstractMesh) => void;
  40378. /**
  40379. * Defines whether the camera should check collision with the objects oh the scene.
  40380. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40381. */
  40382. checkCollisions: boolean;
  40383. /**
  40384. * Defines the collision radius of the camera.
  40385. * This simulates a sphere around the camera.
  40386. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40387. */
  40388. collisionRadius: Vector3;
  40389. protected _collider: Collider;
  40390. protected _previousPosition: Vector3;
  40391. protected _collisionVelocity: Vector3;
  40392. protected _newPosition: Vector3;
  40393. protected _previousAlpha: number;
  40394. protected _previousBeta: number;
  40395. protected _previousRadius: number;
  40396. protected _collisionTriggered: boolean;
  40397. protected _targetBoundingCenter: Nullable<Vector3>;
  40398. private _computationVector;
  40399. /**
  40400. * Instantiates a new ArcRotateCamera in a given scene
  40401. * @param name Defines the name of the camera
  40402. * @param alpha Defines the camera rotation along the logitudinal axis
  40403. * @param beta Defines the camera rotation along the latitudinal axis
  40404. * @param radius Defines the camera distance from its target
  40405. * @param target Defines the camera target
  40406. * @param scene Defines the scene the camera belongs to
  40407. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40408. */
  40409. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40410. /** @hidden */
  40411. _initCache(): void;
  40412. /** @hidden */
  40413. _updateCache(ignoreParentClass?: boolean): void;
  40414. protected _getTargetPosition(): Vector3;
  40415. private _storedAlpha;
  40416. private _storedBeta;
  40417. private _storedRadius;
  40418. private _storedTarget;
  40419. private _storedTargetScreenOffset;
  40420. /**
  40421. * Stores the current state of the camera (alpha, beta, radius and target)
  40422. * @returns the camera itself
  40423. */
  40424. storeState(): Camera;
  40425. /**
  40426. * @hidden
  40427. * Restored camera state. You must call storeState() first
  40428. */
  40429. _restoreStateValues(): boolean;
  40430. /** @hidden */
  40431. _isSynchronizedViewMatrix(): boolean;
  40432. /**
  40433. * Attached controls to the current camera.
  40434. * @param element Defines the element the controls should be listened from
  40435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40436. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40437. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40438. */
  40439. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40440. /**
  40441. * Detach the current controls from the camera.
  40442. * The camera will stop reacting to inputs.
  40443. * @param element Defines the element to stop listening the inputs from
  40444. */
  40445. detachControl(element: HTMLElement): void;
  40446. /** @hidden */
  40447. _checkInputs(): void;
  40448. protected _checkLimits(): void;
  40449. /**
  40450. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40451. */
  40452. rebuildAnglesAndRadius(): void;
  40453. /**
  40454. * Use a position to define the current camera related information like alpha, beta and radius
  40455. * @param position Defines the position to set the camera at
  40456. */
  40457. setPosition(position: Vector3): void;
  40458. /**
  40459. * Defines the target the camera should look at.
  40460. * This will automatically adapt alpha beta and radius to fit within the new target.
  40461. * @param target Defines the new target as a Vector or a mesh
  40462. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40463. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40464. */
  40465. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40466. /** @hidden */
  40467. _getViewMatrix(): Matrix;
  40468. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40469. /**
  40470. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40471. * @param meshes Defines the mesh to zoom on
  40472. * @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)
  40473. */
  40474. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40475. /**
  40476. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40477. * The target will be changed but the radius
  40478. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40479. * @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)
  40480. */
  40481. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40482. min: Vector3;
  40483. max: Vector3;
  40484. distance: number;
  40485. }, doNotUpdateMaxZ?: boolean): void;
  40486. /**
  40487. * @override
  40488. * Override Camera.createRigCamera
  40489. */
  40490. createRigCamera(name: string, cameraIndex: number): Camera;
  40491. /**
  40492. * @hidden
  40493. * @override
  40494. * Override Camera._updateRigCameras
  40495. */
  40496. _updateRigCameras(): void;
  40497. /**
  40498. * Destroy the camera and release the current resources hold by it.
  40499. */
  40500. dispose(): void;
  40501. /**
  40502. * Gets the current object class name.
  40503. * @return the class name
  40504. */
  40505. getClassName(): string;
  40506. }
  40507. }
  40508. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40509. import { Behavior } from "babylonjs/Behaviors/behavior";
  40510. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40511. /**
  40512. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40513. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40514. */
  40515. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40516. /**
  40517. * Gets the name of the behavior.
  40518. */
  40519. get name(): string;
  40520. private _zoomStopsAnimation;
  40521. private _idleRotationSpeed;
  40522. private _idleRotationWaitTime;
  40523. private _idleRotationSpinupTime;
  40524. /**
  40525. * Sets the flag that indicates if user zooming should stop animation.
  40526. */
  40527. set zoomStopsAnimation(flag: boolean);
  40528. /**
  40529. * Gets the flag that indicates if user zooming should stop animation.
  40530. */
  40531. get zoomStopsAnimation(): boolean;
  40532. /**
  40533. * Sets the default speed at which the camera rotates around the model.
  40534. */
  40535. set idleRotationSpeed(speed: number);
  40536. /**
  40537. * Gets the default speed at which the camera rotates around the model.
  40538. */
  40539. get idleRotationSpeed(): number;
  40540. /**
  40541. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40542. */
  40543. set idleRotationWaitTime(time: number);
  40544. /**
  40545. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40546. */
  40547. get idleRotationWaitTime(): number;
  40548. /**
  40549. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40550. */
  40551. set idleRotationSpinupTime(time: number);
  40552. /**
  40553. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40554. */
  40555. get idleRotationSpinupTime(): number;
  40556. /**
  40557. * Gets a value indicating if the camera is currently rotating because of this behavior
  40558. */
  40559. get rotationInProgress(): boolean;
  40560. private _onPrePointerObservableObserver;
  40561. private _onAfterCheckInputsObserver;
  40562. private _attachedCamera;
  40563. private _isPointerDown;
  40564. private _lastFrameTime;
  40565. private _lastInteractionTime;
  40566. private _cameraRotationSpeed;
  40567. /**
  40568. * Initializes the behavior.
  40569. */
  40570. init(): void;
  40571. /**
  40572. * Attaches the behavior to its arc rotate camera.
  40573. * @param camera Defines the camera to attach the behavior to
  40574. */
  40575. attach(camera: ArcRotateCamera): void;
  40576. /**
  40577. * Detaches the behavior from its current arc rotate camera.
  40578. */
  40579. detach(): void;
  40580. /**
  40581. * Returns true if user is scrolling.
  40582. * @return true if user is scrolling.
  40583. */
  40584. private _userIsZooming;
  40585. private _lastFrameRadius;
  40586. private _shouldAnimationStopForInteraction;
  40587. /**
  40588. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40589. */
  40590. private _applyUserInteraction;
  40591. private _userIsMoving;
  40592. }
  40593. }
  40594. declare module "babylonjs/Behaviors/Cameras/index" {
  40595. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40596. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40597. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40598. }
  40599. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40600. import { Mesh } from "babylonjs/Meshes/mesh";
  40601. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40602. import { Behavior } from "babylonjs/Behaviors/behavior";
  40603. /**
  40604. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40605. */
  40606. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40607. private ui;
  40608. /**
  40609. * The name of the behavior
  40610. */
  40611. name: string;
  40612. /**
  40613. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40614. */
  40615. distanceAwayFromFace: number;
  40616. /**
  40617. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40618. */
  40619. distanceAwayFromBottomOfFace: number;
  40620. private _faceVectors;
  40621. private _target;
  40622. private _scene;
  40623. private _onRenderObserver;
  40624. private _tmpMatrix;
  40625. private _tmpVector;
  40626. /**
  40627. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40628. * @param ui The transform node that should be attched to the mesh
  40629. */
  40630. constructor(ui: TransformNode);
  40631. /**
  40632. * Initializes the behavior
  40633. */
  40634. init(): void;
  40635. private _closestFace;
  40636. private _zeroVector;
  40637. private _lookAtTmpMatrix;
  40638. private _lookAtToRef;
  40639. /**
  40640. * Attaches the AttachToBoxBehavior to the passed in mesh
  40641. * @param target The mesh that the specified node will be attached to
  40642. */
  40643. attach(target: Mesh): void;
  40644. /**
  40645. * Detaches the behavior from the mesh
  40646. */
  40647. detach(): void;
  40648. }
  40649. }
  40650. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40651. import { Behavior } from "babylonjs/Behaviors/behavior";
  40652. import { Mesh } from "babylonjs/Meshes/mesh";
  40653. /**
  40654. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40655. */
  40656. export class FadeInOutBehavior implements Behavior<Mesh> {
  40657. /**
  40658. * Time in milliseconds to delay before fading in (Default: 0)
  40659. */
  40660. delay: number;
  40661. /**
  40662. * Time in milliseconds for the mesh to fade in (Default: 300)
  40663. */
  40664. fadeInTime: number;
  40665. private _millisecondsPerFrame;
  40666. private _hovered;
  40667. private _hoverValue;
  40668. private _ownerNode;
  40669. /**
  40670. * Instatiates the FadeInOutBehavior
  40671. */
  40672. constructor();
  40673. /**
  40674. * The name of the behavior
  40675. */
  40676. get name(): string;
  40677. /**
  40678. * Initializes the behavior
  40679. */
  40680. init(): void;
  40681. /**
  40682. * Attaches the fade behavior on the passed in mesh
  40683. * @param ownerNode The mesh that will be faded in/out once attached
  40684. */
  40685. attach(ownerNode: Mesh): void;
  40686. /**
  40687. * Detaches the behavior from the mesh
  40688. */
  40689. detach(): void;
  40690. /**
  40691. * Triggers the mesh to begin fading in or out
  40692. * @param value if the object should fade in or out (true to fade in)
  40693. */
  40694. fadeIn(value: boolean): void;
  40695. private _update;
  40696. private _setAllVisibility;
  40697. }
  40698. }
  40699. declare module "babylonjs/Misc/pivotTools" {
  40700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40701. /**
  40702. * Class containing a set of static utilities functions for managing Pivots
  40703. * @hidden
  40704. */
  40705. export class PivotTools {
  40706. private static _PivotCached;
  40707. private static _OldPivotPoint;
  40708. private static _PivotTranslation;
  40709. private static _PivotTmpVector;
  40710. /** @hidden */
  40711. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40712. /** @hidden */
  40713. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40714. }
  40715. }
  40716. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40717. import { Scene } from "babylonjs/scene";
  40718. import { Vector4 } from "babylonjs/Maths/math.vector";
  40719. import { Mesh } from "babylonjs/Meshes/mesh";
  40720. import { Nullable } from "babylonjs/types";
  40721. import { Plane } from "babylonjs/Maths/math.plane";
  40722. /**
  40723. * Class containing static functions to help procedurally build meshes
  40724. */
  40725. export class PlaneBuilder {
  40726. /**
  40727. * Creates a plane mesh
  40728. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40729. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40730. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40732. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40734. * @param name defines the name of the mesh
  40735. * @param options defines the options used to create the mesh
  40736. * @param scene defines the hosting scene
  40737. * @returns the plane mesh
  40738. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40739. */
  40740. static CreatePlane(name: string, options: {
  40741. size?: number;
  40742. width?: number;
  40743. height?: number;
  40744. sideOrientation?: number;
  40745. frontUVs?: Vector4;
  40746. backUVs?: Vector4;
  40747. updatable?: boolean;
  40748. sourcePlane?: Plane;
  40749. }, scene?: Nullable<Scene>): Mesh;
  40750. }
  40751. }
  40752. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40753. import { Behavior } from "babylonjs/Behaviors/behavior";
  40754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40755. import { Observable } from "babylonjs/Misc/observable";
  40756. import { Vector3 } from "babylonjs/Maths/math.vector";
  40757. import { Ray } from "babylonjs/Culling/ray";
  40758. import "babylonjs/Meshes/Builders/planeBuilder";
  40759. /**
  40760. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40761. */
  40762. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40763. private static _AnyMouseID;
  40764. /**
  40765. * Abstract mesh the behavior is set on
  40766. */
  40767. attachedNode: AbstractMesh;
  40768. private _dragPlane;
  40769. private _scene;
  40770. private _pointerObserver;
  40771. private _beforeRenderObserver;
  40772. private static _planeScene;
  40773. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40774. /**
  40775. * 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)
  40776. */
  40777. maxDragAngle: number;
  40778. /**
  40779. * @hidden
  40780. */
  40781. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40782. /**
  40783. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40784. */
  40785. currentDraggingPointerID: number;
  40786. /**
  40787. * The last position where the pointer hit the drag plane in world space
  40788. */
  40789. lastDragPosition: Vector3;
  40790. /**
  40791. * If the behavior is currently in a dragging state
  40792. */
  40793. dragging: boolean;
  40794. /**
  40795. * 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)
  40796. */
  40797. dragDeltaRatio: number;
  40798. /**
  40799. * If the drag plane orientation should be updated during the dragging (Default: true)
  40800. */
  40801. updateDragPlane: boolean;
  40802. private _debugMode;
  40803. private _moving;
  40804. /**
  40805. * Fires each time the attached mesh is dragged with the pointer
  40806. * * delta between last drag position and current drag position in world space
  40807. * * dragDistance along the drag axis
  40808. * * dragPlaneNormal normal of the current drag plane used during the drag
  40809. * * dragPlanePoint in world space where the drag intersects the drag plane
  40810. */
  40811. onDragObservable: Observable<{
  40812. delta: Vector3;
  40813. dragPlanePoint: Vector3;
  40814. dragPlaneNormal: Vector3;
  40815. dragDistance: number;
  40816. pointerId: number;
  40817. }>;
  40818. /**
  40819. * Fires each time a drag begins (eg. mouse down on mesh)
  40820. */
  40821. onDragStartObservable: Observable<{
  40822. dragPlanePoint: Vector3;
  40823. pointerId: number;
  40824. }>;
  40825. /**
  40826. * Fires each time a drag ends (eg. mouse release after drag)
  40827. */
  40828. onDragEndObservable: Observable<{
  40829. dragPlanePoint: Vector3;
  40830. pointerId: number;
  40831. }>;
  40832. /**
  40833. * If the attached mesh should be moved when dragged
  40834. */
  40835. moveAttached: boolean;
  40836. /**
  40837. * If the drag behavior will react to drag events (Default: true)
  40838. */
  40839. enabled: boolean;
  40840. /**
  40841. * If pointer events should start and release the drag (Default: true)
  40842. */
  40843. startAndReleaseDragOnPointerEvents: boolean;
  40844. /**
  40845. * If camera controls should be detached during the drag
  40846. */
  40847. detachCameraControls: boolean;
  40848. /**
  40849. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40850. */
  40851. useObjectOrientationForDragging: boolean;
  40852. private _options;
  40853. /**
  40854. * Gets the options used by the behavior
  40855. */
  40856. get options(): {
  40857. dragAxis?: Vector3;
  40858. dragPlaneNormal?: Vector3;
  40859. };
  40860. /**
  40861. * Sets the options used by the behavior
  40862. */
  40863. set options(options: {
  40864. dragAxis?: Vector3;
  40865. dragPlaneNormal?: Vector3;
  40866. });
  40867. /**
  40868. * Creates a pointer drag behavior that can be attached to a mesh
  40869. * @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)
  40870. */
  40871. constructor(options?: {
  40872. dragAxis?: Vector3;
  40873. dragPlaneNormal?: Vector3;
  40874. });
  40875. /**
  40876. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40877. */
  40878. validateDrag: (targetPosition: Vector3) => boolean;
  40879. /**
  40880. * The name of the behavior
  40881. */
  40882. get name(): string;
  40883. /**
  40884. * Initializes the behavior
  40885. */
  40886. init(): void;
  40887. private _tmpVector;
  40888. private _alternatePickedPoint;
  40889. private _worldDragAxis;
  40890. private _targetPosition;
  40891. private _attachedElement;
  40892. /**
  40893. * Attaches the drag behavior the passed in mesh
  40894. * @param ownerNode The mesh that will be dragged around once attached
  40895. * @param predicate Predicate to use for pick filtering
  40896. */
  40897. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40898. /**
  40899. * Force relase the drag action by code.
  40900. */
  40901. releaseDrag(): void;
  40902. private _startDragRay;
  40903. private _lastPointerRay;
  40904. /**
  40905. * Simulates the start of a pointer drag event on the behavior
  40906. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40907. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40908. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40909. */
  40910. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40911. private _startDrag;
  40912. private _dragDelta;
  40913. private _moveDrag;
  40914. private _pickWithRayOnDragPlane;
  40915. private _pointA;
  40916. private _pointB;
  40917. private _pointC;
  40918. private _lineA;
  40919. private _lineB;
  40920. private _localAxis;
  40921. private _lookAt;
  40922. private _updateDragPlanePosition;
  40923. /**
  40924. * Detaches the behavior from the mesh
  40925. */
  40926. detach(): void;
  40927. }
  40928. }
  40929. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40930. import { Mesh } from "babylonjs/Meshes/mesh";
  40931. import { Behavior } from "babylonjs/Behaviors/behavior";
  40932. /**
  40933. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40934. */
  40935. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40936. private _dragBehaviorA;
  40937. private _dragBehaviorB;
  40938. private _startDistance;
  40939. private _initialScale;
  40940. private _targetScale;
  40941. private _ownerNode;
  40942. private _sceneRenderObserver;
  40943. /**
  40944. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40945. */
  40946. constructor();
  40947. /**
  40948. * The name of the behavior
  40949. */
  40950. get name(): string;
  40951. /**
  40952. * Initializes the behavior
  40953. */
  40954. init(): void;
  40955. private _getCurrentDistance;
  40956. /**
  40957. * Attaches the scale behavior the passed in mesh
  40958. * @param ownerNode The mesh that will be scaled around once attached
  40959. */
  40960. attach(ownerNode: Mesh): void;
  40961. /**
  40962. * Detaches the behavior from the mesh
  40963. */
  40964. detach(): void;
  40965. }
  40966. }
  40967. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40968. import { Behavior } from "babylonjs/Behaviors/behavior";
  40969. import { Mesh } from "babylonjs/Meshes/mesh";
  40970. import { Observable } from "babylonjs/Misc/observable";
  40971. /**
  40972. * 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
  40973. */
  40974. export class SixDofDragBehavior implements Behavior<Mesh> {
  40975. private static _virtualScene;
  40976. private _ownerNode;
  40977. private _sceneRenderObserver;
  40978. private _scene;
  40979. private _targetPosition;
  40980. private _virtualOriginMesh;
  40981. private _virtualDragMesh;
  40982. private _pointerObserver;
  40983. private _moving;
  40984. private _startingOrientation;
  40985. private _attachedElement;
  40986. /**
  40987. * 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)
  40988. */
  40989. private zDragFactor;
  40990. /**
  40991. * If the object should rotate to face the drag origin
  40992. */
  40993. rotateDraggedObject: boolean;
  40994. /**
  40995. * If the behavior is currently in a dragging state
  40996. */
  40997. dragging: boolean;
  40998. /**
  40999. * 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)
  41000. */
  41001. dragDeltaRatio: number;
  41002. /**
  41003. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41004. */
  41005. currentDraggingPointerID: number;
  41006. /**
  41007. * If camera controls should be detached during the drag
  41008. */
  41009. detachCameraControls: boolean;
  41010. /**
  41011. * Fires each time a drag starts
  41012. */
  41013. onDragStartObservable: Observable<{}>;
  41014. /**
  41015. * Fires each time a drag ends (eg. mouse release after drag)
  41016. */
  41017. onDragEndObservable: Observable<{}>;
  41018. /**
  41019. * 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
  41020. */
  41021. constructor();
  41022. /**
  41023. * The name of the behavior
  41024. */
  41025. get name(): string;
  41026. /**
  41027. * Initializes the behavior
  41028. */
  41029. init(): void;
  41030. /**
  41031. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41032. */
  41033. private get _pointerCamera();
  41034. /**
  41035. * Attaches the scale behavior the passed in mesh
  41036. * @param ownerNode The mesh that will be scaled around once attached
  41037. */
  41038. attach(ownerNode: Mesh): void;
  41039. /**
  41040. * Detaches the behavior from the mesh
  41041. */
  41042. detach(): void;
  41043. }
  41044. }
  41045. declare module "babylonjs/Behaviors/Meshes/index" {
  41046. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41047. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41048. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41049. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41050. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41051. }
  41052. declare module "babylonjs/Behaviors/index" {
  41053. export * from "babylonjs/Behaviors/behavior";
  41054. export * from "babylonjs/Behaviors/Cameras/index";
  41055. export * from "babylonjs/Behaviors/Meshes/index";
  41056. }
  41057. declare module "babylonjs/Bones/boneIKController" {
  41058. import { Bone } from "babylonjs/Bones/bone";
  41059. import { Vector3 } from "babylonjs/Maths/math.vector";
  41060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41061. import { Nullable } from "babylonjs/types";
  41062. /**
  41063. * Class used to apply inverse kinematics to bones
  41064. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41065. */
  41066. export class BoneIKController {
  41067. private static _tmpVecs;
  41068. private static _tmpQuat;
  41069. private static _tmpMats;
  41070. /**
  41071. * Gets or sets the target mesh
  41072. */
  41073. targetMesh: AbstractMesh;
  41074. /** Gets or sets the mesh used as pole */
  41075. poleTargetMesh: AbstractMesh;
  41076. /**
  41077. * Gets or sets the bone used as pole
  41078. */
  41079. poleTargetBone: Nullable<Bone>;
  41080. /**
  41081. * Gets or sets the target position
  41082. */
  41083. targetPosition: Vector3;
  41084. /**
  41085. * Gets or sets the pole target position
  41086. */
  41087. poleTargetPosition: Vector3;
  41088. /**
  41089. * Gets or sets the pole target local offset
  41090. */
  41091. poleTargetLocalOffset: Vector3;
  41092. /**
  41093. * Gets or sets the pole angle
  41094. */
  41095. poleAngle: number;
  41096. /**
  41097. * Gets or sets the mesh associated with the controller
  41098. */
  41099. mesh: AbstractMesh;
  41100. /**
  41101. * 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)
  41102. */
  41103. slerpAmount: number;
  41104. private _bone1Quat;
  41105. private _bone1Mat;
  41106. private _bone2Ang;
  41107. private _bone1;
  41108. private _bone2;
  41109. private _bone1Length;
  41110. private _bone2Length;
  41111. private _maxAngle;
  41112. private _maxReach;
  41113. private _rightHandedSystem;
  41114. private _bendAxis;
  41115. private _slerping;
  41116. private _adjustRoll;
  41117. /**
  41118. * Gets or sets maximum allowed angle
  41119. */
  41120. get maxAngle(): number;
  41121. set maxAngle(value: number);
  41122. /**
  41123. * Creates a new BoneIKController
  41124. * @param mesh defines the mesh to control
  41125. * @param bone defines the bone to control
  41126. * @param options defines options to set up the controller
  41127. */
  41128. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41129. targetMesh?: AbstractMesh;
  41130. poleTargetMesh?: AbstractMesh;
  41131. poleTargetBone?: Bone;
  41132. poleTargetLocalOffset?: Vector3;
  41133. poleAngle?: number;
  41134. bendAxis?: Vector3;
  41135. maxAngle?: number;
  41136. slerpAmount?: number;
  41137. });
  41138. private _setMaxAngle;
  41139. /**
  41140. * Force the controller to update the bones
  41141. */
  41142. update(): void;
  41143. }
  41144. }
  41145. declare module "babylonjs/Bones/boneLookController" {
  41146. import { Vector3 } from "babylonjs/Maths/math.vector";
  41147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41148. import { Bone } from "babylonjs/Bones/bone";
  41149. import { Space } from "babylonjs/Maths/math.axis";
  41150. /**
  41151. * Class used to make a bone look toward a point in space
  41152. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41153. */
  41154. export class BoneLookController {
  41155. private static _tmpVecs;
  41156. private static _tmpQuat;
  41157. private static _tmpMats;
  41158. /**
  41159. * The target Vector3 that the bone will look at
  41160. */
  41161. target: Vector3;
  41162. /**
  41163. * The mesh that the bone is attached to
  41164. */
  41165. mesh: AbstractMesh;
  41166. /**
  41167. * The bone that will be looking to the target
  41168. */
  41169. bone: Bone;
  41170. /**
  41171. * The up axis of the coordinate system that is used when the bone is rotated
  41172. */
  41173. upAxis: Vector3;
  41174. /**
  41175. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41176. */
  41177. upAxisSpace: Space;
  41178. /**
  41179. * Used to make an adjustment to the yaw of the bone
  41180. */
  41181. adjustYaw: number;
  41182. /**
  41183. * Used to make an adjustment to the pitch of the bone
  41184. */
  41185. adjustPitch: number;
  41186. /**
  41187. * Used to make an adjustment to the roll of the bone
  41188. */
  41189. adjustRoll: number;
  41190. /**
  41191. * 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)
  41192. */
  41193. slerpAmount: number;
  41194. private _minYaw;
  41195. private _maxYaw;
  41196. private _minPitch;
  41197. private _maxPitch;
  41198. private _minYawSin;
  41199. private _minYawCos;
  41200. private _maxYawSin;
  41201. private _maxYawCos;
  41202. private _midYawConstraint;
  41203. private _minPitchTan;
  41204. private _maxPitchTan;
  41205. private _boneQuat;
  41206. private _slerping;
  41207. private _transformYawPitch;
  41208. private _transformYawPitchInv;
  41209. private _firstFrameSkipped;
  41210. private _yawRange;
  41211. private _fowardAxis;
  41212. /**
  41213. * Gets or sets the minimum yaw angle that the bone can look to
  41214. */
  41215. get minYaw(): number;
  41216. set minYaw(value: number);
  41217. /**
  41218. * Gets or sets the maximum yaw angle that the bone can look to
  41219. */
  41220. get maxYaw(): number;
  41221. set maxYaw(value: number);
  41222. /**
  41223. * Gets or sets the minimum pitch angle that the bone can look to
  41224. */
  41225. get minPitch(): number;
  41226. set minPitch(value: number);
  41227. /**
  41228. * Gets or sets the maximum pitch angle that the bone can look to
  41229. */
  41230. get maxPitch(): number;
  41231. set maxPitch(value: number);
  41232. /**
  41233. * Create a BoneLookController
  41234. * @param mesh the mesh that the bone belongs to
  41235. * @param bone the bone that will be looking to the target
  41236. * @param target the target Vector3 to look at
  41237. * @param options optional settings:
  41238. * * maxYaw: the maximum angle the bone will yaw to
  41239. * * minYaw: the minimum angle the bone will yaw to
  41240. * * maxPitch: the maximum angle the bone will pitch to
  41241. * * minPitch: the minimum angle the bone will yaw to
  41242. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41243. * * upAxis: the up axis of the coordinate system
  41244. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41245. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41246. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41247. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41248. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41249. * * adjustRoll: used to make an adjustment to the roll of the bone
  41250. **/
  41251. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41252. maxYaw?: number;
  41253. minYaw?: number;
  41254. maxPitch?: number;
  41255. minPitch?: number;
  41256. slerpAmount?: number;
  41257. upAxis?: Vector3;
  41258. upAxisSpace?: Space;
  41259. yawAxis?: Vector3;
  41260. pitchAxis?: Vector3;
  41261. adjustYaw?: number;
  41262. adjustPitch?: number;
  41263. adjustRoll?: number;
  41264. });
  41265. /**
  41266. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41267. */
  41268. update(): void;
  41269. private _getAngleDiff;
  41270. private _getAngleBetween;
  41271. private _isAngleBetween;
  41272. }
  41273. }
  41274. declare module "babylonjs/Bones/index" {
  41275. export * from "babylonjs/Bones/bone";
  41276. export * from "babylonjs/Bones/boneIKController";
  41277. export * from "babylonjs/Bones/boneLookController";
  41278. export * from "babylonjs/Bones/skeleton";
  41279. }
  41280. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41281. import { Nullable } from "babylonjs/types";
  41282. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41283. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41284. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41285. /**
  41286. * Manage the gamepad inputs to control an arc rotate camera.
  41287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41288. */
  41289. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41290. /**
  41291. * Defines the camera the input is attached to.
  41292. */
  41293. camera: ArcRotateCamera;
  41294. /**
  41295. * Defines the gamepad the input is gathering event from.
  41296. */
  41297. gamepad: Nullable<Gamepad>;
  41298. /**
  41299. * Defines the gamepad rotation sensiblity.
  41300. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41301. */
  41302. gamepadRotationSensibility: number;
  41303. /**
  41304. * Defines the gamepad move sensiblity.
  41305. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41306. */
  41307. gamepadMoveSensibility: number;
  41308. private _yAxisScale;
  41309. /**
  41310. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41311. */
  41312. get invertYAxis(): boolean;
  41313. set invertYAxis(value: boolean);
  41314. private _onGamepadConnectedObserver;
  41315. private _onGamepadDisconnectedObserver;
  41316. /**
  41317. * Attach the input controls to a specific dom element to get the input from.
  41318. * @param element Defines the element the controls should be listened from
  41319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41320. */
  41321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41322. /**
  41323. * Detach the current controls from the specified dom element.
  41324. * @param element Defines the element to stop listening the inputs from
  41325. */
  41326. detachControl(element: Nullable<HTMLElement>): void;
  41327. /**
  41328. * Update the current camera state depending on the inputs that have been used this frame.
  41329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41330. */
  41331. checkInputs(): void;
  41332. /**
  41333. * Gets the class name of the current intput.
  41334. * @returns the class name
  41335. */
  41336. getClassName(): string;
  41337. /**
  41338. * Get the friendly name associated with the input class.
  41339. * @returns the input friendly name
  41340. */
  41341. getSimpleName(): string;
  41342. }
  41343. }
  41344. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41345. import { Nullable } from "babylonjs/types";
  41346. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41347. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41348. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41349. interface ArcRotateCameraInputsManager {
  41350. /**
  41351. * Add orientation input support to the input manager.
  41352. * @returns the current input manager
  41353. */
  41354. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41355. }
  41356. }
  41357. /**
  41358. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41360. */
  41361. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41362. /**
  41363. * Defines the camera the input is attached to.
  41364. */
  41365. camera: ArcRotateCamera;
  41366. /**
  41367. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41368. */
  41369. alphaCorrection: number;
  41370. /**
  41371. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41372. */
  41373. gammaCorrection: number;
  41374. private _alpha;
  41375. private _gamma;
  41376. private _dirty;
  41377. private _deviceOrientationHandler;
  41378. /**
  41379. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41380. */
  41381. constructor();
  41382. /**
  41383. * Attach the input controls to a specific dom element to get the input from.
  41384. * @param element Defines the element the controls should be listened from
  41385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41386. */
  41387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41388. /** @hidden */
  41389. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41390. /**
  41391. * Update the current camera state depending on the inputs that have been used this frame.
  41392. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41393. */
  41394. checkInputs(): void;
  41395. /**
  41396. * Detach the current controls from the specified dom element.
  41397. * @param element Defines the element to stop listening the inputs from
  41398. */
  41399. detachControl(element: Nullable<HTMLElement>): void;
  41400. /**
  41401. * Gets the class name of the current intput.
  41402. * @returns the class name
  41403. */
  41404. getClassName(): string;
  41405. /**
  41406. * Get the friendly name associated with the input class.
  41407. * @returns the input friendly name
  41408. */
  41409. getSimpleName(): string;
  41410. }
  41411. }
  41412. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41413. import { Nullable } from "babylonjs/types";
  41414. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41415. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41416. /**
  41417. * Listen to mouse events to control the camera.
  41418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41419. */
  41420. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41421. /**
  41422. * Defines the camera the input is attached to.
  41423. */
  41424. camera: FlyCamera;
  41425. /**
  41426. * Defines if touch is enabled. (Default is true.)
  41427. */
  41428. touchEnabled: boolean;
  41429. /**
  41430. * Defines the buttons associated with the input to handle camera rotation.
  41431. */
  41432. buttons: number[];
  41433. /**
  41434. * Assign buttons for Yaw control.
  41435. */
  41436. buttonsYaw: number[];
  41437. /**
  41438. * Assign buttons for Pitch control.
  41439. */
  41440. buttonsPitch: number[];
  41441. /**
  41442. * Assign buttons for Roll control.
  41443. */
  41444. buttonsRoll: number[];
  41445. /**
  41446. * Detect if any button is being pressed while mouse is moved.
  41447. * -1 = Mouse locked.
  41448. * 0 = Left button.
  41449. * 1 = Middle Button.
  41450. * 2 = Right Button.
  41451. */
  41452. activeButton: number;
  41453. /**
  41454. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41455. * Higher values reduce its sensitivity.
  41456. */
  41457. angularSensibility: number;
  41458. private _mousemoveCallback;
  41459. private _observer;
  41460. private _rollObserver;
  41461. private previousPosition;
  41462. private noPreventDefault;
  41463. private element;
  41464. /**
  41465. * Listen to mouse events to control the camera.
  41466. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41467. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41468. */
  41469. constructor(touchEnabled?: boolean);
  41470. /**
  41471. * Attach the mouse control to the HTML DOM element.
  41472. * @param element Defines the element that listens to the input events.
  41473. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41474. */
  41475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41476. /**
  41477. * Detach the current controls from the specified dom element.
  41478. * @param element Defines the element to stop listening the inputs from
  41479. */
  41480. detachControl(element: Nullable<HTMLElement>): void;
  41481. /**
  41482. * Gets the class name of the current input.
  41483. * @returns the class name.
  41484. */
  41485. getClassName(): string;
  41486. /**
  41487. * Get the friendly name associated with the input class.
  41488. * @returns the input's friendly name.
  41489. */
  41490. getSimpleName(): string;
  41491. private _pointerInput;
  41492. private _onMouseMove;
  41493. /**
  41494. * Rotate camera by mouse offset.
  41495. */
  41496. private rotateCamera;
  41497. }
  41498. }
  41499. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41500. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41501. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41502. /**
  41503. * Default Inputs manager for the FlyCamera.
  41504. * It groups all the default supported inputs for ease of use.
  41505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41506. */
  41507. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41508. /**
  41509. * Instantiates a new FlyCameraInputsManager.
  41510. * @param camera Defines the camera the inputs belong to.
  41511. */
  41512. constructor(camera: FlyCamera);
  41513. /**
  41514. * Add keyboard input support to the input manager.
  41515. * @returns the new FlyCameraKeyboardMoveInput().
  41516. */
  41517. addKeyboard(): FlyCameraInputsManager;
  41518. /**
  41519. * Add mouse input support to the input manager.
  41520. * @param touchEnabled Enable touch screen support.
  41521. * @returns the new FlyCameraMouseInput().
  41522. */
  41523. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41524. }
  41525. }
  41526. declare module "babylonjs/Cameras/flyCamera" {
  41527. import { Scene } from "babylonjs/scene";
  41528. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41530. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41531. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41532. /**
  41533. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41534. * such as in a 3D Space Shooter or a Flight Simulator.
  41535. */
  41536. export class FlyCamera extends TargetCamera {
  41537. /**
  41538. * Define the collision ellipsoid of the camera.
  41539. * This is helpful for simulating a camera body, like a player's body.
  41540. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41541. */
  41542. ellipsoid: Vector3;
  41543. /**
  41544. * Define an offset for the position of the ellipsoid around the camera.
  41545. * This can be helpful if the camera is attached away from the player's body center,
  41546. * such as at its head.
  41547. */
  41548. ellipsoidOffset: Vector3;
  41549. /**
  41550. * Enable or disable collisions of the camera with the rest of the scene objects.
  41551. */
  41552. checkCollisions: boolean;
  41553. /**
  41554. * Enable or disable gravity on the camera.
  41555. */
  41556. applyGravity: boolean;
  41557. /**
  41558. * Define the current direction the camera is moving to.
  41559. */
  41560. cameraDirection: Vector3;
  41561. /**
  41562. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41563. * This overrides and empties cameraRotation.
  41564. */
  41565. rotationQuaternion: Quaternion;
  41566. /**
  41567. * Track Roll to maintain the wanted Rolling when looking around.
  41568. */
  41569. _trackRoll: number;
  41570. /**
  41571. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41572. */
  41573. rollCorrect: number;
  41574. /**
  41575. * Mimic a banked turn, Rolling the camera when Yawing.
  41576. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41577. */
  41578. bankedTurn: boolean;
  41579. /**
  41580. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41581. */
  41582. bankedTurnLimit: number;
  41583. /**
  41584. * Value of 0 disables the banked Roll.
  41585. * Value of 1 is equal to the Yaw angle in radians.
  41586. */
  41587. bankedTurnMultiplier: number;
  41588. /**
  41589. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41590. */
  41591. inputs: FlyCameraInputsManager;
  41592. /**
  41593. * Gets the input sensibility for mouse input.
  41594. * Higher values reduce sensitivity.
  41595. */
  41596. get angularSensibility(): number;
  41597. /**
  41598. * Sets the input sensibility for a mouse input.
  41599. * Higher values reduce sensitivity.
  41600. */
  41601. set angularSensibility(value: number);
  41602. /**
  41603. * Get the keys for camera movement forward.
  41604. */
  41605. get keysForward(): number[];
  41606. /**
  41607. * Set the keys for camera movement forward.
  41608. */
  41609. set keysForward(value: number[]);
  41610. /**
  41611. * Get the keys for camera movement backward.
  41612. */
  41613. get keysBackward(): number[];
  41614. set keysBackward(value: number[]);
  41615. /**
  41616. * Get the keys for camera movement up.
  41617. */
  41618. get keysUp(): number[];
  41619. /**
  41620. * Set the keys for camera movement up.
  41621. */
  41622. set keysUp(value: number[]);
  41623. /**
  41624. * Get the keys for camera movement down.
  41625. */
  41626. get keysDown(): number[];
  41627. /**
  41628. * Set the keys for camera movement down.
  41629. */
  41630. set keysDown(value: number[]);
  41631. /**
  41632. * Get the keys for camera movement left.
  41633. */
  41634. get keysLeft(): number[];
  41635. /**
  41636. * Set the keys for camera movement left.
  41637. */
  41638. set keysLeft(value: number[]);
  41639. /**
  41640. * Set the keys for camera movement right.
  41641. */
  41642. get keysRight(): number[];
  41643. /**
  41644. * Set the keys for camera movement right.
  41645. */
  41646. set keysRight(value: number[]);
  41647. /**
  41648. * Event raised when the camera collides with a mesh in the scene.
  41649. */
  41650. onCollide: (collidedMesh: AbstractMesh) => void;
  41651. private _collider;
  41652. private _needMoveForGravity;
  41653. private _oldPosition;
  41654. private _diffPosition;
  41655. private _newPosition;
  41656. /** @hidden */
  41657. _localDirection: Vector3;
  41658. /** @hidden */
  41659. _transformedDirection: Vector3;
  41660. /**
  41661. * Instantiates a FlyCamera.
  41662. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41663. * such as in a 3D Space Shooter or a Flight Simulator.
  41664. * @param name Define the name of the camera in the scene.
  41665. * @param position Define the starting position of the camera in the scene.
  41666. * @param scene Define the scene the camera belongs to.
  41667. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41668. */
  41669. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41670. /**
  41671. * Attach a control to the HTML DOM element.
  41672. * @param element Defines the element that listens to the input events.
  41673. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41674. */
  41675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41676. /**
  41677. * Detach a control from the HTML DOM element.
  41678. * The camera will stop reacting to that input.
  41679. * @param element Defines the element that listens to the input events.
  41680. */
  41681. detachControl(element: HTMLElement): void;
  41682. private _collisionMask;
  41683. /**
  41684. * Get the mask that the camera ignores in collision events.
  41685. */
  41686. get collisionMask(): number;
  41687. /**
  41688. * Set the mask that the camera ignores in collision events.
  41689. */
  41690. set collisionMask(mask: number);
  41691. /** @hidden */
  41692. _collideWithWorld(displacement: Vector3): void;
  41693. /** @hidden */
  41694. private _onCollisionPositionChange;
  41695. /** @hidden */
  41696. _checkInputs(): void;
  41697. /** @hidden */
  41698. _decideIfNeedsToMove(): boolean;
  41699. /** @hidden */
  41700. _updatePosition(): void;
  41701. /**
  41702. * Restore the Roll to its target value at the rate specified.
  41703. * @param rate - Higher means slower restoring.
  41704. * @hidden
  41705. */
  41706. restoreRoll(rate: number): void;
  41707. /**
  41708. * Destroy the camera and release the current resources held by it.
  41709. */
  41710. dispose(): void;
  41711. /**
  41712. * Get the current object class name.
  41713. * @returns the class name.
  41714. */
  41715. getClassName(): string;
  41716. }
  41717. }
  41718. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41719. import { Nullable } from "babylonjs/types";
  41720. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41721. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41722. /**
  41723. * Listen to keyboard events to control the camera.
  41724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41725. */
  41726. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41727. /**
  41728. * Defines the camera the input is attached to.
  41729. */
  41730. camera: FlyCamera;
  41731. /**
  41732. * The list of keyboard keys used to control the forward move of the camera.
  41733. */
  41734. keysForward: number[];
  41735. /**
  41736. * The list of keyboard keys used to control the backward move of the camera.
  41737. */
  41738. keysBackward: number[];
  41739. /**
  41740. * The list of keyboard keys used to control the forward move of the camera.
  41741. */
  41742. keysUp: number[];
  41743. /**
  41744. * The list of keyboard keys used to control the backward move of the camera.
  41745. */
  41746. keysDown: number[];
  41747. /**
  41748. * The list of keyboard keys used to control the right strafe move of the camera.
  41749. */
  41750. keysRight: number[];
  41751. /**
  41752. * The list of keyboard keys used to control the left strafe move of the camera.
  41753. */
  41754. keysLeft: number[];
  41755. private _keys;
  41756. private _onCanvasBlurObserver;
  41757. private _onKeyboardObserver;
  41758. private _engine;
  41759. private _scene;
  41760. /**
  41761. * Attach the input controls to a specific dom element to get the input from.
  41762. * @param element Defines the element the controls should be listened from
  41763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41764. */
  41765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41766. /**
  41767. * Detach the current controls from the specified dom element.
  41768. * @param element Defines the element to stop listening the inputs from
  41769. */
  41770. detachControl(element: Nullable<HTMLElement>): void;
  41771. /**
  41772. * Gets the class name of the current intput.
  41773. * @returns the class name
  41774. */
  41775. getClassName(): string;
  41776. /** @hidden */
  41777. _onLostFocus(e: FocusEvent): void;
  41778. /**
  41779. * Get the friendly name associated with the input class.
  41780. * @returns the input friendly name
  41781. */
  41782. getSimpleName(): string;
  41783. /**
  41784. * Update the current camera state depending on the inputs that have been used this frame.
  41785. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41786. */
  41787. checkInputs(): void;
  41788. }
  41789. }
  41790. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41791. import { Nullable } from "babylonjs/types";
  41792. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41794. /**
  41795. * Manage the mouse wheel inputs to control a follow camera.
  41796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41797. */
  41798. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41799. /**
  41800. * Defines the camera the input is attached to.
  41801. */
  41802. camera: FollowCamera;
  41803. /**
  41804. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41805. */
  41806. axisControlRadius: boolean;
  41807. /**
  41808. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41809. */
  41810. axisControlHeight: boolean;
  41811. /**
  41812. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41813. */
  41814. axisControlRotation: boolean;
  41815. /**
  41816. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41817. * relation to mouseWheel events.
  41818. */
  41819. wheelPrecision: number;
  41820. /**
  41821. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41822. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41823. */
  41824. wheelDeltaPercentage: number;
  41825. private _wheel;
  41826. private _observer;
  41827. /**
  41828. * Attach the input controls to a specific dom element to get the input from.
  41829. * @param element Defines the element the controls should be listened from
  41830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41831. */
  41832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41833. /**
  41834. * Detach the current controls from the specified dom element.
  41835. * @param element Defines the element to stop listening the inputs from
  41836. */
  41837. detachControl(element: Nullable<HTMLElement>): void;
  41838. /**
  41839. * Gets the class name of the current intput.
  41840. * @returns the class name
  41841. */
  41842. getClassName(): string;
  41843. /**
  41844. * Get the friendly name associated with the input class.
  41845. * @returns the input friendly name
  41846. */
  41847. getSimpleName(): string;
  41848. }
  41849. }
  41850. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41851. import { Nullable } from "babylonjs/types";
  41852. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41853. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41854. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41855. /**
  41856. * Manage the pointers inputs to control an follow camera.
  41857. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41858. */
  41859. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41860. /**
  41861. * Defines the camera the input is attached to.
  41862. */
  41863. camera: FollowCamera;
  41864. /**
  41865. * Gets the class name of the current input.
  41866. * @returns the class name
  41867. */
  41868. getClassName(): string;
  41869. /**
  41870. * Defines the pointer angular sensibility along the X axis or how fast is
  41871. * the camera rotating.
  41872. * A negative number will reverse the axis direction.
  41873. */
  41874. angularSensibilityX: number;
  41875. /**
  41876. * Defines the pointer angular sensibility along the Y axis or how fast is
  41877. * the camera rotating.
  41878. * A negative number will reverse the axis direction.
  41879. */
  41880. angularSensibilityY: number;
  41881. /**
  41882. * Defines the pointer pinch precision or how fast is the camera zooming.
  41883. * A negative number will reverse the axis direction.
  41884. */
  41885. pinchPrecision: number;
  41886. /**
  41887. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41888. * from 0.
  41889. * It defines the percentage of current camera.radius to use as delta when
  41890. * pinch zoom is used.
  41891. */
  41892. pinchDeltaPercentage: number;
  41893. /**
  41894. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41895. */
  41896. axisXControlRadius: boolean;
  41897. /**
  41898. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41899. */
  41900. axisXControlHeight: boolean;
  41901. /**
  41902. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41903. */
  41904. axisXControlRotation: boolean;
  41905. /**
  41906. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41907. */
  41908. axisYControlRadius: boolean;
  41909. /**
  41910. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41911. */
  41912. axisYControlHeight: boolean;
  41913. /**
  41914. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41915. */
  41916. axisYControlRotation: boolean;
  41917. /**
  41918. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41919. */
  41920. axisPinchControlRadius: boolean;
  41921. /**
  41922. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41923. */
  41924. axisPinchControlHeight: boolean;
  41925. /**
  41926. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41927. */
  41928. axisPinchControlRotation: boolean;
  41929. /**
  41930. * Log error messages if basic misconfiguration has occurred.
  41931. */
  41932. warningEnable: boolean;
  41933. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41934. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41935. private _warningCounter;
  41936. private _warning;
  41937. }
  41938. }
  41939. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41940. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41941. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41942. /**
  41943. * Default Inputs manager for the FollowCamera.
  41944. * It groups all the default supported inputs for ease of use.
  41945. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41946. */
  41947. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41948. /**
  41949. * Instantiates a new FollowCameraInputsManager.
  41950. * @param camera Defines the camera the inputs belong to
  41951. */
  41952. constructor(camera: FollowCamera);
  41953. /**
  41954. * Add keyboard input support to the input manager.
  41955. * @returns the current input manager
  41956. */
  41957. addKeyboard(): FollowCameraInputsManager;
  41958. /**
  41959. * Add mouse wheel input support to the input manager.
  41960. * @returns the current input manager
  41961. */
  41962. addMouseWheel(): FollowCameraInputsManager;
  41963. /**
  41964. * Add pointers input support to the input manager.
  41965. * @returns the current input manager
  41966. */
  41967. addPointers(): FollowCameraInputsManager;
  41968. /**
  41969. * Add orientation input support to the input manager.
  41970. * @returns the current input manager
  41971. */
  41972. addVRDeviceOrientation(): FollowCameraInputsManager;
  41973. }
  41974. }
  41975. declare module "babylonjs/Cameras/followCamera" {
  41976. import { Nullable } from "babylonjs/types";
  41977. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41978. import { Scene } from "babylonjs/scene";
  41979. import { Vector3 } from "babylonjs/Maths/math.vector";
  41980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41981. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41982. /**
  41983. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41984. * an arc rotate version arcFollowCamera are available.
  41985. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41986. */
  41987. export class FollowCamera extends TargetCamera {
  41988. /**
  41989. * Distance the follow camera should follow an object at
  41990. */
  41991. radius: number;
  41992. /**
  41993. * Minimum allowed distance of the camera to the axis of rotation
  41994. * (The camera can not get closer).
  41995. * This can help limiting how the Camera is able to move in the scene.
  41996. */
  41997. lowerRadiusLimit: Nullable<number>;
  41998. /**
  41999. * Maximum allowed distance of the camera to the axis of rotation
  42000. * (The camera can not get further).
  42001. * This can help limiting how the Camera is able to move in the scene.
  42002. */
  42003. upperRadiusLimit: Nullable<number>;
  42004. /**
  42005. * Define a rotation offset between the camera and the object it follows
  42006. */
  42007. rotationOffset: number;
  42008. /**
  42009. * Minimum allowed angle to camera position relative to target object.
  42010. * This can help limiting how the Camera is able to move in the scene.
  42011. */
  42012. lowerRotationOffsetLimit: Nullable<number>;
  42013. /**
  42014. * Maximum allowed angle to camera position relative to target object.
  42015. * This can help limiting how the Camera is able to move in the scene.
  42016. */
  42017. upperRotationOffsetLimit: Nullable<number>;
  42018. /**
  42019. * Define a height offset between the camera and the object it follows.
  42020. * It can help following an object from the top (like a car chaing a plane)
  42021. */
  42022. heightOffset: number;
  42023. /**
  42024. * Minimum allowed height of camera position relative to target object.
  42025. * This can help limiting how the Camera is able to move in the scene.
  42026. */
  42027. lowerHeightOffsetLimit: Nullable<number>;
  42028. /**
  42029. * Maximum allowed height of camera position relative to target object.
  42030. * This can help limiting how the Camera is able to move in the scene.
  42031. */
  42032. upperHeightOffsetLimit: Nullable<number>;
  42033. /**
  42034. * Define how fast the camera can accelerate to follow it s target.
  42035. */
  42036. cameraAcceleration: number;
  42037. /**
  42038. * Define the speed limit of the camera following an object.
  42039. */
  42040. maxCameraSpeed: number;
  42041. /**
  42042. * Define the target of the camera.
  42043. */
  42044. lockedTarget: Nullable<AbstractMesh>;
  42045. /**
  42046. * Defines the input associated with the camera.
  42047. */
  42048. inputs: FollowCameraInputsManager;
  42049. /**
  42050. * Instantiates the follow camera.
  42051. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42052. * @param name Define the name of the camera in the scene
  42053. * @param position Define the position of the camera
  42054. * @param scene Define the scene the camera belong to
  42055. * @param lockedTarget Define the target of the camera
  42056. */
  42057. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42058. private _follow;
  42059. /**
  42060. * Attached controls to the current camera.
  42061. * @param element Defines the element the controls should be listened from
  42062. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42063. */
  42064. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42065. /**
  42066. * Detach the current controls from the camera.
  42067. * The camera will stop reacting to inputs.
  42068. * @param element Defines the element to stop listening the inputs from
  42069. */
  42070. detachControl(element: HTMLElement): void;
  42071. /** @hidden */
  42072. _checkInputs(): void;
  42073. private _checkLimits;
  42074. /**
  42075. * Gets the camera class name.
  42076. * @returns the class name
  42077. */
  42078. getClassName(): string;
  42079. }
  42080. /**
  42081. * Arc Rotate version of the follow camera.
  42082. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42083. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42084. */
  42085. export class ArcFollowCamera extends TargetCamera {
  42086. /** The longitudinal angle of the camera */
  42087. alpha: number;
  42088. /** The latitudinal angle of the camera */
  42089. beta: number;
  42090. /** The radius of the camera from its target */
  42091. radius: number;
  42092. /** Define the camera target (the messh it should follow) */
  42093. target: Nullable<AbstractMesh>;
  42094. private _cartesianCoordinates;
  42095. /**
  42096. * Instantiates a new ArcFollowCamera
  42097. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42098. * @param name Define the name of the camera
  42099. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42100. * @param beta Define the rotation angle of the camera around the elevation axis
  42101. * @param radius Define the radius of the camera from its target point
  42102. * @param target Define the target of the camera
  42103. * @param scene Define the scene the camera belongs to
  42104. */
  42105. constructor(name: string,
  42106. /** The longitudinal angle of the camera */
  42107. alpha: number,
  42108. /** The latitudinal angle of the camera */
  42109. beta: number,
  42110. /** The radius of the camera from its target */
  42111. radius: number,
  42112. /** Define the camera target (the messh it should follow) */
  42113. target: Nullable<AbstractMesh>, scene: Scene);
  42114. private _follow;
  42115. /** @hidden */
  42116. _checkInputs(): void;
  42117. /**
  42118. * Returns the class name of the object.
  42119. * It is mostly used internally for serialization purposes.
  42120. */
  42121. getClassName(): string;
  42122. }
  42123. }
  42124. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42125. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42126. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42127. import { Nullable } from "babylonjs/types";
  42128. /**
  42129. * Manage the keyboard inputs to control the movement of a follow camera.
  42130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42131. */
  42132. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42133. /**
  42134. * Defines the camera the input is attached to.
  42135. */
  42136. camera: FollowCamera;
  42137. /**
  42138. * Defines the list of key codes associated with the up action (increase heightOffset)
  42139. */
  42140. keysHeightOffsetIncr: number[];
  42141. /**
  42142. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42143. */
  42144. keysHeightOffsetDecr: number[];
  42145. /**
  42146. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42147. */
  42148. keysHeightOffsetModifierAlt: boolean;
  42149. /**
  42150. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42151. */
  42152. keysHeightOffsetModifierCtrl: boolean;
  42153. /**
  42154. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42155. */
  42156. keysHeightOffsetModifierShift: boolean;
  42157. /**
  42158. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42159. */
  42160. keysRotationOffsetIncr: number[];
  42161. /**
  42162. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42163. */
  42164. keysRotationOffsetDecr: number[];
  42165. /**
  42166. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42167. */
  42168. keysRotationOffsetModifierAlt: boolean;
  42169. /**
  42170. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42171. */
  42172. keysRotationOffsetModifierCtrl: boolean;
  42173. /**
  42174. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42175. */
  42176. keysRotationOffsetModifierShift: boolean;
  42177. /**
  42178. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42179. */
  42180. keysRadiusIncr: number[];
  42181. /**
  42182. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42183. */
  42184. keysRadiusDecr: number[];
  42185. /**
  42186. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42187. */
  42188. keysRadiusModifierAlt: boolean;
  42189. /**
  42190. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42191. */
  42192. keysRadiusModifierCtrl: boolean;
  42193. /**
  42194. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42195. */
  42196. keysRadiusModifierShift: boolean;
  42197. /**
  42198. * Defines the rate of change of heightOffset.
  42199. */
  42200. heightSensibility: number;
  42201. /**
  42202. * Defines the rate of change of rotationOffset.
  42203. */
  42204. rotationSensibility: number;
  42205. /**
  42206. * Defines the rate of change of radius.
  42207. */
  42208. radiusSensibility: number;
  42209. private _keys;
  42210. private _ctrlPressed;
  42211. private _altPressed;
  42212. private _shiftPressed;
  42213. private _onCanvasBlurObserver;
  42214. private _onKeyboardObserver;
  42215. private _engine;
  42216. private _scene;
  42217. /**
  42218. * Attach the input controls to a specific dom element to get the input from.
  42219. * @param element Defines the element the controls should be listened from
  42220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42221. */
  42222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42223. /**
  42224. * Detach the current controls from the specified dom element.
  42225. * @param element Defines the element to stop listening the inputs from
  42226. */
  42227. detachControl(element: Nullable<HTMLElement>): void;
  42228. /**
  42229. * Update the current camera state depending on the inputs that have been used this frame.
  42230. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42231. */
  42232. checkInputs(): void;
  42233. /**
  42234. * Gets the class name of the current input.
  42235. * @returns the class name
  42236. */
  42237. getClassName(): string;
  42238. /**
  42239. * Get the friendly name associated with the input class.
  42240. * @returns the input friendly name
  42241. */
  42242. getSimpleName(): string;
  42243. /**
  42244. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42245. * allow modification of the heightOffset value.
  42246. */
  42247. private _modifierHeightOffset;
  42248. /**
  42249. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42250. * allow modification of the rotationOffset value.
  42251. */
  42252. private _modifierRotationOffset;
  42253. /**
  42254. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42255. * allow modification of the radius value.
  42256. */
  42257. private _modifierRadius;
  42258. }
  42259. }
  42260. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42261. import { Nullable } from "babylonjs/types";
  42262. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42263. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42264. import { Observable } from "babylonjs/Misc/observable";
  42265. module "babylonjs/Cameras/freeCameraInputsManager" {
  42266. interface FreeCameraInputsManager {
  42267. /**
  42268. * @hidden
  42269. */
  42270. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42271. /**
  42272. * Add orientation input support to the input manager.
  42273. * @returns the current input manager
  42274. */
  42275. addDeviceOrientation(): FreeCameraInputsManager;
  42276. }
  42277. }
  42278. /**
  42279. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42280. * Screen rotation is taken into account.
  42281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42282. */
  42283. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42284. private _camera;
  42285. private _screenOrientationAngle;
  42286. private _constantTranform;
  42287. private _screenQuaternion;
  42288. private _alpha;
  42289. private _beta;
  42290. private _gamma;
  42291. /**
  42292. * Can be used to detect if a device orientation sensor is available on a device
  42293. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42294. * @returns a promise that will resolve on orientation change
  42295. */
  42296. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42297. /**
  42298. * @hidden
  42299. */
  42300. _onDeviceOrientationChangedObservable: Observable<void>;
  42301. /**
  42302. * Instantiates a new input
  42303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42304. */
  42305. constructor();
  42306. /**
  42307. * Define the camera controlled by the input.
  42308. */
  42309. get camera(): FreeCamera;
  42310. set camera(camera: FreeCamera);
  42311. /**
  42312. * Attach the input controls to a specific dom element to get the input from.
  42313. * @param element Defines the element the controls should be listened from
  42314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42315. */
  42316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42317. private _orientationChanged;
  42318. private _deviceOrientation;
  42319. /**
  42320. * Detach the current controls from the specified dom element.
  42321. * @param element Defines the element to stop listening the inputs from
  42322. */
  42323. detachControl(element: Nullable<HTMLElement>): void;
  42324. /**
  42325. * Update the current camera state depending on the inputs that have been used this frame.
  42326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42327. */
  42328. checkInputs(): void;
  42329. /**
  42330. * Gets the class name of the current intput.
  42331. * @returns the class name
  42332. */
  42333. getClassName(): string;
  42334. /**
  42335. * Get the friendly name associated with the input class.
  42336. * @returns the input friendly name
  42337. */
  42338. getSimpleName(): string;
  42339. }
  42340. }
  42341. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42342. import { Nullable } from "babylonjs/types";
  42343. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42344. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42345. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42346. /**
  42347. * Manage the gamepad inputs to control a free camera.
  42348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42349. */
  42350. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42351. /**
  42352. * Define the camera the input is attached to.
  42353. */
  42354. camera: FreeCamera;
  42355. /**
  42356. * Define the Gamepad controlling the input
  42357. */
  42358. gamepad: Nullable<Gamepad>;
  42359. /**
  42360. * Defines the gamepad rotation sensiblity.
  42361. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42362. */
  42363. gamepadAngularSensibility: number;
  42364. /**
  42365. * Defines the gamepad move sensiblity.
  42366. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42367. */
  42368. gamepadMoveSensibility: number;
  42369. private _yAxisScale;
  42370. /**
  42371. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42372. */
  42373. get invertYAxis(): boolean;
  42374. set invertYAxis(value: boolean);
  42375. private _onGamepadConnectedObserver;
  42376. private _onGamepadDisconnectedObserver;
  42377. private _cameraTransform;
  42378. private _deltaTransform;
  42379. private _vector3;
  42380. private _vector2;
  42381. /**
  42382. * Attach the input controls to a specific dom element to get the input from.
  42383. * @param element Defines the element the controls should be listened from
  42384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42385. */
  42386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42387. /**
  42388. * Detach the current controls from the specified dom element.
  42389. * @param element Defines the element to stop listening the inputs from
  42390. */
  42391. detachControl(element: Nullable<HTMLElement>): void;
  42392. /**
  42393. * Update the current camera state depending on the inputs that have been used this frame.
  42394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42395. */
  42396. checkInputs(): void;
  42397. /**
  42398. * Gets the class name of the current intput.
  42399. * @returns the class name
  42400. */
  42401. getClassName(): string;
  42402. /**
  42403. * Get the friendly name associated with the input class.
  42404. * @returns the input friendly name
  42405. */
  42406. getSimpleName(): string;
  42407. }
  42408. }
  42409. declare module "babylonjs/Misc/virtualJoystick" {
  42410. import { Nullable } from "babylonjs/types";
  42411. import { Vector3 } from "babylonjs/Maths/math.vector";
  42412. /**
  42413. * Defines the potential axis of a Joystick
  42414. */
  42415. export enum JoystickAxis {
  42416. /** X axis */
  42417. X = 0,
  42418. /** Y axis */
  42419. Y = 1,
  42420. /** Z axis */
  42421. Z = 2
  42422. }
  42423. /**
  42424. * Class used to define virtual joystick (used in touch mode)
  42425. */
  42426. export class VirtualJoystick {
  42427. /**
  42428. * Gets or sets a boolean indicating that left and right values must be inverted
  42429. */
  42430. reverseLeftRight: boolean;
  42431. /**
  42432. * Gets or sets a boolean indicating that up and down values must be inverted
  42433. */
  42434. reverseUpDown: boolean;
  42435. /**
  42436. * Gets the offset value for the position (ie. the change of the position value)
  42437. */
  42438. deltaPosition: Vector3;
  42439. /**
  42440. * Gets a boolean indicating if the virtual joystick was pressed
  42441. */
  42442. pressed: boolean;
  42443. /**
  42444. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42445. */
  42446. static Canvas: Nullable<HTMLCanvasElement>;
  42447. private static _globalJoystickIndex;
  42448. private static vjCanvasContext;
  42449. private static vjCanvasWidth;
  42450. private static vjCanvasHeight;
  42451. private static halfWidth;
  42452. private _action;
  42453. private _axisTargetedByLeftAndRight;
  42454. private _axisTargetedByUpAndDown;
  42455. private _joystickSensibility;
  42456. private _inversedSensibility;
  42457. private _joystickPointerID;
  42458. private _joystickColor;
  42459. private _joystickPointerPos;
  42460. private _joystickPreviousPointerPos;
  42461. private _joystickPointerStartPos;
  42462. private _deltaJoystickVector;
  42463. private _leftJoystick;
  42464. private _touches;
  42465. private _onPointerDownHandlerRef;
  42466. private _onPointerMoveHandlerRef;
  42467. private _onPointerUpHandlerRef;
  42468. private _onResize;
  42469. /**
  42470. * Creates a new virtual joystick
  42471. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42472. */
  42473. constructor(leftJoystick?: boolean);
  42474. /**
  42475. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42476. * @param newJoystickSensibility defines the new sensibility
  42477. */
  42478. setJoystickSensibility(newJoystickSensibility: number): void;
  42479. private _onPointerDown;
  42480. private _onPointerMove;
  42481. private _onPointerUp;
  42482. /**
  42483. * Change the color of the virtual joystick
  42484. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42485. */
  42486. setJoystickColor(newColor: string): void;
  42487. /**
  42488. * Defines a callback to call when the joystick is touched
  42489. * @param action defines the callback
  42490. */
  42491. setActionOnTouch(action: () => any): void;
  42492. /**
  42493. * Defines which axis you'd like to control for left & right
  42494. * @param axis defines the axis to use
  42495. */
  42496. setAxisForLeftRight(axis: JoystickAxis): void;
  42497. /**
  42498. * Defines which axis you'd like to control for up & down
  42499. * @param axis defines the axis to use
  42500. */
  42501. setAxisForUpDown(axis: JoystickAxis): void;
  42502. private _drawVirtualJoystick;
  42503. /**
  42504. * Release internal HTML canvas
  42505. */
  42506. releaseCanvas(): void;
  42507. }
  42508. }
  42509. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42510. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42511. import { Nullable } from "babylonjs/types";
  42512. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42513. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42514. module "babylonjs/Cameras/freeCameraInputsManager" {
  42515. interface FreeCameraInputsManager {
  42516. /**
  42517. * Add virtual joystick input support to the input manager.
  42518. * @returns the current input manager
  42519. */
  42520. addVirtualJoystick(): FreeCameraInputsManager;
  42521. }
  42522. }
  42523. /**
  42524. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42526. */
  42527. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42528. /**
  42529. * Defines the camera the input is attached to.
  42530. */
  42531. camera: FreeCamera;
  42532. private _leftjoystick;
  42533. private _rightjoystick;
  42534. /**
  42535. * Gets the left stick of the virtual joystick.
  42536. * @returns The virtual Joystick
  42537. */
  42538. getLeftJoystick(): VirtualJoystick;
  42539. /**
  42540. * Gets the right stick of the virtual joystick.
  42541. * @returns The virtual Joystick
  42542. */
  42543. getRightJoystick(): VirtualJoystick;
  42544. /**
  42545. * Update the current camera state depending on the inputs that have been used this frame.
  42546. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42547. */
  42548. checkInputs(): void;
  42549. /**
  42550. * Attach the input controls to a specific dom element to get the input from.
  42551. * @param element Defines the element the controls should be listened from
  42552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42553. */
  42554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42555. /**
  42556. * Detach the current controls from the specified dom element.
  42557. * @param element Defines the element to stop listening the inputs from
  42558. */
  42559. detachControl(element: Nullable<HTMLElement>): void;
  42560. /**
  42561. * Gets the class name of the current intput.
  42562. * @returns the class name
  42563. */
  42564. getClassName(): string;
  42565. /**
  42566. * Get the friendly name associated with the input class.
  42567. * @returns the input friendly name
  42568. */
  42569. getSimpleName(): string;
  42570. }
  42571. }
  42572. declare module "babylonjs/Cameras/Inputs/index" {
  42573. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42574. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42575. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42576. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42577. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42578. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42579. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42580. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42581. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42582. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42583. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42584. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42585. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42586. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42587. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42588. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42589. }
  42590. declare module "babylonjs/Cameras/touchCamera" {
  42591. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42592. import { Scene } from "babylonjs/scene";
  42593. import { Vector3 } from "babylonjs/Maths/math.vector";
  42594. /**
  42595. * This represents a FPS type of camera controlled by touch.
  42596. * This is like a universal camera minus the Gamepad controls.
  42597. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42598. */
  42599. export class TouchCamera extends FreeCamera {
  42600. /**
  42601. * Defines the touch sensibility for rotation.
  42602. * The higher the faster.
  42603. */
  42604. get touchAngularSensibility(): number;
  42605. set touchAngularSensibility(value: number);
  42606. /**
  42607. * Defines the touch sensibility for move.
  42608. * The higher the faster.
  42609. */
  42610. get touchMoveSensibility(): number;
  42611. set touchMoveSensibility(value: number);
  42612. /**
  42613. * Instantiates a new touch camera.
  42614. * This represents a FPS type of camera controlled by touch.
  42615. * This is like a universal camera minus the Gamepad controls.
  42616. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42617. * @param name Define the name of the camera in the scene
  42618. * @param position Define the start position of the camera in the scene
  42619. * @param scene Define the scene the camera belongs to
  42620. */
  42621. constructor(name: string, position: Vector3, scene: Scene);
  42622. /**
  42623. * Gets the current object class name.
  42624. * @return the class name
  42625. */
  42626. getClassName(): string;
  42627. /** @hidden */
  42628. _setupInputs(): void;
  42629. }
  42630. }
  42631. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42632. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42633. import { Scene } from "babylonjs/scene";
  42634. import { Vector3 } from "babylonjs/Maths/math.vector";
  42635. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42636. import { Axis } from "babylonjs/Maths/math.axis";
  42637. /**
  42638. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42639. * being tilted forward or back and left or right.
  42640. */
  42641. export class DeviceOrientationCamera extends FreeCamera {
  42642. private _initialQuaternion;
  42643. private _quaternionCache;
  42644. private _tmpDragQuaternion;
  42645. private _disablePointerInputWhenUsingDeviceOrientation;
  42646. /**
  42647. * Creates a new device orientation camera
  42648. * @param name The name of the camera
  42649. * @param position The start position camera
  42650. * @param scene The scene the camera belongs to
  42651. */
  42652. constructor(name: string, position: Vector3, scene: Scene);
  42653. /**
  42654. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42655. */
  42656. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42657. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42658. private _dragFactor;
  42659. /**
  42660. * Enabled turning on the y axis when the orientation sensor is active
  42661. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42662. */
  42663. enableHorizontalDragging(dragFactor?: number): void;
  42664. /**
  42665. * Gets the current instance class name ("DeviceOrientationCamera").
  42666. * This helps avoiding instanceof at run time.
  42667. * @returns the class name
  42668. */
  42669. getClassName(): string;
  42670. /**
  42671. * @hidden
  42672. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42673. */
  42674. _checkInputs(): void;
  42675. /**
  42676. * Reset the camera to its default orientation on the specified axis only.
  42677. * @param axis The axis to reset
  42678. */
  42679. resetToCurrentRotation(axis?: Axis): void;
  42680. }
  42681. }
  42682. declare module "babylonjs/Gamepads/xboxGamepad" {
  42683. import { Observable } from "babylonjs/Misc/observable";
  42684. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42685. /**
  42686. * Defines supported buttons for XBox360 compatible gamepads
  42687. */
  42688. export enum Xbox360Button {
  42689. /** A */
  42690. A = 0,
  42691. /** B */
  42692. B = 1,
  42693. /** X */
  42694. X = 2,
  42695. /** Y */
  42696. Y = 3,
  42697. /** Left button */
  42698. LB = 4,
  42699. /** Right button */
  42700. RB = 5,
  42701. /** Back */
  42702. Back = 8,
  42703. /** Start */
  42704. Start = 9,
  42705. /** Left stick */
  42706. LeftStick = 10,
  42707. /** Right stick */
  42708. RightStick = 11
  42709. }
  42710. /** Defines values for XBox360 DPad */
  42711. export enum Xbox360Dpad {
  42712. /** Up */
  42713. Up = 12,
  42714. /** Down */
  42715. Down = 13,
  42716. /** Left */
  42717. Left = 14,
  42718. /** Right */
  42719. Right = 15
  42720. }
  42721. /**
  42722. * Defines a XBox360 gamepad
  42723. */
  42724. export class Xbox360Pad extends Gamepad {
  42725. private _leftTrigger;
  42726. private _rightTrigger;
  42727. private _onlefttriggerchanged;
  42728. private _onrighttriggerchanged;
  42729. private _onbuttondown;
  42730. private _onbuttonup;
  42731. private _ondpaddown;
  42732. private _ondpadup;
  42733. /** Observable raised when a button is pressed */
  42734. onButtonDownObservable: Observable<Xbox360Button>;
  42735. /** Observable raised when a button is released */
  42736. onButtonUpObservable: Observable<Xbox360Button>;
  42737. /** Observable raised when a pad is pressed */
  42738. onPadDownObservable: Observable<Xbox360Dpad>;
  42739. /** Observable raised when a pad is released */
  42740. onPadUpObservable: Observable<Xbox360Dpad>;
  42741. private _buttonA;
  42742. private _buttonB;
  42743. private _buttonX;
  42744. private _buttonY;
  42745. private _buttonBack;
  42746. private _buttonStart;
  42747. private _buttonLB;
  42748. private _buttonRB;
  42749. private _buttonLeftStick;
  42750. private _buttonRightStick;
  42751. private _dPadUp;
  42752. private _dPadDown;
  42753. private _dPadLeft;
  42754. private _dPadRight;
  42755. private _isXboxOnePad;
  42756. /**
  42757. * Creates a new XBox360 gamepad object
  42758. * @param id defines the id of this gamepad
  42759. * @param index defines its index
  42760. * @param gamepad defines the internal HTML gamepad object
  42761. * @param xboxOne defines if it is a XBox One gamepad
  42762. */
  42763. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42764. /**
  42765. * Defines the callback to call when left trigger is pressed
  42766. * @param callback defines the callback to use
  42767. */
  42768. onlefttriggerchanged(callback: (value: number) => void): void;
  42769. /**
  42770. * Defines the callback to call when right trigger is pressed
  42771. * @param callback defines the callback to use
  42772. */
  42773. onrighttriggerchanged(callback: (value: number) => void): void;
  42774. /**
  42775. * Gets the left trigger value
  42776. */
  42777. get leftTrigger(): number;
  42778. /**
  42779. * Sets the left trigger value
  42780. */
  42781. set leftTrigger(newValue: number);
  42782. /**
  42783. * Gets the right trigger value
  42784. */
  42785. get rightTrigger(): number;
  42786. /**
  42787. * Sets the right trigger value
  42788. */
  42789. set rightTrigger(newValue: number);
  42790. /**
  42791. * Defines the callback to call when a button is pressed
  42792. * @param callback defines the callback to use
  42793. */
  42794. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42795. /**
  42796. * Defines the callback to call when a button is released
  42797. * @param callback defines the callback to use
  42798. */
  42799. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42800. /**
  42801. * Defines the callback to call when a pad is pressed
  42802. * @param callback defines the callback to use
  42803. */
  42804. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42805. /**
  42806. * Defines the callback to call when a pad is released
  42807. * @param callback defines the callback to use
  42808. */
  42809. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42810. private _setButtonValue;
  42811. private _setDPadValue;
  42812. /**
  42813. * Gets the value of the `A` button
  42814. */
  42815. get buttonA(): number;
  42816. /**
  42817. * Sets the value of the `A` button
  42818. */
  42819. set buttonA(value: number);
  42820. /**
  42821. * Gets the value of the `B` button
  42822. */
  42823. get buttonB(): number;
  42824. /**
  42825. * Sets the value of the `B` button
  42826. */
  42827. set buttonB(value: number);
  42828. /**
  42829. * Gets the value of the `X` button
  42830. */
  42831. get buttonX(): number;
  42832. /**
  42833. * Sets the value of the `X` button
  42834. */
  42835. set buttonX(value: number);
  42836. /**
  42837. * Gets the value of the `Y` button
  42838. */
  42839. get buttonY(): number;
  42840. /**
  42841. * Sets the value of the `Y` button
  42842. */
  42843. set buttonY(value: number);
  42844. /**
  42845. * Gets the value of the `Start` button
  42846. */
  42847. get buttonStart(): number;
  42848. /**
  42849. * Sets the value of the `Start` button
  42850. */
  42851. set buttonStart(value: number);
  42852. /**
  42853. * Gets the value of the `Back` button
  42854. */
  42855. get buttonBack(): number;
  42856. /**
  42857. * Sets the value of the `Back` button
  42858. */
  42859. set buttonBack(value: number);
  42860. /**
  42861. * Gets the value of the `Left` button
  42862. */
  42863. get buttonLB(): number;
  42864. /**
  42865. * Sets the value of the `Left` button
  42866. */
  42867. set buttonLB(value: number);
  42868. /**
  42869. * Gets the value of the `Right` button
  42870. */
  42871. get buttonRB(): number;
  42872. /**
  42873. * Sets the value of the `Right` button
  42874. */
  42875. set buttonRB(value: number);
  42876. /**
  42877. * Gets the value of the Left joystick
  42878. */
  42879. get buttonLeftStick(): number;
  42880. /**
  42881. * Sets the value of the Left joystick
  42882. */
  42883. set buttonLeftStick(value: number);
  42884. /**
  42885. * Gets the value of the Right joystick
  42886. */
  42887. get buttonRightStick(): number;
  42888. /**
  42889. * Sets the value of the Right joystick
  42890. */
  42891. set buttonRightStick(value: number);
  42892. /**
  42893. * Gets the value of D-pad up
  42894. */
  42895. get dPadUp(): number;
  42896. /**
  42897. * Sets the value of D-pad up
  42898. */
  42899. set dPadUp(value: number);
  42900. /**
  42901. * Gets the value of D-pad down
  42902. */
  42903. get dPadDown(): number;
  42904. /**
  42905. * Sets the value of D-pad down
  42906. */
  42907. set dPadDown(value: number);
  42908. /**
  42909. * Gets the value of D-pad left
  42910. */
  42911. get dPadLeft(): number;
  42912. /**
  42913. * Sets the value of D-pad left
  42914. */
  42915. set dPadLeft(value: number);
  42916. /**
  42917. * Gets the value of D-pad right
  42918. */
  42919. get dPadRight(): number;
  42920. /**
  42921. * Sets the value of D-pad right
  42922. */
  42923. set dPadRight(value: number);
  42924. /**
  42925. * Force the gamepad to synchronize with device values
  42926. */
  42927. update(): void;
  42928. /**
  42929. * Disposes the gamepad
  42930. */
  42931. dispose(): void;
  42932. }
  42933. }
  42934. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42935. import { Observable } from "babylonjs/Misc/observable";
  42936. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42937. /**
  42938. * Defines supported buttons for DualShock compatible gamepads
  42939. */
  42940. export enum DualShockButton {
  42941. /** Cross */
  42942. Cross = 0,
  42943. /** Circle */
  42944. Circle = 1,
  42945. /** Square */
  42946. Square = 2,
  42947. /** Triangle */
  42948. Triangle = 3,
  42949. /** L1 */
  42950. L1 = 4,
  42951. /** R1 */
  42952. R1 = 5,
  42953. /** Share */
  42954. Share = 8,
  42955. /** Options */
  42956. Options = 9,
  42957. /** Left stick */
  42958. LeftStick = 10,
  42959. /** Right stick */
  42960. RightStick = 11
  42961. }
  42962. /** Defines values for DualShock DPad */
  42963. export enum DualShockDpad {
  42964. /** Up */
  42965. Up = 12,
  42966. /** Down */
  42967. Down = 13,
  42968. /** Left */
  42969. Left = 14,
  42970. /** Right */
  42971. Right = 15
  42972. }
  42973. /**
  42974. * Defines a DualShock gamepad
  42975. */
  42976. export class DualShockPad extends Gamepad {
  42977. private _leftTrigger;
  42978. private _rightTrigger;
  42979. private _onlefttriggerchanged;
  42980. private _onrighttriggerchanged;
  42981. private _onbuttondown;
  42982. private _onbuttonup;
  42983. private _ondpaddown;
  42984. private _ondpadup;
  42985. /** Observable raised when a button is pressed */
  42986. onButtonDownObservable: Observable<DualShockButton>;
  42987. /** Observable raised when a button is released */
  42988. onButtonUpObservable: Observable<DualShockButton>;
  42989. /** Observable raised when a pad is pressed */
  42990. onPadDownObservable: Observable<DualShockDpad>;
  42991. /** Observable raised when a pad is released */
  42992. onPadUpObservable: Observable<DualShockDpad>;
  42993. private _buttonCross;
  42994. private _buttonCircle;
  42995. private _buttonSquare;
  42996. private _buttonTriangle;
  42997. private _buttonShare;
  42998. private _buttonOptions;
  42999. private _buttonL1;
  43000. private _buttonR1;
  43001. private _buttonLeftStick;
  43002. private _buttonRightStick;
  43003. private _dPadUp;
  43004. private _dPadDown;
  43005. private _dPadLeft;
  43006. private _dPadRight;
  43007. /**
  43008. * Creates a new DualShock gamepad object
  43009. * @param id defines the id of this gamepad
  43010. * @param index defines its index
  43011. * @param gamepad defines the internal HTML gamepad object
  43012. */
  43013. constructor(id: string, index: number, gamepad: any);
  43014. /**
  43015. * Defines the callback to call when left trigger is pressed
  43016. * @param callback defines the callback to use
  43017. */
  43018. onlefttriggerchanged(callback: (value: number) => void): void;
  43019. /**
  43020. * Defines the callback to call when right trigger is pressed
  43021. * @param callback defines the callback to use
  43022. */
  43023. onrighttriggerchanged(callback: (value: number) => void): void;
  43024. /**
  43025. * Gets the left trigger value
  43026. */
  43027. get leftTrigger(): number;
  43028. /**
  43029. * Sets the left trigger value
  43030. */
  43031. set leftTrigger(newValue: number);
  43032. /**
  43033. * Gets the right trigger value
  43034. */
  43035. get rightTrigger(): number;
  43036. /**
  43037. * Sets the right trigger value
  43038. */
  43039. set rightTrigger(newValue: number);
  43040. /**
  43041. * Defines the callback to call when a button is pressed
  43042. * @param callback defines the callback to use
  43043. */
  43044. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43045. /**
  43046. * Defines the callback to call when a button is released
  43047. * @param callback defines the callback to use
  43048. */
  43049. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43050. /**
  43051. * Defines the callback to call when a pad is pressed
  43052. * @param callback defines the callback to use
  43053. */
  43054. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43055. /**
  43056. * Defines the callback to call when a pad is released
  43057. * @param callback defines the callback to use
  43058. */
  43059. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43060. private _setButtonValue;
  43061. private _setDPadValue;
  43062. /**
  43063. * Gets the value of the `Cross` button
  43064. */
  43065. get buttonCross(): number;
  43066. /**
  43067. * Sets the value of the `Cross` button
  43068. */
  43069. set buttonCross(value: number);
  43070. /**
  43071. * Gets the value of the `Circle` button
  43072. */
  43073. get buttonCircle(): number;
  43074. /**
  43075. * Sets the value of the `Circle` button
  43076. */
  43077. set buttonCircle(value: number);
  43078. /**
  43079. * Gets the value of the `Square` button
  43080. */
  43081. get buttonSquare(): number;
  43082. /**
  43083. * Sets the value of the `Square` button
  43084. */
  43085. set buttonSquare(value: number);
  43086. /**
  43087. * Gets the value of the `Triangle` button
  43088. */
  43089. get buttonTriangle(): number;
  43090. /**
  43091. * Sets the value of the `Triangle` button
  43092. */
  43093. set buttonTriangle(value: number);
  43094. /**
  43095. * Gets the value of the `Options` button
  43096. */
  43097. get buttonOptions(): number;
  43098. /**
  43099. * Sets the value of the `Options` button
  43100. */
  43101. set buttonOptions(value: number);
  43102. /**
  43103. * Gets the value of the `Share` button
  43104. */
  43105. get buttonShare(): number;
  43106. /**
  43107. * Sets the value of the `Share` button
  43108. */
  43109. set buttonShare(value: number);
  43110. /**
  43111. * Gets the value of the `L1` button
  43112. */
  43113. get buttonL1(): number;
  43114. /**
  43115. * Sets the value of the `L1` button
  43116. */
  43117. set buttonL1(value: number);
  43118. /**
  43119. * Gets the value of the `R1` button
  43120. */
  43121. get buttonR1(): number;
  43122. /**
  43123. * Sets the value of the `R1` button
  43124. */
  43125. set buttonR1(value: number);
  43126. /**
  43127. * Gets the value of the Left joystick
  43128. */
  43129. get buttonLeftStick(): number;
  43130. /**
  43131. * Sets the value of the Left joystick
  43132. */
  43133. set buttonLeftStick(value: number);
  43134. /**
  43135. * Gets the value of the Right joystick
  43136. */
  43137. get buttonRightStick(): number;
  43138. /**
  43139. * Sets the value of the Right joystick
  43140. */
  43141. set buttonRightStick(value: number);
  43142. /**
  43143. * Gets the value of D-pad up
  43144. */
  43145. get dPadUp(): number;
  43146. /**
  43147. * Sets the value of D-pad up
  43148. */
  43149. set dPadUp(value: number);
  43150. /**
  43151. * Gets the value of D-pad down
  43152. */
  43153. get dPadDown(): number;
  43154. /**
  43155. * Sets the value of D-pad down
  43156. */
  43157. set dPadDown(value: number);
  43158. /**
  43159. * Gets the value of D-pad left
  43160. */
  43161. get dPadLeft(): number;
  43162. /**
  43163. * Sets the value of D-pad left
  43164. */
  43165. set dPadLeft(value: number);
  43166. /**
  43167. * Gets the value of D-pad right
  43168. */
  43169. get dPadRight(): number;
  43170. /**
  43171. * Sets the value of D-pad right
  43172. */
  43173. set dPadRight(value: number);
  43174. /**
  43175. * Force the gamepad to synchronize with device values
  43176. */
  43177. update(): void;
  43178. /**
  43179. * Disposes the gamepad
  43180. */
  43181. dispose(): void;
  43182. }
  43183. }
  43184. declare module "babylonjs/Gamepads/gamepadManager" {
  43185. import { Observable } from "babylonjs/Misc/observable";
  43186. import { Nullable } from "babylonjs/types";
  43187. import { Scene } from "babylonjs/scene";
  43188. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43189. /**
  43190. * Manager for handling gamepads
  43191. */
  43192. export class GamepadManager {
  43193. private _scene?;
  43194. private _babylonGamepads;
  43195. private _oneGamepadConnected;
  43196. /** @hidden */
  43197. _isMonitoring: boolean;
  43198. private _gamepadEventSupported;
  43199. private _gamepadSupport?;
  43200. /**
  43201. * observable to be triggered when the gamepad controller has been connected
  43202. */
  43203. onGamepadConnectedObservable: Observable<Gamepad>;
  43204. /**
  43205. * observable to be triggered when the gamepad controller has been disconnected
  43206. */
  43207. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43208. private _onGamepadConnectedEvent;
  43209. private _onGamepadDisconnectedEvent;
  43210. /**
  43211. * Initializes the gamepad manager
  43212. * @param _scene BabylonJS scene
  43213. */
  43214. constructor(_scene?: Scene | undefined);
  43215. /**
  43216. * The gamepads in the game pad manager
  43217. */
  43218. get gamepads(): Gamepad[];
  43219. /**
  43220. * Get the gamepad controllers based on type
  43221. * @param type The type of gamepad controller
  43222. * @returns Nullable gamepad
  43223. */
  43224. getGamepadByType(type?: number): Nullable<Gamepad>;
  43225. /**
  43226. * Disposes the gamepad manager
  43227. */
  43228. dispose(): void;
  43229. private _addNewGamepad;
  43230. private _startMonitoringGamepads;
  43231. private _stopMonitoringGamepads;
  43232. /** @hidden */
  43233. _checkGamepadsStatus(): void;
  43234. private _updateGamepadObjects;
  43235. }
  43236. }
  43237. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43238. import { Nullable } from "babylonjs/types";
  43239. import { Scene } from "babylonjs/scene";
  43240. import { ISceneComponent } from "babylonjs/sceneComponent";
  43241. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43242. module "babylonjs/scene" {
  43243. interface Scene {
  43244. /** @hidden */
  43245. _gamepadManager: Nullable<GamepadManager>;
  43246. /**
  43247. * Gets the gamepad manager associated with the scene
  43248. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43249. */
  43250. gamepadManager: GamepadManager;
  43251. }
  43252. }
  43253. module "babylonjs/Cameras/freeCameraInputsManager" {
  43254. /**
  43255. * Interface representing a free camera inputs manager
  43256. */
  43257. interface FreeCameraInputsManager {
  43258. /**
  43259. * Adds gamepad input support to the FreeCameraInputsManager.
  43260. * @returns the FreeCameraInputsManager
  43261. */
  43262. addGamepad(): FreeCameraInputsManager;
  43263. }
  43264. }
  43265. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43266. /**
  43267. * Interface representing an arc rotate camera inputs manager
  43268. */
  43269. interface ArcRotateCameraInputsManager {
  43270. /**
  43271. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43272. * @returns the camera inputs manager
  43273. */
  43274. addGamepad(): ArcRotateCameraInputsManager;
  43275. }
  43276. }
  43277. /**
  43278. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43279. */
  43280. export class GamepadSystemSceneComponent implements ISceneComponent {
  43281. /**
  43282. * The component name helpfull to identify the component in the list of scene components.
  43283. */
  43284. readonly name: string;
  43285. /**
  43286. * The scene the component belongs to.
  43287. */
  43288. scene: Scene;
  43289. /**
  43290. * Creates a new instance of the component for the given scene
  43291. * @param scene Defines the scene to register the component in
  43292. */
  43293. constructor(scene: Scene);
  43294. /**
  43295. * Registers the component in a given scene
  43296. */
  43297. register(): void;
  43298. /**
  43299. * Rebuilds the elements related to this component in case of
  43300. * context lost for instance.
  43301. */
  43302. rebuild(): void;
  43303. /**
  43304. * Disposes the component and the associated ressources
  43305. */
  43306. dispose(): void;
  43307. private _beforeCameraUpdate;
  43308. }
  43309. }
  43310. declare module "babylonjs/Cameras/universalCamera" {
  43311. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43312. import { Scene } from "babylonjs/scene";
  43313. import { Vector3 } from "babylonjs/Maths/math.vector";
  43314. import "babylonjs/Gamepads/gamepadSceneComponent";
  43315. /**
  43316. * 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,
  43317. * which still works and will still be found in many Playgrounds.
  43318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43319. */
  43320. export class UniversalCamera extends TouchCamera {
  43321. /**
  43322. * Defines the gamepad rotation sensiblity.
  43323. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43324. */
  43325. get gamepadAngularSensibility(): number;
  43326. set gamepadAngularSensibility(value: number);
  43327. /**
  43328. * Defines the gamepad move sensiblity.
  43329. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43330. */
  43331. get gamepadMoveSensibility(): number;
  43332. set gamepadMoveSensibility(value: number);
  43333. /**
  43334. * 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,
  43335. * which still works and will still be found in many Playgrounds.
  43336. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43337. * @param name Define the name of the camera in the scene
  43338. * @param position Define the start position of the camera in the scene
  43339. * @param scene Define the scene the camera belongs to
  43340. */
  43341. constructor(name: string, position: Vector3, scene: Scene);
  43342. /**
  43343. * Gets the current object class name.
  43344. * @return the class name
  43345. */
  43346. getClassName(): string;
  43347. }
  43348. }
  43349. declare module "babylonjs/Cameras/gamepadCamera" {
  43350. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43351. import { Scene } from "babylonjs/scene";
  43352. import { Vector3 } from "babylonjs/Maths/math.vector";
  43353. /**
  43354. * This represents a FPS type of camera. This is only here for back compat purpose.
  43355. * Please use the UniversalCamera instead as both are identical.
  43356. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43357. */
  43358. export class GamepadCamera extends UniversalCamera {
  43359. /**
  43360. * Instantiates a new Gamepad Camera
  43361. * This represents a FPS type of camera. This is only here for back compat purpose.
  43362. * Please use the UniversalCamera instead as both are identical.
  43363. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43364. * @param name Define the name of the camera in the scene
  43365. * @param position Define the start position of the camera in the scene
  43366. * @param scene Define the scene the camera belongs to
  43367. */
  43368. constructor(name: string, position: Vector3, scene: Scene);
  43369. /**
  43370. * Gets the current object class name.
  43371. * @return the class name
  43372. */
  43373. getClassName(): string;
  43374. }
  43375. }
  43376. declare module "babylonjs/Shaders/pass.fragment" {
  43377. /** @hidden */
  43378. export var passPixelShader: {
  43379. name: string;
  43380. shader: string;
  43381. };
  43382. }
  43383. declare module "babylonjs/Shaders/passCube.fragment" {
  43384. /** @hidden */
  43385. export var passCubePixelShader: {
  43386. name: string;
  43387. shader: string;
  43388. };
  43389. }
  43390. declare module "babylonjs/PostProcesses/passPostProcess" {
  43391. import { Nullable } from "babylonjs/types";
  43392. import { Camera } from "babylonjs/Cameras/camera";
  43393. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43394. import { Engine } from "babylonjs/Engines/engine";
  43395. import "babylonjs/Shaders/pass.fragment";
  43396. import "babylonjs/Shaders/passCube.fragment";
  43397. /**
  43398. * PassPostProcess which produces an output the same as it's input
  43399. */
  43400. export class PassPostProcess extends PostProcess {
  43401. /**
  43402. * Creates the PassPostProcess
  43403. * @param name The name of the effect.
  43404. * @param options The required width/height ratio to downsize to before computing the render pass.
  43405. * @param camera The camera to apply the render pass to.
  43406. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43407. * @param engine The engine which the post process will be applied. (default: current engine)
  43408. * @param reusable If the post process can be reused on the same frame. (default: false)
  43409. * @param textureType The type of texture to be used when performing the post processing.
  43410. * @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)
  43411. */
  43412. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43413. }
  43414. /**
  43415. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43416. */
  43417. export class PassCubePostProcess extends PostProcess {
  43418. private _face;
  43419. /**
  43420. * Gets or sets the cube face to display.
  43421. * * 0 is +X
  43422. * * 1 is -X
  43423. * * 2 is +Y
  43424. * * 3 is -Y
  43425. * * 4 is +Z
  43426. * * 5 is -Z
  43427. */
  43428. get face(): number;
  43429. set face(value: number);
  43430. /**
  43431. * Creates the PassCubePostProcess
  43432. * @param name The name of the effect.
  43433. * @param options The required width/height ratio to downsize to before computing the render pass.
  43434. * @param camera The camera to apply the render pass to.
  43435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43436. * @param engine The engine which the post process will be applied. (default: current engine)
  43437. * @param reusable If the post process can be reused on the same frame. (default: false)
  43438. * @param textureType The type of texture to be used when performing the post processing.
  43439. * @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)
  43440. */
  43441. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43442. }
  43443. }
  43444. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43445. /** @hidden */
  43446. export var anaglyphPixelShader: {
  43447. name: string;
  43448. shader: string;
  43449. };
  43450. }
  43451. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43452. import { Engine } from "babylonjs/Engines/engine";
  43453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43454. import { Camera } from "babylonjs/Cameras/camera";
  43455. import "babylonjs/Shaders/anaglyph.fragment";
  43456. /**
  43457. * Postprocess used to generate anaglyphic rendering
  43458. */
  43459. export class AnaglyphPostProcess extends PostProcess {
  43460. private _passedProcess;
  43461. /**
  43462. * Creates a new AnaglyphPostProcess
  43463. * @param name defines postprocess name
  43464. * @param options defines creation options or target ratio scale
  43465. * @param rigCameras defines cameras using this postprocess
  43466. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43467. * @param engine defines hosting engine
  43468. * @param reusable defines if the postprocess will be reused multiple times per frame
  43469. */
  43470. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43471. }
  43472. }
  43473. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43474. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43475. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43476. import { Scene } from "babylonjs/scene";
  43477. import { Vector3 } from "babylonjs/Maths/math.vector";
  43478. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43479. /**
  43480. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43481. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43482. */
  43483. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43484. /**
  43485. * Creates a new AnaglyphArcRotateCamera
  43486. * @param name defines camera name
  43487. * @param alpha defines alpha angle (in radians)
  43488. * @param beta defines beta angle (in radians)
  43489. * @param radius defines radius
  43490. * @param target defines camera target
  43491. * @param interaxialDistance defines distance between each color axis
  43492. * @param scene defines the hosting scene
  43493. */
  43494. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43495. /**
  43496. * Gets camera class name
  43497. * @returns AnaglyphArcRotateCamera
  43498. */
  43499. getClassName(): string;
  43500. }
  43501. }
  43502. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43504. import { Scene } from "babylonjs/scene";
  43505. import { Vector3 } from "babylonjs/Maths/math.vector";
  43506. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43507. /**
  43508. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43509. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43510. */
  43511. export class AnaglyphFreeCamera extends FreeCamera {
  43512. /**
  43513. * Creates a new AnaglyphFreeCamera
  43514. * @param name defines camera name
  43515. * @param position defines initial position
  43516. * @param interaxialDistance defines distance between each color axis
  43517. * @param scene defines the hosting scene
  43518. */
  43519. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43520. /**
  43521. * Gets camera class name
  43522. * @returns AnaglyphFreeCamera
  43523. */
  43524. getClassName(): string;
  43525. }
  43526. }
  43527. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43528. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43529. import { Scene } from "babylonjs/scene";
  43530. import { Vector3 } from "babylonjs/Maths/math.vector";
  43531. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43532. /**
  43533. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43534. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43535. */
  43536. export class AnaglyphGamepadCamera extends GamepadCamera {
  43537. /**
  43538. * Creates a new AnaglyphGamepadCamera
  43539. * @param name defines camera name
  43540. * @param position defines initial position
  43541. * @param interaxialDistance defines distance between each color axis
  43542. * @param scene defines the hosting scene
  43543. */
  43544. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43545. /**
  43546. * Gets camera class name
  43547. * @returns AnaglyphGamepadCamera
  43548. */
  43549. getClassName(): string;
  43550. }
  43551. }
  43552. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43553. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43554. import { Scene } from "babylonjs/scene";
  43555. import { Vector3 } from "babylonjs/Maths/math.vector";
  43556. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43557. /**
  43558. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43559. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43560. */
  43561. export class AnaglyphUniversalCamera extends UniversalCamera {
  43562. /**
  43563. * Creates a new AnaglyphUniversalCamera
  43564. * @param name defines camera name
  43565. * @param position defines initial position
  43566. * @param interaxialDistance defines distance between each color axis
  43567. * @param scene defines the hosting scene
  43568. */
  43569. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43570. /**
  43571. * Gets camera class name
  43572. * @returns AnaglyphUniversalCamera
  43573. */
  43574. getClassName(): string;
  43575. }
  43576. }
  43577. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43578. /** @hidden */
  43579. export var stereoscopicInterlacePixelShader: {
  43580. name: string;
  43581. shader: string;
  43582. };
  43583. }
  43584. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43585. import { Camera } from "babylonjs/Cameras/camera";
  43586. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43587. import { Engine } from "babylonjs/Engines/engine";
  43588. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43589. /**
  43590. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43591. */
  43592. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43593. private _stepSize;
  43594. private _passedProcess;
  43595. /**
  43596. * Initializes a StereoscopicInterlacePostProcessI
  43597. * @param name The name of the effect.
  43598. * @param rigCameras The rig cameras to be appled to the post process
  43599. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43600. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43602. * @param engine The engine which the post process will be applied. (default: current engine)
  43603. * @param reusable If the post process can be reused on the same frame. (default: false)
  43604. */
  43605. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43606. }
  43607. /**
  43608. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43609. */
  43610. export class StereoscopicInterlacePostProcess extends PostProcess {
  43611. private _stepSize;
  43612. private _passedProcess;
  43613. /**
  43614. * Initializes a StereoscopicInterlacePostProcess
  43615. * @param name The name of the effect.
  43616. * @param rigCameras The rig cameras to be appled to the post process
  43617. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43618. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43619. * @param engine The engine which the post process will be applied. (default: current engine)
  43620. * @param reusable If the post process can be reused on the same frame. (default: false)
  43621. */
  43622. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43623. }
  43624. }
  43625. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43626. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43627. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43628. import { Scene } from "babylonjs/scene";
  43629. import { Vector3 } from "babylonjs/Maths/math.vector";
  43630. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43631. /**
  43632. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43633. * @see http://doc.babylonjs.com/features/cameras
  43634. */
  43635. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43636. /**
  43637. * Creates a new StereoscopicArcRotateCamera
  43638. * @param name defines camera name
  43639. * @param alpha defines alpha angle (in radians)
  43640. * @param beta defines beta angle (in radians)
  43641. * @param radius defines radius
  43642. * @param target defines camera target
  43643. * @param interaxialDistance defines distance between each color axis
  43644. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43645. * @param scene defines the hosting scene
  43646. */
  43647. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43648. /**
  43649. * Gets camera class name
  43650. * @returns StereoscopicArcRotateCamera
  43651. */
  43652. getClassName(): string;
  43653. }
  43654. }
  43655. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43657. import { Scene } from "babylonjs/scene";
  43658. import { Vector3 } from "babylonjs/Maths/math.vector";
  43659. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43660. /**
  43661. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43662. * @see http://doc.babylonjs.com/features/cameras
  43663. */
  43664. export class StereoscopicFreeCamera extends FreeCamera {
  43665. /**
  43666. * Creates a new StereoscopicFreeCamera
  43667. * @param name defines camera name
  43668. * @param position defines initial position
  43669. * @param interaxialDistance defines distance between each color axis
  43670. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43671. * @param scene defines the hosting scene
  43672. */
  43673. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43674. /**
  43675. * Gets camera class name
  43676. * @returns StereoscopicFreeCamera
  43677. */
  43678. getClassName(): string;
  43679. }
  43680. }
  43681. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43682. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43683. import { Scene } from "babylonjs/scene";
  43684. import { Vector3 } from "babylonjs/Maths/math.vector";
  43685. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43686. /**
  43687. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43688. * @see http://doc.babylonjs.com/features/cameras
  43689. */
  43690. export class StereoscopicGamepadCamera extends GamepadCamera {
  43691. /**
  43692. * Creates a new StereoscopicGamepadCamera
  43693. * @param name defines camera name
  43694. * @param position defines initial position
  43695. * @param interaxialDistance defines distance between each color axis
  43696. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43697. * @param scene defines the hosting scene
  43698. */
  43699. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43700. /**
  43701. * Gets camera class name
  43702. * @returns StereoscopicGamepadCamera
  43703. */
  43704. getClassName(): string;
  43705. }
  43706. }
  43707. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43708. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43709. import { Scene } from "babylonjs/scene";
  43710. import { Vector3 } from "babylonjs/Maths/math.vector";
  43711. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43712. /**
  43713. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43714. * @see http://doc.babylonjs.com/features/cameras
  43715. */
  43716. export class StereoscopicUniversalCamera extends UniversalCamera {
  43717. /**
  43718. * Creates a new StereoscopicUniversalCamera
  43719. * @param name defines camera name
  43720. * @param position defines initial position
  43721. * @param interaxialDistance defines distance between each color axis
  43722. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43723. * @param scene defines the hosting scene
  43724. */
  43725. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43726. /**
  43727. * Gets camera class name
  43728. * @returns StereoscopicUniversalCamera
  43729. */
  43730. getClassName(): string;
  43731. }
  43732. }
  43733. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43734. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43735. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43736. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43737. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43738. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43739. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43740. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43741. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43742. }
  43743. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43744. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43745. import { Scene } from "babylonjs/scene";
  43746. import { Vector3 } from "babylonjs/Maths/math.vector";
  43747. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43748. /**
  43749. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43750. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43751. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43752. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43753. */
  43754. export class VirtualJoysticksCamera extends FreeCamera {
  43755. /**
  43756. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43757. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43758. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43759. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43760. * @param name Define the name of the camera in the scene
  43761. * @param position Define the start position of the camera in the scene
  43762. * @param scene Define the scene the camera belongs to
  43763. */
  43764. constructor(name: string, position: Vector3, scene: Scene);
  43765. /**
  43766. * Gets the current object class name.
  43767. * @return the class name
  43768. */
  43769. getClassName(): string;
  43770. }
  43771. }
  43772. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43773. import { Matrix } from "babylonjs/Maths/math.vector";
  43774. /**
  43775. * This represents all the required metrics to create a VR camera.
  43776. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43777. */
  43778. export class VRCameraMetrics {
  43779. /**
  43780. * Define the horizontal resolution off the screen.
  43781. */
  43782. hResolution: number;
  43783. /**
  43784. * Define the vertical resolution off the screen.
  43785. */
  43786. vResolution: number;
  43787. /**
  43788. * Define the horizontal screen size.
  43789. */
  43790. hScreenSize: number;
  43791. /**
  43792. * Define the vertical screen size.
  43793. */
  43794. vScreenSize: number;
  43795. /**
  43796. * Define the vertical screen center position.
  43797. */
  43798. vScreenCenter: number;
  43799. /**
  43800. * Define the distance of the eyes to the screen.
  43801. */
  43802. eyeToScreenDistance: number;
  43803. /**
  43804. * Define the distance between both lenses
  43805. */
  43806. lensSeparationDistance: number;
  43807. /**
  43808. * Define the distance between both viewer's eyes.
  43809. */
  43810. interpupillaryDistance: number;
  43811. /**
  43812. * Define the distortion factor of the VR postprocess.
  43813. * Please, touch with care.
  43814. */
  43815. distortionK: number[];
  43816. /**
  43817. * Define the chromatic aberration correction factors for the VR post process.
  43818. */
  43819. chromaAbCorrection: number[];
  43820. /**
  43821. * Define the scale factor of the post process.
  43822. * The smaller the better but the slower.
  43823. */
  43824. postProcessScaleFactor: number;
  43825. /**
  43826. * Define an offset for the lens center.
  43827. */
  43828. lensCenterOffset: number;
  43829. /**
  43830. * Define if the current vr camera should compensate the distortion of the lense or not.
  43831. */
  43832. compensateDistortion: boolean;
  43833. /**
  43834. * Defines if multiview should be enabled when rendering (Default: false)
  43835. */
  43836. multiviewEnabled: boolean;
  43837. /**
  43838. * Gets the rendering aspect ratio based on the provided resolutions.
  43839. */
  43840. get aspectRatio(): number;
  43841. /**
  43842. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43843. */
  43844. get aspectRatioFov(): number;
  43845. /**
  43846. * @hidden
  43847. */
  43848. get leftHMatrix(): Matrix;
  43849. /**
  43850. * @hidden
  43851. */
  43852. get rightHMatrix(): Matrix;
  43853. /**
  43854. * @hidden
  43855. */
  43856. get leftPreViewMatrix(): Matrix;
  43857. /**
  43858. * @hidden
  43859. */
  43860. get rightPreViewMatrix(): Matrix;
  43861. /**
  43862. * Get the default VRMetrics based on the most generic setup.
  43863. * @returns the default vr metrics
  43864. */
  43865. static GetDefault(): VRCameraMetrics;
  43866. }
  43867. }
  43868. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43869. /** @hidden */
  43870. export var vrDistortionCorrectionPixelShader: {
  43871. name: string;
  43872. shader: string;
  43873. };
  43874. }
  43875. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43876. import { Camera } from "babylonjs/Cameras/camera";
  43877. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43878. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43879. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43880. /**
  43881. * VRDistortionCorrectionPostProcess used for mobile VR
  43882. */
  43883. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43884. private _isRightEye;
  43885. private _distortionFactors;
  43886. private _postProcessScaleFactor;
  43887. private _lensCenterOffset;
  43888. private _scaleIn;
  43889. private _scaleFactor;
  43890. private _lensCenter;
  43891. /**
  43892. * Initializes the VRDistortionCorrectionPostProcess
  43893. * @param name The name of the effect.
  43894. * @param camera The camera to apply the render pass to.
  43895. * @param isRightEye If this is for the right eye distortion
  43896. * @param vrMetrics All the required metrics for the VR camera
  43897. */
  43898. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43899. }
  43900. }
  43901. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43902. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43903. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43904. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43905. import { Scene } from "babylonjs/scene";
  43906. import { Vector3 } from "babylonjs/Maths/math.vector";
  43907. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43908. import "babylonjs/Cameras/RigModes/vrRigMode";
  43909. /**
  43910. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43911. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43912. */
  43913. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43914. /**
  43915. * Creates a new VRDeviceOrientationArcRotateCamera
  43916. * @param name defines camera name
  43917. * @param alpha defines the camera rotation along the logitudinal axis
  43918. * @param beta defines the camera rotation along the latitudinal axis
  43919. * @param radius defines the camera distance from its target
  43920. * @param target defines the camera target
  43921. * @param scene defines the scene the camera belongs to
  43922. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43923. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43924. */
  43925. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43926. /**
  43927. * Gets camera class name
  43928. * @returns VRDeviceOrientationArcRotateCamera
  43929. */
  43930. getClassName(): string;
  43931. }
  43932. }
  43933. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43934. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43935. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43936. import { Scene } from "babylonjs/scene";
  43937. import { Vector3 } from "babylonjs/Maths/math.vector";
  43938. import "babylonjs/Cameras/RigModes/vrRigMode";
  43939. /**
  43940. * Camera used to simulate VR rendering (based on FreeCamera)
  43941. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43942. */
  43943. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43944. /**
  43945. * Creates a new VRDeviceOrientationFreeCamera
  43946. * @param name defines camera name
  43947. * @param position defines the start position of the camera
  43948. * @param scene defines the scene the camera belongs to
  43949. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43950. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43951. */
  43952. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43953. /**
  43954. * Gets camera class name
  43955. * @returns VRDeviceOrientationFreeCamera
  43956. */
  43957. getClassName(): string;
  43958. }
  43959. }
  43960. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43961. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43962. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43963. import { Scene } from "babylonjs/scene";
  43964. import { Vector3 } from "babylonjs/Maths/math.vector";
  43965. import "babylonjs/Gamepads/gamepadSceneComponent";
  43966. /**
  43967. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43968. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43969. */
  43970. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43971. /**
  43972. * Creates a new VRDeviceOrientationGamepadCamera
  43973. * @param name defines camera name
  43974. * @param position defines the start position of the camera
  43975. * @param scene defines the scene the camera belongs to
  43976. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43977. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43978. */
  43979. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43980. /**
  43981. * Gets camera class name
  43982. * @returns VRDeviceOrientationGamepadCamera
  43983. */
  43984. getClassName(): string;
  43985. }
  43986. }
  43987. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43988. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43989. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43990. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43991. /** @hidden */
  43992. export var imageProcessingPixelShader: {
  43993. name: string;
  43994. shader: string;
  43995. };
  43996. }
  43997. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43998. import { Nullable } from "babylonjs/types";
  43999. import { Color4 } from "babylonjs/Maths/math.color";
  44000. import { Camera } from "babylonjs/Cameras/camera";
  44001. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44002. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44003. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44004. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44005. import { Engine } from "babylonjs/Engines/engine";
  44006. import "babylonjs/Shaders/imageProcessing.fragment";
  44007. import "babylonjs/Shaders/postprocess.vertex";
  44008. /**
  44009. * ImageProcessingPostProcess
  44010. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44011. */
  44012. export class ImageProcessingPostProcess extends PostProcess {
  44013. /**
  44014. * Default configuration related to image processing available in the PBR Material.
  44015. */
  44016. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44017. /**
  44018. * Gets the image processing configuration used either in this material.
  44019. */
  44020. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44021. /**
  44022. * Sets the Default image processing configuration used either in the this material.
  44023. *
  44024. * If sets to null, the scene one is in use.
  44025. */
  44026. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44027. /**
  44028. * Keep track of the image processing observer to allow dispose and replace.
  44029. */
  44030. private _imageProcessingObserver;
  44031. /**
  44032. * Attaches a new image processing configuration to the PBR Material.
  44033. * @param configuration
  44034. */
  44035. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44036. /**
  44037. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44038. */
  44039. get colorCurves(): Nullable<ColorCurves>;
  44040. /**
  44041. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44042. */
  44043. set colorCurves(value: Nullable<ColorCurves>);
  44044. /**
  44045. * Gets wether the color curves effect is enabled.
  44046. */
  44047. get colorCurvesEnabled(): boolean;
  44048. /**
  44049. * Sets wether the color curves effect is enabled.
  44050. */
  44051. set colorCurvesEnabled(value: boolean);
  44052. /**
  44053. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44054. */
  44055. get colorGradingTexture(): Nullable<BaseTexture>;
  44056. /**
  44057. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44058. */
  44059. set colorGradingTexture(value: Nullable<BaseTexture>);
  44060. /**
  44061. * Gets wether the color grading effect is enabled.
  44062. */
  44063. get colorGradingEnabled(): boolean;
  44064. /**
  44065. * Gets wether the color grading effect is enabled.
  44066. */
  44067. set colorGradingEnabled(value: boolean);
  44068. /**
  44069. * Gets exposure used in the effect.
  44070. */
  44071. get exposure(): number;
  44072. /**
  44073. * Sets exposure used in the effect.
  44074. */
  44075. set exposure(value: number);
  44076. /**
  44077. * Gets wether tonemapping is enabled or not.
  44078. */
  44079. get toneMappingEnabled(): boolean;
  44080. /**
  44081. * Sets wether tonemapping is enabled or not
  44082. */
  44083. set toneMappingEnabled(value: boolean);
  44084. /**
  44085. * Gets the type of tone mapping effect.
  44086. */
  44087. get toneMappingType(): number;
  44088. /**
  44089. * Sets the type of tone mapping effect.
  44090. */
  44091. set toneMappingType(value: number);
  44092. /**
  44093. * Gets contrast used in the effect.
  44094. */
  44095. get contrast(): number;
  44096. /**
  44097. * Sets contrast used in the effect.
  44098. */
  44099. set contrast(value: number);
  44100. /**
  44101. * Gets Vignette stretch size.
  44102. */
  44103. get vignetteStretch(): number;
  44104. /**
  44105. * Sets Vignette stretch size.
  44106. */
  44107. set vignetteStretch(value: number);
  44108. /**
  44109. * Gets Vignette centre X Offset.
  44110. */
  44111. get vignetteCentreX(): number;
  44112. /**
  44113. * Sets Vignette centre X Offset.
  44114. */
  44115. set vignetteCentreX(value: number);
  44116. /**
  44117. * Gets Vignette centre Y Offset.
  44118. */
  44119. get vignetteCentreY(): number;
  44120. /**
  44121. * Sets Vignette centre Y Offset.
  44122. */
  44123. set vignetteCentreY(value: number);
  44124. /**
  44125. * Gets Vignette weight or intensity of the vignette effect.
  44126. */
  44127. get vignetteWeight(): number;
  44128. /**
  44129. * Sets Vignette weight or intensity of the vignette effect.
  44130. */
  44131. set vignetteWeight(value: number);
  44132. /**
  44133. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44134. * if vignetteEnabled is set to true.
  44135. */
  44136. get vignetteColor(): Color4;
  44137. /**
  44138. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44139. * if vignetteEnabled is set to true.
  44140. */
  44141. set vignetteColor(value: Color4);
  44142. /**
  44143. * Gets Camera field of view used by the Vignette effect.
  44144. */
  44145. get vignetteCameraFov(): number;
  44146. /**
  44147. * Sets Camera field of view used by the Vignette effect.
  44148. */
  44149. set vignetteCameraFov(value: number);
  44150. /**
  44151. * Gets the vignette blend mode allowing different kind of effect.
  44152. */
  44153. get vignetteBlendMode(): number;
  44154. /**
  44155. * Sets the vignette blend mode allowing different kind of effect.
  44156. */
  44157. set vignetteBlendMode(value: number);
  44158. /**
  44159. * Gets wether the vignette effect is enabled.
  44160. */
  44161. get vignetteEnabled(): boolean;
  44162. /**
  44163. * Sets wether the vignette effect is enabled.
  44164. */
  44165. set vignetteEnabled(value: boolean);
  44166. private _fromLinearSpace;
  44167. /**
  44168. * Gets wether the input of the processing is in Gamma or Linear Space.
  44169. */
  44170. get fromLinearSpace(): boolean;
  44171. /**
  44172. * Sets wether the input of the processing is in Gamma or Linear Space.
  44173. */
  44174. set fromLinearSpace(value: boolean);
  44175. /**
  44176. * Defines cache preventing GC.
  44177. */
  44178. private _defines;
  44179. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44180. /**
  44181. * "ImageProcessingPostProcess"
  44182. * @returns "ImageProcessingPostProcess"
  44183. */
  44184. getClassName(): string;
  44185. protected _updateParameters(): void;
  44186. dispose(camera?: Camera): void;
  44187. }
  44188. }
  44189. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44190. import { Scene } from "babylonjs/scene";
  44191. import { Color3 } from "babylonjs/Maths/math.color";
  44192. import { Mesh } from "babylonjs/Meshes/mesh";
  44193. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44194. import { Nullable } from "babylonjs/types";
  44195. /**
  44196. * Class containing static functions to help procedurally build meshes
  44197. */
  44198. export class GroundBuilder {
  44199. /**
  44200. * Creates a ground mesh
  44201. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44202. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44204. * @param name defines the name of the mesh
  44205. * @param options defines the options used to create the mesh
  44206. * @param scene defines the hosting scene
  44207. * @returns the ground mesh
  44208. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44209. */
  44210. static CreateGround(name: string, options: {
  44211. width?: number;
  44212. height?: number;
  44213. subdivisions?: number;
  44214. subdivisionsX?: number;
  44215. subdivisionsY?: number;
  44216. updatable?: boolean;
  44217. }, scene: any): Mesh;
  44218. /**
  44219. * Creates a tiled ground mesh
  44220. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44221. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44222. * * 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
  44223. * * 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
  44224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44225. * @param name defines the name of the mesh
  44226. * @param options defines the options used to create the mesh
  44227. * @param scene defines the hosting scene
  44228. * @returns the tiled ground mesh
  44229. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44230. */
  44231. static CreateTiledGround(name: string, options: {
  44232. xmin: number;
  44233. zmin: number;
  44234. xmax: number;
  44235. zmax: number;
  44236. subdivisions?: {
  44237. w: number;
  44238. h: number;
  44239. };
  44240. precision?: {
  44241. w: number;
  44242. h: number;
  44243. };
  44244. updatable?: boolean;
  44245. }, scene?: Nullable<Scene>): Mesh;
  44246. /**
  44247. * Creates a ground mesh from a height map
  44248. * * The parameter `url` sets the URL of the height map image resource.
  44249. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44250. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44251. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44252. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44253. * * 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.
  44254. * * 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).
  44255. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44257. * @param name defines the name of the mesh
  44258. * @param url defines the url to the height map
  44259. * @param options defines the options used to create the mesh
  44260. * @param scene defines the hosting scene
  44261. * @returns the ground mesh
  44262. * @see https://doc.babylonjs.com/babylon101/height_map
  44263. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44264. */
  44265. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44266. width?: number;
  44267. height?: number;
  44268. subdivisions?: number;
  44269. minHeight?: number;
  44270. maxHeight?: number;
  44271. colorFilter?: Color3;
  44272. alphaFilter?: number;
  44273. updatable?: boolean;
  44274. onReady?: (mesh: GroundMesh) => void;
  44275. }, scene?: Nullable<Scene>): GroundMesh;
  44276. }
  44277. }
  44278. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44279. import { Vector4 } from "babylonjs/Maths/math.vector";
  44280. import { Mesh } from "babylonjs/Meshes/mesh";
  44281. /**
  44282. * Class containing static functions to help procedurally build meshes
  44283. */
  44284. export class TorusBuilder {
  44285. /**
  44286. * Creates a torus mesh
  44287. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44288. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44289. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44291. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44293. * @param name defines the name of the mesh
  44294. * @param options defines the options used to create the mesh
  44295. * @param scene defines the hosting scene
  44296. * @returns the torus mesh
  44297. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44298. */
  44299. static CreateTorus(name: string, options: {
  44300. diameter?: number;
  44301. thickness?: number;
  44302. tessellation?: number;
  44303. updatable?: boolean;
  44304. sideOrientation?: number;
  44305. frontUVs?: Vector4;
  44306. backUVs?: Vector4;
  44307. }, scene: any): Mesh;
  44308. }
  44309. }
  44310. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44311. import { Vector4 } from "babylonjs/Maths/math.vector";
  44312. import { Color4 } from "babylonjs/Maths/math.color";
  44313. import { Mesh } from "babylonjs/Meshes/mesh";
  44314. /**
  44315. * Class containing static functions to help procedurally build meshes
  44316. */
  44317. export class CylinderBuilder {
  44318. /**
  44319. * Creates a cylinder or a cone mesh
  44320. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44321. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44322. * * 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.
  44323. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44324. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44325. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44326. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44327. * * 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).
  44328. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44329. * * 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).
  44330. * * 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
  44331. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44332. * * 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
  44333. * * 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.
  44334. * * If `enclose` is false, a ring surface is one element.
  44335. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44336. * * 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
  44337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44340. * @param name defines the name of the mesh
  44341. * @param options defines the options used to create the mesh
  44342. * @param scene defines the hosting scene
  44343. * @returns the cylinder mesh
  44344. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44345. */
  44346. static CreateCylinder(name: string, options: {
  44347. height?: number;
  44348. diameterTop?: number;
  44349. diameterBottom?: number;
  44350. diameter?: number;
  44351. tessellation?: number;
  44352. subdivisions?: number;
  44353. arc?: number;
  44354. faceColors?: Color4[];
  44355. faceUV?: Vector4[];
  44356. updatable?: boolean;
  44357. hasRings?: boolean;
  44358. enclose?: boolean;
  44359. cap?: number;
  44360. sideOrientation?: number;
  44361. frontUVs?: Vector4;
  44362. backUVs?: Vector4;
  44363. }, scene: any): Mesh;
  44364. }
  44365. }
  44366. declare module "babylonjs/XR/webXRTypes" {
  44367. import { Nullable } from "babylonjs/types";
  44368. import { IDisposable } from "babylonjs/scene";
  44369. /**
  44370. * States of the webXR experience
  44371. */
  44372. export enum WebXRState {
  44373. /**
  44374. * Transitioning to being in XR mode
  44375. */
  44376. ENTERING_XR = 0,
  44377. /**
  44378. * Transitioning to non XR mode
  44379. */
  44380. EXITING_XR = 1,
  44381. /**
  44382. * In XR mode and presenting
  44383. */
  44384. IN_XR = 2,
  44385. /**
  44386. * Not entered XR mode
  44387. */
  44388. NOT_IN_XR = 3
  44389. }
  44390. /**
  44391. * Abstraction of the XR render target
  44392. */
  44393. export interface WebXRRenderTarget extends IDisposable {
  44394. /**
  44395. * xrpresent context of the canvas which can be used to display/mirror xr content
  44396. */
  44397. canvasContext: WebGLRenderingContext;
  44398. /**
  44399. * xr layer for the canvas
  44400. */
  44401. xrLayer: Nullable<XRWebGLLayer>;
  44402. /**
  44403. * Initializes the xr layer for the session
  44404. * @param xrSession xr session
  44405. * @returns a promise that will resolve once the XR Layer has been created
  44406. */
  44407. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44408. }
  44409. }
  44410. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44411. import { Nullable } from "babylonjs/types";
  44412. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44413. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44414. /**
  44415. * COnfiguration object for WebXR output canvas
  44416. */
  44417. export class WebXRManagedOutputCanvasOptions {
  44418. /**
  44419. * An optional canvas in case you wish to create it yourself and provide it here.
  44420. * If not provided, a new canvas will be created
  44421. */
  44422. canvasElement?: HTMLCanvasElement;
  44423. /**
  44424. * Options for this XR Layer output
  44425. */
  44426. canvasOptions?: XRWebGLLayerOptions;
  44427. /**
  44428. * CSS styling for a newly created canvas (if not provided)
  44429. */
  44430. newCanvasCssStyle?: string;
  44431. /**
  44432. * Get the default values of the configuration object
  44433. * @returns default values of this configuration object
  44434. */
  44435. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44436. }
  44437. /**
  44438. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44439. */
  44440. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44441. private _options;
  44442. private _canvas;
  44443. private _engine;
  44444. /**
  44445. * Rendering context of the canvas which can be used to display/mirror xr content
  44446. */
  44447. canvasContext: WebGLRenderingContext;
  44448. /**
  44449. * xr layer for the canvas
  44450. */
  44451. xrLayer: Nullable<XRWebGLLayer>;
  44452. /**
  44453. * Initializes the canvas to be added/removed upon entering/exiting xr
  44454. * @param _xrSessionManager The XR Session manager
  44455. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44456. */
  44457. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44458. /**
  44459. * Disposes of the object
  44460. */
  44461. dispose(): void;
  44462. /**
  44463. * Initializes the xr layer for the session
  44464. * @param xrSession xr session
  44465. * @returns a promise that will resolve once the XR Layer has been created
  44466. */
  44467. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44468. private _addCanvas;
  44469. private _removeCanvas;
  44470. private _setManagedOutputCanvas;
  44471. }
  44472. }
  44473. declare module "babylonjs/XR/webXRSessionManager" {
  44474. import { Observable } from "babylonjs/Misc/observable";
  44475. import { Nullable } from "babylonjs/types";
  44476. import { IDisposable, Scene } from "babylonjs/scene";
  44477. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44478. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44479. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44480. /**
  44481. * Manages an XRSession to work with Babylon's engine
  44482. * @see https://doc.babylonjs.com/how_to/webxr
  44483. */
  44484. export class WebXRSessionManager implements IDisposable {
  44485. /** The scene which the session should be created for */
  44486. scene: Scene;
  44487. private _referenceSpace;
  44488. private _rttProvider;
  44489. private _sessionEnded;
  44490. private _xrNavigator;
  44491. private baseLayer;
  44492. /**
  44493. * The base reference space from which the session started. good if you want to reset your
  44494. * reference space
  44495. */
  44496. baseReferenceSpace: XRReferenceSpace;
  44497. /**
  44498. * Current XR frame
  44499. */
  44500. currentFrame: Nullable<XRFrame>;
  44501. /** WebXR timestamp updated every frame */
  44502. currentTimestamp: number;
  44503. /**
  44504. * Used just in case of a failure to initialize an immersive session.
  44505. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44506. */
  44507. defaultHeightCompensation: number;
  44508. /**
  44509. * Fires every time a new xrFrame arrives which can be used to update the camera
  44510. */
  44511. onXRFrameObservable: Observable<XRFrame>;
  44512. /**
  44513. * Fires when the reference space changed
  44514. */
  44515. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44516. /**
  44517. * Fires when the xr session is ended either by the device or manually done
  44518. */
  44519. onXRSessionEnded: Observable<any>;
  44520. /**
  44521. * Fires when the xr session is ended either by the device or manually done
  44522. */
  44523. onXRSessionInit: Observable<XRSession>;
  44524. /**
  44525. * Underlying xr session
  44526. */
  44527. session: XRSession;
  44528. /**
  44529. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44530. * or get the offset the player is currently at.
  44531. */
  44532. viewerReferenceSpace: XRReferenceSpace;
  44533. /**
  44534. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44535. * @param scene The scene which the session should be created for
  44536. */
  44537. constructor(
  44538. /** The scene which the session should be created for */
  44539. scene: Scene);
  44540. /**
  44541. * The current reference space used in this session. This reference space can constantly change!
  44542. * It is mainly used to offset the camera's position.
  44543. */
  44544. get referenceSpace(): XRReferenceSpace;
  44545. /**
  44546. * Set a new reference space and triggers the observable
  44547. */
  44548. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44549. /**
  44550. * Disposes of the session manager
  44551. */
  44552. dispose(): void;
  44553. /**
  44554. * Stops the xrSession and restores the render loop
  44555. * @returns Promise which resolves after it exits XR
  44556. */
  44557. exitXRAsync(): Promise<void>;
  44558. /**
  44559. * Gets the correct render target texture to be rendered this frame for this eye
  44560. * @param eye the eye for which to get the render target
  44561. * @returns the render target for the specified eye
  44562. */
  44563. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44564. /**
  44565. * Creates a WebXRRenderTarget object for the XR session
  44566. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44567. * @param options optional options to provide when creating a new render target
  44568. * @returns a WebXR render target to which the session can render
  44569. */
  44570. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44571. /**
  44572. * Initializes the manager
  44573. * After initialization enterXR can be called to start an XR session
  44574. * @returns Promise which resolves after it is initialized
  44575. */
  44576. initializeAsync(): Promise<void>;
  44577. /**
  44578. * Initializes an xr session
  44579. * @param xrSessionMode mode to initialize
  44580. * @param xrSessionInit defines optional and required values to pass to the session builder
  44581. * @returns a promise which will resolve once the session has been initialized
  44582. */
  44583. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44584. /**
  44585. * Checks if a session would be supported for the creation options specified
  44586. * @param sessionMode session mode to check if supported eg. immersive-vr
  44587. * @returns A Promise that resolves to true if supported and false if not
  44588. */
  44589. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44590. /**
  44591. * Resets the reference space to the one started the session
  44592. */
  44593. resetReferenceSpace(): void;
  44594. /**
  44595. * Starts rendering to the xr layer
  44596. */
  44597. runXRRenderLoop(): void;
  44598. /**
  44599. * Sets the reference space on the xr session
  44600. * @param referenceSpaceType space to set
  44601. * @returns a promise that will resolve once the reference space has been set
  44602. */
  44603. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44604. /**
  44605. * Updates the render state of the session
  44606. * @param state state to set
  44607. * @returns a promise that resolves once the render state has been updated
  44608. */
  44609. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44610. /**
  44611. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44612. * @param sessionMode defines the session to test
  44613. * @returns a promise with boolean as final value
  44614. */
  44615. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44616. private _createRenderTargetTexture;
  44617. }
  44618. }
  44619. declare module "babylonjs/XR/webXRCamera" {
  44620. import { Scene } from "babylonjs/scene";
  44621. import { Camera } from "babylonjs/Cameras/camera";
  44622. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44623. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44624. /**
  44625. * WebXR Camera which holds the views for the xrSession
  44626. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44627. */
  44628. export class WebXRCamera extends FreeCamera {
  44629. private _xrSessionManager;
  44630. private _firstFrame;
  44631. private _referenceQuaternion;
  44632. private _referencedPosition;
  44633. private _xrInvPositionCache;
  44634. private _xrInvQuaternionCache;
  44635. /**
  44636. * Should position compensation execute on first frame.
  44637. * This is used when copying the position from a native (non XR) camera
  44638. */
  44639. compensateOnFirstFrame: boolean;
  44640. /**
  44641. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44642. * @param name the name of the camera
  44643. * @param scene the scene to add the camera to
  44644. * @param _xrSessionManager a constructed xr session manager
  44645. */
  44646. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44647. /**
  44648. * Return the user's height, unrelated to the current ground.
  44649. * This will be the y position of this camera, when ground level is 0.
  44650. */
  44651. get realWorldHeight(): number;
  44652. /** @hidden */
  44653. _updateForDualEyeDebugging(): void;
  44654. /**
  44655. * Sets this camera's transformation based on a non-vr camera
  44656. * @param otherCamera the non-vr camera to copy the transformation from
  44657. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44658. */
  44659. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44660. /**
  44661. * Gets the current instance class name ("WebXRCamera").
  44662. * @returns the class name
  44663. */
  44664. getClassName(): string;
  44665. private _updateFromXRSession;
  44666. private _updateNumberOfRigCameras;
  44667. private _updateReferenceSpace;
  44668. private _updateReferenceSpaceOffset;
  44669. }
  44670. }
  44671. declare module "babylonjs/XR/webXRFeaturesManager" {
  44672. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44673. import { IDisposable } from "babylonjs/scene";
  44674. /**
  44675. * Defining the interface required for a (webxr) feature
  44676. */
  44677. export interface IWebXRFeature extends IDisposable {
  44678. /**
  44679. * Is this feature attached
  44680. */
  44681. attached: boolean;
  44682. /**
  44683. * Should auto-attach be disabled?
  44684. */
  44685. disableAutoAttach: boolean;
  44686. /**
  44687. * Attach the feature to the session
  44688. * Will usually be called by the features manager
  44689. *
  44690. * @param force should attachment be forced (even when already attached)
  44691. * @returns true if successful.
  44692. */
  44693. attach(force?: boolean): boolean;
  44694. /**
  44695. * Detach the feature from the session
  44696. * Will usually be called by the features manager
  44697. *
  44698. * @returns true if successful.
  44699. */
  44700. detach(): boolean;
  44701. }
  44702. /**
  44703. * A list of the currently available features without referencing them
  44704. */
  44705. export class WebXRFeatureName {
  44706. /**
  44707. * The name of the anchor system feature
  44708. */
  44709. static ANCHOR_SYSTEM: string;
  44710. /**
  44711. * The name of the background remover feature
  44712. */
  44713. static BACKGROUND_REMOVER: string;
  44714. /**
  44715. * The name of the hit test feature
  44716. */
  44717. static HIT_TEST: string;
  44718. /**
  44719. * physics impostors for xr controllers feature
  44720. */
  44721. static PHYSICS_CONTROLLERS: string;
  44722. /**
  44723. * The name of the plane detection feature
  44724. */
  44725. static PLANE_DETECTION: string;
  44726. /**
  44727. * The name of the pointer selection feature
  44728. */
  44729. static POINTER_SELECTION: string;
  44730. /**
  44731. * The name of the teleportation feature
  44732. */
  44733. static TELEPORTATION: string;
  44734. }
  44735. /**
  44736. * Defining the constructor of a feature. Used to register the modules.
  44737. */
  44738. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44739. /**
  44740. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44741. * It is mainly used in AR sessions.
  44742. *
  44743. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44744. */
  44745. export class WebXRFeaturesManager implements IDisposable {
  44746. private _xrSessionManager;
  44747. private static readonly _AvailableFeatures;
  44748. private _features;
  44749. /**
  44750. * constructs a new features manages.
  44751. *
  44752. * @param _xrSessionManager an instance of WebXRSessionManager
  44753. */
  44754. constructor(_xrSessionManager: WebXRSessionManager);
  44755. /**
  44756. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44757. * Mainly used internally.
  44758. *
  44759. * @param featureName the name of the feature to register
  44760. * @param constructorFunction the function used to construct the module
  44761. * @param version the (babylon) version of the module
  44762. * @param stable is that a stable version of this module
  44763. */
  44764. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44765. /**
  44766. * Returns a constructor of a specific feature.
  44767. *
  44768. * @param featureName the name of the feature to construct
  44769. * @param version the version of the feature to load
  44770. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44771. * @param options optional options provided to the module.
  44772. * @returns a function that, when called, will return a new instance of this feature
  44773. */
  44774. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44775. /**
  44776. * Can be used to return the list of features currently registered
  44777. *
  44778. * @returns an Array of available features
  44779. */
  44780. static GetAvailableFeatures(): string[];
  44781. /**
  44782. * Gets the versions available for a specific feature
  44783. * @param featureName the name of the feature
  44784. * @returns an array with the available versions
  44785. */
  44786. static GetAvailableVersions(featureName: string): string[];
  44787. /**
  44788. * Return the latest unstable version of this feature
  44789. * @param featureName the name of the feature to search
  44790. * @returns the version number. if not found will return -1
  44791. */
  44792. static GetLatestVersionOfFeature(featureName: string): number;
  44793. /**
  44794. * Return the latest stable version of this feature
  44795. * @param featureName the name of the feature to search
  44796. * @returns the version number. if not found will return -1
  44797. */
  44798. static GetStableVersionOfFeature(featureName: string): number;
  44799. /**
  44800. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44801. * Can be used during a session to start a feature
  44802. * @param featureName the name of feature to attach
  44803. */
  44804. attachFeature(featureName: string): void;
  44805. /**
  44806. * Can be used inside a session or when the session ends to detach a specific feature
  44807. * @param featureName the name of the feature to detach
  44808. */
  44809. detachFeature(featureName: string): void;
  44810. /**
  44811. * Used to disable an already-enabled feature
  44812. * The feature will be disposed and will be recreated once enabled.
  44813. * @param featureName the feature to disable
  44814. * @returns true if disable was successful
  44815. */
  44816. disableFeature(featureName: string | {
  44817. Name: string;
  44818. }): boolean;
  44819. /**
  44820. * dispose this features manager
  44821. */
  44822. dispose(): void;
  44823. /**
  44824. * 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.
  44825. * 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.
  44826. *
  44827. * @param featureName the name of the feature to load or the class of the feature
  44828. * @param version optional version to load. if not provided the latest version will be enabled
  44829. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44830. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44831. * @returns a new constructed feature or throws an error if feature not found.
  44832. */
  44833. enableFeature(featureName: string | {
  44834. Name: string;
  44835. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44836. /**
  44837. * get the implementation of an enabled feature.
  44838. * @param featureName the name of the feature to load
  44839. * @returns the feature class, if found
  44840. */
  44841. getEnabledFeature(featureName: string): IWebXRFeature;
  44842. /**
  44843. * Get the list of enabled features
  44844. * @returns an array of enabled features
  44845. */
  44846. getEnabledFeatures(): string[];
  44847. }
  44848. }
  44849. declare module "babylonjs/XR/webXRExperienceHelper" {
  44850. import { Observable } from "babylonjs/Misc/observable";
  44851. import { IDisposable, Scene } from "babylonjs/scene";
  44852. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44853. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44854. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44855. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44856. /**
  44857. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44858. * @see https://doc.babylonjs.com/how_to/webxr
  44859. */
  44860. export class WebXRExperienceHelper implements IDisposable {
  44861. private scene;
  44862. private _nonVRCamera;
  44863. private _originalSceneAutoClear;
  44864. private _supported;
  44865. /**
  44866. * Camera used to render xr content
  44867. */
  44868. camera: WebXRCamera;
  44869. /** A features manager for this xr session */
  44870. featuresManager: WebXRFeaturesManager;
  44871. /**
  44872. * Observers registered here will be triggered after the camera's initial transformation is set
  44873. * This can be used to set a different ground level or an extra rotation.
  44874. *
  44875. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44876. * to the position set after this observable is done executing.
  44877. */
  44878. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44879. /**
  44880. * Fires when the state of the experience helper has changed
  44881. */
  44882. onStateChangedObservable: Observable<WebXRState>;
  44883. /** Session manager used to keep track of xr session */
  44884. sessionManager: WebXRSessionManager;
  44885. /**
  44886. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44887. */
  44888. state: WebXRState;
  44889. /**
  44890. * Creates a WebXRExperienceHelper
  44891. * @param scene The scene the helper should be created in
  44892. */
  44893. private constructor();
  44894. /**
  44895. * Creates the experience helper
  44896. * @param scene the scene to attach the experience helper to
  44897. * @returns a promise for the experience helper
  44898. */
  44899. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44900. /**
  44901. * Disposes of the experience helper
  44902. */
  44903. dispose(): void;
  44904. /**
  44905. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44906. * @param sessionMode options for the XR session
  44907. * @param referenceSpaceType frame of reference of the XR session
  44908. * @param renderTarget the output canvas that will be used to enter XR mode
  44909. * @returns promise that resolves after xr mode has entered
  44910. */
  44911. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44912. /**
  44913. * Exits XR mode and returns the scene to its original state
  44914. * @returns promise that resolves after xr mode has exited
  44915. */
  44916. exitXRAsync(): Promise<void>;
  44917. private _nonXRToXRCamera;
  44918. private _setState;
  44919. }
  44920. }
  44921. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44922. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44923. import { Observable } from "babylonjs/Misc/observable";
  44924. import { IDisposable } from "babylonjs/scene";
  44925. /**
  44926. * X-Y values for axes in WebXR
  44927. */
  44928. export interface IWebXRMotionControllerAxesValue {
  44929. /**
  44930. * The value of the x axis
  44931. */
  44932. x: number;
  44933. /**
  44934. * The value of the y-axis
  44935. */
  44936. y: number;
  44937. }
  44938. /**
  44939. * changed / previous values for the values of this component
  44940. */
  44941. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44942. /**
  44943. * current (this frame) value
  44944. */
  44945. current: T;
  44946. /**
  44947. * previous (last change) value
  44948. */
  44949. previous: T;
  44950. }
  44951. /**
  44952. * Represents changes in the component between current frame and last values recorded
  44953. */
  44954. export interface IWebXRMotionControllerComponentChanges {
  44955. /**
  44956. * will be populated with previous and current values if axes changed
  44957. */
  44958. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44959. /**
  44960. * will be populated with previous and current values if pressed changed
  44961. */
  44962. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44963. /**
  44964. * will be populated with previous and current values if touched changed
  44965. */
  44966. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44967. /**
  44968. * will be populated with previous and current values if value changed
  44969. */
  44970. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44971. }
  44972. /**
  44973. * This class represents a single component (for example button or thumbstick) of a motion controller
  44974. */
  44975. export class WebXRControllerComponent implements IDisposable {
  44976. /**
  44977. * the id of this component
  44978. */
  44979. id: string;
  44980. /**
  44981. * the type of the component
  44982. */
  44983. type: MotionControllerComponentType;
  44984. private _buttonIndex;
  44985. private _axesIndices;
  44986. private _axes;
  44987. private _changes;
  44988. private _currentValue;
  44989. private _hasChanges;
  44990. private _pressed;
  44991. private _touched;
  44992. /**
  44993. * button component type
  44994. */
  44995. static BUTTON_TYPE: MotionControllerComponentType;
  44996. /**
  44997. * squeeze component type
  44998. */
  44999. static SQUEEZE_TYPE: MotionControllerComponentType;
  45000. /**
  45001. * Thumbstick component type
  45002. */
  45003. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45004. /**
  45005. * Touchpad component type
  45006. */
  45007. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45008. /**
  45009. * trigger component type
  45010. */
  45011. static TRIGGER_TYPE: MotionControllerComponentType;
  45012. /**
  45013. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45014. * the axes data changes
  45015. */
  45016. onAxisValueChangedObservable: Observable<{
  45017. x: number;
  45018. y: number;
  45019. }>;
  45020. /**
  45021. * Observers registered here will be triggered when the state of a button changes
  45022. * State change is either pressed / touched / value
  45023. */
  45024. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45025. /**
  45026. * Creates a new component for a motion controller.
  45027. * It is created by the motion controller itself
  45028. *
  45029. * @param id the id of this component
  45030. * @param type the type of the component
  45031. * @param _buttonIndex index in the buttons array of the gamepad
  45032. * @param _axesIndices indices of the values in the axes array of the gamepad
  45033. */
  45034. constructor(
  45035. /**
  45036. * the id of this component
  45037. */
  45038. id: string,
  45039. /**
  45040. * the type of the component
  45041. */
  45042. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45043. /**
  45044. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45045. */
  45046. get axes(): IWebXRMotionControllerAxesValue;
  45047. /**
  45048. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45049. */
  45050. get changes(): IWebXRMotionControllerComponentChanges;
  45051. /**
  45052. * Return whether or not the component changed the last frame
  45053. */
  45054. get hasChanges(): boolean;
  45055. /**
  45056. * is the button currently pressed
  45057. */
  45058. get pressed(): boolean;
  45059. /**
  45060. * is the button currently touched
  45061. */
  45062. get touched(): boolean;
  45063. /**
  45064. * Get the current value of this component
  45065. */
  45066. get value(): number;
  45067. /**
  45068. * Dispose this component
  45069. */
  45070. dispose(): void;
  45071. /**
  45072. * Are there axes correlating to this component
  45073. * @return true is axes data is available
  45074. */
  45075. isAxes(): boolean;
  45076. /**
  45077. * Is this component a button (hence - pressable)
  45078. * @returns true if can be pressed
  45079. */
  45080. isButton(): boolean;
  45081. /**
  45082. * update this component using the gamepad object it is in. Called on every frame
  45083. * @param nativeController the native gamepad controller object
  45084. */
  45085. update(nativeController: IMinimalMotionControllerObject): void;
  45086. }
  45087. }
  45088. declare module "babylonjs/Loading/sceneLoader" {
  45089. import { Observable } from "babylonjs/Misc/observable";
  45090. import { Nullable } from "babylonjs/types";
  45091. import { Scene } from "babylonjs/scene";
  45092. import { Engine } from "babylonjs/Engines/engine";
  45093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45094. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45095. import { AssetContainer } from "babylonjs/assetContainer";
  45096. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45097. import { Skeleton } from "babylonjs/Bones/skeleton";
  45098. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45099. import { WebRequest } from "babylonjs/Misc/webRequest";
  45100. /**
  45101. * Class used to represent data loading progression
  45102. */
  45103. export class SceneLoaderProgressEvent {
  45104. /** defines if data length to load can be evaluated */
  45105. readonly lengthComputable: boolean;
  45106. /** defines the loaded data length */
  45107. readonly loaded: number;
  45108. /** defines the data length to load */
  45109. readonly total: number;
  45110. /**
  45111. * Create a new progress event
  45112. * @param lengthComputable defines if data length to load can be evaluated
  45113. * @param loaded defines the loaded data length
  45114. * @param total defines the data length to load
  45115. */
  45116. constructor(
  45117. /** defines if data length to load can be evaluated */
  45118. lengthComputable: boolean,
  45119. /** defines the loaded data length */
  45120. loaded: number,
  45121. /** defines the data length to load */
  45122. total: number);
  45123. /**
  45124. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45125. * @param event defines the source event
  45126. * @returns a new SceneLoaderProgressEvent
  45127. */
  45128. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45129. }
  45130. /**
  45131. * Interface used by SceneLoader plugins to define supported file extensions
  45132. */
  45133. export interface ISceneLoaderPluginExtensions {
  45134. /**
  45135. * Defines the list of supported extensions
  45136. */
  45137. [extension: string]: {
  45138. isBinary: boolean;
  45139. };
  45140. }
  45141. /**
  45142. * Interface used by SceneLoader plugin factory
  45143. */
  45144. export interface ISceneLoaderPluginFactory {
  45145. /**
  45146. * Defines the name of the factory
  45147. */
  45148. name: string;
  45149. /**
  45150. * Function called to create a new plugin
  45151. * @return the new plugin
  45152. */
  45153. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45154. /**
  45155. * The callback that returns true if the data can be directly loaded.
  45156. * @param data string containing the file data
  45157. * @returns if the data can be loaded directly
  45158. */
  45159. canDirectLoad?(data: string): boolean;
  45160. }
  45161. /**
  45162. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45163. */
  45164. export interface ISceneLoaderPluginBase {
  45165. /**
  45166. * The friendly name of this plugin.
  45167. */
  45168. name: string;
  45169. /**
  45170. * The file extensions supported by this plugin.
  45171. */
  45172. extensions: string | ISceneLoaderPluginExtensions;
  45173. /**
  45174. * The callback called when loading from a url.
  45175. * @param scene scene loading this url
  45176. * @param url url to load
  45177. * @param onSuccess callback called when the file successfully loads
  45178. * @param onProgress callback called while file is loading (if the server supports this mode)
  45179. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45180. * @param onError callback called when the file fails to load
  45181. * @returns a file request object
  45182. */
  45183. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45184. /**
  45185. * The callback called when loading from a file object.
  45186. * @param scene scene loading this file
  45187. * @param file defines the file to load
  45188. * @param onSuccess defines the callback to call when data is loaded
  45189. * @param onProgress defines the callback to call during loading process
  45190. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45191. * @param onError defines the callback to call when an error occurs
  45192. * @returns a file request object
  45193. */
  45194. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45195. /**
  45196. * The callback that returns true if the data can be directly loaded.
  45197. * @param data string containing the file data
  45198. * @returns if the data can be loaded directly
  45199. */
  45200. canDirectLoad?(data: string): boolean;
  45201. /**
  45202. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45203. * @param scene scene loading this data
  45204. * @param data string containing the data
  45205. * @returns data to pass to the plugin
  45206. */
  45207. directLoad?(scene: Scene, data: string): any;
  45208. /**
  45209. * The callback that allows custom handling of the root url based on the response url.
  45210. * @param rootUrl the original root url
  45211. * @param responseURL the response url if available
  45212. * @returns the new root url
  45213. */
  45214. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45215. }
  45216. /**
  45217. * Interface used to define a SceneLoader plugin
  45218. */
  45219. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45220. /**
  45221. * Import meshes into a scene.
  45222. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45223. * @param scene The scene to import into
  45224. * @param data The data to import
  45225. * @param rootUrl The root url for scene and resources
  45226. * @param meshes The meshes array to import into
  45227. * @param particleSystems The particle systems array to import into
  45228. * @param skeletons The skeletons array to import into
  45229. * @param onError The callback when import fails
  45230. * @returns True if successful or false otherwise
  45231. */
  45232. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45233. /**
  45234. * Load into a scene.
  45235. * @param scene The scene to load into
  45236. * @param data The data to import
  45237. * @param rootUrl The root url for scene and resources
  45238. * @param onError The callback when import fails
  45239. * @returns True if successful or false otherwise
  45240. */
  45241. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45242. /**
  45243. * Load into an asset container.
  45244. * @param scene The scene to load into
  45245. * @param data The data to import
  45246. * @param rootUrl The root url for scene and resources
  45247. * @param onError The callback when import fails
  45248. * @returns The loaded asset container
  45249. */
  45250. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45251. }
  45252. /**
  45253. * Interface used to define an async SceneLoader plugin
  45254. */
  45255. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45256. /**
  45257. * Import meshes into a scene.
  45258. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45259. * @param scene The scene to import into
  45260. * @param data The data to import
  45261. * @param rootUrl The root url for scene and resources
  45262. * @param onProgress The callback when the load progresses
  45263. * @param fileName Defines the name of the file to load
  45264. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45265. */
  45266. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45267. meshes: AbstractMesh[];
  45268. particleSystems: IParticleSystem[];
  45269. skeletons: Skeleton[];
  45270. animationGroups: AnimationGroup[];
  45271. }>;
  45272. /**
  45273. * Load into a scene.
  45274. * @param scene The scene to load into
  45275. * @param data The data to import
  45276. * @param rootUrl The root url for scene and resources
  45277. * @param onProgress The callback when the load progresses
  45278. * @param fileName Defines the name of the file to load
  45279. * @returns Nothing
  45280. */
  45281. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45282. /**
  45283. * Load into an asset container.
  45284. * @param scene The scene to load into
  45285. * @param data The data to import
  45286. * @param rootUrl The root url for scene and resources
  45287. * @param onProgress The callback when the load progresses
  45288. * @param fileName Defines the name of the file to load
  45289. * @returns The loaded asset container
  45290. */
  45291. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45292. }
  45293. /**
  45294. * Mode that determines how to handle old animation groups before loading new ones.
  45295. */
  45296. export enum SceneLoaderAnimationGroupLoadingMode {
  45297. /**
  45298. * Reset all old animations to initial state then dispose them.
  45299. */
  45300. Clean = 0,
  45301. /**
  45302. * Stop all old animations.
  45303. */
  45304. Stop = 1,
  45305. /**
  45306. * Restart old animations from first frame.
  45307. */
  45308. Sync = 2,
  45309. /**
  45310. * Old animations remains untouched.
  45311. */
  45312. NoSync = 3
  45313. }
  45314. /**
  45315. * Class used to load scene from various file formats using registered plugins
  45316. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45317. */
  45318. export class SceneLoader {
  45319. /**
  45320. * No logging while loading
  45321. */
  45322. static readonly NO_LOGGING: number;
  45323. /**
  45324. * Minimal logging while loading
  45325. */
  45326. static readonly MINIMAL_LOGGING: number;
  45327. /**
  45328. * Summary logging while loading
  45329. */
  45330. static readonly SUMMARY_LOGGING: number;
  45331. /**
  45332. * Detailled logging while loading
  45333. */
  45334. static readonly DETAILED_LOGGING: number;
  45335. /**
  45336. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45337. */
  45338. static get ForceFullSceneLoadingForIncremental(): boolean;
  45339. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45340. /**
  45341. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45342. */
  45343. static get ShowLoadingScreen(): boolean;
  45344. static set ShowLoadingScreen(value: boolean);
  45345. /**
  45346. * Defines the current logging level (while loading the scene)
  45347. * @ignorenaming
  45348. */
  45349. static get loggingLevel(): number;
  45350. static set loggingLevel(value: number);
  45351. /**
  45352. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45353. */
  45354. static get CleanBoneMatrixWeights(): boolean;
  45355. static set CleanBoneMatrixWeights(value: boolean);
  45356. /**
  45357. * Event raised when a plugin is used to load a scene
  45358. */
  45359. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45360. private static _registeredPlugins;
  45361. private static _getDefaultPlugin;
  45362. private static _getPluginForExtension;
  45363. private static _getPluginForDirectLoad;
  45364. private static _getPluginForFilename;
  45365. private static _getDirectLoad;
  45366. private static _loadData;
  45367. private static _getFileInfo;
  45368. /**
  45369. * Gets a plugin that can load the given extension
  45370. * @param extension defines the extension to load
  45371. * @returns a plugin or null if none works
  45372. */
  45373. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45374. /**
  45375. * Gets a boolean indicating that the given extension can be loaded
  45376. * @param extension defines the extension to load
  45377. * @returns true if the extension is supported
  45378. */
  45379. static IsPluginForExtensionAvailable(extension: string): boolean;
  45380. /**
  45381. * Adds a new plugin to the list of registered plugins
  45382. * @param plugin defines the plugin to add
  45383. */
  45384. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45385. /**
  45386. * Import meshes into a scene
  45387. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45388. * @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)
  45389. * @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)
  45390. * @param scene the instance of BABYLON.Scene to append to
  45391. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45392. * @param onProgress a callback with a progress event for each file being loaded
  45393. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45394. * @param pluginExtension the extension used to determine the plugin
  45395. * @returns The loaded plugin
  45396. */
  45397. 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>;
  45398. /**
  45399. * Import meshes into a scene
  45400. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45401. * @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)
  45402. * @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)
  45403. * @param scene the instance of BABYLON.Scene to append to
  45404. * @param onProgress a callback with a progress event for each file being loaded
  45405. * @param pluginExtension the extension used to determine the plugin
  45406. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45407. */
  45408. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45409. meshes: AbstractMesh[];
  45410. particleSystems: IParticleSystem[];
  45411. skeletons: Skeleton[];
  45412. animationGroups: AnimationGroup[];
  45413. }>;
  45414. /**
  45415. * Load a scene
  45416. * @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)
  45417. * @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)
  45418. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45419. * @param onSuccess a callback with the scene when import succeeds
  45420. * @param onProgress a callback with a progress event for each file being loaded
  45421. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45422. * @param pluginExtension the extension used to determine the plugin
  45423. * @returns The loaded plugin
  45424. */
  45425. 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>;
  45426. /**
  45427. * Load a scene
  45428. * @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)
  45429. * @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)
  45430. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45431. * @param onProgress a callback with a progress event for each file being loaded
  45432. * @param pluginExtension the extension used to determine the plugin
  45433. * @returns The loaded scene
  45434. */
  45435. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45436. /**
  45437. * Append a scene
  45438. * @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)
  45439. * @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)
  45440. * @param scene is the instance of BABYLON.Scene to append to
  45441. * @param onSuccess a callback with the scene when import succeeds
  45442. * @param onProgress a callback with a progress event for each file being loaded
  45443. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45444. * @param pluginExtension the extension used to determine the plugin
  45445. * @returns The loaded plugin
  45446. */
  45447. 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>;
  45448. /**
  45449. * Append a scene
  45450. * @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)
  45451. * @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)
  45452. * @param scene is the instance of BABYLON.Scene to append to
  45453. * @param onProgress a callback with a progress event for each file being loaded
  45454. * @param pluginExtension the extension used to determine the plugin
  45455. * @returns The given scene
  45456. */
  45457. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45458. /**
  45459. * Load a scene into an asset container
  45460. * @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)
  45461. * @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)
  45462. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45463. * @param onSuccess a callback with the scene when import succeeds
  45464. * @param onProgress a callback with a progress event for each file being loaded
  45465. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45466. * @param pluginExtension the extension used to determine the plugin
  45467. * @returns The loaded plugin
  45468. */
  45469. 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>;
  45470. /**
  45471. * Load a scene into an asset container
  45472. * @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)
  45473. * @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)
  45474. * @param scene is the instance of Scene to append to
  45475. * @param onProgress a callback with a progress event for each file being loaded
  45476. * @param pluginExtension the extension used to determine the plugin
  45477. * @returns The loaded asset container
  45478. */
  45479. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45480. /**
  45481. * Import animations from a file into a scene
  45482. * @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)
  45483. * @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)
  45484. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45485. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45486. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45487. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45488. * @param onSuccess a callback with the scene when import succeeds
  45489. * @param onProgress a callback with a progress event for each file being loaded
  45490. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45491. */
  45492. 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;
  45493. /**
  45494. * Import animations from a file into a scene
  45495. * @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)
  45496. * @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)
  45497. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45498. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45499. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45500. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45501. * @param onSuccess a callback with the scene when import succeeds
  45502. * @param onProgress a callback with a progress event for each file being loaded
  45503. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45504. * @returns the updated scene with imported animations
  45505. */
  45506. 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>;
  45507. }
  45508. }
  45509. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45510. import { IDisposable, Scene } from "babylonjs/scene";
  45511. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45512. import { Observable } from "babylonjs/Misc/observable";
  45513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45514. import { Nullable } from "babylonjs/types";
  45515. /**
  45516. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45517. */
  45518. export type MotionControllerHandness = "none" | "left" | "right";
  45519. /**
  45520. * The type of components available in motion controllers.
  45521. * This is not the name of the component.
  45522. */
  45523. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45524. /**
  45525. * The state of a controller component
  45526. */
  45527. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45528. /**
  45529. * The schema of motion controller layout.
  45530. * No object will be initialized using this interface
  45531. * This is used just to define the profile.
  45532. */
  45533. export interface IMotionControllerLayout {
  45534. /**
  45535. * Path to load the assets. Usually relative to the base path
  45536. */
  45537. assetPath: string;
  45538. /**
  45539. * Available components (unsorted)
  45540. */
  45541. components: {
  45542. /**
  45543. * A map of component Ids
  45544. */
  45545. [componentId: string]: {
  45546. /**
  45547. * The type of input the component outputs
  45548. */
  45549. type: MotionControllerComponentType;
  45550. /**
  45551. * The indices of this component in the gamepad object
  45552. */
  45553. gamepadIndices: {
  45554. /**
  45555. * Index of button
  45556. */
  45557. button?: number;
  45558. /**
  45559. * If available, index of x-axis
  45560. */
  45561. xAxis?: number;
  45562. /**
  45563. * If available, index of y-axis
  45564. */
  45565. yAxis?: number;
  45566. };
  45567. /**
  45568. * The mesh's root node name
  45569. */
  45570. rootNodeName: string;
  45571. /**
  45572. * Animation definitions for this model
  45573. */
  45574. visualResponses: {
  45575. [stateKey: string]: {
  45576. /**
  45577. * What property will be animated
  45578. */
  45579. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45580. /**
  45581. * What states influence this visual response
  45582. */
  45583. states: MotionControllerComponentStateType[];
  45584. /**
  45585. * Type of animation - movement or visibility
  45586. */
  45587. valueNodeProperty: "transform" | "visibility";
  45588. /**
  45589. * Base node name to move. Its position will be calculated according to the min and max nodes
  45590. */
  45591. valueNodeName?: string;
  45592. /**
  45593. * Minimum movement node
  45594. */
  45595. minNodeName?: string;
  45596. /**
  45597. * Max movement node
  45598. */
  45599. maxNodeName?: string;
  45600. };
  45601. };
  45602. /**
  45603. * If touch enabled, what is the name of node to display user feedback
  45604. */
  45605. touchPointNodeName?: string;
  45606. };
  45607. };
  45608. /**
  45609. * Is it xr standard mapping or not
  45610. */
  45611. gamepadMapping: "" | "xr-standard";
  45612. /**
  45613. * Base root node of this entire model
  45614. */
  45615. rootNodeName: string;
  45616. /**
  45617. * Defines the main button component id
  45618. */
  45619. selectComponentId: string;
  45620. }
  45621. /**
  45622. * A definition for the layout map in the input profile
  45623. */
  45624. export interface IMotionControllerLayoutMap {
  45625. /**
  45626. * Layouts with handness type as a key
  45627. */
  45628. [handness: string]: IMotionControllerLayout;
  45629. }
  45630. /**
  45631. * The XR Input profile schema
  45632. * Profiles can be found here:
  45633. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45634. */
  45635. export interface IMotionControllerProfile {
  45636. /**
  45637. * fallback profiles for this profileId
  45638. */
  45639. fallbackProfileIds: string[];
  45640. /**
  45641. * The layout map, with handness as key
  45642. */
  45643. layouts: IMotionControllerLayoutMap;
  45644. /**
  45645. * The id of this profile
  45646. * correlates to the profile(s) in the xrInput.profiles array
  45647. */
  45648. profileId: string;
  45649. }
  45650. /**
  45651. * A helper-interface for the 3 meshes needed for controller button animation
  45652. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45653. */
  45654. export interface IMotionControllerButtonMeshMap {
  45655. /**
  45656. * the mesh that defines the pressed value mesh position.
  45657. * This is used to find the max-position of this button
  45658. */
  45659. pressedMesh: AbstractMesh;
  45660. /**
  45661. * the mesh that defines the unpressed value mesh position.
  45662. * This is used to find the min (or initial) position of this button
  45663. */
  45664. unpressedMesh: AbstractMesh;
  45665. /**
  45666. * The mesh that will be changed when value changes
  45667. */
  45668. valueMesh: AbstractMesh;
  45669. }
  45670. /**
  45671. * A helper-interface for the 3 meshes needed for controller axis animation.
  45672. * This will be expanded when touchpad animations are fully supported
  45673. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45674. */
  45675. export interface IMotionControllerMeshMap {
  45676. /**
  45677. * the mesh that defines the maximum value mesh position.
  45678. */
  45679. maxMesh?: AbstractMesh;
  45680. /**
  45681. * the mesh that defines the minimum value mesh position.
  45682. */
  45683. minMesh?: AbstractMesh;
  45684. /**
  45685. * The mesh that will be changed when axis value changes
  45686. */
  45687. valueMesh: AbstractMesh;
  45688. }
  45689. /**
  45690. * The elements needed for change-detection of the gamepad objects in motion controllers
  45691. */
  45692. export interface IMinimalMotionControllerObject {
  45693. /**
  45694. * Available axes of this controller
  45695. */
  45696. axes: number[];
  45697. /**
  45698. * An array of available buttons
  45699. */
  45700. buttons: Array<{
  45701. /**
  45702. * Value of the button/trigger
  45703. */
  45704. value: number;
  45705. /**
  45706. * If the button/trigger is currently touched
  45707. */
  45708. touched: boolean;
  45709. /**
  45710. * If the button/trigger is currently pressed
  45711. */
  45712. pressed: boolean;
  45713. }>;
  45714. }
  45715. /**
  45716. * An Abstract Motion controller
  45717. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45718. * Each component has an observable to check for changes in value and state
  45719. */
  45720. export abstract class WebXRAbstractMotionController implements IDisposable {
  45721. protected scene: Scene;
  45722. protected layout: IMotionControllerLayout;
  45723. /**
  45724. * The gamepad object correlating to this controller
  45725. */
  45726. gamepadObject: IMinimalMotionControllerObject;
  45727. /**
  45728. * handness (left/right/none) of this controller
  45729. */
  45730. handness: MotionControllerHandness;
  45731. private _initComponent;
  45732. private _modelReady;
  45733. /**
  45734. * A map of components (WebXRControllerComponent) in this motion controller
  45735. * Components have a ComponentType and can also have both button and axis definitions
  45736. */
  45737. readonly components: {
  45738. [id: string]: WebXRControllerComponent;
  45739. };
  45740. /**
  45741. * Disable the model's animation. Can be set at any time.
  45742. */
  45743. disableAnimation: boolean;
  45744. /**
  45745. * Observers registered here will be triggered when the model of this controller is done loading
  45746. */
  45747. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45748. /**
  45749. * The profile id of this motion controller
  45750. */
  45751. abstract profileId: string;
  45752. /**
  45753. * The root mesh of the model. It is null if the model was not yet initialized
  45754. */
  45755. rootMesh: Nullable<AbstractMesh>;
  45756. /**
  45757. * constructs a new abstract motion controller
  45758. * @param scene the scene to which the model of the controller will be added
  45759. * @param layout The profile layout to load
  45760. * @param gamepadObject The gamepad object correlating to this controller
  45761. * @param handness handness (left/right/none) of this controller
  45762. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45763. */
  45764. constructor(scene: Scene, layout: IMotionControllerLayout,
  45765. /**
  45766. * The gamepad object correlating to this controller
  45767. */
  45768. gamepadObject: IMinimalMotionControllerObject,
  45769. /**
  45770. * handness (left/right/none) of this controller
  45771. */
  45772. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45773. /**
  45774. * Dispose this controller, the model mesh and all its components
  45775. */
  45776. dispose(): void;
  45777. /**
  45778. * Returns all components of specific type
  45779. * @param type the type to search for
  45780. * @return an array of components with this type
  45781. */
  45782. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45783. /**
  45784. * get a component based an its component id as defined in layout.components
  45785. * @param id the id of the component
  45786. * @returns the component correlates to the id or undefined if not found
  45787. */
  45788. getComponent(id: string): WebXRControllerComponent;
  45789. /**
  45790. * Get the list of components available in this motion controller
  45791. * @returns an array of strings correlating to available components
  45792. */
  45793. getComponentIds(): string[];
  45794. /**
  45795. * Get the first component of specific type
  45796. * @param type type of component to find
  45797. * @return a controller component or null if not found
  45798. */
  45799. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45800. /**
  45801. * Get the main (Select) component of this controller as defined in the layout
  45802. * @returns the main component of this controller
  45803. */
  45804. getMainComponent(): WebXRControllerComponent;
  45805. /**
  45806. * Loads the model correlating to this controller
  45807. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45808. * @returns A promise fulfilled with the result of the model loading
  45809. */
  45810. loadModel(): Promise<boolean>;
  45811. /**
  45812. * Update this model using the current XRFrame
  45813. * @param xrFrame the current xr frame to use and update the model
  45814. */
  45815. updateFromXRFrame(xrFrame: XRFrame): void;
  45816. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45817. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45818. /**
  45819. * Moves the axis on the controller mesh based on its current state
  45820. * @param axis the index of the axis
  45821. * @param axisValue the value of the axis which determines the meshes new position
  45822. * @hidden
  45823. */
  45824. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45825. /**
  45826. * Update the model itself with the current frame data
  45827. * @param xrFrame the frame to use for updating the model mesh
  45828. */
  45829. protected updateModel(xrFrame: XRFrame): void;
  45830. /**
  45831. * Get the filename and path for this controller's model
  45832. * @returns a map of filename and path
  45833. */
  45834. protected abstract _getFilenameAndPath(): {
  45835. filename: string;
  45836. path: string;
  45837. };
  45838. /**
  45839. * This function is called before the mesh is loaded. It checks for loading constraints.
  45840. * For example, this function can check if the GLB loader is available
  45841. * If this function returns false, the generic controller will be loaded instead
  45842. * @returns Is the client ready to load the mesh
  45843. */
  45844. protected abstract _getModelLoadingConstraints(): boolean;
  45845. /**
  45846. * This function will be called after the model was successfully loaded and can be used
  45847. * for mesh transformations before it is available for the user
  45848. * @param meshes the loaded meshes
  45849. */
  45850. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45851. /**
  45852. * Set the root mesh for this controller. Important for the WebXR controller class
  45853. * @param meshes the loaded meshes
  45854. */
  45855. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45856. /**
  45857. * A function executed each frame that updates the mesh (if needed)
  45858. * @param xrFrame the current xrFrame
  45859. */
  45860. protected abstract _updateModel(xrFrame: XRFrame): void;
  45861. private _getGenericFilenameAndPath;
  45862. private _getGenericParentMesh;
  45863. }
  45864. }
  45865. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45866. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45867. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45868. import { Scene } from "babylonjs/scene";
  45869. /**
  45870. * A generic trigger-only motion controller for WebXR
  45871. */
  45872. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45873. /**
  45874. * Static version of the profile id of this controller
  45875. */
  45876. static ProfileId: string;
  45877. profileId: string;
  45878. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45879. protected _getFilenameAndPath(): {
  45880. filename: string;
  45881. path: string;
  45882. };
  45883. protected _getModelLoadingConstraints(): boolean;
  45884. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45885. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45886. protected _updateModel(): void;
  45887. }
  45888. }
  45889. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45890. import { Vector4 } from "babylonjs/Maths/math.vector";
  45891. import { Mesh } from "babylonjs/Meshes/mesh";
  45892. import { Scene } from "babylonjs/scene";
  45893. import { Nullable } from "babylonjs/types";
  45894. /**
  45895. * Class containing static functions to help procedurally build meshes
  45896. */
  45897. export class SphereBuilder {
  45898. /**
  45899. * Creates a sphere mesh
  45900. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45901. * * 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`)
  45902. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45903. * * 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
  45904. * * 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)
  45905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45906. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45908. * @param name defines the name of the mesh
  45909. * @param options defines the options used to create the mesh
  45910. * @param scene defines the hosting scene
  45911. * @returns the sphere mesh
  45912. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45913. */
  45914. static CreateSphere(name: string, options: {
  45915. segments?: number;
  45916. diameter?: number;
  45917. diameterX?: number;
  45918. diameterY?: number;
  45919. diameterZ?: number;
  45920. arc?: number;
  45921. slice?: number;
  45922. sideOrientation?: number;
  45923. frontUVs?: Vector4;
  45924. backUVs?: Vector4;
  45925. updatable?: boolean;
  45926. }, scene?: Nullable<Scene>): Mesh;
  45927. }
  45928. }
  45929. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45931. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45932. import { Scene } from "babylonjs/scene";
  45933. /**
  45934. * A profiled motion controller has its profile loaded from an online repository.
  45935. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45936. */
  45937. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45938. private _repositoryUrl;
  45939. private _buttonMeshMapping;
  45940. private _touchDots;
  45941. /**
  45942. * The profile ID of this controller. Will be populated when the controller initializes.
  45943. */
  45944. profileId: string;
  45945. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45946. dispose(): void;
  45947. protected _getFilenameAndPath(): {
  45948. filename: string;
  45949. path: string;
  45950. };
  45951. protected _getModelLoadingConstraints(): boolean;
  45952. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45953. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45954. protected _updateModel(_xrFrame: XRFrame): void;
  45955. }
  45956. }
  45957. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45958. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45959. import { Scene } from "babylonjs/scene";
  45960. /**
  45961. * A construction function type to create a new controller based on an xrInput object
  45962. */
  45963. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45964. /**
  45965. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45966. *
  45967. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45968. * it should be replaced with auto-loaded controllers.
  45969. *
  45970. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45971. */
  45972. export class WebXRMotionControllerManager {
  45973. private static _AvailableControllers;
  45974. private static _Fallbacks;
  45975. private static _ProfileLoadingPromises;
  45976. private static _ProfilesList;
  45977. /**
  45978. * The base URL of the online controller repository. Can be changed at any time.
  45979. */
  45980. static BaseRepositoryUrl: string;
  45981. /**
  45982. * Which repository gets priority - local or online
  45983. */
  45984. static PrioritizeOnlineRepository: boolean;
  45985. /**
  45986. * Use the online repository, or use only locally-defined controllers
  45987. */
  45988. static UseOnlineRepository: boolean;
  45989. /**
  45990. * Clear the cache used for profile loading and reload when requested again
  45991. */
  45992. static ClearProfilesCache(): void;
  45993. /**
  45994. * Register the default fallbacks.
  45995. * This function is called automatically when this file is imported.
  45996. */
  45997. static DefaultFallbacks(): void;
  45998. /**
  45999. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46000. * @param profileId the profile to which a fallback needs to be found
  46001. * @return an array with corresponding fallback profiles
  46002. */
  46003. static FindFallbackWithProfileId(profileId: string): string[];
  46004. /**
  46005. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46006. * The order of search:
  46007. *
  46008. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46009. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46010. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46011. * 4) return the generic trigger controller if none were found
  46012. *
  46013. * @param xrInput the xrInput to which a new controller is initialized
  46014. * @param scene the scene to which the model will be added
  46015. * @param forceProfile force a certain profile for this controller
  46016. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46017. */
  46018. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46019. /**
  46020. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46021. *
  46022. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46023. *
  46024. * @param type the profile type to register
  46025. * @param constructFunction the function to be called when loading this profile
  46026. */
  46027. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46028. /**
  46029. * Register a fallback to a specific profile.
  46030. * @param profileId the profileId that will receive the fallbacks
  46031. * @param fallbacks A list of fallback profiles
  46032. */
  46033. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46034. /**
  46035. * Will update the list of profiles available in the repository
  46036. * @return a promise that resolves to a map of profiles available online
  46037. */
  46038. static UpdateProfilesList(): Promise<{
  46039. [profile: string]: string;
  46040. }>;
  46041. private static _LoadProfileFromRepository;
  46042. private static _LoadProfilesFromAvailableControllers;
  46043. }
  46044. }
  46045. declare module "babylonjs/XR/webXRInputSource" {
  46046. import { Observable } from "babylonjs/Misc/observable";
  46047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46048. import { Ray } from "babylonjs/Culling/ray";
  46049. import { Scene } from "babylonjs/scene";
  46050. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46051. /**
  46052. * Configuration options for the WebXR controller creation
  46053. */
  46054. export interface IWebXRControllerOptions {
  46055. /**
  46056. * Should the controller mesh be animated when a user interacts with it
  46057. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46058. */
  46059. disableMotionControllerAnimation?: boolean;
  46060. /**
  46061. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46062. */
  46063. doNotLoadControllerMesh?: boolean;
  46064. /**
  46065. * Force a specific controller type for this controller.
  46066. * This can be used when creating your own profile or when testing different controllers
  46067. */
  46068. forceControllerProfile?: string;
  46069. }
  46070. /**
  46071. * Represents an XR controller
  46072. */
  46073. export class WebXRInputSource {
  46074. private _scene;
  46075. /** The underlying input source for the controller */
  46076. inputSource: XRInputSource;
  46077. private _options;
  46078. private _tmpQuaternion;
  46079. private _tmpVector;
  46080. private _uniqueId;
  46081. /**
  46082. * 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
  46083. */
  46084. grip?: AbstractMesh;
  46085. /**
  46086. * If available, this is the gamepad object related to this controller.
  46087. * Using this object it is possible to get click events and trackpad changes of the
  46088. * webxr controller that is currently being used.
  46089. */
  46090. motionController?: WebXRAbstractMotionController;
  46091. /**
  46092. * Event that fires when the controller is removed/disposed.
  46093. * The object provided as event data is this controller, after associated assets were disposed.
  46094. * uniqueId is still available.
  46095. */
  46096. onDisposeObservable: Observable<WebXRInputSource>;
  46097. /**
  46098. * Will be triggered when the mesh associated with the motion controller is done loading.
  46099. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46100. * A shortened version of controller -> motion controller -> on mesh loaded.
  46101. */
  46102. onMeshLoadedObservable: Observable<AbstractMesh>;
  46103. /**
  46104. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46105. */
  46106. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46107. /**
  46108. * Pointer which can be used to select objects or attach a visible laser to
  46109. */
  46110. pointer: AbstractMesh;
  46111. /**
  46112. * Creates the controller
  46113. * @see https://doc.babylonjs.com/how_to/webxr
  46114. * @param _scene the scene which the controller should be associated to
  46115. * @param inputSource the underlying input source for the controller
  46116. * @param _options options for this controller creation
  46117. */
  46118. constructor(_scene: Scene,
  46119. /** The underlying input source for the controller */
  46120. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46121. /**
  46122. * Get this controllers unique id
  46123. */
  46124. get uniqueId(): string;
  46125. /**
  46126. * Disposes of the object
  46127. */
  46128. dispose(): void;
  46129. /**
  46130. * Gets a world space ray coming from the pointer or grip
  46131. * @param result the resulting ray
  46132. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46133. */
  46134. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46135. /**
  46136. * Updates the controller pose based on the given XRFrame
  46137. * @param xrFrame xr frame to update the pose with
  46138. * @param referenceSpace reference space to use
  46139. */
  46140. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46141. }
  46142. }
  46143. declare module "babylonjs/XR/webXRInput" {
  46144. import { Observable } from "babylonjs/Misc/observable";
  46145. import { IDisposable } from "babylonjs/scene";
  46146. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46147. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46148. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46149. /**
  46150. * The schema for initialization options of the XR Input class
  46151. */
  46152. export interface IWebXRInputOptions {
  46153. /**
  46154. * If set to true no model will be automatically loaded
  46155. */
  46156. doNotLoadControllerMeshes?: boolean;
  46157. /**
  46158. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46159. * If not found, the xr input profile data will be used.
  46160. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46161. */
  46162. forceInputProfile?: string;
  46163. /**
  46164. * Do not send a request to the controller repository to load the profile.
  46165. *
  46166. * Instead, use the controllers available in babylon itself.
  46167. */
  46168. disableOnlineControllerRepository?: boolean;
  46169. /**
  46170. * A custom URL for the controllers repository
  46171. */
  46172. customControllersRepositoryURL?: string;
  46173. /**
  46174. * Should the controller model's components not move according to the user input
  46175. */
  46176. disableControllerAnimation?: boolean;
  46177. }
  46178. /**
  46179. * XR input used to track XR inputs such as controllers/rays
  46180. */
  46181. export class WebXRInput implements IDisposable {
  46182. /**
  46183. * the xr session manager for this session
  46184. */
  46185. xrSessionManager: WebXRSessionManager;
  46186. /**
  46187. * the WebXR camera for this session. Mainly used for teleportation
  46188. */
  46189. xrCamera: WebXRCamera;
  46190. private readonly options;
  46191. /**
  46192. * XR controllers being tracked
  46193. */
  46194. controllers: Array<WebXRInputSource>;
  46195. private _frameObserver;
  46196. private _sessionEndedObserver;
  46197. private _sessionInitObserver;
  46198. /**
  46199. * Event when a controller has been connected/added
  46200. */
  46201. onControllerAddedObservable: Observable<WebXRInputSource>;
  46202. /**
  46203. * Event when a controller has been removed/disconnected
  46204. */
  46205. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46206. /**
  46207. * Initializes the WebXRInput
  46208. * @param xrSessionManager the xr session manager for this session
  46209. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46210. * @param options = initialization options for this xr input
  46211. */
  46212. constructor(
  46213. /**
  46214. * the xr session manager for this session
  46215. */
  46216. xrSessionManager: WebXRSessionManager,
  46217. /**
  46218. * the WebXR camera for this session. Mainly used for teleportation
  46219. */
  46220. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46221. private _onInputSourcesChange;
  46222. private _addAndRemoveControllers;
  46223. /**
  46224. * Disposes of the object
  46225. */
  46226. dispose(): void;
  46227. }
  46228. }
  46229. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46230. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46231. import { Observable, EventState } from "babylonjs/Misc/observable";
  46232. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46233. /**
  46234. * This is the base class for all WebXR features.
  46235. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46236. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46237. */
  46238. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46239. protected _xrSessionManager: WebXRSessionManager;
  46240. private _attached;
  46241. private _removeOnDetach;
  46242. /**
  46243. * Should auto-attach be disabled?
  46244. */
  46245. disableAutoAttach: boolean;
  46246. /**
  46247. * Construct a new (abstract) WebXR feature
  46248. * @param _xrSessionManager the xr session manager for this feature
  46249. */
  46250. constructor(_xrSessionManager: WebXRSessionManager);
  46251. /**
  46252. * Is this feature attached
  46253. */
  46254. get attached(): boolean;
  46255. /**
  46256. * attach this feature
  46257. *
  46258. * @param force should attachment be forced (even when already attached)
  46259. * @returns true if successful, false is failed or already attached
  46260. */
  46261. attach(force?: boolean): boolean;
  46262. /**
  46263. * detach this feature.
  46264. *
  46265. * @returns true if successful, false if failed or already detached
  46266. */
  46267. detach(): boolean;
  46268. /**
  46269. * Dispose this feature and all of the resources attached
  46270. */
  46271. dispose(): void;
  46272. /**
  46273. * This is used to register callbacks that will automatically be removed when detach is called.
  46274. * @param observable the observable to which the observer will be attached
  46275. * @param callback the callback to register
  46276. */
  46277. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46278. /**
  46279. * Code in this function will be executed on each xrFrame received from the browser.
  46280. * This function will not execute after the feature is detached.
  46281. * @param _xrFrame the current frame
  46282. */
  46283. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46284. }
  46285. }
  46286. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46287. import { IDisposable, Scene } from "babylonjs/scene";
  46288. import { Nullable } from "babylonjs/types";
  46289. import { Observable } from "babylonjs/Misc/observable";
  46290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46291. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46292. import { Camera } from "babylonjs/Cameras/camera";
  46293. /**
  46294. * Renders a layer on top of an existing scene
  46295. */
  46296. export class UtilityLayerRenderer implements IDisposable {
  46297. /** the original scene that will be rendered on top of */
  46298. originalScene: Scene;
  46299. private _pointerCaptures;
  46300. private _lastPointerEvents;
  46301. private static _DefaultUtilityLayer;
  46302. private static _DefaultKeepDepthUtilityLayer;
  46303. private _sharedGizmoLight;
  46304. private _renderCamera;
  46305. /**
  46306. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46307. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46308. * @returns the camera that is used when rendering the utility layer
  46309. */
  46310. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46311. /**
  46312. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46313. * @param cam the camera that should be used when rendering the utility layer
  46314. */
  46315. setRenderCamera(cam: Nullable<Camera>): void;
  46316. /**
  46317. * @hidden
  46318. * Light which used by gizmos to get light shading
  46319. */
  46320. _getSharedGizmoLight(): HemisphericLight;
  46321. /**
  46322. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46323. */
  46324. pickUtilitySceneFirst: boolean;
  46325. /**
  46326. * 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)
  46327. */
  46328. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46329. /**
  46330. * 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)
  46331. */
  46332. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46333. /**
  46334. * The scene that is rendered on top of the original scene
  46335. */
  46336. utilityLayerScene: Scene;
  46337. /**
  46338. * If the utility layer should automatically be rendered on top of existing scene
  46339. */
  46340. shouldRender: boolean;
  46341. /**
  46342. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46343. */
  46344. onlyCheckPointerDownEvents: boolean;
  46345. /**
  46346. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46347. */
  46348. processAllEvents: boolean;
  46349. /**
  46350. * Observable raised when the pointer move from the utility layer scene to the main scene
  46351. */
  46352. onPointerOutObservable: Observable<number>;
  46353. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46354. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46355. private _afterRenderObserver;
  46356. private _sceneDisposeObserver;
  46357. private _originalPointerObserver;
  46358. /**
  46359. * Instantiates a UtilityLayerRenderer
  46360. * @param originalScene the original scene that will be rendered on top of
  46361. * @param handleEvents boolean indicating if the utility layer should handle events
  46362. */
  46363. constructor(
  46364. /** the original scene that will be rendered on top of */
  46365. originalScene: Scene, handleEvents?: boolean);
  46366. private _notifyObservers;
  46367. /**
  46368. * Renders the utility layers scene on top of the original scene
  46369. */
  46370. render(): void;
  46371. /**
  46372. * Disposes of the renderer
  46373. */
  46374. dispose(): void;
  46375. private _updateCamera;
  46376. }
  46377. }
  46378. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46379. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46381. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46382. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46383. import { Scene } from "babylonjs/scene";
  46384. import { Nullable } from "babylonjs/types";
  46385. import { Color3 } from "babylonjs/Maths/math.color";
  46386. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46387. /**
  46388. * Options interface for the pointer selection module
  46389. */
  46390. export interface IWebXRControllerPointerSelectionOptions {
  46391. /**
  46392. * if provided, this scene will be used to render meshes.
  46393. */
  46394. customUtilityLayerScene?: Scene;
  46395. /**
  46396. * 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)
  46397. * If not disabled, the last picked point will be used to execute a pointer up event
  46398. * If disabled, pointer up event will be triggered right after the pointer down event.
  46399. * Used in screen and gaze target ray mode only
  46400. */
  46401. disablePointerUpOnTouchOut: boolean;
  46402. /**
  46403. * For gaze mode (time to select instead of press)
  46404. */
  46405. forceGazeMode: boolean;
  46406. /**
  46407. * 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
  46408. * to start a new countdown to the pointer down event.
  46409. * Defaults to 1.
  46410. */
  46411. gazeModePointerMovedFactor?: number;
  46412. /**
  46413. * Different button type to use instead of the main component
  46414. */
  46415. overrideButtonId?: string;
  46416. /**
  46417. * use this rendering group id for the meshes (optional)
  46418. */
  46419. renderingGroupId?: number;
  46420. /**
  46421. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46422. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46423. * 3000 means 3 seconds between pointing at something and selecting it
  46424. */
  46425. timeToSelect?: number;
  46426. /**
  46427. * Should meshes created here be added to a utility layer or the main scene
  46428. */
  46429. useUtilityLayer?: boolean;
  46430. /**
  46431. * the xr input to use with this pointer selection
  46432. */
  46433. xrInput: WebXRInput;
  46434. }
  46435. /**
  46436. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46437. */
  46438. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46439. private readonly _options;
  46440. private static _idCounter;
  46441. private _attachController;
  46442. private _controllers;
  46443. private _scene;
  46444. private _tmpVectorForPickCompare;
  46445. /**
  46446. * The module's name
  46447. */
  46448. static readonly Name: string;
  46449. /**
  46450. * The (Babylon) version of this module.
  46451. * This is an integer representing the implementation version.
  46452. * This number does not correspond to the WebXR specs version
  46453. */
  46454. static readonly Version: number;
  46455. /**
  46456. * Disable lighting on the laser pointer (so it will always be visible)
  46457. */
  46458. disablePointerLighting: boolean;
  46459. /**
  46460. * Disable lighting on the selection mesh (so it will always be visible)
  46461. */
  46462. disableSelectionMeshLighting: boolean;
  46463. /**
  46464. * Should the laser pointer be displayed
  46465. */
  46466. displayLaserPointer: boolean;
  46467. /**
  46468. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46469. */
  46470. displaySelectionMesh: boolean;
  46471. /**
  46472. * This color will be set to the laser pointer when selection is triggered
  46473. */
  46474. laserPointerPickedColor: Color3;
  46475. /**
  46476. * Default color of the laser pointer
  46477. */
  46478. lasterPointerDefaultColor: Color3;
  46479. /**
  46480. * default color of the selection ring
  46481. */
  46482. selectionMeshDefaultColor: Color3;
  46483. /**
  46484. * This color will be applied to the selection ring when selection is triggered
  46485. */
  46486. selectionMeshPickedColor: Color3;
  46487. /**
  46488. * Optional filter to be used for ray selection. This predicate shares behavior with
  46489. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46490. */
  46491. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46492. /**
  46493. * constructs a new background remover module
  46494. * @param _xrSessionManager the session manager for this module
  46495. * @param _options read-only options to be used in this module
  46496. */
  46497. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46498. /**
  46499. * attach this feature
  46500. * Will usually be called by the features manager
  46501. *
  46502. * @returns true if successful.
  46503. */
  46504. attach(): boolean;
  46505. /**
  46506. * detach this feature.
  46507. * Will usually be called by the features manager
  46508. *
  46509. * @returns true if successful.
  46510. */
  46511. detach(): boolean;
  46512. /**
  46513. * Will get the mesh under a specific pointer.
  46514. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46515. * @param controllerId the controllerId to check
  46516. * @returns The mesh under pointer or null if no mesh is under the pointer
  46517. */
  46518. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46519. /**
  46520. * Get the xr controller that correlates to the pointer id in the pointer event
  46521. *
  46522. * @param id the pointer id to search for
  46523. * @returns the controller that correlates to this id or null if not found
  46524. */
  46525. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46526. protected _onXRFrame(_xrFrame: XRFrame): void;
  46527. private _attachGazeMode;
  46528. private _attachScreenRayMode;
  46529. private _attachTrackedPointerRayMode;
  46530. private _convertNormalToDirectionOfRay;
  46531. private _detachController;
  46532. private _generateNewMeshPair;
  46533. private _pickingMoved;
  46534. private _updatePointerDistance;
  46535. }
  46536. }
  46537. declare module "babylonjs/XR/webXREnterExitUI" {
  46538. import { Nullable } from "babylonjs/types";
  46539. import { Observable } from "babylonjs/Misc/observable";
  46540. import { IDisposable, Scene } from "babylonjs/scene";
  46541. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46542. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46543. /**
  46544. * Button which can be used to enter a different mode of XR
  46545. */
  46546. export class WebXREnterExitUIButton {
  46547. /** button element */
  46548. element: HTMLElement;
  46549. /** XR initialization options for the button */
  46550. sessionMode: XRSessionMode;
  46551. /** Reference space type */
  46552. referenceSpaceType: XRReferenceSpaceType;
  46553. /**
  46554. * Creates a WebXREnterExitUIButton
  46555. * @param element button element
  46556. * @param sessionMode XR initialization session mode
  46557. * @param referenceSpaceType the type of reference space to be used
  46558. */
  46559. constructor(
  46560. /** button element */
  46561. element: HTMLElement,
  46562. /** XR initialization options for the button */
  46563. sessionMode: XRSessionMode,
  46564. /** Reference space type */
  46565. referenceSpaceType: XRReferenceSpaceType);
  46566. /**
  46567. * Extendable function which can be used to update the button's visuals when the state changes
  46568. * @param activeButton the current active button in the UI
  46569. */
  46570. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46571. }
  46572. /**
  46573. * Options to create the webXR UI
  46574. */
  46575. export class WebXREnterExitUIOptions {
  46576. /**
  46577. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46578. */
  46579. customButtons?: Array<WebXREnterExitUIButton>;
  46580. /**
  46581. * A reference space type to use when creating the default button.
  46582. * Default is local-floor
  46583. */
  46584. referenceSpaceType?: XRReferenceSpaceType;
  46585. /**
  46586. * Context to enter xr with
  46587. */
  46588. renderTarget?: Nullable<WebXRRenderTarget>;
  46589. /**
  46590. * A session mode to use when creating the default button.
  46591. * Default is immersive-vr
  46592. */
  46593. sessionMode?: XRSessionMode;
  46594. }
  46595. /**
  46596. * UI to allow the user to enter/exit XR mode
  46597. */
  46598. export class WebXREnterExitUI implements IDisposable {
  46599. private scene;
  46600. /** version of the options passed to this UI */
  46601. options: WebXREnterExitUIOptions;
  46602. private _activeButton;
  46603. private _buttons;
  46604. private _overlay;
  46605. /**
  46606. * Fired every time the active button is changed.
  46607. *
  46608. * When xr is entered via a button that launches xr that button will be the callback parameter
  46609. *
  46610. * When exiting xr the callback parameter will be null)
  46611. */
  46612. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46613. /**
  46614. *
  46615. * @param scene babylon scene object to use
  46616. * @param options (read-only) version of the options passed to this UI
  46617. */
  46618. private constructor();
  46619. /**
  46620. * Creates UI to allow the user to enter/exit XR mode
  46621. * @param scene the scene to add the ui to
  46622. * @param helper the xr experience helper to enter/exit xr with
  46623. * @param options options to configure the UI
  46624. * @returns the created ui
  46625. */
  46626. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46627. /**
  46628. * Disposes of the XR UI component
  46629. */
  46630. dispose(): void;
  46631. private _updateButtons;
  46632. }
  46633. }
  46634. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46635. import { Vector3 } from "babylonjs/Maths/math.vector";
  46636. import { Color4 } from "babylonjs/Maths/math.color";
  46637. import { Nullable } from "babylonjs/types";
  46638. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46639. import { Scene } from "babylonjs/scene";
  46640. /**
  46641. * Class containing static functions to help procedurally build meshes
  46642. */
  46643. export class LinesBuilder {
  46644. /**
  46645. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46646. * * 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
  46647. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46648. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46649. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46650. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46651. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46652. * * 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
  46653. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46656. * @param name defines the name of the new line system
  46657. * @param options defines the options used to create the line system
  46658. * @param scene defines the hosting scene
  46659. * @returns a new line system mesh
  46660. */
  46661. static CreateLineSystem(name: string, options: {
  46662. lines: Vector3[][];
  46663. updatable?: boolean;
  46664. instance?: Nullable<LinesMesh>;
  46665. colors?: Nullable<Color4[][]>;
  46666. useVertexAlpha?: boolean;
  46667. }, scene: Nullable<Scene>): LinesMesh;
  46668. /**
  46669. * Creates a line mesh
  46670. * 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
  46671. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46672. * * The parameter `points` is an array successive Vector3
  46673. * * 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
  46674. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46675. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46676. * * When updating an instance, remember that only point positions can change, not the number of points
  46677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46679. * @param name defines the name of the new line system
  46680. * @param options defines the options used to create the line system
  46681. * @param scene defines the hosting scene
  46682. * @returns a new line mesh
  46683. */
  46684. static CreateLines(name: string, options: {
  46685. points: Vector3[];
  46686. updatable?: boolean;
  46687. instance?: Nullable<LinesMesh>;
  46688. colors?: Color4[];
  46689. useVertexAlpha?: boolean;
  46690. }, scene?: Nullable<Scene>): LinesMesh;
  46691. /**
  46692. * Creates a dashed line mesh
  46693. * * 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
  46694. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46695. * * The parameter `points` is an array successive Vector3
  46696. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46697. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46698. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46699. * * 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
  46700. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46701. * * When updating an instance, remember that only point positions can change, not the number of points
  46702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46703. * @param name defines the name of the mesh
  46704. * @param options defines the options used to create the mesh
  46705. * @param scene defines the hosting scene
  46706. * @returns the dashed line mesh
  46707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46708. */
  46709. static CreateDashedLines(name: string, options: {
  46710. points: Vector3[];
  46711. dashSize?: number;
  46712. gapSize?: number;
  46713. dashNb?: number;
  46714. updatable?: boolean;
  46715. instance?: LinesMesh;
  46716. useVertexAlpha?: boolean;
  46717. }, scene?: Nullable<Scene>): LinesMesh;
  46718. }
  46719. }
  46720. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46721. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46722. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46723. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46725. import { Vector3 } from "babylonjs/Maths/math.vector";
  46726. import { Material } from "babylonjs/Materials/material";
  46727. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46728. import { Scene } from "babylonjs/scene";
  46729. /**
  46730. * The options container for the teleportation module
  46731. */
  46732. export interface IWebXRTeleportationOptions {
  46733. /**
  46734. * if provided, this scene will be used to render meshes.
  46735. */
  46736. customUtilityLayerScene?: Scene;
  46737. /**
  46738. * Values to configure the default target mesh
  46739. */
  46740. defaultTargetMeshOptions?: {
  46741. /**
  46742. * Fill color of the teleportation area
  46743. */
  46744. teleportationFillColor?: string;
  46745. /**
  46746. * Border color for the teleportation area
  46747. */
  46748. teleportationBorderColor?: string;
  46749. /**
  46750. * Disable the mesh's animation sequence
  46751. */
  46752. disableAnimation?: boolean;
  46753. /**
  46754. * Disable lighting on the material or the ring and arrow
  46755. */
  46756. disableLighting?: boolean;
  46757. /**
  46758. * Override the default material of the torus and arrow
  46759. */
  46760. torusArrowMaterial?: Material;
  46761. };
  46762. /**
  46763. * A list of meshes to use as floor meshes.
  46764. * Meshes can be added and removed after initializing the feature using the
  46765. * addFloorMesh and removeFloorMesh functions
  46766. * If empty, rotation will still work
  46767. */
  46768. floorMeshes?: AbstractMesh[];
  46769. /**
  46770. * use this rendering group id for the meshes (optional)
  46771. */
  46772. renderingGroupId?: number;
  46773. /**
  46774. * Should teleportation move only to snap points
  46775. */
  46776. snapPointsOnly?: boolean;
  46777. /**
  46778. * An array of points to which the teleportation will snap to.
  46779. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46780. */
  46781. snapPositions?: Vector3[];
  46782. /**
  46783. * How close should the teleportation ray be in order to snap to position.
  46784. * Default to 0.8 units (meters)
  46785. */
  46786. snapToPositionRadius?: number;
  46787. /**
  46788. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46789. * If you want to support rotation, make sure your mesh has a direction indicator.
  46790. *
  46791. * When left untouched, the default mesh will be initialized.
  46792. */
  46793. teleportationTargetMesh?: AbstractMesh;
  46794. /**
  46795. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46796. */
  46797. timeToTeleport?: number;
  46798. /**
  46799. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46800. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46801. */
  46802. useMainComponentOnly?: boolean;
  46803. /**
  46804. * Should meshes created here be added to a utility layer or the main scene
  46805. */
  46806. useUtilityLayer?: boolean;
  46807. /**
  46808. * Babylon XR Input class for controller
  46809. */
  46810. xrInput: WebXRInput;
  46811. }
  46812. /**
  46813. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46814. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46815. * the input of the attached controllers.
  46816. */
  46817. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46818. private _options;
  46819. private _controllers;
  46820. private _currentTeleportationControllerId;
  46821. private _floorMeshes;
  46822. private _quadraticBezierCurve;
  46823. private _selectionFeature;
  46824. private _snapToPositions;
  46825. private _snappedToPoint;
  46826. private _teleportationRingMaterial?;
  46827. private _tmpRay;
  46828. private _tmpVector;
  46829. /**
  46830. * The module's name
  46831. */
  46832. static readonly Name: string;
  46833. /**
  46834. * The (Babylon) version of this module.
  46835. * This is an integer representing the implementation version.
  46836. * This number does not correspond to the webxr specs version
  46837. */
  46838. static readonly Version: number;
  46839. /**
  46840. * Is movement backwards enabled
  46841. */
  46842. backwardsMovementEnabled: boolean;
  46843. /**
  46844. * Distance to travel when moving backwards
  46845. */
  46846. backwardsTeleportationDistance: number;
  46847. /**
  46848. * The distance from the user to the inspection point in the direction of the controller
  46849. * A higher number will allow the user to move further
  46850. * defaults to 5 (meters, in xr units)
  46851. */
  46852. parabolicCheckRadius: number;
  46853. /**
  46854. * Should the module support parabolic ray on top of direct ray
  46855. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46856. * Very helpful when moving between floors / different heights
  46857. */
  46858. parabolicRayEnabled: boolean;
  46859. /**
  46860. * How much rotation should be applied when rotating right and left
  46861. */
  46862. rotationAngle: number;
  46863. /**
  46864. * Is rotation enabled when moving forward?
  46865. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46866. */
  46867. rotationEnabled: boolean;
  46868. /**
  46869. * constructs a new anchor system
  46870. * @param _xrSessionManager an instance of WebXRSessionManager
  46871. * @param _options configuration object for this feature
  46872. */
  46873. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46874. /**
  46875. * Get the snapPointsOnly flag
  46876. */
  46877. get snapPointsOnly(): boolean;
  46878. /**
  46879. * Sets the snapPointsOnly flag
  46880. * @param snapToPoints should teleportation be exclusively to snap points
  46881. */
  46882. set snapPointsOnly(snapToPoints: boolean);
  46883. /**
  46884. * Add a new mesh to the floor meshes array
  46885. * @param mesh the mesh to use as floor mesh
  46886. */
  46887. addFloorMesh(mesh: AbstractMesh): void;
  46888. /**
  46889. * Add a new snap-to point to fix teleportation to this position
  46890. * @param newSnapPoint The new Snap-To point
  46891. */
  46892. addSnapPoint(newSnapPoint: Vector3): void;
  46893. attach(): boolean;
  46894. detach(): boolean;
  46895. dispose(): void;
  46896. /**
  46897. * Remove a mesh from the floor meshes array
  46898. * @param mesh the mesh to remove
  46899. */
  46900. removeFloorMesh(mesh: AbstractMesh): void;
  46901. /**
  46902. * Remove a mesh from the floor meshes array using its name
  46903. * @param name the mesh name to remove
  46904. */
  46905. removeFloorMeshByName(name: string): void;
  46906. /**
  46907. * 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
  46908. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46909. * @returns was the point found and removed or not
  46910. */
  46911. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46912. /**
  46913. * This function sets a selection feature that will be disabled when
  46914. * the forward ray is shown and will be reattached when hidden.
  46915. * This is used to remove the selection rays when moving.
  46916. * @param selectionFeature the feature to disable when forward movement is enabled
  46917. */
  46918. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46919. protected _onXRFrame(_xrFrame: XRFrame): void;
  46920. private _attachController;
  46921. private _createDefaultTargetMesh;
  46922. private _detachController;
  46923. private _findClosestSnapPointWithRadius;
  46924. private _setTargetMeshPosition;
  46925. private _setTargetMeshVisibility;
  46926. private _showParabolicPath;
  46927. private _teleportForward;
  46928. }
  46929. }
  46930. declare module "babylonjs/XR/webXRDefaultExperience" {
  46931. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46932. import { Scene } from "babylonjs/scene";
  46933. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46934. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46935. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46936. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46938. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46939. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46940. /**
  46941. * Options for the default xr helper
  46942. */
  46943. export class WebXRDefaultExperienceOptions {
  46944. /**
  46945. * Enable or disable default UI to enter XR
  46946. */
  46947. disableDefaultUI?: boolean;
  46948. /**
  46949. * Should teleportation not initialize. defaults to false.
  46950. */
  46951. disableTeleportation?: boolean;
  46952. /**
  46953. * Floor meshes that will be used for teleport
  46954. */
  46955. floorMeshes?: Array<AbstractMesh>;
  46956. /**
  46957. * If set to true, the first frame will not be used to reset position
  46958. * The first frame is mainly used when copying transformation from the old camera
  46959. * Mainly used in AR
  46960. */
  46961. ignoreNativeCameraTransformation?: boolean;
  46962. /**
  46963. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46964. */
  46965. inputOptions?: IWebXRInputOptions;
  46966. /**
  46967. * optional configuration for the output canvas
  46968. */
  46969. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46970. /**
  46971. * optional UI options. This can be used among other to change session mode and reference space type
  46972. */
  46973. uiOptions?: WebXREnterExitUIOptions;
  46974. /**
  46975. * When loading teleportation and pointer select, use stable versions instead of latest.
  46976. */
  46977. useStablePlugins?: boolean;
  46978. }
  46979. /**
  46980. * Default experience which provides a similar setup to the previous webVRExperience
  46981. */
  46982. export class WebXRDefaultExperience {
  46983. /**
  46984. * Base experience
  46985. */
  46986. baseExperience: WebXRExperienceHelper;
  46987. /**
  46988. * Enables ui for entering/exiting xr
  46989. */
  46990. enterExitUI: WebXREnterExitUI;
  46991. /**
  46992. * Input experience extension
  46993. */
  46994. input: WebXRInput;
  46995. /**
  46996. * Enables laser pointer and selection
  46997. */
  46998. pointerSelection: WebXRControllerPointerSelection;
  46999. /**
  47000. * Default target xr should render to
  47001. */
  47002. renderTarget: WebXRRenderTarget;
  47003. /**
  47004. * Enables teleportation
  47005. */
  47006. teleportation: WebXRMotionControllerTeleportation;
  47007. private constructor();
  47008. /**
  47009. * Creates the default xr experience
  47010. * @param scene scene
  47011. * @param options options for basic configuration
  47012. * @returns resulting WebXRDefaultExperience
  47013. */
  47014. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47015. /**
  47016. * DIsposes of the experience helper
  47017. */
  47018. dispose(): void;
  47019. }
  47020. }
  47021. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47022. import { Observable } from "babylonjs/Misc/observable";
  47023. import { Nullable } from "babylonjs/types";
  47024. import { Camera } from "babylonjs/Cameras/camera";
  47025. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47026. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47027. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47028. import { Scene } from "babylonjs/scene";
  47029. import { Vector3 } from "babylonjs/Maths/math.vector";
  47030. import { Color3 } from "babylonjs/Maths/math.color";
  47031. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47033. import { Mesh } from "babylonjs/Meshes/mesh";
  47034. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47035. import { EasingFunction } from "babylonjs/Animations/easing";
  47036. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47037. import "babylonjs/Meshes/Builders/groundBuilder";
  47038. import "babylonjs/Meshes/Builders/torusBuilder";
  47039. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47040. import "babylonjs/Gamepads/gamepadSceneComponent";
  47041. import "babylonjs/Animations/animatable";
  47042. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47043. /**
  47044. * Options to modify the vr teleportation behavior.
  47045. */
  47046. export interface VRTeleportationOptions {
  47047. /**
  47048. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47049. */
  47050. floorMeshName?: string;
  47051. /**
  47052. * A list of meshes to be used as the teleportation floor. (default: empty)
  47053. */
  47054. floorMeshes?: Mesh[];
  47055. /**
  47056. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47057. */
  47058. teleportationMode?: number;
  47059. /**
  47060. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47061. */
  47062. teleportationTime?: number;
  47063. /**
  47064. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47065. */
  47066. teleportationSpeed?: number;
  47067. /**
  47068. * The easing function used in the animation or null for Linear. (default CircleEase)
  47069. */
  47070. easingFunction?: EasingFunction;
  47071. }
  47072. /**
  47073. * Options to modify the vr experience helper's behavior.
  47074. */
  47075. export interface VRExperienceHelperOptions extends WebVROptions {
  47076. /**
  47077. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47078. */
  47079. createDeviceOrientationCamera?: boolean;
  47080. /**
  47081. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47082. */
  47083. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47084. /**
  47085. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47086. */
  47087. laserToggle?: boolean;
  47088. /**
  47089. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47090. */
  47091. floorMeshes?: Mesh[];
  47092. /**
  47093. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47094. */
  47095. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47096. /**
  47097. * Defines if WebXR should be used instead of WebVR (if available)
  47098. */
  47099. useXR?: boolean;
  47100. }
  47101. /**
  47102. * Event containing information after VR has been entered
  47103. */
  47104. export class OnAfterEnteringVRObservableEvent {
  47105. /**
  47106. * If entering vr was successful
  47107. */
  47108. success: boolean;
  47109. }
  47110. /**
  47111. * Helps to quickly add VR support to an existing scene.
  47112. * See http://doc.babylonjs.com/how_to/webvr_helper
  47113. */
  47114. export class VRExperienceHelper {
  47115. /** Options to modify the vr experience helper's behavior. */
  47116. webVROptions: VRExperienceHelperOptions;
  47117. private _scene;
  47118. private _position;
  47119. private _btnVR;
  47120. private _btnVRDisplayed;
  47121. private _webVRsupported;
  47122. private _webVRready;
  47123. private _webVRrequesting;
  47124. private _webVRpresenting;
  47125. private _hasEnteredVR;
  47126. private _fullscreenVRpresenting;
  47127. private _inputElement;
  47128. private _webVRCamera;
  47129. private _vrDeviceOrientationCamera;
  47130. private _deviceOrientationCamera;
  47131. private _existingCamera;
  47132. private _onKeyDown;
  47133. private _onVrDisplayPresentChange;
  47134. private _onVRDisplayChanged;
  47135. private _onVRRequestPresentStart;
  47136. private _onVRRequestPresentComplete;
  47137. /**
  47138. * 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)
  47139. */
  47140. enableGazeEvenWhenNoPointerLock: boolean;
  47141. /**
  47142. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47143. */
  47144. exitVROnDoubleTap: boolean;
  47145. /**
  47146. * Observable raised right before entering VR.
  47147. */
  47148. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47149. /**
  47150. * Observable raised when entering VR has completed.
  47151. */
  47152. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47153. /**
  47154. * Observable raised when exiting VR.
  47155. */
  47156. onExitingVRObservable: Observable<VRExperienceHelper>;
  47157. /**
  47158. * Observable raised when controller mesh is loaded.
  47159. */
  47160. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47161. /** Return this.onEnteringVRObservable
  47162. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47163. */
  47164. get onEnteringVR(): Observable<VRExperienceHelper>;
  47165. /** Return this.onExitingVRObservable
  47166. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47167. */
  47168. get onExitingVR(): Observable<VRExperienceHelper>;
  47169. /** Return this.onControllerMeshLoadedObservable
  47170. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47171. */
  47172. get onControllerMeshLoaded(): Observable<WebVRController>;
  47173. private _rayLength;
  47174. private _useCustomVRButton;
  47175. private _teleportationRequested;
  47176. private _teleportActive;
  47177. private _floorMeshName;
  47178. private _floorMeshesCollection;
  47179. private _teleportationMode;
  47180. private _teleportationTime;
  47181. private _teleportationSpeed;
  47182. private _teleportationEasing;
  47183. private _rotationAllowed;
  47184. private _teleportBackwardsVector;
  47185. private _teleportationTarget;
  47186. private _isDefaultTeleportationTarget;
  47187. private _postProcessMove;
  47188. private _teleportationFillColor;
  47189. private _teleportationBorderColor;
  47190. private _rotationAngle;
  47191. private _haloCenter;
  47192. private _cameraGazer;
  47193. private _padSensibilityUp;
  47194. private _padSensibilityDown;
  47195. private _leftController;
  47196. private _rightController;
  47197. private _gazeColor;
  47198. private _laserColor;
  47199. private _pickedLaserColor;
  47200. private _pickedGazeColor;
  47201. /**
  47202. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47203. */
  47204. onNewMeshSelected: Observable<AbstractMesh>;
  47205. /**
  47206. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47207. * This observable will provide the mesh and the controller used to select the mesh
  47208. */
  47209. onMeshSelectedWithController: Observable<{
  47210. mesh: AbstractMesh;
  47211. controller: WebVRController;
  47212. }>;
  47213. /**
  47214. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47215. */
  47216. onNewMeshPicked: Observable<PickingInfo>;
  47217. private _circleEase;
  47218. /**
  47219. * Observable raised before camera teleportation
  47220. */
  47221. onBeforeCameraTeleport: Observable<Vector3>;
  47222. /**
  47223. * Observable raised after camera teleportation
  47224. */
  47225. onAfterCameraTeleport: Observable<Vector3>;
  47226. /**
  47227. * Observable raised when current selected mesh gets unselected
  47228. */
  47229. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47230. private _raySelectionPredicate;
  47231. /**
  47232. * To be optionaly changed by user to define custom ray selection
  47233. */
  47234. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47235. /**
  47236. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47237. */
  47238. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47239. /**
  47240. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47241. */
  47242. teleportationEnabled: boolean;
  47243. private _defaultHeight;
  47244. private _teleportationInitialized;
  47245. private _interactionsEnabled;
  47246. private _interactionsRequested;
  47247. private _displayGaze;
  47248. private _displayLaserPointer;
  47249. /**
  47250. * The mesh used to display where the user is going to teleport.
  47251. */
  47252. get teleportationTarget(): Mesh;
  47253. /**
  47254. * Sets the mesh to be used to display where the user is going to teleport.
  47255. */
  47256. set teleportationTarget(value: Mesh);
  47257. /**
  47258. * 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
  47259. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47260. * See http://doc.babylonjs.com/resources/baking_transformations
  47261. */
  47262. get gazeTrackerMesh(): Mesh;
  47263. set gazeTrackerMesh(value: Mesh);
  47264. /**
  47265. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47266. */
  47267. updateGazeTrackerScale: boolean;
  47268. /**
  47269. * If the gaze trackers color should be updated when selecting meshes
  47270. */
  47271. updateGazeTrackerColor: boolean;
  47272. /**
  47273. * If the controller laser color should be updated when selecting meshes
  47274. */
  47275. updateControllerLaserColor: boolean;
  47276. /**
  47277. * The gaze tracking mesh corresponding to the left controller
  47278. */
  47279. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47280. /**
  47281. * The gaze tracking mesh corresponding to the right controller
  47282. */
  47283. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47284. /**
  47285. * If the ray of the gaze should be displayed.
  47286. */
  47287. get displayGaze(): boolean;
  47288. /**
  47289. * Sets if the ray of the gaze should be displayed.
  47290. */
  47291. set displayGaze(value: boolean);
  47292. /**
  47293. * If the ray of the LaserPointer should be displayed.
  47294. */
  47295. get displayLaserPointer(): boolean;
  47296. /**
  47297. * Sets if the ray of the LaserPointer should be displayed.
  47298. */
  47299. set displayLaserPointer(value: boolean);
  47300. /**
  47301. * The deviceOrientationCamera used as the camera when not in VR.
  47302. */
  47303. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47304. /**
  47305. * Based on the current WebVR support, returns the current VR camera used.
  47306. */
  47307. get currentVRCamera(): Nullable<Camera>;
  47308. /**
  47309. * The webVRCamera which is used when in VR.
  47310. */
  47311. get webVRCamera(): WebVRFreeCamera;
  47312. /**
  47313. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47314. */
  47315. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47316. /**
  47317. * The html button that is used to trigger entering into VR.
  47318. */
  47319. get vrButton(): Nullable<HTMLButtonElement>;
  47320. private get _teleportationRequestInitiated();
  47321. /**
  47322. * Defines whether or not Pointer lock should be requested when switching to
  47323. * full screen.
  47324. */
  47325. requestPointerLockOnFullScreen: boolean;
  47326. /**
  47327. * If asking to force XR, this will be populated with the default xr experience
  47328. */
  47329. xr: WebXRDefaultExperience;
  47330. /**
  47331. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47332. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47333. */
  47334. xrTestDone: boolean;
  47335. /**
  47336. * Instantiates a VRExperienceHelper.
  47337. * Helps to quickly add VR support to an existing scene.
  47338. * @param scene The scene the VRExperienceHelper belongs to.
  47339. * @param webVROptions Options to modify the vr experience helper's behavior.
  47340. */
  47341. constructor(scene: Scene,
  47342. /** Options to modify the vr experience helper's behavior. */
  47343. webVROptions?: VRExperienceHelperOptions);
  47344. private completeVRInit;
  47345. private _onDefaultMeshLoaded;
  47346. private _onResize;
  47347. private _onFullscreenChange;
  47348. /**
  47349. * Gets a value indicating if we are currently in VR mode.
  47350. */
  47351. get isInVRMode(): boolean;
  47352. private onVrDisplayPresentChange;
  47353. private onVRDisplayChanged;
  47354. private moveButtonToBottomRight;
  47355. private displayVRButton;
  47356. private updateButtonVisibility;
  47357. private _cachedAngularSensibility;
  47358. /**
  47359. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47360. * Otherwise, will use the fullscreen API.
  47361. */
  47362. enterVR(): void;
  47363. /**
  47364. * Attempt to exit VR, or fullscreen.
  47365. */
  47366. exitVR(): void;
  47367. /**
  47368. * The position of the vr experience helper.
  47369. */
  47370. get position(): Vector3;
  47371. /**
  47372. * Sets the position of the vr experience helper.
  47373. */
  47374. set position(value: Vector3);
  47375. /**
  47376. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47377. */
  47378. enableInteractions(): void;
  47379. private get _noControllerIsActive();
  47380. private beforeRender;
  47381. private _isTeleportationFloor;
  47382. /**
  47383. * Adds a floor mesh to be used for teleportation.
  47384. * @param floorMesh the mesh to be used for teleportation.
  47385. */
  47386. addFloorMesh(floorMesh: Mesh): void;
  47387. /**
  47388. * Removes a floor mesh from being used for teleportation.
  47389. * @param floorMesh the mesh to be removed.
  47390. */
  47391. removeFloorMesh(floorMesh: Mesh): void;
  47392. /**
  47393. * Enables interactions and teleportation using the VR controllers and gaze.
  47394. * @param vrTeleportationOptions options to modify teleportation behavior.
  47395. */
  47396. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47397. private _onNewGamepadConnected;
  47398. private _tryEnableInteractionOnController;
  47399. private _onNewGamepadDisconnected;
  47400. private _enableInteractionOnController;
  47401. private _checkTeleportWithRay;
  47402. private _checkRotate;
  47403. private _checkTeleportBackwards;
  47404. private _enableTeleportationOnController;
  47405. private _createTeleportationCircles;
  47406. private _displayTeleportationTarget;
  47407. private _hideTeleportationTarget;
  47408. private _rotateCamera;
  47409. private _moveTeleportationSelectorTo;
  47410. private _workingVector;
  47411. private _workingQuaternion;
  47412. private _workingMatrix;
  47413. /**
  47414. * Time Constant Teleportation Mode
  47415. */
  47416. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47417. /**
  47418. * Speed Constant Teleportation Mode
  47419. */
  47420. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47421. /**
  47422. * Teleports the users feet to the desired location
  47423. * @param location The location where the user's feet should be placed
  47424. */
  47425. teleportCamera(location: Vector3): void;
  47426. private _convertNormalToDirectionOfRay;
  47427. private _castRayAndSelectObject;
  47428. private _notifySelectedMeshUnselected;
  47429. /**
  47430. * Permanently set new colors for the laser pointer
  47431. * @param color the new laser color
  47432. * @param pickedColor the new laser color when picked mesh detected
  47433. */
  47434. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47435. /**
  47436. * Set lighting enabled / disabled on the laser pointer of both controllers
  47437. * @param enabled should the lighting be enabled on the laser pointer
  47438. */
  47439. setLaserLightingState(enabled?: boolean): void;
  47440. /**
  47441. * Permanently set new colors for the gaze pointer
  47442. * @param color the new gaze color
  47443. * @param pickedColor the new gaze color when picked mesh detected
  47444. */
  47445. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47446. /**
  47447. * Sets the color of the laser ray from the vr controllers.
  47448. * @param color new color for the ray.
  47449. */
  47450. changeLaserColor(color: Color3): void;
  47451. /**
  47452. * Sets the color of the ray from the vr headsets gaze.
  47453. * @param color new color for the ray.
  47454. */
  47455. changeGazeColor(color: Color3): void;
  47456. /**
  47457. * Exits VR and disposes of the vr experience helper
  47458. */
  47459. dispose(): void;
  47460. /**
  47461. * Gets the name of the VRExperienceHelper class
  47462. * @returns "VRExperienceHelper"
  47463. */
  47464. getClassName(): string;
  47465. }
  47466. }
  47467. declare module "babylonjs/Cameras/VR/index" {
  47468. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47469. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47470. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47471. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47472. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47473. export * from "babylonjs/Cameras/VR/webVRCamera";
  47474. }
  47475. declare module "babylonjs/Cameras/RigModes/index" {
  47476. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47477. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47478. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47479. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47480. }
  47481. declare module "babylonjs/Cameras/index" {
  47482. export * from "babylonjs/Cameras/Inputs/index";
  47483. export * from "babylonjs/Cameras/cameraInputsManager";
  47484. export * from "babylonjs/Cameras/camera";
  47485. export * from "babylonjs/Cameras/targetCamera";
  47486. export * from "babylonjs/Cameras/freeCamera";
  47487. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47488. export * from "babylonjs/Cameras/touchCamera";
  47489. export * from "babylonjs/Cameras/arcRotateCamera";
  47490. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47491. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47492. export * from "babylonjs/Cameras/flyCamera";
  47493. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47494. export * from "babylonjs/Cameras/followCamera";
  47495. export * from "babylonjs/Cameras/followCameraInputsManager";
  47496. export * from "babylonjs/Cameras/gamepadCamera";
  47497. export * from "babylonjs/Cameras/Stereoscopic/index";
  47498. export * from "babylonjs/Cameras/universalCamera";
  47499. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47500. export * from "babylonjs/Cameras/VR/index";
  47501. export * from "babylonjs/Cameras/RigModes/index";
  47502. }
  47503. declare module "babylonjs/Collisions/index" {
  47504. export * from "babylonjs/Collisions/collider";
  47505. export * from "babylonjs/Collisions/collisionCoordinator";
  47506. export * from "babylonjs/Collisions/pickingInfo";
  47507. export * from "babylonjs/Collisions/intersectionInfo";
  47508. export * from "babylonjs/Collisions/meshCollisionData";
  47509. }
  47510. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47511. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47512. import { Vector3 } from "babylonjs/Maths/math.vector";
  47513. import { Ray } from "babylonjs/Culling/ray";
  47514. import { Plane } from "babylonjs/Maths/math.plane";
  47515. /**
  47516. * Contains an array of blocks representing the octree
  47517. */
  47518. export interface IOctreeContainer<T> {
  47519. /**
  47520. * Blocks within the octree
  47521. */
  47522. blocks: Array<OctreeBlock<T>>;
  47523. }
  47524. /**
  47525. * Class used to store a cell in an octree
  47526. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47527. */
  47528. export class OctreeBlock<T> {
  47529. /**
  47530. * Gets the content of the current block
  47531. */
  47532. entries: T[];
  47533. /**
  47534. * Gets the list of block children
  47535. */
  47536. blocks: Array<OctreeBlock<T>>;
  47537. private _depth;
  47538. private _maxDepth;
  47539. private _capacity;
  47540. private _minPoint;
  47541. private _maxPoint;
  47542. private _boundingVectors;
  47543. private _creationFunc;
  47544. /**
  47545. * Creates a new block
  47546. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47547. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47548. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47549. * @param depth defines the current depth of this block in the octree
  47550. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47551. * @param creationFunc defines a callback to call when an element is added to the block
  47552. */
  47553. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47554. /**
  47555. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47556. */
  47557. get capacity(): number;
  47558. /**
  47559. * Gets the minimum vector (in world space) of the block's bounding box
  47560. */
  47561. get minPoint(): Vector3;
  47562. /**
  47563. * Gets the maximum vector (in world space) of the block's bounding box
  47564. */
  47565. get maxPoint(): Vector3;
  47566. /**
  47567. * Add a new element to this block
  47568. * @param entry defines the element to add
  47569. */
  47570. addEntry(entry: T): void;
  47571. /**
  47572. * Remove an element from this block
  47573. * @param entry defines the element to remove
  47574. */
  47575. removeEntry(entry: T): void;
  47576. /**
  47577. * Add an array of elements to this block
  47578. * @param entries defines the array of elements to add
  47579. */
  47580. addEntries(entries: T[]): void;
  47581. /**
  47582. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47583. * @param frustumPlanes defines the frustum planes to test
  47584. * @param selection defines the array to store current content if selection is positive
  47585. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47586. */
  47587. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47588. /**
  47589. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47590. * @param sphereCenter defines the bounding sphere center
  47591. * @param sphereRadius defines the bounding sphere radius
  47592. * @param selection defines the array to store current content if selection is positive
  47593. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47594. */
  47595. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47596. /**
  47597. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47598. * @param ray defines the ray to test with
  47599. * @param selection defines the array to store current content if selection is positive
  47600. */
  47601. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47602. /**
  47603. * Subdivide the content into child blocks (this block will then be empty)
  47604. */
  47605. createInnerBlocks(): void;
  47606. /**
  47607. * @hidden
  47608. */
  47609. 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;
  47610. }
  47611. }
  47612. declare module "babylonjs/Culling/Octrees/octree" {
  47613. import { SmartArray } from "babylonjs/Misc/smartArray";
  47614. import { Vector3 } from "babylonjs/Maths/math.vector";
  47615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47617. import { Ray } from "babylonjs/Culling/ray";
  47618. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47619. import { Plane } from "babylonjs/Maths/math.plane";
  47620. /**
  47621. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47622. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47623. */
  47624. export class Octree<T> {
  47625. /** 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.) */
  47626. maxDepth: number;
  47627. /**
  47628. * Blocks within the octree containing objects
  47629. */
  47630. blocks: Array<OctreeBlock<T>>;
  47631. /**
  47632. * Content stored in the octree
  47633. */
  47634. dynamicContent: T[];
  47635. private _maxBlockCapacity;
  47636. private _selectionContent;
  47637. private _creationFunc;
  47638. /**
  47639. * Creates a octree
  47640. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47641. * @param creationFunc function to be used to instatiate the octree
  47642. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47643. * @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.)
  47644. */
  47645. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47646. /** 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.) */
  47647. maxDepth?: number);
  47648. /**
  47649. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47650. * @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);
  47651. * @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);
  47652. * @param entries meshes to be added to the octree blocks
  47653. */
  47654. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47655. /**
  47656. * Adds a mesh to the octree
  47657. * @param entry Mesh to add to the octree
  47658. */
  47659. addMesh(entry: T): void;
  47660. /**
  47661. * Remove an element from the octree
  47662. * @param entry defines the element to remove
  47663. */
  47664. removeMesh(entry: T): void;
  47665. /**
  47666. * Selects an array of meshes within the frustum
  47667. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47668. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47669. * @returns array of meshes within the frustum
  47670. */
  47671. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47672. /**
  47673. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47674. * @param sphereCenter defines the bounding sphere center
  47675. * @param sphereRadius defines the bounding sphere radius
  47676. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47677. * @returns an array of objects that intersect the sphere
  47678. */
  47679. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47680. /**
  47681. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47682. * @param ray defines the ray to test with
  47683. * @returns array of intersected objects
  47684. */
  47685. intersectsRay(ray: Ray): SmartArray<T>;
  47686. /**
  47687. * Adds a mesh into the octree block if it intersects the block
  47688. */
  47689. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47690. /**
  47691. * Adds a submesh into the octree block if it intersects the block
  47692. */
  47693. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47694. }
  47695. }
  47696. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47697. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47698. import { Scene } from "babylonjs/scene";
  47699. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47701. import { Ray } from "babylonjs/Culling/ray";
  47702. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47703. import { Collider } from "babylonjs/Collisions/collider";
  47704. module "babylonjs/scene" {
  47705. interface Scene {
  47706. /**
  47707. * @hidden
  47708. * Backing Filed
  47709. */
  47710. _selectionOctree: Octree<AbstractMesh>;
  47711. /**
  47712. * Gets the octree used to boost mesh selection (picking)
  47713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47714. */
  47715. selectionOctree: Octree<AbstractMesh>;
  47716. /**
  47717. * Creates or updates the octree used to boost selection (picking)
  47718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47719. * @param maxCapacity defines the maximum capacity per leaf
  47720. * @param maxDepth defines the maximum depth of the octree
  47721. * @returns an octree of AbstractMesh
  47722. */
  47723. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47724. }
  47725. }
  47726. module "babylonjs/Meshes/abstractMesh" {
  47727. interface AbstractMesh {
  47728. /**
  47729. * @hidden
  47730. * Backing Field
  47731. */
  47732. _submeshesOctree: Octree<SubMesh>;
  47733. /**
  47734. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47735. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47736. * @param maxCapacity defines the maximum size of each block (64 by default)
  47737. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47738. * @returns the new octree
  47739. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47740. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47741. */
  47742. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47743. }
  47744. }
  47745. /**
  47746. * Defines the octree scene component responsible to manage any octrees
  47747. * in a given scene.
  47748. */
  47749. export class OctreeSceneComponent {
  47750. /**
  47751. * The component name help to identify the component in the list of scene components.
  47752. */
  47753. readonly name: string;
  47754. /**
  47755. * The scene the component belongs to.
  47756. */
  47757. scene: Scene;
  47758. /**
  47759. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47760. */
  47761. readonly checksIsEnabled: boolean;
  47762. /**
  47763. * Creates a new instance of the component for the given scene
  47764. * @param scene Defines the scene to register the component in
  47765. */
  47766. constructor(scene: Scene);
  47767. /**
  47768. * Registers the component in a given scene
  47769. */
  47770. register(): void;
  47771. /**
  47772. * Return the list of active meshes
  47773. * @returns the list of active meshes
  47774. */
  47775. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47776. /**
  47777. * Return the list of active sub meshes
  47778. * @param mesh The mesh to get the candidates sub meshes from
  47779. * @returns the list of active sub meshes
  47780. */
  47781. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47782. private _tempRay;
  47783. /**
  47784. * Return the list of sub meshes intersecting with a given local ray
  47785. * @param mesh defines the mesh to find the submesh for
  47786. * @param localRay defines the ray in local space
  47787. * @returns the list of intersecting sub meshes
  47788. */
  47789. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47790. /**
  47791. * Return the list of sub meshes colliding with a collider
  47792. * @param mesh defines the mesh to find the submesh for
  47793. * @param collider defines the collider to evaluate the collision against
  47794. * @returns the list of colliding sub meshes
  47795. */
  47796. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47797. /**
  47798. * Rebuilds the elements related to this component in case of
  47799. * context lost for instance.
  47800. */
  47801. rebuild(): void;
  47802. /**
  47803. * Disposes the component and the associated ressources.
  47804. */
  47805. dispose(): void;
  47806. }
  47807. }
  47808. declare module "babylonjs/Culling/Octrees/index" {
  47809. export * from "babylonjs/Culling/Octrees/octree";
  47810. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47811. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47812. }
  47813. declare module "babylonjs/Culling/index" {
  47814. export * from "babylonjs/Culling/boundingBox";
  47815. export * from "babylonjs/Culling/boundingInfo";
  47816. export * from "babylonjs/Culling/boundingSphere";
  47817. export * from "babylonjs/Culling/Octrees/index";
  47818. export * from "babylonjs/Culling/ray";
  47819. }
  47820. declare module "babylonjs/Gizmos/gizmo" {
  47821. import { Nullable } from "babylonjs/types";
  47822. import { IDisposable } from "babylonjs/scene";
  47823. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47824. import { Mesh } from "babylonjs/Meshes/mesh";
  47825. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47826. /**
  47827. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47828. */
  47829. export class Gizmo implements IDisposable {
  47830. /** The utility layer the gizmo will be added to */
  47831. gizmoLayer: UtilityLayerRenderer;
  47832. /**
  47833. * The root mesh of the gizmo
  47834. */
  47835. _rootMesh: Mesh;
  47836. private _attachedMesh;
  47837. /**
  47838. * Ratio for the scale of the gizmo (Default: 1)
  47839. */
  47840. scaleRatio: number;
  47841. /**
  47842. * If a custom mesh has been set (Default: false)
  47843. */
  47844. protected _customMeshSet: boolean;
  47845. /**
  47846. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47847. * * When set, interactions will be enabled
  47848. */
  47849. get attachedMesh(): Nullable<AbstractMesh>;
  47850. set attachedMesh(value: Nullable<AbstractMesh>);
  47851. /**
  47852. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47853. * @param mesh The mesh to replace the default mesh of the gizmo
  47854. */
  47855. setCustomMesh(mesh: Mesh): void;
  47856. /**
  47857. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47858. */
  47859. updateGizmoRotationToMatchAttachedMesh: boolean;
  47860. /**
  47861. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47862. */
  47863. updateGizmoPositionToMatchAttachedMesh: boolean;
  47864. /**
  47865. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47866. */
  47867. updateScale: boolean;
  47868. protected _interactionsEnabled: boolean;
  47869. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47870. private _beforeRenderObserver;
  47871. private _tempVector;
  47872. /**
  47873. * Creates a gizmo
  47874. * @param gizmoLayer The utility layer the gizmo will be added to
  47875. */
  47876. constructor(
  47877. /** The utility layer the gizmo will be added to */
  47878. gizmoLayer?: UtilityLayerRenderer);
  47879. /**
  47880. * Updates the gizmo to match the attached mesh's position/rotation
  47881. */
  47882. protected _update(): void;
  47883. /**
  47884. * Disposes of the gizmo
  47885. */
  47886. dispose(): void;
  47887. }
  47888. }
  47889. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47890. import { Observable } from "babylonjs/Misc/observable";
  47891. import { Nullable } from "babylonjs/types";
  47892. import { Vector3 } from "babylonjs/Maths/math.vector";
  47893. import { Color3 } from "babylonjs/Maths/math.color";
  47894. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47896. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47897. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47898. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47899. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47900. import { Scene } from "babylonjs/scene";
  47901. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47902. /**
  47903. * Single plane drag gizmo
  47904. */
  47905. export class PlaneDragGizmo extends Gizmo {
  47906. /**
  47907. * Drag behavior responsible for the gizmos dragging interactions
  47908. */
  47909. dragBehavior: PointerDragBehavior;
  47910. private _pointerObserver;
  47911. /**
  47912. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47913. */
  47914. snapDistance: number;
  47915. /**
  47916. * Event that fires each time the gizmo snaps to a new location.
  47917. * * snapDistance is the the change in distance
  47918. */
  47919. onSnapObservable: Observable<{
  47920. snapDistance: number;
  47921. }>;
  47922. private _plane;
  47923. private _coloredMaterial;
  47924. private _hoverMaterial;
  47925. private _isEnabled;
  47926. private _parent;
  47927. /** @hidden */
  47928. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47929. /** @hidden */
  47930. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47931. /**
  47932. * Creates a PlaneDragGizmo
  47933. * @param gizmoLayer The utility layer the gizmo will be added to
  47934. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47935. * @param color The color of the gizmo
  47936. */
  47937. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47938. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47939. /**
  47940. * If the gizmo is enabled
  47941. */
  47942. set isEnabled(value: boolean);
  47943. get isEnabled(): boolean;
  47944. /**
  47945. * Disposes of the gizmo
  47946. */
  47947. dispose(): void;
  47948. }
  47949. }
  47950. declare module "babylonjs/Gizmos/positionGizmo" {
  47951. import { Observable } from "babylonjs/Misc/observable";
  47952. import { Nullable } from "babylonjs/types";
  47953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47954. import { Mesh } from "babylonjs/Meshes/mesh";
  47955. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47956. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47957. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47958. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47959. /**
  47960. * Gizmo that enables dragging a mesh along 3 axis
  47961. */
  47962. export class PositionGizmo extends Gizmo {
  47963. /**
  47964. * Internal gizmo used for interactions on the x axis
  47965. */
  47966. xGizmo: AxisDragGizmo;
  47967. /**
  47968. * Internal gizmo used for interactions on the y axis
  47969. */
  47970. yGizmo: AxisDragGizmo;
  47971. /**
  47972. * Internal gizmo used for interactions on the z axis
  47973. */
  47974. zGizmo: AxisDragGizmo;
  47975. /**
  47976. * Internal gizmo used for interactions on the yz plane
  47977. */
  47978. xPlaneGizmo: PlaneDragGizmo;
  47979. /**
  47980. * Internal gizmo used for interactions on the xz plane
  47981. */
  47982. yPlaneGizmo: PlaneDragGizmo;
  47983. /**
  47984. * Internal gizmo used for interactions on the xy plane
  47985. */
  47986. zPlaneGizmo: PlaneDragGizmo;
  47987. /**
  47988. * private variables
  47989. */
  47990. private _meshAttached;
  47991. private _updateGizmoRotationToMatchAttachedMesh;
  47992. private _snapDistance;
  47993. private _scaleRatio;
  47994. /** Fires an event when any of it's sub gizmos are dragged */
  47995. onDragStartObservable: Observable<unknown>;
  47996. /** Fires an event when any of it's sub gizmos are released from dragging */
  47997. onDragEndObservable: Observable<unknown>;
  47998. /**
  47999. * If set to true, planar drag is enabled
  48000. */
  48001. private _planarGizmoEnabled;
  48002. get attachedMesh(): Nullable<AbstractMesh>;
  48003. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48004. /**
  48005. * Creates a PositionGizmo
  48006. * @param gizmoLayer The utility layer the gizmo will be added to
  48007. */
  48008. constructor(gizmoLayer?: UtilityLayerRenderer);
  48009. /**
  48010. * If the planar drag gizmo is enabled
  48011. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48012. */
  48013. set planarGizmoEnabled(value: boolean);
  48014. get planarGizmoEnabled(): boolean;
  48015. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48016. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48017. /**
  48018. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48019. */
  48020. set snapDistance(value: number);
  48021. get snapDistance(): number;
  48022. /**
  48023. * Ratio for the scale of the gizmo (Default: 1)
  48024. */
  48025. set scaleRatio(value: number);
  48026. get scaleRatio(): number;
  48027. /**
  48028. * Disposes of the gizmo
  48029. */
  48030. dispose(): void;
  48031. /**
  48032. * CustomMeshes are not supported by this gizmo
  48033. * @param mesh The mesh to replace the default mesh of the gizmo
  48034. */
  48035. setCustomMesh(mesh: Mesh): void;
  48036. }
  48037. }
  48038. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48039. import { Observable } from "babylonjs/Misc/observable";
  48040. import { Nullable } from "babylonjs/types";
  48041. import { Vector3 } from "babylonjs/Maths/math.vector";
  48042. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48044. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48045. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48046. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48047. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48048. import { Scene } from "babylonjs/scene";
  48049. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48050. import { Color3 } from "babylonjs/Maths/math.color";
  48051. /**
  48052. * Single axis drag gizmo
  48053. */
  48054. export class AxisDragGizmo extends Gizmo {
  48055. /**
  48056. * Drag behavior responsible for the gizmos dragging interactions
  48057. */
  48058. dragBehavior: PointerDragBehavior;
  48059. private _pointerObserver;
  48060. /**
  48061. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48062. */
  48063. snapDistance: number;
  48064. /**
  48065. * Event that fires each time the gizmo snaps to a new location.
  48066. * * snapDistance is the the change in distance
  48067. */
  48068. onSnapObservable: Observable<{
  48069. snapDistance: number;
  48070. }>;
  48071. private _isEnabled;
  48072. private _parent;
  48073. private _arrow;
  48074. private _coloredMaterial;
  48075. private _hoverMaterial;
  48076. /** @hidden */
  48077. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48078. /** @hidden */
  48079. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48080. /**
  48081. * Creates an AxisDragGizmo
  48082. * @param gizmoLayer The utility layer the gizmo will be added to
  48083. * @param dragAxis The axis which the gizmo will be able to drag on
  48084. * @param color The color of the gizmo
  48085. */
  48086. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48087. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48088. /**
  48089. * If the gizmo is enabled
  48090. */
  48091. set isEnabled(value: boolean);
  48092. get isEnabled(): boolean;
  48093. /**
  48094. * Disposes of the gizmo
  48095. */
  48096. dispose(): void;
  48097. }
  48098. }
  48099. declare module "babylonjs/Debug/axesViewer" {
  48100. import { Vector3 } from "babylonjs/Maths/math.vector";
  48101. import { Nullable } from "babylonjs/types";
  48102. import { Scene } from "babylonjs/scene";
  48103. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48104. /**
  48105. * The Axes viewer will show 3 axes in a specific point in space
  48106. */
  48107. export class AxesViewer {
  48108. private _xAxis;
  48109. private _yAxis;
  48110. private _zAxis;
  48111. private _scaleLinesFactor;
  48112. private _instanced;
  48113. /**
  48114. * Gets the hosting scene
  48115. */
  48116. scene: Scene;
  48117. /**
  48118. * Gets or sets a number used to scale line length
  48119. */
  48120. scaleLines: number;
  48121. /** Gets the node hierarchy used to render x-axis */
  48122. get xAxis(): TransformNode;
  48123. /** Gets the node hierarchy used to render y-axis */
  48124. get yAxis(): TransformNode;
  48125. /** Gets the node hierarchy used to render z-axis */
  48126. get zAxis(): TransformNode;
  48127. /**
  48128. * Creates a new AxesViewer
  48129. * @param scene defines the hosting scene
  48130. * @param scaleLines defines a number used to scale line length (1 by default)
  48131. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48132. * @param xAxis defines the node hierarchy used to render the x-axis
  48133. * @param yAxis defines the node hierarchy used to render the y-axis
  48134. * @param zAxis defines the node hierarchy used to render the z-axis
  48135. */
  48136. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48137. /**
  48138. * Force the viewer to update
  48139. * @param position defines the position of the viewer
  48140. * @param xaxis defines the x axis of the viewer
  48141. * @param yaxis defines the y axis of the viewer
  48142. * @param zaxis defines the z axis of the viewer
  48143. */
  48144. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48145. /**
  48146. * Creates an instance of this axes viewer.
  48147. * @returns a new axes viewer with instanced meshes
  48148. */
  48149. createInstance(): AxesViewer;
  48150. /** Releases resources */
  48151. dispose(): void;
  48152. private static _SetRenderingGroupId;
  48153. }
  48154. }
  48155. declare module "babylonjs/Debug/boneAxesViewer" {
  48156. import { Nullable } from "babylonjs/types";
  48157. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48158. import { Vector3 } from "babylonjs/Maths/math.vector";
  48159. import { Mesh } from "babylonjs/Meshes/mesh";
  48160. import { Bone } from "babylonjs/Bones/bone";
  48161. import { Scene } from "babylonjs/scene";
  48162. /**
  48163. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48164. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48165. */
  48166. export class BoneAxesViewer extends AxesViewer {
  48167. /**
  48168. * Gets or sets the target mesh where to display the axes viewer
  48169. */
  48170. mesh: Nullable<Mesh>;
  48171. /**
  48172. * Gets or sets the target bone where to display the axes viewer
  48173. */
  48174. bone: Nullable<Bone>;
  48175. /** Gets current position */
  48176. pos: Vector3;
  48177. /** Gets direction of X axis */
  48178. xaxis: Vector3;
  48179. /** Gets direction of Y axis */
  48180. yaxis: Vector3;
  48181. /** Gets direction of Z axis */
  48182. zaxis: Vector3;
  48183. /**
  48184. * Creates a new BoneAxesViewer
  48185. * @param scene defines the hosting scene
  48186. * @param bone defines the target bone
  48187. * @param mesh defines the target mesh
  48188. * @param scaleLines defines a scaling factor for line length (1 by default)
  48189. */
  48190. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48191. /**
  48192. * Force the viewer to update
  48193. */
  48194. update(): void;
  48195. /** Releases resources */
  48196. dispose(): void;
  48197. }
  48198. }
  48199. declare module "babylonjs/Debug/debugLayer" {
  48200. import { Scene } from "babylonjs/scene";
  48201. /**
  48202. * Interface used to define scene explorer extensibility option
  48203. */
  48204. export interface IExplorerExtensibilityOption {
  48205. /**
  48206. * Define the option label
  48207. */
  48208. label: string;
  48209. /**
  48210. * Defines the action to execute on click
  48211. */
  48212. action: (entity: any) => void;
  48213. }
  48214. /**
  48215. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48216. */
  48217. export interface IExplorerExtensibilityGroup {
  48218. /**
  48219. * Defines a predicate to test if a given type mut be extended
  48220. */
  48221. predicate: (entity: any) => boolean;
  48222. /**
  48223. * Gets the list of options added to a type
  48224. */
  48225. entries: IExplorerExtensibilityOption[];
  48226. }
  48227. /**
  48228. * Interface used to define the options to use to create the Inspector
  48229. */
  48230. export interface IInspectorOptions {
  48231. /**
  48232. * Display in overlay mode (default: false)
  48233. */
  48234. overlay?: boolean;
  48235. /**
  48236. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48237. */
  48238. globalRoot?: HTMLElement;
  48239. /**
  48240. * Display the Scene explorer
  48241. */
  48242. showExplorer?: boolean;
  48243. /**
  48244. * Display the property inspector
  48245. */
  48246. showInspector?: boolean;
  48247. /**
  48248. * Display in embed mode (both panes on the right)
  48249. */
  48250. embedMode?: boolean;
  48251. /**
  48252. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48253. */
  48254. handleResize?: boolean;
  48255. /**
  48256. * Allow the panes to popup (default: true)
  48257. */
  48258. enablePopup?: boolean;
  48259. /**
  48260. * Allow the panes to be closed by users (default: true)
  48261. */
  48262. enableClose?: boolean;
  48263. /**
  48264. * Optional list of extensibility entries
  48265. */
  48266. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48267. /**
  48268. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48269. */
  48270. inspectorURL?: string;
  48271. /**
  48272. * Optional initial tab (default to DebugLayerTab.Properties)
  48273. */
  48274. initialTab?: DebugLayerTab;
  48275. }
  48276. module "babylonjs/scene" {
  48277. interface Scene {
  48278. /**
  48279. * @hidden
  48280. * Backing field
  48281. */
  48282. _debugLayer: DebugLayer;
  48283. /**
  48284. * Gets the debug layer (aka Inspector) associated with the scene
  48285. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48286. */
  48287. debugLayer: DebugLayer;
  48288. }
  48289. }
  48290. /**
  48291. * Enum of inspector action tab
  48292. */
  48293. export enum DebugLayerTab {
  48294. /**
  48295. * Properties tag (default)
  48296. */
  48297. Properties = 0,
  48298. /**
  48299. * Debug tab
  48300. */
  48301. Debug = 1,
  48302. /**
  48303. * Statistics tab
  48304. */
  48305. Statistics = 2,
  48306. /**
  48307. * Tools tab
  48308. */
  48309. Tools = 3,
  48310. /**
  48311. * Settings tab
  48312. */
  48313. Settings = 4
  48314. }
  48315. /**
  48316. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48317. * what is happening in your scene
  48318. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48319. */
  48320. export class DebugLayer {
  48321. /**
  48322. * Define the url to get the inspector script from.
  48323. * By default it uses the babylonjs CDN.
  48324. * @ignoreNaming
  48325. */
  48326. static InspectorURL: string;
  48327. private _scene;
  48328. private BJSINSPECTOR;
  48329. private _onPropertyChangedObservable?;
  48330. /**
  48331. * Observable triggered when a property is changed through the inspector.
  48332. */
  48333. get onPropertyChangedObservable(): any;
  48334. /**
  48335. * Instantiates a new debug layer.
  48336. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48337. * what is happening in your scene
  48338. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48339. * @param scene Defines the scene to inspect
  48340. */
  48341. constructor(scene: Scene);
  48342. /** Creates the inspector window. */
  48343. private _createInspector;
  48344. /**
  48345. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48346. * @param entity defines the entity to select
  48347. * @param lineContainerTitle defines the specific block to highlight
  48348. */
  48349. select(entity: any, lineContainerTitle?: string): void;
  48350. /** Get the inspector from bundle or global */
  48351. private _getGlobalInspector;
  48352. /**
  48353. * Get if the inspector is visible or not.
  48354. * @returns true if visible otherwise, false
  48355. */
  48356. isVisible(): boolean;
  48357. /**
  48358. * Hide the inspector and close its window.
  48359. */
  48360. hide(): void;
  48361. /**
  48362. * Launch the debugLayer.
  48363. * @param config Define the configuration of the inspector
  48364. * @return a promise fulfilled when the debug layer is visible
  48365. */
  48366. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48367. }
  48368. }
  48369. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48370. import { Nullable } from "babylonjs/types";
  48371. import { Scene } from "babylonjs/scene";
  48372. import { Vector4 } from "babylonjs/Maths/math.vector";
  48373. import { Color4 } from "babylonjs/Maths/math.color";
  48374. import { Mesh } from "babylonjs/Meshes/mesh";
  48375. /**
  48376. * Class containing static functions to help procedurally build meshes
  48377. */
  48378. export class BoxBuilder {
  48379. /**
  48380. * Creates a box mesh
  48381. * * The parameter `size` sets the size (float) of each box side (default 1)
  48382. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48383. * * 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)
  48384. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48388. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48389. * @param name defines the name of the mesh
  48390. * @param options defines the options used to create the mesh
  48391. * @param scene defines the hosting scene
  48392. * @returns the box mesh
  48393. */
  48394. static CreateBox(name: string, options: {
  48395. size?: number;
  48396. width?: number;
  48397. height?: number;
  48398. depth?: number;
  48399. faceUV?: Vector4[];
  48400. faceColors?: Color4[];
  48401. sideOrientation?: number;
  48402. frontUVs?: Vector4;
  48403. backUVs?: Vector4;
  48404. wrap?: boolean;
  48405. topBaseAt?: number;
  48406. bottomBaseAt?: number;
  48407. updatable?: boolean;
  48408. }, scene?: Nullable<Scene>): Mesh;
  48409. }
  48410. }
  48411. declare module "babylonjs/Debug/physicsViewer" {
  48412. import { Nullable } from "babylonjs/types";
  48413. import { Scene } from "babylonjs/scene";
  48414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48415. import { Mesh } from "babylonjs/Meshes/mesh";
  48416. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48417. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48418. /**
  48419. * Used to show the physics impostor around the specific mesh
  48420. */
  48421. export class PhysicsViewer {
  48422. /** @hidden */
  48423. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48424. /** @hidden */
  48425. protected _meshes: Array<Nullable<AbstractMesh>>;
  48426. /** @hidden */
  48427. protected _scene: Nullable<Scene>;
  48428. /** @hidden */
  48429. protected _numMeshes: number;
  48430. /** @hidden */
  48431. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48432. private _renderFunction;
  48433. private _utilityLayer;
  48434. private _debugBoxMesh;
  48435. private _debugSphereMesh;
  48436. private _debugCylinderMesh;
  48437. private _debugMaterial;
  48438. private _debugMeshMeshes;
  48439. /**
  48440. * Creates a new PhysicsViewer
  48441. * @param scene defines the hosting scene
  48442. */
  48443. constructor(scene: Scene);
  48444. /** @hidden */
  48445. protected _updateDebugMeshes(): void;
  48446. /**
  48447. * Renders a specified physic impostor
  48448. * @param impostor defines the impostor to render
  48449. * @param targetMesh defines the mesh represented by the impostor
  48450. * @returns the new debug mesh used to render the impostor
  48451. */
  48452. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48453. /**
  48454. * Hides a specified physic impostor
  48455. * @param impostor defines the impostor to hide
  48456. */
  48457. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48458. private _getDebugMaterial;
  48459. private _getDebugBoxMesh;
  48460. private _getDebugSphereMesh;
  48461. private _getDebugCylinderMesh;
  48462. private _getDebugMeshMesh;
  48463. private _getDebugMesh;
  48464. /** Releases all resources */
  48465. dispose(): void;
  48466. }
  48467. }
  48468. declare module "babylonjs/Debug/rayHelper" {
  48469. import { Nullable } from "babylonjs/types";
  48470. import { Ray } from "babylonjs/Culling/ray";
  48471. import { Vector3 } from "babylonjs/Maths/math.vector";
  48472. import { Color3 } from "babylonjs/Maths/math.color";
  48473. import { Scene } from "babylonjs/scene";
  48474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48475. import "babylonjs/Meshes/Builders/linesBuilder";
  48476. /**
  48477. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48478. * in order to better appreciate the issue one might have.
  48479. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48480. */
  48481. export class RayHelper {
  48482. /**
  48483. * Defines the ray we are currently tryin to visualize.
  48484. */
  48485. ray: Nullable<Ray>;
  48486. private _renderPoints;
  48487. private _renderLine;
  48488. private _renderFunction;
  48489. private _scene;
  48490. private _updateToMeshFunction;
  48491. private _attachedToMesh;
  48492. private _meshSpaceDirection;
  48493. private _meshSpaceOrigin;
  48494. /**
  48495. * Helper function to create a colored helper in a scene in one line.
  48496. * @param ray Defines the ray we are currently tryin to visualize
  48497. * @param scene Defines the scene the ray is used in
  48498. * @param color Defines the color we want to see the ray in
  48499. * @returns The newly created ray helper.
  48500. */
  48501. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48502. /**
  48503. * Instantiate a new ray helper.
  48504. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48505. * in order to better appreciate the issue one might have.
  48506. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48507. * @param ray Defines the ray we are currently tryin to visualize
  48508. */
  48509. constructor(ray: Ray);
  48510. /**
  48511. * Shows the ray we are willing to debug.
  48512. * @param scene Defines the scene the ray needs to be rendered in
  48513. * @param color Defines the color the ray needs to be rendered in
  48514. */
  48515. show(scene: Scene, color?: Color3): void;
  48516. /**
  48517. * Hides the ray we are debugging.
  48518. */
  48519. hide(): void;
  48520. private _render;
  48521. /**
  48522. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48523. * @param mesh Defines the mesh we want the helper attached to
  48524. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48525. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48526. * @param length Defines the length of the ray
  48527. */
  48528. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48529. /**
  48530. * Detach the ray helper from the mesh it has previously been attached to.
  48531. */
  48532. detachFromMesh(): void;
  48533. private _updateToMesh;
  48534. /**
  48535. * Dispose the helper and release its associated resources.
  48536. */
  48537. dispose(): void;
  48538. }
  48539. }
  48540. declare module "babylonjs/Debug/skeletonViewer" {
  48541. import { Color3 } from "babylonjs/Maths/math.color";
  48542. import { Scene } from "babylonjs/scene";
  48543. import { Nullable } from "babylonjs/types";
  48544. import { Skeleton } from "babylonjs/Bones/skeleton";
  48545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48546. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48547. /**
  48548. * Class used to render a debug view of a given skeleton
  48549. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48550. */
  48551. export class SkeletonViewer {
  48552. /** defines the skeleton to render */
  48553. skeleton: Skeleton;
  48554. /** defines the mesh attached to the skeleton */
  48555. mesh: AbstractMesh;
  48556. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48557. autoUpdateBonesMatrices: boolean;
  48558. /** defines the rendering group id to use with the viewer */
  48559. renderingGroupId: number;
  48560. /** Gets or sets the color used to render the skeleton */
  48561. color: Color3;
  48562. private _scene;
  48563. private _debugLines;
  48564. private _debugMesh;
  48565. private _isEnabled;
  48566. private _renderFunction;
  48567. private _utilityLayer;
  48568. /**
  48569. * Returns the mesh used to render the bones
  48570. */
  48571. get debugMesh(): Nullable<LinesMesh>;
  48572. /**
  48573. * Creates a new SkeletonViewer
  48574. * @param skeleton defines the skeleton to render
  48575. * @param mesh defines the mesh attached to the skeleton
  48576. * @param scene defines the hosting scene
  48577. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48578. * @param renderingGroupId defines the rendering group id to use with the viewer
  48579. */
  48580. constructor(
  48581. /** defines the skeleton to render */
  48582. skeleton: Skeleton,
  48583. /** defines the mesh attached to the skeleton */
  48584. mesh: AbstractMesh, scene: Scene,
  48585. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48586. autoUpdateBonesMatrices?: boolean,
  48587. /** defines the rendering group id to use with the viewer */
  48588. renderingGroupId?: number);
  48589. /** Gets or sets a boolean indicating if the viewer is enabled */
  48590. set isEnabled(value: boolean);
  48591. get isEnabled(): boolean;
  48592. private _getBonePosition;
  48593. private _getLinesForBonesWithLength;
  48594. private _getLinesForBonesNoLength;
  48595. /** Update the viewer to sync with current skeleton state */
  48596. update(): void;
  48597. /** Release associated resources */
  48598. dispose(): void;
  48599. }
  48600. }
  48601. declare module "babylonjs/Debug/index" {
  48602. export * from "babylonjs/Debug/axesViewer";
  48603. export * from "babylonjs/Debug/boneAxesViewer";
  48604. export * from "babylonjs/Debug/debugLayer";
  48605. export * from "babylonjs/Debug/physicsViewer";
  48606. export * from "babylonjs/Debug/rayHelper";
  48607. export * from "babylonjs/Debug/skeletonViewer";
  48608. }
  48609. declare module "babylonjs/Engines/nullEngine" {
  48610. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48611. import { Engine } from "babylonjs/Engines/engine";
  48612. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48613. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48614. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48615. import { Effect } from "babylonjs/Materials/effect";
  48616. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48617. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48618. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48619. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48620. /**
  48621. * Options to create the null engine
  48622. */
  48623. export class NullEngineOptions {
  48624. /**
  48625. * Render width (Default: 512)
  48626. */
  48627. renderWidth: number;
  48628. /**
  48629. * Render height (Default: 256)
  48630. */
  48631. renderHeight: number;
  48632. /**
  48633. * Texture size (Default: 512)
  48634. */
  48635. textureSize: number;
  48636. /**
  48637. * If delta time between frames should be constant
  48638. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48639. */
  48640. deterministicLockstep: boolean;
  48641. /**
  48642. * Maximum about of steps between frames (Default: 4)
  48643. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48644. */
  48645. lockstepMaxSteps: number;
  48646. }
  48647. /**
  48648. * The null engine class provides support for headless version of babylon.js.
  48649. * This can be used in server side scenario or for testing purposes
  48650. */
  48651. export class NullEngine extends Engine {
  48652. private _options;
  48653. /**
  48654. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48655. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48656. * @returns true if engine is in deterministic lock step mode
  48657. */
  48658. isDeterministicLockStep(): boolean;
  48659. /**
  48660. * Gets the max steps when engine is running in deterministic lock step
  48661. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48662. * @returns the max steps
  48663. */
  48664. getLockstepMaxSteps(): number;
  48665. /**
  48666. * Gets the current hardware scaling level.
  48667. * By default the hardware scaling level is computed from the window device ratio.
  48668. * 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.
  48669. * @returns a number indicating the current hardware scaling level
  48670. */
  48671. getHardwareScalingLevel(): number;
  48672. constructor(options?: NullEngineOptions);
  48673. /**
  48674. * Creates a vertex buffer
  48675. * @param vertices the data for the vertex buffer
  48676. * @returns the new WebGL static buffer
  48677. */
  48678. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48679. /**
  48680. * Creates a new index buffer
  48681. * @param indices defines the content of the index buffer
  48682. * @param updatable defines if the index buffer must be updatable
  48683. * @returns a new webGL buffer
  48684. */
  48685. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48686. /**
  48687. * Clear the current render buffer or the current render target (if any is set up)
  48688. * @param color defines the color to use
  48689. * @param backBuffer defines if the back buffer must be cleared
  48690. * @param depth defines if the depth buffer must be cleared
  48691. * @param stencil defines if the stencil buffer must be cleared
  48692. */
  48693. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48694. /**
  48695. * Gets the current render width
  48696. * @param useScreen defines if screen size must be used (or the current render target if any)
  48697. * @returns a number defining the current render width
  48698. */
  48699. getRenderWidth(useScreen?: boolean): number;
  48700. /**
  48701. * Gets the current render height
  48702. * @param useScreen defines if screen size must be used (or the current render target if any)
  48703. * @returns a number defining the current render height
  48704. */
  48705. getRenderHeight(useScreen?: boolean): number;
  48706. /**
  48707. * Set the WebGL's viewport
  48708. * @param viewport defines the viewport element to be used
  48709. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48710. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48711. */
  48712. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48713. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48714. /**
  48715. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48716. * @param pipelineContext defines the pipeline context to use
  48717. * @param uniformsNames defines the list of uniform names
  48718. * @returns an array of webGL uniform locations
  48719. */
  48720. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48721. /**
  48722. * Gets the lsit of active attributes for a given webGL program
  48723. * @param pipelineContext defines the pipeline context to use
  48724. * @param attributesNames defines the list of attribute names to get
  48725. * @returns an array of indices indicating the offset of each attribute
  48726. */
  48727. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48728. /**
  48729. * Binds an effect to the webGL context
  48730. * @param effect defines the effect to bind
  48731. */
  48732. bindSamplers(effect: Effect): void;
  48733. /**
  48734. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48735. * @param effect defines the effect to activate
  48736. */
  48737. enableEffect(effect: Effect): void;
  48738. /**
  48739. * Set various states to the webGL context
  48740. * @param culling defines backface culling state
  48741. * @param zOffset defines the value to apply to zOffset (0 by default)
  48742. * @param force defines if states must be applied even if cache is up to date
  48743. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48744. */
  48745. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48746. /**
  48747. * Set the value of an uniform to an array of int32
  48748. * @param uniform defines the webGL uniform location where to store the value
  48749. * @param array defines the array of int32 to store
  48750. */
  48751. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48752. /**
  48753. * Set the value of an uniform to an array of int32 (stored as vec2)
  48754. * @param uniform defines the webGL uniform location where to store the value
  48755. * @param array defines the array of int32 to store
  48756. */
  48757. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48758. /**
  48759. * Set the value of an uniform to an array of int32 (stored as vec3)
  48760. * @param uniform defines the webGL uniform location where to store the value
  48761. * @param array defines the array of int32 to store
  48762. */
  48763. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48764. /**
  48765. * Set the value of an uniform to an array of int32 (stored as vec4)
  48766. * @param uniform defines the webGL uniform location where to store the value
  48767. * @param array defines the array of int32 to store
  48768. */
  48769. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48770. /**
  48771. * Set the value of an uniform to an array of float32
  48772. * @param uniform defines the webGL uniform location where to store the value
  48773. * @param array defines the array of float32 to store
  48774. */
  48775. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48776. /**
  48777. * Set the value of an uniform to an array of float32 (stored as vec2)
  48778. * @param uniform defines the webGL uniform location where to store the value
  48779. * @param array defines the array of float32 to store
  48780. */
  48781. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48782. /**
  48783. * Set the value of an uniform to an array of float32 (stored as vec3)
  48784. * @param uniform defines the webGL uniform location where to store the value
  48785. * @param array defines the array of float32 to store
  48786. */
  48787. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48788. /**
  48789. * Set the value of an uniform to an array of float32 (stored as vec4)
  48790. * @param uniform defines the webGL uniform location where to store the value
  48791. * @param array defines the array of float32 to store
  48792. */
  48793. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48794. /**
  48795. * Set the value of an uniform to an array of number
  48796. * @param uniform defines the webGL uniform location where to store the value
  48797. * @param array defines the array of number to store
  48798. */
  48799. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48800. /**
  48801. * Set the value of an uniform to an array of number (stored as vec2)
  48802. * @param uniform defines the webGL uniform location where to store the value
  48803. * @param array defines the array of number to store
  48804. */
  48805. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48806. /**
  48807. * Set the value of an uniform to an array of number (stored as vec3)
  48808. * @param uniform defines the webGL uniform location where to store the value
  48809. * @param array defines the array of number to store
  48810. */
  48811. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48812. /**
  48813. * Set the value of an uniform to an array of number (stored as vec4)
  48814. * @param uniform defines the webGL uniform location where to store the value
  48815. * @param array defines the array of number to store
  48816. */
  48817. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48818. /**
  48819. * Set the value of an uniform to an array of float32 (stored as matrices)
  48820. * @param uniform defines the webGL uniform location where to store the value
  48821. * @param matrices defines the array of float32 to store
  48822. */
  48823. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48824. /**
  48825. * Set the value of an uniform to a matrix (3x3)
  48826. * @param uniform defines the webGL uniform location where to store the value
  48827. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48828. */
  48829. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48830. /**
  48831. * Set the value of an uniform to a matrix (2x2)
  48832. * @param uniform defines the webGL uniform location where to store the value
  48833. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48834. */
  48835. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48836. /**
  48837. * Set the value of an uniform to a number (float)
  48838. * @param uniform defines the webGL uniform location where to store the value
  48839. * @param value defines the float number to store
  48840. */
  48841. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48842. /**
  48843. * Set the value of an uniform to a vec2
  48844. * @param uniform defines the webGL uniform location where to store the value
  48845. * @param x defines the 1st component of the value
  48846. * @param y defines the 2nd component of the value
  48847. */
  48848. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48849. /**
  48850. * Set the value of an uniform to a vec3
  48851. * @param uniform defines the webGL uniform location where to store the value
  48852. * @param x defines the 1st component of the value
  48853. * @param y defines the 2nd component of the value
  48854. * @param z defines the 3rd component of the value
  48855. */
  48856. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48857. /**
  48858. * Set the value of an uniform to a boolean
  48859. * @param uniform defines the webGL uniform location where to store the value
  48860. * @param bool defines the boolean to store
  48861. */
  48862. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48863. /**
  48864. * Set the value of an uniform to a vec4
  48865. * @param uniform defines the webGL uniform location where to store the value
  48866. * @param x defines the 1st component of the value
  48867. * @param y defines the 2nd component of the value
  48868. * @param z defines the 3rd component of the value
  48869. * @param w defines the 4th component of the value
  48870. */
  48871. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48872. /**
  48873. * Sets the current alpha mode
  48874. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48875. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48876. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48877. */
  48878. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48879. /**
  48880. * Bind webGl buffers directly to the webGL context
  48881. * @param vertexBuffers defines the vertex buffer to bind
  48882. * @param indexBuffer defines the index buffer to bind
  48883. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48884. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48885. * @param effect defines the effect associated with the vertex buffer
  48886. */
  48887. bindBuffers(vertexBuffers: {
  48888. [key: string]: VertexBuffer;
  48889. }, indexBuffer: DataBuffer, effect: Effect): void;
  48890. /**
  48891. * Force the entire cache to be cleared
  48892. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48893. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48894. */
  48895. wipeCaches(bruteForce?: boolean): void;
  48896. /**
  48897. * Send a draw order
  48898. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48899. * @param indexStart defines the starting index
  48900. * @param indexCount defines the number of index to draw
  48901. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48902. */
  48903. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48904. /**
  48905. * Draw a list of indexed primitives
  48906. * @param fillMode defines the primitive to use
  48907. * @param indexStart defines the starting index
  48908. * @param indexCount defines the number of index to draw
  48909. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48910. */
  48911. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48912. /**
  48913. * Draw a list of unindexed primitives
  48914. * @param fillMode defines the primitive to use
  48915. * @param verticesStart defines the index of first vertex to draw
  48916. * @param verticesCount defines the count of vertices to draw
  48917. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48918. */
  48919. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48920. /** @hidden */
  48921. _createTexture(): WebGLTexture;
  48922. /** @hidden */
  48923. _releaseTexture(texture: InternalTexture): void;
  48924. /**
  48925. * Usually called from Texture.ts.
  48926. * Passed information to create a WebGLTexture
  48927. * @param urlArg defines a value which contains one of the following:
  48928. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48929. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48930. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48931. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48932. * @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)
  48933. * @param scene needed for loading to the correct scene
  48934. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48935. * @param onLoad optional callback to be called upon successful completion
  48936. * @param onError optional callback to be called upon failure
  48937. * @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
  48938. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48939. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48940. * @param forcedExtension defines the extension to use to pick the right loader
  48941. * @param mimeType defines an optional mime type
  48942. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48943. */
  48944. 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;
  48945. /**
  48946. * Creates a new render target texture
  48947. * @param size defines the size of the texture
  48948. * @param options defines the options used to create the texture
  48949. * @returns a new render target texture stored in an InternalTexture
  48950. */
  48951. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48952. /**
  48953. * Update the sampling mode of a given texture
  48954. * @param samplingMode defines the required sampling mode
  48955. * @param texture defines the texture to update
  48956. */
  48957. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48958. /**
  48959. * Binds the frame buffer to the specified texture.
  48960. * @param texture The texture to render to or null for the default canvas
  48961. * @param faceIndex The face of the texture to render to in case of cube texture
  48962. * @param requiredWidth The width of the target to render to
  48963. * @param requiredHeight The height of the target to render to
  48964. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48965. * @param lodLevel defines le lod level to bind to the frame buffer
  48966. */
  48967. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48968. /**
  48969. * Unbind the current render target texture from the webGL context
  48970. * @param texture defines the render target texture to unbind
  48971. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48972. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48973. */
  48974. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48975. /**
  48976. * Creates a dynamic vertex buffer
  48977. * @param vertices the data for the dynamic vertex buffer
  48978. * @returns the new WebGL dynamic buffer
  48979. */
  48980. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48981. /**
  48982. * Update the content of a dynamic texture
  48983. * @param texture defines the texture to update
  48984. * @param canvas defines the canvas containing the source
  48985. * @param invertY defines if data must be stored with Y axis inverted
  48986. * @param premulAlpha defines if alpha is stored as premultiplied
  48987. * @param format defines the format of the data
  48988. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48989. */
  48990. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48991. /**
  48992. * Gets a boolean indicating if all created effects are ready
  48993. * @returns true if all effects are ready
  48994. */
  48995. areAllEffectsReady(): boolean;
  48996. /**
  48997. * @hidden
  48998. * Get the current error code of the webGL context
  48999. * @returns the error code
  49000. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49001. */
  49002. getError(): number;
  49003. /** @hidden */
  49004. _getUnpackAlignement(): number;
  49005. /** @hidden */
  49006. _unpackFlipY(value: boolean): void;
  49007. /**
  49008. * Update a dynamic index buffer
  49009. * @param indexBuffer defines the target index buffer
  49010. * @param indices defines the data to update
  49011. * @param offset defines the offset in the target index buffer where update should start
  49012. */
  49013. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49014. /**
  49015. * Updates a dynamic vertex buffer.
  49016. * @param vertexBuffer the vertex buffer to update
  49017. * @param vertices the data used to update the vertex buffer
  49018. * @param byteOffset the byte offset of the data (optional)
  49019. * @param byteLength the byte length of the data (optional)
  49020. */
  49021. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49022. /** @hidden */
  49023. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49024. /** @hidden */
  49025. _bindTexture(channel: number, texture: InternalTexture): void;
  49026. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49027. /**
  49028. * 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
  49029. */
  49030. releaseEffects(): void;
  49031. displayLoadingUI(): void;
  49032. hideLoadingUI(): void;
  49033. /** @hidden */
  49034. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49035. /** @hidden */
  49036. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49037. /** @hidden */
  49038. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49039. /** @hidden */
  49040. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49041. }
  49042. }
  49043. declare module "babylonjs/Instrumentation/timeToken" {
  49044. import { Nullable } from "babylonjs/types";
  49045. /**
  49046. * @hidden
  49047. **/
  49048. export class _TimeToken {
  49049. _startTimeQuery: Nullable<WebGLQuery>;
  49050. _endTimeQuery: Nullable<WebGLQuery>;
  49051. _timeElapsedQuery: Nullable<WebGLQuery>;
  49052. _timeElapsedQueryEnded: boolean;
  49053. }
  49054. }
  49055. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49056. import { Nullable, int } from "babylonjs/types";
  49057. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49058. /** @hidden */
  49059. export class _OcclusionDataStorage {
  49060. /** @hidden */
  49061. occlusionInternalRetryCounter: number;
  49062. /** @hidden */
  49063. isOcclusionQueryInProgress: boolean;
  49064. /** @hidden */
  49065. isOccluded: boolean;
  49066. /** @hidden */
  49067. occlusionRetryCount: number;
  49068. /** @hidden */
  49069. occlusionType: number;
  49070. /** @hidden */
  49071. occlusionQueryAlgorithmType: number;
  49072. }
  49073. module "babylonjs/Engines/engine" {
  49074. interface Engine {
  49075. /**
  49076. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49077. * @return the new query
  49078. */
  49079. createQuery(): WebGLQuery;
  49080. /**
  49081. * Delete and release a webGL query
  49082. * @param query defines the query to delete
  49083. * @return the current engine
  49084. */
  49085. deleteQuery(query: WebGLQuery): Engine;
  49086. /**
  49087. * Check if a given query has resolved and got its value
  49088. * @param query defines the query to check
  49089. * @returns true if the query got its value
  49090. */
  49091. isQueryResultAvailable(query: WebGLQuery): boolean;
  49092. /**
  49093. * Gets the value of a given query
  49094. * @param query defines the query to check
  49095. * @returns the value of the query
  49096. */
  49097. getQueryResult(query: WebGLQuery): number;
  49098. /**
  49099. * Initiates an occlusion query
  49100. * @param algorithmType defines the algorithm to use
  49101. * @param query defines the query to use
  49102. * @returns the current engine
  49103. * @see http://doc.babylonjs.com/features/occlusionquery
  49104. */
  49105. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49106. /**
  49107. * Ends an occlusion query
  49108. * @see http://doc.babylonjs.com/features/occlusionquery
  49109. * @param algorithmType defines the algorithm to use
  49110. * @returns the current engine
  49111. */
  49112. endOcclusionQuery(algorithmType: number): Engine;
  49113. /**
  49114. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49115. * Please note that only one query can be issued at a time
  49116. * @returns a time token used to track the time span
  49117. */
  49118. startTimeQuery(): Nullable<_TimeToken>;
  49119. /**
  49120. * Ends a time query
  49121. * @param token defines the token used to measure the time span
  49122. * @returns the time spent (in ns)
  49123. */
  49124. endTimeQuery(token: _TimeToken): int;
  49125. /** @hidden */
  49126. _currentNonTimestampToken: Nullable<_TimeToken>;
  49127. /** @hidden */
  49128. _createTimeQuery(): WebGLQuery;
  49129. /** @hidden */
  49130. _deleteTimeQuery(query: WebGLQuery): void;
  49131. /** @hidden */
  49132. _getGlAlgorithmType(algorithmType: number): number;
  49133. /** @hidden */
  49134. _getTimeQueryResult(query: WebGLQuery): any;
  49135. /** @hidden */
  49136. _getTimeQueryAvailability(query: WebGLQuery): any;
  49137. }
  49138. }
  49139. module "babylonjs/Meshes/abstractMesh" {
  49140. interface AbstractMesh {
  49141. /**
  49142. * Backing filed
  49143. * @hidden
  49144. */
  49145. __occlusionDataStorage: _OcclusionDataStorage;
  49146. /**
  49147. * Access property
  49148. * @hidden
  49149. */
  49150. _occlusionDataStorage: _OcclusionDataStorage;
  49151. /**
  49152. * 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.
  49153. * The default value is -1 which means don't break the query and wait till the result
  49154. * @see http://doc.babylonjs.com/features/occlusionquery
  49155. */
  49156. occlusionRetryCount: number;
  49157. /**
  49158. * 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:
  49159. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49160. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49161. * * 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.
  49162. * @see http://doc.babylonjs.com/features/occlusionquery
  49163. */
  49164. occlusionType: number;
  49165. /**
  49166. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49167. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49168. * * 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.
  49169. * @see http://doc.babylonjs.com/features/occlusionquery
  49170. */
  49171. occlusionQueryAlgorithmType: number;
  49172. /**
  49173. * 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
  49174. * @see http://doc.babylonjs.com/features/occlusionquery
  49175. */
  49176. isOccluded: boolean;
  49177. /**
  49178. * Flag to check the progress status of the query
  49179. * @see http://doc.babylonjs.com/features/occlusionquery
  49180. */
  49181. isOcclusionQueryInProgress: boolean;
  49182. }
  49183. }
  49184. }
  49185. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49186. import { Nullable } from "babylonjs/types";
  49187. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49188. /** @hidden */
  49189. export var _forceTransformFeedbackToBundle: boolean;
  49190. module "babylonjs/Engines/engine" {
  49191. interface Engine {
  49192. /**
  49193. * Creates a webGL transform feedback object
  49194. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49195. * @returns the webGL transform feedback object
  49196. */
  49197. createTransformFeedback(): WebGLTransformFeedback;
  49198. /**
  49199. * Delete a webGL transform feedback object
  49200. * @param value defines the webGL transform feedback object to delete
  49201. */
  49202. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49203. /**
  49204. * Bind a webGL transform feedback object to the webgl context
  49205. * @param value defines the webGL transform feedback object to bind
  49206. */
  49207. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49208. /**
  49209. * Begins a transform feedback operation
  49210. * @param usePoints defines if points or triangles must be used
  49211. */
  49212. beginTransformFeedback(usePoints: boolean): void;
  49213. /**
  49214. * Ends a transform feedback operation
  49215. */
  49216. endTransformFeedback(): void;
  49217. /**
  49218. * Specify the varyings to use with transform feedback
  49219. * @param program defines the associated webGL program
  49220. * @param value defines the list of strings representing the varying names
  49221. */
  49222. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49223. /**
  49224. * Bind a webGL buffer for a transform feedback operation
  49225. * @param value defines the webGL buffer to bind
  49226. */
  49227. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49228. }
  49229. }
  49230. }
  49231. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49232. import { Scene } from "babylonjs/scene";
  49233. import { Engine } from "babylonjs/Engines/engine";
  49234. import { Texture } from "babylonjs/Materials/Textures/texture";
  49235. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49236. import "babylonjs/Engines/Extensions/engine.multiRender";
  49237. /**
  49238. * Creation options of the multi render target texture.
  49239. */
  49240. export interface IMultiRenderTargetOptions {
  49241. /**
  49242. * Define if the texture needs to create mip maps after render.
  49243. */
  49244. generateMipMaps?: boolean;
  49245. /**
  49246. * Define the types of all the draw buffers we want to create
  49247. */
  49248. types?: number[];
  49249. /**
  49250. * Define the sampling modes of all the draw buffers we want to create
  49251. */
  49252. samplingModes?: number[];
  49253. /**
  49254. * Define if a depth buffer is required
  49255. */
  49256. generateDepthBuffer?: boolean;
  49257. /**
  49258. * Define if a stencil buffer is required
  49259. */
  49260. generateStencilBuffer?: boolean;
  49261. /**
  49262. * Define if a depth texture is required instead of a depth buffer
  49263. */
  49264. generateDepthTexture?: boolean;
  49265. /**
  49266. * Define the number of desired draw buffers
  49267. */
  49268. textureCount?: number;
  49269. /**
  49270. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49271. */
  49272. doNotChangeAspectRatio?: boolean;
  49273. /**
  49274. * Define the default type of the buffers we are creating
  49275. */
  49276. defaultType?: number;
  49277. }
  49278. /**
  49279. * A multi render target, like a render target provides the ability to render to a texture.
  49280. * Unlike the render target, it can render to several draw buffers in one draw.
  49281. * This is specially interesting in deferred rendering or for any effects requiring more than
  49282. * just one color from a single pass.
  49283. */
  49284. export class MultiRenderTarget extends RenderTargetTexture {
  49285. private _internalTextures;
  49286. private _textures;
  49287. private _multiRenderTargetOptions;
  49288. /**
  49289. * Get if draw buffers are currently supported by the used hardware and browser.
  49290. */
  49291. get isSupported(): boolean;
  49292. /**
  49293. * Get the list of textures generated by the multi render target.
  49294. */
  49295. get textures(): Texture[];
  49296. /**
  49297. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49298. */
  49299. get depthTexture(): Texture;
  49300. /**
  49301. * Set the wrapping mode on U of all the textures we are rendering to.
  49302. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49303. */
  49304. set wrapU(wrap: number);
  49305. /**
  49306. * Set the wrapping mode on V of all the textures we are rendering to.
  49307. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49308. */
  49309. set wrapV(wrap: number);
  49310. /**
  49311. * Instantiate a new multi render target texture.
  49312. * A multi render target, like a render target provides the ability to render to a texture.
  49313. * Unlike the render target, it can render to several draw buffers in one draw.
  49314. * This is specially interesting in deferred rendering or for any effects requiring more than
  49315. * just one color from a single pass.
  49316. * @param name Define the name of the texture
  49317. * @param size Define the size of the buffers to render to
  49318. * @param count Define the number of target we are rendering into
  49319. * @param scene Define the scene the texture belongs to
  49320. * @param options Define the options used to create the multi render target
  49321. */
  49322. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49323. /** @hidden */
  49324. _rebuild(): void;
  49325. private _createInternalTextures;
  49326. private _createTextures;
  49327. /**
  49328. * Define the number of samples used if MSAA is enabled.
  49329. */
  49330. get samples(): number;
  49331. set samples(value: number);
  49332. /**
  49333. * Resize all the textures in the multi render target.
  49334. * Be carrefull as it will recreate all the data in the new texture.
  49335. * @param size Define the new size
  49336. */
  49337. resize(size: any): void;
  49338. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49339. /**
  49340. * Dispose the render targets and their associated resources
  49341. */
  49342. dispose(): void;
  49343. /**
  49344. * Release all the underlying texture used as draw buffers.
  49345. */
  49346. releaseInternalTextures(): void;
  49347. }
  49348. }
  49349. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49350. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49351. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49352. import { Nullable } from "babylonjs/types";
  49353. module "babylonjs/Engines/thinEngine" {
  49354. interface ThinEngine {
  49355. /**
  49356. * Unbind a list of render target textures from the webGL context
  49357. * This is used only when drawBuffer extension or webGL2 are active
  49358. * @param textures defines the render target textures to unbind
  49359. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49360. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49361. */
  49362. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49363. /**
  49364. * Create a multi render target texture
  49365. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49366. * @param size defines the size of the texture
  49367. * @param options defines the creation options
  49368. * @returns the cube texture as an InternalTexture
  49369. */
  49370. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49371. /**
  49372. * Update the sample count for a given multiple render target texture
  49373. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49374. * @param textures defines the textures to update
  49375. * @param samples defines the sample count to set
  49376. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49377. */
  49378. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49379. }
  49380. }
  49381. }
  49382. declare module "babylonjs/Engines/Extensions/engine.views" {
  49383. import { Camera } from "babylonjs/Cameras/camera";
  49384. import { Nullable } from "babylonjs/types";
  49385. /**
  49386. * Class used to define an additional view for the engine
  49387. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49388. */
  49389. export class EngineView {
  49390. /** Defines the canvas where to render the view */
  49391. target: HTMLCanvasElement;
  49392. /** Defines an optional camera used to render the view (will use active camera else) */
  49393. camera?: Camera;
  49394. }
  49395. module "babylonjs/Engines/engine" {
  49396. interface Engine {
  49397. /**
  49398. * Gets or sets the HTML element to use for attaching events
  49399. */
  49400. inputElement: Nullable<HTMLElement>;
  49401. /**
  49402. * Gets the current engine view
  49403. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49404. */
  49405. activeView: Nullable<EngineView>;
  49406. /** Gets or sets the list of views */
  49407. views: EngineView[];
  49408. /**
  49409. * Register a new child canvas
  49410. * @param canvas defines the canvas to register
  49411. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49412. * @returns the associated view
  49413. */
  49414. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49415. /**
  49416. * Remove a registered child canvas
  49417. * @param canvas defines the canvas to remove
  49418. * @returns the current engine
  49419. */
  49420. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49421. }
  49422. }
  49423. }
  49424. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49425. import { Nullable } from "babylonjs/types";
  49426. module "babylonjs/Engines/engine" {
  49427. interface Engine {
  49428. /** @hidden */
  49429. _excludedCompressedTextures: string[];
  49430. /** @hidden */
  49431. _textureFormatInUse: string;
  49432. /**
  49433. * Gets the list of texture formats supported
  49434. */
  49435. readonly texturesSupported: Array<string>;
  49436. /**
  49437. * Gets the texture format in use
  49438. */
  49439. readonly textureFormatInUse: Nullable<string>;
  49440. /**
  49441. * Set the compressed texture extensions or file names to skip.
  49442. *
  49443. * @param skippedFiles defines the list of those texture files you want to skip
  49444. * Example: [".dds", ".env", "myfile.png"]
  49445. */
  49446. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49447. /**
  49448. * Set the compressed texture format to use, based on the formats you have, and the formats
  49449. * supported by the hardware / browser.
  49450. *
  49451. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49452. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49453. * to API arguments needed to compressed textures. This puts the burden on the container
  49454. * generator to house the arcane code for determining these for current & future formats.
  49455. *
  49456. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49457. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49458. *
  49459. * Note: The result of this call is not taken into account when a texture is base64.
  49460. *
  49461. * @param formatsAvailable defines the list of those format families you have created
  49462. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49463. *
  49464. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49465. * @returns The extension selected.
  49466. */
  49467. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49468. }
  49469. }
  49470. }
  49471. declare module "babylonjs/Engines/Extensions/index" {
  49472. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49473. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49474. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49475. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49476. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49477. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49478. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49479. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49480. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49481. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49482. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49483. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49484. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49485. export * from "babylonjs/Engines/Extensions/engine.views";
  49486. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49487. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49488. }
  49489. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49490. import { Nullable } from "babylonjs/types";
  49491. /**
  49492. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49493. */
  49494. export interface CubeMapInfo {
  49495. /**
  49496. * The pixel array for the front face.
  49497. * This is stored in format, left to right, up to down format.
  49498. */
  49499. front: Nullable<ArrayBufferView>;
  49500. /**
  49501. * The pixel array for the back face.
  49502. * This is stored in format, left to right, up to down format.
  49503. */
  49504. back: Nullable<ArrayBufferView>;
  49505. /**
  49506. * The pixel array for the left face.
  49507. * This is stored in format, left to right, up to down format.
  49508. */
  49509. left: Nullable<ArrayBufferView>;
  49510. /**
  49511. * The pixel array for the right face.
  49512. * This is stored in format, left to right, up to down format.
  49513. */
  49514. right: Nullable<ArrayBufferView>;
  49515. /**
  49516. * The pixel array for the up face.
  49517. * This is stored in format, left to right, up to down format.
  49518. */
  49519. up: Nullable<ArrayBufferView>;
  49520. /**
  49521. * The pixel array for the down face.
  49522. * This is stored in format, left to right, up to down format.
  49523. */
  49524. down: Nullable<ArrayBufferView>;
  49525. /**
  49526. * The size of the cubemap stored.
  49527. *
  49528. * Each faces will be size * size pixels.
  49529. */
  49530. size: number;
  49531. /**
  49532. * The format of the texture.
  49533. *
  49534. * RGBA, RGB.
  49535. */
  49536. format: number;
  49537. /**
  49538. * The type of the texture data.
  49539. *
  49540. * UNSIGNED_INT, FLOAT.
  49541. */
  49542. type: number;
  49543. /**
  49544. * Specifies whether the texture is in gamma space.
  49545. */
  49546. gammaSpace: boolean;
  49547. }
  49548. /**
  49549. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49550. */
  49551. export class PanoramaToCubeMapTools {
  49552. private static FACE_FRONT;
  49553. private static FACE_BACK;
  49554. private static FACE_RIGHT;
  49555. private static FACE_LEFT;
  49556. private static FACE_DOWN;
  49557. private static FACE_UP;
  49558. /**
  49559. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49560. *
  49561. * @param float32Array The source data.
  49562. * @param inputWidth The width of the input panorama.
  49563. * @param inputHeight The height of the input panorama.
  49564. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49565. * @return The cubemap data
  49566. */
  49567. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49568. private static CreateCubemapTexture;
  49569. private static CalcProjectionSpherical;
  49570. }
  49571. }
  49572. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49573. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49574. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49575. import { Nullable } from "babylonjs/types";
  49576. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49577. /**
  49578. * Helper class dealing with the extraction of spherical polynomial dataArray
  49579. * from a cube map.
  49580. */
  49581. export class CubeMapToSphericalPolynomialTools {
  49582. private static FileFaces;
  49583. /**
  49584. * Converts a texture to the according Spherical Polynomial data.
  49585. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49586. *
  49587. * @param texture The texture to extract the information from.
  49588. * @return The Spherical Polynomial data.
  49589. */
  49590. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49591. /**
  49592. * Converts a cubemap to the according Spherical Polynomial data.
  49593. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49594. *
  49595. * @param cubeInfo The Cube map to extract the information from.
  49596. * @return The Spherical Polynomial data.
  49597. */
  49598. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49599. }
  49600. }
  49601. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49602. import { Nullable } from "babylonjs/types";
  49603. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49604. module "babylonjs/Materials/Textures/baseTexture" {
  49605. interface BaseTexture {
  49606. /**
  49607. * Get the polynomial representation of the texture data.
  49608. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49609. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49610. */
  49611. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49612. }
  49613. }
  49614. }
  49615. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49616. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49617. /** @hidden */
  49618. export var rgbdEncodePixelShader: {
  49619. name: string;
  49620. shader: string;
  49621. };
  49622. }
  49623. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49624. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49625. /** @hidden */
  49626. export var rgbdDecodePixelShader: {
  49627. name: string;
  49628. shader: string;
  49629. };
  49630. }
  49631. declare module "babylonjs/Misc/environmentTextureTools" {
  49632. import { Nullable } from "babylonjs/types";
  49633. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49635. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49636. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49637. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49638. import "babylonjs/Shaders/rgbdEncode.fragment";
  49639. import "babylonjs/Shaders/rgbdDecode.fragment";
  49640. /**
  49641. * Raw texture data and descriptor sufficient for WebGL texture upload
  49642. */
  49643. export interface EnvironmentTextureInfo {
  49644. /**
  49645. * Version of the environment map
  49646. */
  49647. version: number;
  49648. /**
  49649. * Width of image
  49650. */
  49651. width: number;
  49652. /**
  49653. * Irradiance information stored in the file.
  49654. */
  49655. irradiance: any;
  49656. /**
  49657. * Specular information stored in the file.
  49658. */
  49659. specular: any;
  49660. }
  49661. /**
  49662. * Defines One Image in the file. It requires only the position in the file
  49663. * as well as the length.
  49664. */
  49665. interface BufferImageData {
  49666. /**
  49667. * Length of the image data.
  49668. */
  49669. length: number;
  49670. /**
  49671. * Position of the data from the null terminator delimiting the end of the JSON.
  49672. */
  49673. position: number;
  49674. }
  49675. /**
  49676. * Defines the specular data enclosed in the file.
  49677. * This corresponds to the version 1 of the data.
  49678. */
  49679. export interface EnvironmentTextureSpecularInfoV1 {
  49680. /**
  49681. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49682. */
  49683. specularDataPosition?: number;
  49684. /**
  49685. * This contains all the images data needed to reconstruct the cubemap.
  49686. */
  49687. mipmaps: Array<BufferImageData>;
  49688. /**
  49689. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49690. */
  49691. lodGenerationScale: number;
  49692. }
  49693. /**
  49694. * Sets of helpers addressing the serialization and deserialization of environment texture
  49695. * stored in a BabylonJS env file.
  49696. * Those files are usually stored as .env files.
  49697. */
  49698. export class EnvironmentTextureTools {
  49699. /**
  49700. * Magic number identifying the env file.
  49701. */
  49702. private static _MagicBytes;
  49703. /**
  49704. * Gets the environment info from an env file.
  49705. * @param data The array buffer containing the .env bytes.
  49706. * @returns the environment file info (the json header) if successfully parsed.
  49707. */
  49708. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49709. /**
  49710. * Creates an environment texture from a loaded cube texture.
  49711. * @param texture defines the cube texture to convert in env file
  49712. * @return a promise containing the environment data if succesfull.
  49713. */
  49714. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49715. /**
  49716. * Creates a JSON representation of the spherical data.
  49717. * @param texture defines the texture containing the polynomials
  49718. * @return the JSON representation of the spherical info
  49719. */
  49720. private static _CreateEnvTextureIrradiance;
  49721. /**
  49722. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49723. * @param data the image data
  49724. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49725. * @return the views described by info providing access to the underlying buffer
  49726. */
  49727. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49728. /**
  49729. * Uploads the texture info contained in the env file to the GPU.
  49730. * @param texture defines the internal texture to upload to
  49731. * @param data defines the data to load
  49732. * @param info defines the texture info retrieved through the GetEnvInfo method
  49733. * @returns a promise
  49734. */
  49735. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49736. private static _OnImageReadyAsync;
  49737. /**
  49738. * Uploads the levels of image data to the GPU.
  49739. * @param texture defines the internal texture to upload to
  49740. * @param imageData defines the array buffer views of image data [mipmap][face]
  49741. * @returns a promise
  49742. */
  49743. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49744. /**
  49745. * Uploads spherical polynomials information to the texture.
  49746. * @param texture defines the texture we are trying to upload the information to
  49747. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49748. */
  49749. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49750. /** @hidden */
  49751. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49752. }
  49753. }
  49754. declare module "babylonjs/Maths/math.vertexFormat" {
  49755. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49756. /**
  49757. * Contains position and normal vectors for a vertex
  49758. */
  49759. export class PositionNormalVertex {
  49760. /** the position of the vertex (defaut: 0,0,0) */
  49761. position: Vector3;
  49762. /** the normal of the vertex (defaut: 0,1,0) */
  49763. normal: Vector3;
  49764. /**
  49765. * Creates a PositionNormalVertex
  49766. * @param position the position of the vertex (defaut: 0,0,0)
  49767. * @param normal the normal of the vertex (defaut: 0,1,0)
  49768. */
  49769. constructor(
  49770. /** the position of the vertex (defaut: 0,0,0) */
  49771. position?: Vector3,
  49772. /** the normal of the vertex (defaut: 0,1,0) */
  49773. normal?: Vector3);
  49774. /**
  49775. * Clones the PositionNormalVertex
  49776. * @returns the cloned PositionNormalVertex
  49777. */
  49778. clone(): PositionNormalVertex;
  49779. }
  49780. /**
  49781. * Contains position, normal and uv vectors for a vertex
  49782. */
  49783. export class PositionNormalTextureVertex {
  49784. /** the position of the vertex (defaut: 0,0,0) */
  49785. position: Vector3;
  49786. /** the normal of the vertex (defaut: 0,1,0) */
  49787. normal: Vector3;
  49788. /** the uv of the vertex (default: 0,0) */
  49789. uv: Vector2;
  49790. /**
  49791. * Creates a PositionNormalTextureVertex
  49792. * @param position the position of the vertex (defaut: 0,0,0)
  49793. * @param normal the normal of the vertex (defaut: 0,1,0)
  49794. * @param uv the uv of the vertex (default: 0,0)
  49795. */
  49796. constructor(
  49797. /** the position of the vertex (defaut: 0,0,0) */
  49798. position?: Vector3,
  49799. /** the normal of the vertex (defaut: 0,1,0) */
  49800. normal?: Vector3,
  49801. /** the uv of the vertex (default: 0,0) */
  49802. uv?: Vector2);
  49803. /**
  49804. * Clones the PositionNormalTextureVertex
  49805. * @returns the cloned PositionNormalTextureVertex
  49806. */
  49807. clone(): PositionNormalTextureVertex;
  49808. }
  49809. }
  49810. declare module "babylonjs/Maths/math" {
  49811. export * from "babylonjs/Maths/math.axis";
  49812. export * from "babylonjs/Maths/math.color";
  49813. export * from "babylonjs/Maths/math.constants";
  49814. export * from "babylonjs/Maths/math.frustum";
  49815. export * from "babylonjs/Maths/math.path";
  49816. export * from "babylonjs/Maths/math.plane";
  49817. export * from "babylonjs/Maths/math.size";
  49818. export * from "babylonjs/Maths/math.vector";
  49819. export * from "babylonjs/Maths/math.vertexFormat";
  49820. export * from "babylonjs/Maths/math.viewport";
  49821. }
  49822. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49823. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49824. /** @hidden */
  49825. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49826. private _genericAttributeLocation;
  49827. private _varyingLocationCount;
  49828. private _varyingLocationMap;
  49829. private _replacements;
  49830. private _textureCount;
  49831. private _uniforms;
  49832. lineProcessor(line: string): string;
  49833. attributeProcessor(attribute: string): string;
  49834. varyingProcessor(varying: string, isFragment: boolean): string;
  49835. uniformProcessor(uniform: string): string;
  49836. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49837. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49838. }
  49839. }
  49840. declare module "babylonjs/Engines/nativeEngine" {
  49841. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49842. import { Engine } from "babylonjs/Engines/engine";
  49843. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49844. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49845. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49846. import { Effect } from "babylonjs/Materials/effect";
  49847. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49848. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49849. import { IColor4Like } from "babylonjs/Maths/math.like";
  49850. import { Scene } from "babylonjs/scene";
  49851. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49852. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49853. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49854. /**
  49855. * Container for accessors for natively-stored mesh data buffers.
  49856. */
  49857. class NativeDataBuffer extends DataBuffer {
  49858. /**
  49859. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49860. */
  49861. nativeIndexBuffer?: any;
  49862. /**
  49863. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49864. */
  49865. nativeVertexBuffer?: any;
  49866. }
  49867. /** @hidden */
  49868. class NativeTexture extends InternalTexture {
  49869. getInternalTexture(): InternalTexture;
  49870. getViewCount(): number;
  49871. }
  49872. /** @hidden */
  49873. export class NativeEngine extends Engine {
  49874. private readonly _native;
  49875. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49876. private readonly INVALID_HANDLE;
  49877. getHardwareScalingLevel(): number;
  49878. constructor();
  49879. /**
  49880. * Can be used to override the current requestAnimationFrame requester.
  49881. * @hidden
  49882. */
  49883. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49884. /**
  49885. * Override default engine behavior.
  49886. * @param color
  49887. * @param backBuffer
  49888. * @param depth
  49889. * @param stencil
  49890. */
  49891. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49892. /**
  49893. * Gets host document
  49894. * @returns the host document object
  49895. */
  49896. getHostDocument(): Nullable<Document>;
  49897. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49898. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49899. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49900. recordVertexArrayObject(vertexBuffers: {
  49901. [key: string]: VertexBuffer;
  49902. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49903. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49904. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49905. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49906. /**
  49907. * Draw a list of indexed primitives
  49908. * @param fillMode defines the primitive to use
  49909. * @param indexStart defines the starting index
  49910. * @param indexCount defines the number of index to draw
  49911. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49912. */
  49913. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49914. /**
  49915. * Draw a list of unindexed primitives
  49916. * @param fillMode defines the primitive to use
  49917. * @param verticesStart defines the index of first vertex to draw
  49918. * @param verticesCount defines the count of vertices to draw
  49919. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49920. */
  49921. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49922. createPipelineContext(): IPipelineContext;
  49923. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49924. /** @hidden */
  49925. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49926. /** @hidden */
  49927. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49928. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49929. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49930. protected _setProgram(program: WebGLProgram): void;
  49931. _releaseEffect(effect: Effect): void;
  49932. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49933. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49934. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49935. bindSamplers(effect: Effect): void;
  49936. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49937. getRenderWidth(useScreen?: boolean): number;
  49938. getRenderHeight(useScreen?: boolean): number;
  49939. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49940. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49941. /**
  49942. * Set the z offset to apply to current rendering
  49943. * @param value defines the offset to apply
  49944. */
  49945. setZOffset(value: number): void;
  49946. /**
  49947. * Gets the current value of the zOffset
  49948. * @returns the current zOffset state
  49949. */
  49950. getZOffset(): number;
  49951. /**
  49952. * Enable or disable depth buffering
  49953. * @param enable defines the state to set
  49954. */
  49955. setDepthBuffer(enable: boolean): void;
  49956. /**
  49957. * Gets a boolean indicating if depth writing is enabled
  49958. * @returns the current depth writing state
  49959. */
  49960. getDepthWrite(): boolean;
  49961. /**
  49962. * Enable or disable depth writing
  49963. * @param enable defines the state to set
  49964. */
  49965. setDepthWrite(enable: boolean): void;
  49966. /**
  49967. * Enable or disable color writing
  49968. * @param enable defines the state to set
  49969. */
  49970. setColorWrite(enable: boolean): void;
  49971. /**
  49972. * Gets a boolean indicating if color writing is enabled
  49973. * @returns the current color writing state
  49974. */
  49975. getColorWrite(): boolean;
  49976. /**
  49977. * Sets alpha constants used by some alpha blending modes
  49978. * @param r defines the red component
  49979. * @param g defines the green component
  49980. * @param b defines the blue component
  49981. * @param a defines the alpha component
  49982. */
  49983. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49984. /**
  49985. * Sets the current alpha mode
  49986. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49987. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49988. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49989. */
  49990. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49991. /**
  49992. * Gets the current alpha mode
  49993. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49994. * @returns the current alpha mode
  49995. */
  49996. getAlphaMode(): number;
  49997. setInt(uniform: WebGLUniformLocation, int: number): void;
  49998. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49999. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50000. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50001. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50002. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50003. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50004. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50005. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50006. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50007. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50008. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50009. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50010. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50011. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50012. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50013. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50014. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50015. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50016. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50017. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50018. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50019. wipeCaches(bruteForce?: boolean): void;
  50020. _createTexture(): WebGLTexture;
  50021. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50022. /**
  50023. * Usually called from Texture.ts.
  50024. * Passed information to create a WebGLTexture
  50025. * @param urlArg defines a value which contains one of the following:
  50026. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50027. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50028. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50029. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50030. * @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)
  50031. * @param scene needed for loading to the correct scene
  50032. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50033. * @param onLoad optional callback to be called upon successful completion
  50034. * @param onError optional callback to be called upon failure
  50035. * @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
  50036. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50037. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50038. * @param forcedExtension defines the extension to use to pick the right loader
  50039. * @param mimeType defines an optional mime type
  50040. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50041. */
  50042. 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;
  50043. /**
  50044. * Creates a cube texture
  50045. * @param rootUrl defines the url where the files to load is located
  50046. * @param scene defines the current scene
  50047. * @param files defines the list of files to load (1 per face)
  50048. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50049. * @param onLoad defines an optional callback raised when the texture is loaded
  50050. * @param onError defines an optional callback raised if there is an issue to load the texture
  50051. * @param format defines the format of the data
  50052. * @param forcedExtension defines the extension to use to pick the right loader
  50053. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50054. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50055. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50056. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50057. * @returns the cube texture as an InternalTexture
  50058. */
  50059. 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;
  50060. private _getSamplingFilter;
  50061. private static _GetNativeTextureFormat;
  50062. createRenderTargetTexture(size: number | {
  50063. width: number;
  50064. height: number;
  50065. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50066. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50067. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50068. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50069. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50070. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50071. /**
  50072. * Updates a dynamic vertex buffer.
  50073. * @param vertexBuffer the vertex buffer to update
  50074. * @param data the data used to update the vertex buffer
  50075. * @param byteOffset the byte offset of the data (optional)
  50076. * @param byteLength the byte length of the data (optional)
  50077. */
  50078. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50079. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50080. private _updateAnisotropicLevel;
  50081. private _getAddressMode;
  50082. /** @hidden */
  50083. _bindTexture(channel: number, texture: InternalTexture): void;
  50084. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50085. releaseEffects(): void;
  50086. /** @hidden */
  50087. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50088. /** @hidden */
  50089. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50090. /** @hidden */
  50091. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50092. /** @hidden */
  50093. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50094. }
  50095. }
  50096. declare module "babylonjs/Engines/index" {
  50097. export * from "babylonjs/Engines/constants";
  50098. export * from "babylonjs/Engines/engineCapabilities";
  50099. export * from "babylonjs/Engines/instancingAttributeInfo";
  50100. export * from "babylonjs/Engines/thinEngine";
  50101. export * from "babylonjs/Engines/engine";
  50102. export * from "babylonjs/Engines/engineStore";
  50103. export * from "babylonjs/Engines/nullEngine";
  50104. export * from "babylonjs/Engines/Extensions/index";
  50105. export * from "babylonjs/Engines/IPipelineContext";
  50106. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50107. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50108. export * from "babylonjs/Engines/nativeEngine";
  50109. }
  50110. declare module "babylonjs/Events/clipboardEvents" {
  50111. /**
  50112. * Gather the list of clipboard event types as constants.
  50113. */
  50114. export class ClipboardEventTypes {
  50115. /**
  50116. * The clipboard event is fired when a copy command is active (pressed).
  50117. */
  50118. static readonly COPY: number;
  50119. /**
  50120. * The clipboard event is fired when a cut command is active (pressed).
  50121. */
  50122. static readonly CUT: number;
  50123. /**
  50124. * The clipboard event is fired when a paste command is active (pressed).
  50125. */
  50126. static readonly PASTE: number;
  50127. }
  50128. /**
  50129. * This class is used to store clipboard related info for the onClipboardObservable event.
  50130. */
  50131. export class ClipboardInfo {
  50132. /**
  50133. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50134. */
  50135. type: number;
  50136. /**
  50137. * Defines the related dom event
  50138. */
  50139. event: ClipboardEvent;
  50140. /**
  50141. *Creates an instance of ClipboardInfo.
  50142. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50143. * @param event Defines the related dom event
  50144. */
  50145. constructor(
  50146. /**
  50147. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50148. */
  50149. type: number,
  50150. /**
  50151. * Defines the related dom event
  50152. */
  50153. event: ClipboardEvent);
  50154. /**
  50155. * Get the clipboard event's type from the keycode.
  50156. * @param keyCode Defines the keyCode for the current keyboard event.
  50157. * @return {number}
  50158. */
  50159. static GetTypeFromCharacter(keyCode: number): number;
  50160. }
  50161. }
  50162. declare module "babylonjs/Events/index" {
  50163. export * from "babylonjs/Events/keyboardEvents";
  50164. export * from "babylonjs/Events/pointerEvents";
  50165. export * from "babylonjs/Events/clipboardEvents";
  50166. }
  50167. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50168. import { Scene } from "babylonjs/scene";
  50169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50170. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50171. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50172. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50173. /**
  50174. * Google Daydream controller
  50175. */
  50176. export class DaydreamController extends WebVRController {
  50177. /**
  50178. * Base Url for the controller model.
  50179. */
  50180. static MODEL_BASE_URL: string;
  50181. /**
  50182. * File name for the controller model.
  50183. */
  50184. static MODEL_FILENAME: string;
  50185. /**
  50186. * Gamepad Id prefix used to identify Daydream Controller.
  50187. */
  50188. static readonly GAMEPAD_ID_PREFIX: string;
  50189. /**
  50190. * Creates a new DaydreamController from a gamepad
  50191. * @param vrGamepad the gamepad that the controller should be created from
  50192. */
  50193. constructor(vrGamepad: any);
  50194. /**
  50195. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50196. * @param scene scene in which to add meshes
  50197. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50198. */
  50199. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50200. /**
  50201. * Called once for each button that changed state since the last frame
  50202. * @param buttonIdx Which button index changed
  50203. * @param state New state of the button
  50204. * @param changes Which properties on the state changed since last frame
  50205. */
  50206. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50207. }
  50208. }
  50209. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50210. import { Scene } from "babylonjs/scene";
  50211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50212. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50213. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50214. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50215. /**
  50216. * Gear VR Controller
  50217. */
  50218. export class GearVRController extends WebVRController {
  50219. /**
  50220. * Base Url for the controller model.
  50221. */
  50222. static MODEL_BASE_URL: string;
  50223. /**
  50224. * File name for the controller model.
  50225. */
  50226. static MODEL_FILENAME: string;
  50227. /**
  50228. * Gamepad Id prefix used to identify this controller.
  50229. */
  50230. static readonly GAMEPAD_ID_PREFIX: string;
  50231. private readonly _buttonIndexToObservableNameMap;
  50232. /**
  50233. * Creates a new GearVRController from a gamepad
  50234. * @param vrGamepad the gamepad that the controller should be created from
  50235. */
  50236. constructor(vrGamepad: any);
  50237. /**
  50238. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50239. * @param scene scene in which to add meshes
  50240. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50241. */
  50242. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50243. /**
  50244. * Called once for each button that changed state since the last frame
  50245. * @param buttonIdx Which button index changed
  50246. * @param state New state of the button
  50247. * @param changes Which properties on the state changed since last frame
  50248. */
  50249. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50250. }
  50251. }
  50252. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50253. import { Scene } from "babylonjs/scene";
  50254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50255. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50256. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50257. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50258. /**
  50259. * Generic Controller
  50260. */
  50261. export class GenericController extends WebVRController {
  50262. /**
  50263. * Base Url for the controller model.
  50264. */
  50265. static readonly MODEL_BASE_URL: string;
  50266. /**
  50267. * File name for the controller model.
  50268. */
  50269. static readonly MODEL_FILENAME: string;
  50270. /**
  50271. * Creates a new GenericController from a gamepad
  50272. * @param vrGamepad the gamepad that the controller should be created from
  50273. */
  50274. constructor(vrGamepad: any);
  50275. /**
  50276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50277. * @param scene scene in which to add meshes
  50278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50279. */
  50280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50281. /**
  50282. * Called once for each button that changed state since the last frame
  50283. * @param buttonIdx Which button index changed
  50284. * @param state New state of the button
  50285. * @param changes Which properties on the state changed since last frame
  50286. */
  50287. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50288. }
  50289. }
  50290. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50291. import { Observable } from "babylonjs/Misc/observable";
  50292. import { Scene } from "babylonjs/scene";
  50293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50294. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50295. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50296. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50297. /**
  50298. * Oculus Touch Controller
  50299. */
  50300. export class OculusTouchController extends WebVRController {
  50301. /**
  50302. * Base Url for the controller model.
  50303. */
  50304. static MODEL_BASE_URL: string;
  50305. /**
  50306. * File name for the left controller model.
  50307. */
  50308. static MODEL_LEFT_FILENAME: string;
  50309. /**
  50310. * File name for the right controller model.
  50311. */
  50312. static MODEL_RIGHT_FILENAME: string;
  50313. /**
  50314. * Base Url for the Quest controller model.
  50315. */
  50316. static QUEST_MODEL_BASE_URL: string;
  50317. /**
  50318. * @hidden
  50319. * If the controllers are running on a device that needs the updated Quest controller models
  50320. */
  50321. static _IsQuest: boolean;
  50322. /**
  50323. * Fired when the secondary trigger on this controller is modified
  50324. */
  50325. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50326. /**
  50327. * Fired when the thumb rest on this controller is modified
  50328. */
  50329. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50330. /**
  50331. * Creates a new OculusTouchController from a gamepad
  50332. * @param vrGamepad the gamepad that the controller should be created from
  50333. */
  50334. constructor(vrGamepad: any);
  50335. /**
  50336. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50337. * @param scene scene in which to add meshes
  50338. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50339. */
  50340. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50341. /**
  50342. * Fired when the A button on this controller is modified
  50343. */
  50344. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50345. /**
  50346. * Fired when the B button on this controller is modified
  50347. */
  50348. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50349. /**
  50350. * Fired when the X button on this controller is modified
  50351. */
  50352. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50353. /**
  50354. * Fired when the Y button on this controller is modified
  50355. */
  50356. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50357. /**
  50358. * Called once for each button that changed state since the last frame
  50359. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50360. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50361. * 2) secondary trigger (same)
  50362. * 3) A (right) X (left), touch, pressed = value
  50363. * 4) B / Y
  50364. * 5) thumb rest
  50365. * @param buttonIdx Which button index changed
  50366. * @param state New state of the button
  50367. * @param changes Which properties on the state changed since last frame
  50368. */
  50369. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50370. }
  50371. }
  50372. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50373. import { Scene } from "babylonjs/scene";
  50374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50375. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50376. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50377. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50378. import { Observable } from "babylonjs/Misc/observable";
  50379. /**
  50380. * Vive Controller
  50381. */
  50382. export class ViveController extends WebVRController {
  50383. /**
  50384. * Base Url for the controller model.
  50385. */
  50386. static MODEL_BASE_URL: string;
  50387. /**
  50388. * File name for the controller model.
  50389. */
  50390. static MODEL_FILENAME: string;
  50391. /**
  50392. * Creates a new ViveController from a gamepad
  50393. * @param vrGamepad the gamepad that the controller should be created from
  50394. */
  50395. constructor(vrGamepad: any);
  50396. /**
  50397. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50398. * @param scene scene in which to add meshes
  50399. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50400. */
  50401. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50402. /**
  50403. * Fired when the left button on this controller is modified
  50404. */
  50405. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50406. /**
  50407. * Fired when the right button on this controller is modified
  50408. */
  50409. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50410. /**
  50411. * Fired when the menu button on this controller is modified
  50412. */
  50413. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50414. /**
  50415. * Called once for each button that changed state since the last frame
  50416. * Vive mapping:
  50417. * 0: touchpad
  50418. * 1: trigger
  50419. * 2: left AND right buttons
  50420. * 3: menu button
  50421. * @param buttonIdx Which button index changed
  50422. * @param state New state of the button
  50423. * @param changes Which properties on the state changed since last frame
  50424. */
  50425. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50426. }
  50427. }
  50428. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50429. import { Observable } from "babylonjs/Misc/observable";
  50430. import { Scene } from "babylonjs/scene";
  50431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50432. import { Ray } from "babylonjs/Culling/ray";
  50433. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50434. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50435. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50436. /**
  50437. * Defines the WindowsMotionController object that the state of the windows motion controller
  50438. */
  50439. export class WindowsMotionController extends WebVRController {
  50440. /**
  50441. * The base url used to load the left and right controller models
  50442. */
  50443. static MODEL_BASE_URL: string;
  50444. /**
  50445. * The name of the left controller model file
  50446. */
  50447. static MODEL_LEFT_FILENAME: string;
  50448. /**
  50449. * The name of the right controller model file
  50450. */
  50451. static MODEL_RIGHT_FILENAME: string;
  50452. /**
  50453. * The controller name prefix for this controller type
  50454. */
  50455. static readonly GAMEPAD_ID_PREFIX: string;
  50456. /**
  50457. * The controller id pattern for this controller type
  50458. */
  50459. private static readonly GAMEPAD_ID_PATTERN;
  50460. private _loadedMeshInfo;
  50461. protected readonly _mapping: {
  50462. buttons: string[];
  50463. buttonMeshNames: {
  50464. trigger: string;
  50465. menu: string;
  50466. grip: string;
  50467. thumbstick: string;
  50468. trackpad: string;
  50469. };
  50470. buttonObservableNames: {
  50471. trigger: string;
  50472. menu: string;
  50473. grip: string;
  50474. thumbstick: string;
  50475. trackpad: string;
  50476. };
  50477. axisMeshNames: string[];
  50478. pointingPoseMeshName: string;
  50479. };
  50480. /**
  50481. * Fired when the trackpad on this controller is clicked
  50482. */
  50483. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50484. /**
  50485. * Fired when the trackpad on this controller is modified
  50486. */
  50487. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50488. /**
  50489. * The current x and y values of this controller's trackpad
  50490. */
  50491. trackpad: StickValues;
  50492. /**
  50493. * Creates a new WindowsMotionController from a gamepad
  50494. * @param vrGamepad the gamepad that the controller should be created from
  50495. */
  50496. constructor(vrGamepad: any);
  50497. /**
  50498. * Fired when the trigger on this controller is modified
  50499. */
  50500. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50501. /**
  50502. * Fired when the menu button on this controller is modified
  50503. */
  50504. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50505. /**
  50506. * Fired when the grip button on this controller is modified
  50507. */
  50508. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50509. /**
  50510. * Fired when the thumbstick button on this controller is modified
  50511. */
  50512. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50513. /**
  50514. * Fired when the touchpad button on this controller is modified
  50515. */
  50516. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50517. /**
  50518. * Fired when the touchpad values on this controller are modified
  50519. */
  50520. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50521. protected _updateTrackpad(): void;
  50522. /**
  50523. * Called once per frame by the engine.
  50524. */
  50525. update(): void;
  50526. /**
  50527. * Called once for each button that changed state since the last frame
  50528. * @param buttonIdx Which button index changed
  50529. * @param state New state of the button
  50530. * @param changes Which properties on the state changed since last frame
  50531. */
  50532. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50533. /**
  50534. * Moves the buttons on the controller mesh based on their current state
  50535. * @param buttonName the name of the button to move
  50536. * @param buttonValue the value of the button which determines the buttons new position
  50537. */
  50538. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50539. /**
  50540. * Moves the axis on the controller mesh based on its current state
  50541. * @param axis the index of the axis
  50542. * @param axisValue the value of the axis which determines the meshes new position
  50543. * @hidden
  50544. */
  50545. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50546. /**
  50547. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50548. * @param scene scene in which to add meshes
  50549. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50550. */
  50551. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50552. /**
  50553. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50554. * can be transformed by button presses and axes values, based on this._mapping.
  50555. *
  50556. * @param scene scene in which the meshes exist
  50557. * @param meshes list of meshes that make up the controller model to process
  50558. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50559. */
  50560. private processModel;
  50561. private createMeshInfo;
  50562. /**
  50563. * Gets the ray of the controller in the direction the controller is pointing
  50564. * @param length the length the resulting ray should be
  50565. * @returns a ray in the direction the controller is pointing
  50566. */
  50567. getForwardRay(length?: number): Ray;
  50568. /**
  50569. * Disposes of the controller
  50570. */
  50571. dispose(): void;
  50572. }
  50573. /**
  50574. * This class represents a new windows motion controller in XR.
  50575. */
  50576. export class XRWindowsMotionController extends WindowsMotionController {
  50577. /**
  50578. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50579. */
  50580. protected readonly _mapping: {
  50581. buttons: string[];
  50582. buttonMeshNames: {
  50583. trigger: string;
  50584. menu: string;
  50585. grip: string;
  50586. thumbstick: string;
  50587. trackpad: string;
  50588. };
  50589. buttonObservableNames: {
  50590. trigger: string;
  50591. menu: string;
  50592. grip: string;
  50593. thumbstick: string;
  50594. trackpad: string;
  50595. };
  50596. axisMeshNames: string[];
  50597. pointingPoseMeshName: string;
  50598. };
  50599. /**
  50600. * Construct a new XR-Based windows motion controller
  50601. *
  50602. * @param gamepadInfo the gamepad object from the browser
  50603. */
  50604. constructor(gamepadInfo: any);
  50605. /**
  50606. * holds the thumbstick values (X,Y)
  50607. */
  50608. thumbstickValues: StickValues;
  50609. /**
  50610. * Fired when the thumbstick on this controller is clicked
  50611. */
  50612. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50613. /**
  50614. * Fired when the thumbstick on this controller is modified
  50615. */
  50616. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50617. /**
  50618. * Fired when the touchpad button on this controller is modified
  50619. */
  50620. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50621. /**
  50622. * Fired when the touchpad values on this controller are modified
  50623. */
  50624. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50625. /**
  50626. * Fired when the thumbstick button on this controller is modified
  50627. * here to prevent breaking changes
  50628. */
  50629. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50630. /**
  50631. * updating the thumbstick(!) and not the trackpad.
  50632. * This is named this way due to the difference between WebVR and XR and to avoid
  50633. * changing the parent class.
  50634. */
  50635. protected _updateTrackpad(): void;
  50636. /**
  50637. * Disposes the class with joy
  50638. */
  50639. dispose(): void;
  50640. }
  50641. }
  50642. declare module "babylonjs/Gamepads/Controllers/index" {
  50643. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50644. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50645. export * from "babylonjs/Gamepads/Controllers/genericController";
  50646. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50647. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50648. export * from "babylonjs/Gamepads/Controllers/viveController";
  50649. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50650. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50651. }
  50652. declare module "babylonjs/Gamepads/index" {
  50653. export * from "babylonjs/Gamepads/Controllers/index";
  50654. export * from "babylonjs/Gamepads/gamepad";
  50655. export * from "babylonjs/Gamepads/gamepadManager";
  50656. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50657. export * from "babylonjs/Gamepads/xboxGamepad";
  50658. export * from "babylonjs/Gamepads/dualShockGamepad";
  50659. }
  50660. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50661. import { Scene } from "babylonjs/scene";
  50662. import { Vector4 } from "babylonjs/Maths/math.vector";
  50663. import { Color4 } from "babylonjs/Maths/math.color";
  50664. import { Mesh } from "babylonjs/Meshes/mesh";
  50665. import { Nullable } from "babylonjs/types";
  50666. /**
  50667. * Class containing static functions to help procedurally build meshes
  50668. */
  50669. export class PolyhedronBuilder {
  50670. /**
  50671. * Creates a polyhedron mesh
  50672. * * 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
  50673. * * The parameter `size` (positive float, default 1) sets the polygon size
  50674. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50675. * * 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`
  50676. * * 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
  50677. * * 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)`)
  50678. * * 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
  50679. * * 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
  50680. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50681. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50683. * @param name defines the name of the mesh
  50684. * @param options defines the options used to create the mesh
  50685. * @param scene defines the hosting scene
  50686. * @returns the polyhedron mesh
  50687. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50688. */
  50689. static CreatePolyhedron(name: string, options: {
  50690. type?: number;
  50691. size?: number;
  50692. sizeX?: number;
  50693. sizeY?: number;
  50694. sizeZ?: number;
  50695. custom?: any;
  50696. faceUV?: Vector4[];
  50697. faceColors?: Color4[];
  50698. flat?: boolean;
  50699. updatable?: boolean;
  50700. sideOrientation?: number;
  50701. frontUVs?: Vector4;
  50702. backUVs?: Vector4;
  50703. }, scene?: Nullable<Scene>): Mesh;
  50704. }
  50705. }
  50706. declare module "babylonjs/Gizmos/scaleGizmo" {
  50707. import { Observable } from "babylonjs/Misc/observable";
  50708. import { Nullable } from "babylonjs/types";
  50709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50710. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50711. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50712. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50713. /**
  50714. * Gizmo that enables scaling a mesh along 3 axis
  50715. */
  50716. export class ScaleGizmo extends Gizmo {
  50717. /**
  50718. * Internal gizmo used for interactions on the x axis
  50719. */
  50720. xGizmo: AxisScaleGizmo;
  50721. /**
  50722. * Internal gizmo used for interactions on the y axis
  50723. */
  50724. yGizmo: AxisScaleGizmo;
  50725. /**
  50726. * Internal gizmo used for interactions on the z axis
  50727. */
  50728. zGizmo: AxisScaleGizmo;
  50729. /**
  50730. * Internal gizmo used to scale all axis equally
  50731. */
  50732. uniformScaleGizmo: AxisScaleGizmo;
  50733. private _meshAttached;
  50734. private _updateGizmoRotationToMatchAttachedMesh;
  50735. private _snapDistance;
  50736. private _scaleRatio;
  50737. private _uniformScalingMesh;
  50738. private _octahedron;
  50739. private _sensitivity;
  50740. /** Fires an event when any of it's sub gizmos are dragged */
  50741. onDragStartObservable: Observable<unknown>;
  50742. /** Fires an event when any of it's sub gizmos are released from dragging */
  50743. onDragEndObservable: Observable<unknown>;
  50744. get attachedMesh(): Nullable<AbstractMesh>;
  50745. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50746. /**
  50747. * Creates a ScaleGizmo
  50748. * @param gizmoLayer The utility layer the gizmo will be added to
  50749. */
  50750. constructor(gizmoLayer?: UtilityLayerRenderer);
  50751. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50752. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50753. /**
  50754. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50755. */
  50756. set snapDistance(value: number);
  50757. get snapDistance(): number;
  50758. /**
  50759. * Ratio for the scale of the gizmo (Default: 1)
  50760. */
  50761. set scaleRatio(value: number);
  50762. get scaleRatio(): number;
  50763. /**
  50764. * Sensitivity factor for dragging (Default: 1)
  50765. */
  50766. set sensitivity(value: number);
  50767. get sensitivity(): number;
  50768. /**
  50769. * Disposes of the gizmo
  50770. */
  50771. dispose(): void;
  50772. }
  50773. }
  50774. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50775. import { Observable } from "babylonjs/Misc/observable";
  50776. import { Nullable } from "babylonjs/types";
  50777. import { Vector3 } from "babylonjs/Maths/math.vector";
  50778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50779. import { Mesh } from "babylonjs/Meshes/mesh";
  50780. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50781. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50782. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50783. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50784. import { Color3 } from "babylonjs/Maths/math.color";
  50785. /**
  50786. * Single axis scale gizmo
  50787. */
  50788. export class AxisScaleGizmo extends Gizmo {
  50789. /**
  50790. * Drag behavior responsible for the gizmos dragging interactions
  50791. */
  50792. dragBehavior: PointerDragBehavior;
  50793. private _pointerObserver;
  50794. /**
  50795. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50796. */
  50797. snapDistance: number;
  50798. /**
  50799. * Event that fires each time the gizmo snaps to a new location.
  50800. * * snapDistance is the the change in distance
  50801. */
  50802. onSnapObservable: Observable<{
  50803. snapDistance: number;
  50804. }>;
  50805. /**
  50806. * If the scaling operation should be done on all axis (default: false)
  50807. */
  50808. uniformScaling: boolean;
  50809. /**
  50810. * Custom sensitivity value for the drag strength
  50811. */
  50812. sensitivity: number;
  50813. private _isEnabled;
  50814. private _parent;
  50815. private _arrow;
  50816. private _coloredMaterial;
  50817. private _hoverMaterial;
  50818. /**
  50819. * Creates an AxisScaleGizmo
  50820. * @param gizmoLayer The utility layer the gizmo will be added to
  50821. * @param dragAxis The axis which the gizmo will be able to scale on
  50822. * @param color The color of the gizmo
  50823. */
  50824. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50825. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50826. /**
  50827. * If the gizmo is enabled
  50828. */
  50829. set isEnabled(value: boolean);
  50830. get isEnabled(): boolean;
  50831. /**
  50832. * Disposes of the gizmo
  50833. */
  50834. dispose(): void;
  50835. /**
  50836. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50837. * @param mesh The mesh to replace the default mesh of the gizmo
  50838. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50839. */
  50840. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50841. }
  50842. }
  50843. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50844. import { Observable } from "babylonjs/Misc/observable";
  50845. import { Nullable } from "babylonjs/types";
  50846. import { Vector3 } from "babylonjs/Maths/math.vector";
  50847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50848. import { Mesh } from "babylonjs/Meshes/mesh";
  50849. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50850. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50851. import { Color3 } from "babylonjs/Maths/math.color";
  50852. import "babylonjs/Meshes/Builders/boxBuilder";
  50853. /**
  50854. * Bounding box gizmo
  50855. */
  50856. export class BoundingBoxGizmo extends Gizmo {
  50857. private _lineBoundingBox;
  50858. private _rotateSpheresParent;
  50859. private _scaleBoxesParent;
  50860. private _boundingDimensions;
  50861. private _renderObserver;
  50862. private _pointerObserver;
  50863. private _scaleDragSpeed;
  50864. private _tmpQuaternion;
  50865. private _tmpVector;
  50866. private _tmpRotationMatrix;
  50867. /**
  50868. * 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)
  50869. */
  50870. ignoreChildren: boolean;
  50871. /**
  50872. * 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)
  50873. */
  50874. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50875. /**
  50876. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50877. */
  50878. rotationSphereSize: number;
  50879. /**
  50880. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50881. */
  50882. scaleBoxSize: number;
  50883. /**
  50884. * 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)
  50885. */
  50886. fixedDragMeshScreenSize: boolean;
  50887. /**
  50888. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50889. */
  50890. fixedDragMeshScreenSizeDistanceFactor: number;
  50891. /**
  50892. * Fired when a rotation sphere or scale box is dragged
  50893. */
  50894. onDragStartObservable: Observable<{}>;
  50895. /**
  50896. * Fired when a scale box is dragged
  50897. */
  50898. onScaleBoxDragObservable: Observable<{}>;
  50899. /**
  50900. * Fired when a scale box drag is ended
  50901. */
  50902. onScaleBoxDragEndObservable: Observable<{}>;
  50903. /**
  50904. * Fired when a rotation sphere is dragged
  50905. */
  50906. onRotationSphereDragObservable: Observable<{}>;
  50907. /**
  50908. * Fired when a rotation sphere drag is ended
  50909. */
  50910. onRotationSphereDragEndObservable: Observable<{}>;
  50911. /**
  50912. * 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)
  50913. */
  50914. scalePivot: Nullable<Vector3>;
  50915. /**
  50916. * Mesh used as a pivot to rotate the attached mesh
  50917. */
  50918. private _anchorMesh;
  50919. private _existingMeshScale;
  50920. private _dragMesh;
  50921. private pointerDragBehavior;
  50922. private coloredMaterial;
  50923. private hoverColoredMaterial;
  50924. /**
  50925. * Sets the color of the bounding box gizmo
  50926. * @param color the color to set
  50927. */
  50928. setColor(color: Color3): void;
  50929. /**
  50930. * Creates an BoundingBoxGizmo
  50931. * @param gizmoLayer The utility layer the gizmo will be added to
  50932. * @param color The color of the gizmo
  50933. */
  50934. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50935. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50936. private _selectNode;
  50937. /**
  50938. * Updates the bounding box information for the Gizmo
  50939. */
  50940. updateBoundingBox(): void;
  50941. private _updateRotationSpheres;
  50942. private _updateScaleBoxes;
  50943. /**
  50944. * Enables rotation on the specified axis and disables rotation on the others
  50945. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50946. */
  50947. setEnabledRotationAxis(axis: string): void;
  50948. /**
  50949. * Enables/disables scaling
  50950. * @param enable if scaling should be enabled
  50951. * @param homogeneousScaling defines if scaling should only be homogeneous
  50952. */
  50953. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  50954. private _updateDummy;
  50955. /**
  50956. * Enables a pointer drag behavior on the bounding box of the gizmo
  50957. */
  50958. enableDragBehavior(): void;
  50959. /**
  50960. * Disposes of the gizmo
  50961. */
  50962. dispose(): void;
  50963. /**
  50964. * 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)
  50965. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50966. * @returns the bounding box mesh with the passed in mesh as a child
  50967. */
  50968. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50969. /**
  50970. * CustomMeshes are not supported by this gizmo
  50971. * @param mesh The mesh to replace the default mesh of the gizmo
  50972. */
  50973. setCustomMesh(mesh: Mesh): void;
  50974. }
  50975. }
  50976. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50977. import { Observable } from "babylonjs/Misc/observable";
  50978. import { Nullable } from "babylonjs/types";
  50979. import { Vector3 } from "babylonjs/Maths/math.vector";
  50980. import { Color3 } from "babylonjs/Maths/math.color";
  50981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50982. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50983. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50984. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50985. import "babylonjs/Meshes/Builders/linesBuilder";
  50986. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50987. /**
  50988. * Single plane rotation gizmo
  50989. */
  50990. export class PlaneRotationGizmo extends Gizmo {
  50991. /**
  50992. * Drag behavior responsible for the gizmos dragging interactions
  50993. */
  50994. dragBehavior: PointerDragBehavior;
  50995. private _pointerObserver;
  50996. /**
  50997. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50998. */
  50999. snapDistance: number;
  51000. /**
  51001. * Event that fires each time the gizmo snaps to a new location.
  51002. * * snapDistance is the the change in distance
  51003. */
  51004. onSnapObservable: Observable<{
  51005. snapDistance: number;
  51006. }>;
  51007. private _isEnabled;
  51008. private _parent;
  51009. /**
  51010. * Creates a PlaneRotationGizmo
  51011. * @param gizmoLayer The utility layer the gizmo will be added to
  51012. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51013. * @param color The color of the gizmo
  51014. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51015. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51016. */
  51017. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51018. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51019. /**
  51020. * If the gizmo is enabled
  51021. */
  51022. set isEnabled(value: boolean);
  51023. get isEnabled(): boolean;
  51024. /**
  51025. * Disposes of the gizmo
  51026. */
  51027. dispose(): void;
  51028. }
  51029. }
  51030. declare module "babylonjs/Gizmos/rotationGizmo" {
  51031. import { Observable } from "babylonjs/Misc/observable";
  51032. import { Nullable } from "babylonjs/types";
  51033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51034. import { Mesh } from "babylonjs/Meshes/mesh";
  51035. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51036. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51037. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51038. /**
  51039. * Gizmo that enables rotating a mesh along 3 axis
  51040. */
  51041. export class RotationGizmo extends Gizmo {
  51042. /**
  51043. * Internal gizmo used for interactions on the x axis
  51044. */
  51045. xGizmo: PlaneRotationGizmo;
  51046. /**
  51047. * Internal gizmo used for interactions on the y axis
  51048. */
  51049. yGizmo: PlaneRotationGizmo;
  51050. /**
  51051. * Internal gizmo used for interactions on the z axis
  51052. */
  51053. zGizmo: PlaneRotationGizmo;
  51054. /** Fires an event when any of it's sub gizmos are dragged */
  51055. onDragStartObservable: Observable<unknown>;
  51056. /** Fires an event when any of it's sub gizmos are released from dragging */
  51057. onDragEndObservable: Observable<unknown>;
  51058. private _meshAttached;
  51059. get attachedMesh(): Nullable<AbstractMesh>;
  51060. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51061. /**
  51062. * Creates a RotationGizmo
  51063. * @param gizmoLayer The utility layer the gizmo will be added to
  51064. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51065. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51066. */
  51067. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51068. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51069. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51070. /**
  51071. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51072. */
  51073. set snapDistance(value: number);
  51074. get snapDistance(): number;
  51075. /**
  51076. * Ratio for the scale of the gizmo (Default: 1)
  51077. */
  51078. set scaleRatio(value: number);
  51079. get scaleRatio(): number;
  51080. /**
  51081. * Disposes of the gizmo
  51082. */
  51083. dispose(): void;
  51084. /**
  51085. * CustomMeshes are not supported by this gizmo
  51086. * @param mesh The mesh to replace the default mesh of the gizmo
  51087. */
  51088. setCustomMesh(mesh: Mesh): void;
  51089. }
  51090. }
  51091. declare module "babylonjs/Gizmos/gizmoManager" {
  51092. import { Observable } from "babylonjs/Misc/observable";
  51093. import { Nullable } from "babylonjs/types";
  51094. import { Scene, IDisposable } from "babylonjs/scene";
  51095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51096. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51097. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51098. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51099. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51100. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51101. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51102. /**
  51103. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51104. */
  51105. export class GizmoManager implements IDisposable {
  51106. private scene;
  51107. /**
  51108. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51109. */
  51110. gizmos: {
  51111. positionGizmo: Nullable<PositionGizmo>;
  51112. rotationGizmo: Nullable<RotationGizmo>;
  51113. scaleGizmo: Nullable<ScaleGizmo>;
  51114. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51115. };
  51116. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51117. clearGizmoOnEmptyPointerEvent: boolean;
  51118. /** Fires an event when the manager is attached to a mesh */
  51119. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51120. private _gizmosEnabled;
  51121. private _pointerObserver;
  51122. private _attachedMesh;
  51123. private _boundingBoxColor;
  51124. private _defaultUtilityLayer;
  51125. private _defaultKeepDepthUtilityLayer;
  51126. /**
  51127. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51128. */
  51129. boundingBoxDragBehavior: SixDofDragBehavior;
  51130. /**
  51131. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51132. */
  51133. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51134. /**
  51135. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51136. */
  51137. usePointerToAttachGizmos: boolean;
  51138. /**
  51139. * Utility layer that the bounding box gizmo belongs to
  51140. */
  51141. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51142. /**
  51143. * Utility layer that all gizmos besides bounding box belong to
  51144. */
  51145. get utilityLayer(): UtilityLayerRenderer;
  51146. /**
  51147. * Instatiates a gizmo manager
  51148. * @param scene the scene to overlay the gizmos on top of
  51149. */
  51150. constructor(scene: Scene);
  51151. /**
  51152. * Attaches a set of gizmos to the specified mesh
  51153. * @param mesh The mesh the gizmo's should be attached to
  51154. */
  51155. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51156. /**
  51157. * If the position gizmo is enabled
  51158. */
  51159. set positionGizmoEnabled(value: boolean);
  51160. get positionGizmoEnabled(): boolean;
  51161. /**
  51162. * If the rotation gizmo is enabled
  51163. */
  51164. set rotationGizmoEnabled(value: boolean);
  51165. get rotationGizmoEnabled(): boolean;
  51166. /**
  51167. * If the scale gizmo is enabled
  51168. */
  51169. set scaleGizmoEnabled(value: boolean);
  51170. get scaleGizmoEnabled(): boolean;
  51171. /**
  51172. * If the boundingBox gizmo is enabled
  51173. */
  51174. set boundingBoxGizmoEnabled(value: boolean);
  51175. get boundingBoxGizmoEnabled(): boolean;
  51176. /**
  51177. * Disposes of the gizmo manager
  51178. */
  51179. dispose(): void;
  51180. }
  51181. }
  51182. declare module "babylonjs/Lights/directionalLight" {
  51183. import { Camera } from "babylonjs/Cameras/camera";
  51184. import { Scene } from "babylonjs/scene";
  51185. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51187. import { Light } from "babylonjs/Lights/light";
  51188. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51189. import { Effect } from "babylonjs/Materials/effect";
  51190. /**
  51191. * A directional light is defined by a direction (what a surprise!).
  51192. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51193. * 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.
  51194. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51195. */
  51196. export class DirectionalLight extends ShadowLight {
  51197. private _shadowFrustumSize;
  51198. /**
  51199. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51200. */
  51201. get shadowFrustumSize(): number;
  51202. /**
  51203. * Specifies a fix frustum size for the shadow generation.
  51204. */
  51205. set shadowFrustumSize(value: number);
  51206. private _shadowOrthoScale;
  51207. /**
  51208. * Gets the shadow projection scale against the optimal computed one.
  51209. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51210. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51211. */
  51212. get shadowOrthoScale(): number;
  51213. /**
  51214. * Sets the shadow projection scale against the optimal computed one.
  51215. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51216. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51217. */
  51218. set shadowOrthoScale(value: number);
  51219. /**
  51220. * Automatically compute the projection matrix to best fit (including all the casters)
  51221. * on each frame.
  51222. */
  51223. autoUpdateExtends: boolean;
  51224. /**
  51225. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51226. * on each frame. autoUpdateExtends must be set to true for this to work
  51227. */
  51228. autoCalcShadowZBounds: boolean;
  51229. private _orthoLeft;
  51230. private _orthoRight;
  51231. private _orthoTop;
  51232. private _orthoBottom;
  51233. /**
  51234. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51235. * The directional light is emitted from everywhere in the given direction.
  51236. * It can cast shadows.
  51237. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51238. * @param name The friendly name of the light
  51239. * @param direction The direction of the light
  51240. * @param scene The scene the light belongs to
  51241. */
  51242. constructor(name: string, direction: Vector3, scene: Scene);
  51243. /**
  51244. * Returns the string "DirectionalLight".
  51245. * @return The class name
  51246. */
  51247. getClassName(): string;
  51248. /**
  51249. * Returns the integer 1.
  51250. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51251. */
  51252. getTypeID(): number;
  51253. /**
  51254. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  51255. * Returns the DirectionalLight Shadow projection matrix.
  51256. */
  51257. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51258. /**
  51259. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51260. * Returns the DirectionalLight Shadow projection matrix.
  51261. */
  51262. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51263. /**
  51264. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51265. * Returns the DirectionalLight Shadow projection matrix.
  51266. */
  51267. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51268. protected _buildUniformLayout(): void;
  51269. /**
  51270. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51271. * @param effect The effect to update
  51272. * @param lightIndex The index of the light in the effect to update
  51273. * @returns The directional light
  51274. */
  51275. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51276. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51277. /**
  51278. * Gets the minZ used for shadow according to both the scene and the light.
  51279. *
  51280. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51281. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51282. * @param activeCamera The camera we are returning the min for
  51283. * @returns the depth min z
  51284. */
  51285. getDepthMinZ(activeCamera: Camera): number;
  51286. /**
  51287. * Gets the maxZ used for shadow according to both the scene and the light.
  51288. *
  51289. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51290. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51291. * @param activeCamera The camera we are returning the max for
  51292. * @returns the depth max z
  51293. */
  51294. getDepthMaxZ(activeCamera: Camera): number;
  51295. /**
  51296. * Prepares the list of defines specific to the light type.
  51297. * @param defines the list of defines
  51298. * @param lightIndex defines the index of the light for the effect
  51299. */
  51300. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51301. }
  51302. }
  51303. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51304. import { Mesh } from "babylonjs/Meshes/mesh";
  51305. /**
  51306. * Class containing static functions to help procedurally build meshes
  51307. */
  51308. export class HemisphereBuilder {
  51309. /**
  51310. * Creates a hemisphere mesh
  51311. * @param name defines the name of the mesh
  51312. * @param options defines the options used to create the mesh
  51313. * @param scene defines the hosting scene
  51314. * @returns the hemisphere mesh
  51315. */
  51316. static CreateHemisphere(name: string, options: {
  51317. segments?: number;
  51318. diameter?: number;
  51319. sideOrientation?: number;
  51320. }, scene: any): Mesh;
  51321. }
  51322. }
  51323. declare module "babylonjs/Lights/spotLight" {
  51324. import { Nullable } from "babylonjs/types";
  51325. import { Scene } from "babylonjs/scene";
  51326. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51328. import { Effect } from "babylonjs/Materials/effect";
  51329. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51330. import { Light } from "babylonjs/Lights/light";
  51331. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51332. /**
  51333. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51334. * These values define a cone of light starting from the position, emitting toward the direction.
  51335. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51336. * and the exponent defines the speed of the decay of the light with distance (reach).
  51337. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51338. */
  51339. export class SpotLight extends ShadowLight {
  51340. private _angle;
  51341. private _innerAngle;
  51342. private _cosHalfAngle;
  51343. private _lightAngleScale;
  51344. private _lightAngleOffset;
  51345. /**
  51346. * Gets the cone angle of the spot light in Radians.
  51347. */
  51348. get angle(): number;
  51349. /**
  51350. * Sets the cone angle of the spot light in Radians.
  51351. */
  51352. set angle(value: number);
  51353. /**
  51354. * Only used in gltf falloff mode, this defines the angle where
  51355. * the directional falloff will start before cutting at angle which could be seen
  51356. * as outer angle.
  51357. */
  51358. get innerAngle(): number;
  51359. /**
  51360. * Only used in gltf falloff mode, this defines the angle where
  51361. * the directional falloff will start before cutting at angle which could be seen
  51362. * as outer angle.
  51363. */
  51364. set innerAngle(value: number);
  51365. private _shadowAngleScale;
  51366. /**
  51367. * Allows scaling the angle of the light for shadow generation only.
  51368. */
  51369. get shadowAngleScale(): number;
  51370. /**
  51371. * Allows scaling the angle of the light for shadow generation only.
  51372. */
  51373. set shadowAngleScale(value: number);
  51374. /**
  51375. * The light decay speed with the distance from the emission spot.
  51376. */
  51377. exponent: number;
  51378. private _projectionTextureMatrix;
  51379. /**
  51380. * Allows reading the projecton texture
  51381. */
  51382. get projectionTextureMatrix(): Matrix;
  51383. protected _projectionTextureLightNear: number;
  51384. /**
  51385. * Gets the near clip of the Spotlight for texture projection.
  51386. */
  51387. get projectionTextureLightNear(): number;
  51388. /**
  51389. * Sets the near clip of the Spotlight for texture projection.
  51390. */
  51391. set projectionTextureLightNear(value: number);
  51392. protected _projectionTextureLightFar: number;
  51393. /**
  51394. * Gets the far clip of the Spotlight for texture projection.
  51395. */
  51396. get projectionTextureLightFar(): number;
  51397. /**
  51398. * Sets the far clip of the Spotlight for texture projection.
  51399. */
  51400. set projectionTextureLightFar(value: number);
  51401. protected _projectionTextureUpDirection: Vector3;
  51402. /**
  51403. * Gets the Up vector of the Spotlight for texture projection.
  51404. */
  51405. get projectionTextureUpDirection(): Vector3;
  51406. /**
  51407. * Sets the Up vector of the Spotlight for texture projection.
  51408. */
  51409. set projectionTextureUpDirection(value: Vector3);
  51410. private _projectionTexture;
  51411. /**
  51412. * Gets the projection texture of the light.
  51413. */
  51414. get projectionTexture(): Nullable<BaseTexture>;
  51415. /**
  51416. * Sets the projection texture of the light.
  51417. */
  51418. set projectionTexture(value: Nullable<BaseTexture>);
  51419. private _projectionTextureViewLightDirty;
  51420. private _projectionTextureProjectionLightDirty;
  51421. private _projectionTextureDirty;
  51422. private _projectionTextureViewTargetVector;
  51423. private _projectionTextureViewLightMatrix;
  51424. private _projectionTextureProjectionLightMatrix;
  51425. private _projectionTextureScalingMatrix;
  51426. /**
  51427. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51428. * It can cast shadows.
  51429. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51430. * @param name The light friendly name
  51431. * @param position The position of the spot light in the scene
  51432. * @param direction The direction of the light in the scene
  51433. * @param angle The cone angle of the light in Radians
  51434. * @param exponent The light decay speed with the distance from the emission spot
  51435. * @param scene The scene the lights belongs to
  51436. */
  51437. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51438. /**
  51439. * Returns the string "SpotLight".
  51440. * @returns the class name
  51441. */
  51442. getClassName(): string;
  51443. /**
  51444. * Returns the integer 2.
  51445. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51446. */
  51447. getTypeID(): number;
  51448. /**
  51449. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51450. */
  51451. protected _setDirection(value: Vector3): void;
  51452. /**
  51453. * Overrides the position setter to recompute the projection texture view light Matrix.
  51454. */
  51455. protected _setPosition(value: Vector3): void;
  51456. /**
  51457. * 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.
  51458. * Returns the SpotLight.
  51459. */
  51460. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51461. protected _computeProjectionTextureViewLightMatrix(): void;
  51462. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51463. /**
  51464. * Main function for light texture projection matrix computing.
  51465. */
  51466. protected _computeProjectionTextureMatrix(): void;
  51467. protected _buildUniformLayout(): void;
  51468. private _computeAngleValues;
  51469. /**
  51470. * Sets the passed Effect "effect" with the Light textures.
  51471. * @param effect The effect to update
  51472. * @param lightIndex The index of the light in the effect to update
  51473. * @returns The light
  51474. */
  51475. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51476. /**
  51477. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51478. * @param effect The effect to update
  51479. * @param lightIndex The index of the light in the effect to update
  51480. * @returns The spot light
  51481. */
  51482. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51483. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51484. /**
  51485. * Disposes the light and the associated resources.
  51486. */
  51487. dispose(): void;
  51488. /**
  51489. * Prepares the list of defines specific to the light type.
  51490. * @param defines the list of defines
  51491. * @param lightIndex defines the index of the light for the effect
  51492. */
  51493. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51494. }
  51495. }
  51496. declare module "babylonjs/Gizmos/lightGizmo" {
  51497. import { Nullable } from "babylonjs/types";
  51498. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51499. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51500. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51501. import { Light } from "babylonjs/Lights/light";
  51502. /**
  51503. * Gizmo that enables viewing a light
  51504. */
  51505. export class LightGizmo extends Gizmo {
  51506. private _lightMesh;
  51507. private _material;
  51508. private _cachedPosition;
  51509. private _cachedForward;
  51510. private _attachedMeshParent;
  51511. /**
  51512. * Creates a LightGizmo
  51513. * @param gizmoLayer The utility layer the gizmo will be added to
  51514. */
  51515. constructor(gizmoLayer?: UtilityLayerRenderer);
  51516. private _light;
  51517. /**
  51518. * The light that the gizmo is attached to
  51519. */
  51520. set light(light: Nullable<Light>);
  51521. get light(): Nullable<Light>;
  51522. /**
  51523. * Gets the material used to render the light gizmo
  51524. */
  51525. get material(): StandardMaterial;
  51526. /**
  51527. * @hidden
  51528. * Updates the gizmo to match the attached mesh's position/rotation
  51529. */
  51530. protected _update(): void;
  51531. private static _Scale;
  51532. /**
  51533. * Creates the lines for a light mesh
  51534. */
  51535. private static _CreateLightLines;
  51536. /**
  51537. * Disposes of the light gizmo
  51538. */
  51539. dispose(): void;
  51540. private static _CreateHemisphericLightMesh;
  51541. private static _CreatePointLightMesh;
  51542. private static _CreateSpotLightMesh;
  51543. private static _CreateDirectionalLightMesh;
  51544. }
  51545. }
  51546. declare module "babylonjs/Gizmos/index" {
  51547. export * from "babylonjs/Gizmos/axisDragGizmo";
  51548. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51549. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51550. export * from "babylonjs/Gizmos/gizmo";
  51551. export * from "babylonjs/Gizmos/gizmoManager";
  51552. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51553. export * from "babylonjs/Gizmos/positionGizmo";
  51554. export * from "babylonjs/Gizmos/rotationGizmo";
  51555. export * from "babylonjs/Gizmos/scaleGizmo";
  51556. export * from "babylonjs/Gizmos/lightGizmo";
  51557. export * from "babylonjs/Gizmos/planeDragGizmo";
  51558. }
  51559. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51560. /** @hidden */
  51561. export var backgroundFragmentDeclaration: {
  51562. name: string;
  51563. shader: string;
  51564. };
  51565. }
  51566. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51567. /** @hidden */
  51568. export var backgroundUboDeclaration: {
  51569. name: string;
  51570. shader: string;
  51571. };
  51572. }
  51573. declare module "babylonjs/Shaders/background.fragment" {
  51574. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51575. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51576. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51577. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51578. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51579. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51580. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51581. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51582. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51583. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51584. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51585. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51586. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51587. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51588. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51589. /** @hidden */
  51590. export var backgroundPixelShader: {
  51591. name: string;
  51592. shader: string;
  51593. };
  51594. }
  51595. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51596. /** @hidden */
  51597. export var backgroundVertexDeclaration: {
  51598. name: string;
  51599. shader: string;
  51600. };
  51601. }
  51602. declare module "babylonjs/Shaders/background.vertex" {
  51603. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51604. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51606. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51607. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51608. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51609. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51610. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51611. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51612. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51613. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51614. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51615. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51616. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51617. /** @hidden */
  51618. export var backgroundVertexShader: {
  51619. name: string;
  51620. shader: string;
  51621. };
  51622. }
  51623. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51624. import { Nullable, int, float } from "babylonjs/types";
  51625. import { Scene } from "babylonjs/scene";
  51626. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51627. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51629. import { Mesh } from "babylonjs/Meshes/mesh";
  51630. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51631. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51632. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51634. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51635. import { Color3 } from "babylonjs/Maths/math.color";
  51636. import "babylonjs/Shaders/background.fragment";
  51637. import "babylonjs/Shaders/background.vertex";
  51638. /**
  51639. * Background material used to create an efficient environement around your scene.
  51640. */
  51641. export class BackgroundMaterial extends PushMaterial {
  51642. /**
  51643. * Standard reflectance value at parallel view angle.
  51644. */
  51645. static StandardReflectance0: number;
  51646. /**
  51647. * Standard reflectance value at grazing angle.
  51648. */
  51649. static StandardReflectance90: number;
  51650. protected _primaryColor: Color3;
  51651. /**
  51652. * Key light Color (multiply against the environement texture)
  51653. */
  51654. primaryColor: Color3;
  51655. protected __perceptualColor: Nullable<Color3>;
  51656. /**
  51657. * Experimental Internal Use Only.
  51658. *
  51659. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51660. * This acts as a helper to set the primary color to a more "human friendly" value.
  51661. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51662. * output color as close as possible from the chosen value.
  51663. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51664. * part of lighting setup.)
  51665. */
  51666. get _perceptualColor(): Nullable<Color3>;
  51667. set _perceptualColor(value: Nullable<Color3>);
  51668. protected _primaryColorShadowLevel: float;
  51669. /**
  51670. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51671. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51672. */
  51673. get primaryColorShadowLevel(): float;
  51674. set primaryColorShadowLevel(value: float);
  51675. protected _primaryColorHighlightLevel: float;
  51676. /**
  51677. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51678. * The primary color is used at the level chosen to define what the white area would look.
  51679. */
  51680. get primaryColorHighlightLevel(): float;
  51681. set primaryColorHighlightLevel(value: float);
  51682. protected _reflectionTexture: Nullable<BaseTexture>;
  51683. /**
  51684. * Reflection Texture used in the material.
  51685. * Should be author in a specific way for the best result (refer to the documentation).
  51686. */
  51687. reflectionTexture: Nullable<BaseTexture>;
  51688. protected _reflectionBlur: float;
  51689. /**
  51690. * Reflection Texture level of blur.
  51691. *
  51692. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51693. * texture twice.
  51694. */
  51695. reflectionBlur: float;
  51696. protected _diffuseTexture: Nullable<BaseTexture>;
  51697. /**
  51698. * Diffuse Texture used in the material.
  51699. * Should be author in a specific way for the best result (refer to the documentation).
  51700. */
  51701. diffuseTexture: Nullable<BaseTexture>;
  51702. protected _shadowLights: Nullable<IShadowLight[]>;
  51703. /**
  51704. * Specify the list of lights casting shadow on the material.
  51705. * All scene shadow lights will be included if null.
  51706. */
  51707. shadowLights: Nullable<IShadowLight[]>;
  51708. protected _shadowLevel: float;
  51709. /**
  51710. * Helps adjusting the shadow to a softer level if required.
  51711. * 0 means black shadows and 1 means no shadows.
  51712. */
  51713. shadowLevel: float;
  51714. protected _sceneCenter: Vector3;
  51715. /**
  51716. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51717. * It is usually zero but might be interesting to modify according to your setup.
  51718. */
  51719. sceneCenter: Vector3;
  51720. protected _opacityFresnel: boolean;
  51721. /**
  51722. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51723. * This helps ensuring a nice transition when the camera goes under the ground.
  51724. */
  51725. opacityFresnel: boolean;
  51726. protected _reflectionFresnel: boolean;
  51727. /**
  51728. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51729. * This helps adding a mirror texture on the ground.
  51730. */
  51731. reflectionFresnel: boolean;
  51732. protected _reflectionFalloffDistance: number;
  51733. /**
  51734. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51735. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51736. */
  51737. reflectionFalloffDistance: number;
  51738. protected _reflectionAmount: number;
  51739. /**
  51740. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51741. */
  51742. reflectionAmount: number;
  51743. protected _reflectionReflectance0: number;
  51744. /**
  51745. * This specifies the weight of the reflection at grazing angle.
  51746. */
  51747. reflectionReflectance0: number;
  51748. protected _reflectionReflectance90: number;
  51749. /**
  51750. * This specifies the weight of the reflection at a perpendicular point of view.
  51751. */
  51752. reflectionReflectance90: number;
  51753. /**
  51754. * Sets the reflection reflectance fresnel values according to the default standard
  51755. * empirically know to work well :-)
  51756. */
  51757. set reflectionStandardFresnelWeight(value: number);
  51758. protected _useRGBColor: boolean;
  51759. /**
  51760. * Helps to directly use the maps channels instead of their level.
  51761. */
  51762. useRGBColor: boolean;
  51763. protected _enableNoise: boolean;
  51764. /**
  51765. * This helps reducing the banding effect that could occur on the background.
  51766. */
  51767. enableNoise: boolean;
  51768. /**
  51769. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51770. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51771. * Recommended to be keep at 1.0 except for special cases.
  51772. */
  51773. get fovMultiplier(): number;
  51774. set fovMultiplier(value: number);
  51775. private _fovMultiplier;
  51776. /**
  51777. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51778. */
  51779. useEquirectangularFOV: boolean;
  51780. private _maxSimultaneousLights;
  51781. /**
  51782. * Number of Simultaneous lights allowed on the material.
  51783. */
  51784. maxSimultaneousLights: int;
  51785. /**
  51786. * Default configuration related to image processing available in the Background Material.
  51787. */
  51788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51789. /**
  51790. * Keep track of the image processing observer to allow dispose and replace.
  51791. */
  51792. private _imageProcessingObserver;
  51793. /**
  51794. * Attaches a new image processing configuration to the PBR Material.
  51795. * @param configuration (if null the scene configuration will be use)
  51796. */
  51797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51798. /**
  51799. * Gets the image processing configuration used either in this material.
  51800. */
  51801. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51802. /**
  51803. * Sets the Default image processing configuration used either in the this material.
  51804. *
  51805. * If sets to null, the scene one is in use.
  51806. */
  51807. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51808. /**
  51809. * Gets wether the color curves effect is enabled.
  51810. */
  51811. get cameraColorCurvesEnabled(): boolean;
  51812. /**
  51813. * Sets wether the color curves effect is enabled.
  51814. */
  51815. set cameraColorCurvesEnabled(value: boolean);
  51816. /**
  51817. * Gets wether the color grading effect is enabled.
  51818. */
  51819. get cameraColorGradingEnabled(): boolean;
  51820. /**
  51821. * Gets wether the color grading effect is enabled.
  51822. */
  51823. set cameraColorGradingEnabled(value: boolean);
  51824. /**
  51825. * Gets wether tonemapping is enabled or not.
  51826. */
  51827. get cameraToneMappingEnabled(): boolean;
  51828. /**
  51829. * Sets wether tonemapping is enabled or not
  51830. */
  51831. set cameraToneMappingEnabled(value: boolean);
  51832. /**
  51833. * The camera exposure used on this material.
  51834. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51835. * This corresponds to a photographic exposure.
  51836. */
  51837. get cameraExposure(): float;
  51838. /**
  51839. * The camera exposure used on this material.
  51840. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51841. * This corresponds to a photographic exposure.
  51842. */
  51843. set cameraExposure(value: float);
  51844. /**
  51845. * Gets The camera contrast used on this material.
  51846. */
  51847. get cameraContrast(): float;
  51848. /**
  51849. * Sets The camera contrast used on this material.
  51850. */
  51851. set cameraContrast(value: float);
  51852. /**
  51853. * Gets the Color Grading 2D Lookup Texture.
  51854. */
  51855. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51856. /**
  51857. * Sets the Color Grading 2D Lookup Texture.
  51858. */
  51859. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51860. /**
  51861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51863. * 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;
  51864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51865. */
  51866. get cameraColorCurves(): Nullable<ColorCurves>;
  51867. /**
  51868. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51869. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51870. * 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;
  51871. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51872. */
  51873. set cameraColorCurves(value: Nullable<ColorCurves>);
  51874. /**
  51875. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51876. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51877. */
  51878. switchToBGR: boolean;
  51879. private _renderTargets;
  51880. private _reflectionControls;
  51881. private _white;
  51882. private _primaryShadowColor;
  51883. private _primaryHighlightColor;
  51884. /**
  51885. * Instantiates a Background Material in the given scene
  51886. * @param name The friendly name of the material
  51887. * @param scene The scene to add the material to
  51888. */
  51889. constructor(name: string, scene: Scene);
  51890. /**
  51891. * Gets a boolean indicating that current material needs to register RTT
  51892. */
  51893. get hasRenderTargetTextures(): boolean;
  51894. /**
  51895. * The entire material has been created in order to prevent overdraw.
  51896. * @returns false
  51897. */
  51898. needAlphaTesting(): boolean;
  51899. /**
  51900. * The entire material has been created in order to prevent overdraw.
  51901. * @returns true if blending is enable
  51902. */
  51903. needAlphaBlending(): boolean;
  51904. /**
  51905. * Checks wether the material is ready to be rendered for a given mesh.
  51906. * @param mesh The mesh to render
  51907. * @param subMesh The submesh to check against
  51908. * @param useInstances Specify wether or not the material is used with instances
  51909. * @returns true if all the dependencies are ready (Textures, Effects...)
  51910. */
  51911. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51912. /**
  51913. * Compute the primary color according to the chosen perceptual color.
  51914. */
  51915. private _computePrimaryColorFromPerceptualColor;
  51916. /**
  51917. * Compute the highlights and shadow colors according to their chosen levels.
  51918. */
  51919. private _computePrimaryColors;
  51920. /**
  51921. * Build the uniform buffer used in the material.
  51922. */
  51923. buildUniformLayout(): void;
  51924. /**
  51925. * Unbind the material.
  51926. */
  51927. unbind(): void;
  51928. /**
  51929. * Bind only the world matrix to the material.
  51930. * @param world The world matrix to bind.
  51931. */
  51932. bindOnlyWorldMatrix(world: Matrix): void;
  51933. /**
  51934. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51935. * @param world The world matrix to bind.
  51936. * @param subMesh The submesh to bind for.
  51937. */
  51938. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51939. /**
  51940. * Checks to see if a texture is used in the material.
  51941. * @param texture - Base texture to use.
  51942. * @returns - Boolean specifying if a texture is used in the material.
  51943. */
  51944. hasTexture(texture: BaseTexture): boolean;
  51945. /**
  51946. * Dispose the material.
  51947. * @param forceDisposeEffect Force disposal of the associated effect.
  51948. * @param forceDisposeTextures Force disposal of the associated textures.
  51949. */
  51950. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51951. /**
  51952. * Clones the material.
  51953. * @param name The cloned name.
  51954. * @returns The cloned material.
  51955. */
  51956. clone(name: string): BackgroundMaterial;
  51957. /**
  51958. * Serializes the current material to its JSON representation.
  51959. * @returns The JSON representation.
  51960. */
  51961. serialize(): any;
  51962. /**
  51963. * Gets the class name of the material
  51964. * @returns "BackgroundMaterial"
  51965. */
  51966. getClassName(): string;
  51967. /**
  51968. * Parse a JSON input to create back a background material.
  51969. * @param source The JSON data to parse
  51970. * @param scene The scene to create the parsed material in
  51971. * @param rootUrl The root url of the assets the material depends upon
  51972. * @returns the instantiated BackgroundMaterial.
  51973. */
  51974. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51975. }
  51976. }
  51977. declare module "babylonjs/Helpers/environmentHelper" {
  51978. import { Observable } from "babylonjs/Misc/observable";
  51979. import { Nullable } from "babylonjs/types";
  51980. import { Scene } from "babylonjs/scene";
  51981. import { Vector3 } from "babylonjs/Maths/math.vector";
  51982. import { Color3 } from "babylonjs/Maths/math.color";
  51983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51984. import { Mesh } from "babylonjs/Meshes/mesh";
  51985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51986. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51987. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51988. import "babylonjs/Meshes/Builders/planeBuilder";
  51989. import "babylonjs/Meshes/Builders/boxBuilder";
  51990. /**
  51991. * Represents the different options available during the creation of
  51992. * a Environment helper.
  51993. *
  51994. * This can control the default ground, skybox and image processing setup of your scene.
  51995. */
  51996. export interface IEnvironmentHelperOptions {
  51997. /**
  51998. * Specifies whether or not to create a ground.
  51999. * True by default.
  52000. */
  52001. createGround: boolean;
  52002. /**
  52003. * Specifies the ground size.
  52004. * 15 by default.
  52005. */
  52006. groundSize: number;
  52007. /**
  52008. * The texture used on the ground for the main color.
  52009. * Comes from the BabylonJS CDN by default.
  52010. *
  52011. * Remarks: Can be either a texture or a url.
  52012. */
  52013. groundTexture: string | BaseTexture;
  52014. /**
  52015. * The color mixed in the ground texture by default.
  52016. * BabylonJS clearColor by default.
  52017. */
  52018. groundColor: Color3;
  52019. /**
  52020. * Specifies the ground opacity.
  52021. * 1 by default.
  52022. */
  52023. groundOpacity: number;
  52024. /**
  52025. * Enables the ground to receive shadows.
  52026. * True by default.
  52027. */
  52028. enableGroundShadow: boolean;
  52029. /**
  52030. * Helps preventing the shadow to be fully black on the ground.
  52031. * 0.5 by default.
  52032. */
  52033. groundShadowLevel: number;
  52034. /**
  52035. * Creates a mirror texture attach to the ground.
  52036. * false by default.
  52037. */
  52038. enableGroundMirror: boolean;
  52039. /**
  52040. * Specifies the ground mirror size ratio.
  52041. * 0.3 by default as the default kernel is 64.
  52042. */
  52043. groundMirrorSizeRatio: number;
  52044. /**
  52045. * Specifies the ground mirror blur kernel size.
  52046. * 64 by default.
  52047. */
  52048. groundMirrorBlurKernel: number;
  52049. /**
  52050. * Specifies the ground mirror visibility amount.
  52051. * 1 by default
  52052. */
  52053. groundMirrorAmount: number;
  52054. /**
  52055. * Specifies the ground mirror reflectance weight.
  52056. * This uses the standard weight of the background material to setup the fresnel effect
  52057. * of the mirror.
  52058. * 1 by default.
  52059. */
  52060. groundMirrorFresnelWeight: number;
  52061. /**
  52062. * Specifies the ground mirror Falloff distance.
  52063. * This can helps reducing the size of the reflection.
  52064. * 0 by Default.
  52065. */
  52066. groundMirrorFallOffDistance: number;
  52067. /**
  52068. * Specifies the ground mirror texture type.
  52069. * Unsigned Int by Default.
  52070. */
  52071. groundMirrorTextureType: number;
  52072. /**
  52073. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52074. * the shown objects.
  52075. */
  52076. groundYBias: number;
  52077. /**
  52078. * Specifies whether or not to create a skybox.
  52079. * True by default.
  52080. */
  52081. createSkybox: boolean;
  52082. /**
  52083. * Specifies the skybox size.
  52084. * 20 by default.
  52085. */
  52086. skyboxSize: number;
  52087. /**
  52088. * The texture used on the skybox for the main color.
  52089. * Comes from the BabylonJS CDN by default.
  52090. *
  52091. * Remarks: Can be either a texture or a url.
  52092. */
  52093. skyboxTexture: string | BaseTexture;
  52094. /**
  52095. * The color mixed in the skybox texture by default.
  52096. * BabylonJS clearColor by default.
  52097. */
  52098. skyboxColor: Color3;
  52099. /**
  52100. * The background rotation around the Y axis of the scene.
  52101. * This helps aligning the key lights of your scene with the background.
  52102. * 0 by default.
  52103. */
  52104. backgroundYRotation: number;
  52105. /**
  52106. * Compute automatically the size of the elements to best fit with the scene.
  52107. */
  52108. sizeAuto: boolean;
  52109. /**
  52110. * Default position of the rootMesh if autoSize is not true.
  52111. */
  52112. rootPosition: Vector3;
  52113. /**
  52114. * Sets up the image processing in the scene.
  52115. * true by default.
  52116. */
  52117. setupImageProcessing: boolean;
  52118. /**
  52119. * The texture used as your environment texture in the scene.
  52120. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52121. *
  52122. * Remarks: Can be either a texture or a url.
  52123. */
  52124. environmentTexture: string | BaseTexture;
  52125. /**
  52126. * The value of the exposure to apply to the scene.
  52127. * 0.6 by default if setupImageProcessing is true.
  52128. */
  52129. cameraExposure: number;
  52130. /**
  52131. * The value of the contrast to apply to the scene.
  52132. * 1.6 by default if setupImageProcessing is true.
  52133. */
  52134. cameraContrast: number;
  52135. /**
  52136. * Specifies whether or not tonemapping should be enabled in the scene.
  52137. * true by default if setupImageProcessing is true.
  52138. */
  52139. toneMappingEnabled: boolean;
  52140. }
  52141. /**
  52142. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52143. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52144. * It also helps with the default setup of your imageProcessing configuration.
  52145. */
  52146. export class EnvironmentHelper {
  52147. /**
  52148. * Default ground texture URL.
  52149. */
  52150. private static _groundTextureCDNUrl;
  52151. /**
  52152. * Default skybox texture URL.
  52153. */
  52154. private static _skyboxTextureCDNUrl;
  52155. /**
  52156. * Default environment texture URL.
  52157. */
  52158. private static _environmentTextureCDNUrl;
  52159. /**
  52160. * Creates the default options for the helper.
  52161. */
  52162. private static _getDefaultOptions;
  52163. private _rootMesh;
  52164. /**
  52165. * Gets the root mesh created by the helper.
  52166. */
  52167. get rootMesh(): Mesh;
  52168. private _skybox;
  52169. /**
  52170. * Gets the skybox created by the helper.
  52171. */
  52172. get skybox(): Nullable<Mesh>;
  52173. private _skyboxTexture;
  52174. /**
  52175. * Gets the skybox texture created by the helper.
  52176. */
  52177. get skyboxTexture(): Nullable<BaseTexture>;
  52178. private _skyboxMaterial;
  52179. /**
  52180. * Gets the skybox material created by the helper.
  52181. */
  52182. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52183. private _ground;
  52184. /**
  52185. * Gets the ground mesh created by the helper.
  52186. */
  52187. get ground(): Nullable<Mesh>;
  52188. private _groundTexture;
  52189. /**
  52190. * Gets the ground texture created by the helper.
  52191. */
  52192. get groundTexture(): Nullable<BaseTexture>;
  52193. private _groundMirror;
  52194. /**
  52195. * Gets the ground mirror created by the helper.
  52196. */
  52197. get groundMirror(): Nullable<MirrorTexture>;
  52198. /**
  52199. * Gets the ground mirror render list to helps pushing the meshes
  52200. * you wish in the ground reflection.
  52201. */
  52202. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52203. private _groundMaterial;
  52204. /**
  52205. * Gets the ground material created by the helper.
  52206. */
  52207. get groundMaterial(): Nullable<BackgroundMaterial>;
  52208. /**
  52209. * Stores the creation options.
  52210. */
  52211. private readonly _scene;
  52212. private _options;
  52213. /**
  52214. * This observable will be notified with any error during the creation of the environment,
  52215. * mainly texture creation errors.
  52216. */
  52217. onErrorObservable: Observable<{
  52218. message?: string;
  52219. exception?: any;
  52220. }>;
  52221. /**
  52222. * constructor
  52223. * @param options Defines the options we want to customize the helper
  52224. * @param scene The scene to add the material to
  52225. */
  52226. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52227. /**
  52228. * Updates the background according to the new options
  52229. * @param options
  52230. */
  52231. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52232. /**
  52233. * Sets the primary color of all the available elements.
  52234. * @param color the main color to affect to the ground and the background
  52235. */
  52236. setMainColor(color: Color3): void;
  52237. /**
  52238. * Setup the image processing according to the specified options.
  52239. */
  52240. private _setupImageProcessing;
  52241. /**
  52242. * Setup the environment texture according to the specified options.
  52243. */
  52244. private _setupEnvironmentTexture;
  52245. /**
  52246. * Setup the background according to the specified options.
  52247. */
  52248. private _setupBackground;
  52249. /**
  52250. * Get the scene sizes according to the setup.
  52251. */
  52252. private _getSceneSize;
  52253. /**
  52254. * Setup the ground according to the specified options.
  52255. */
  52256. private _setupGround;
  52257. /**
  52258. * Setup the ground material according to the specified options.
  52259. */
  52260. private _setupGroundMaterial;
  52261. /**
  52262. * Setup the ground diffuse texture according to the specified options.
  52263. */
  52264. private _setupGroundDiffuseTexture;
  52265. /**
  52266. * Setup the ground mirror texture according to the specified options.
  52267. */
  52268. private _setupGroundMirrorTexture;
  52269. /**
  52270. * Setup the ground to receive the mirror texture.
  52271. */
  52272. private _setupMirrorInGroundMaterial;
  52273. /**
  52274. * Setup the skybox according to the specified options.
  52275. */
  52276. private _setupSkybox;
  52277. /**
  52278. * Setup the skybox material according to the specified options.
  52279. */
  52280. private _setupSkyboxMaterial;
  52281. /**
  52282. * Setup the skybox reflection texture according to the specified options.
  52283. */
  52284. private _setupSkyboxReflectionTexture;
  52285. private _errorHandler;
  52286. /**
  52287. * Dispose all the elements created by the Helper.
  52288. */
  52289. dispose(): void;
  52290. }
  52291. }
  52292. declare module "babylonjs/Helpers/photoDome" {
  52293. import { Observable } from "babylonjs/Misc/observable";
  52294. import { Nullable } from "babylonjs/types";
  52295. import { Scene } from "babylonjs/scene";
  52296. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52297. import { Mesh } from "babylonjs/Meshes/mesh";
  52298. import { Texture } from "babylonjs/Materials/Textures/texture";
  52299. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52300. import "babylonjs/Meshes/Builders/sphereBuilder";
  52301. /**
  52302. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52303. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52304. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52305. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52306. */
  52307. export class PhotoDome extends TransformNode {
  52308. /**
  52309. * Define the image as a Monoscopic panoramic 360 image.
  52310. */
  52311. static readonly MODE_MONOSCOPIC: number;
  52312. /**
  52313. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52314. */
  52315. static readonly MODE_TOPBOTTOM: number;
  52316. /**
  52317. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52318. */
  52319. static readonly MODE_SIDEBYSIDE: number;
  52320. private _useDirectMapping;
  52321. /**
  52322. * The texture being displayed on the sphere
  52323. */
  52324. protected _photoTexture: Texture;
  52325. /**
  52326. * Gets or sets the texture being displayed on the sphere
  52327. */
  52328. get photoTexture(): Texture;
  52329. set photoTexture(value: Texture);
  52330. /**
  52331. * Observable raised when an error occured while loading the 360 image
  52332. */
  52333. onLoadErrorObservable: Observable<string>;
  52334. /**
  52335. * The skybox material
  52336. */
  52337. protected _material: BackgroundMaterial;
  52338. /**
  52339. * The surface used for the skybox
  52340. */
  52341. protected _mesh: Mesh;
  52342. /**
  52343. * Gets the mesh used for the skybox.
  52344. */
  52345. get mesh(): Mesh;
  52346. /**
  52347. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52348. * Also see the options.resolution property.
  52349. */
  52350. get fovMultiplier(): number;
  52351. set fovMultiplier(value: number);
  52352. private _imageMode;
  52353. /**
  52354. * Gets or set the current video mode for the video. It can be:
  52355. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52356. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52357. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52358. */
  52359. get imageMode(): number;
  52360. set imageMode(value: number);
  52361. /**
  52362. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52363. * @param name Element's name, child elements will append suffixes for their own names.
  52364. * @param urlsOfPhoto defines the url of the photo to display
  52365. * @param options defines an object containing optional or exposed sub element properties
  52366. * @param onError defines a callback called when an error occured while loading the texture
  52367. */
  52368. constructor(name: string, urlOfPhoto: string, options: {
  52369. resolution?: number;
  52370. size?: number;
  52371. useDirectMapping?: boolean;
  52372. faceForward?: boolean;
  52373. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52374. private _onBeforeCameraRenderObserver;
  52375. private _changeImageMode;
  52376. /**
  52377. * Releases resources associated with this node.
  52378. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52379. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52380. */
  52381. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52382. }
  52383. }
  52384. declare module "babylonjs/Misc/rgbdTextureTools" {
  52385. import "babylonjs/Shaders/rgbdDecode.fragment";
  52386. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52387. import { Texture } from "babylonjs/Materials/Textures/texture";
  52388. /**
  52389. * Class used to host RGBD texture specific utilities
  52390. */
  52391. export class RGBDTextureTools {
  52392. /**
  52393. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52394. * @param texture the texture to expand.
  52395. */
  52396. static ExpandRGBDTexture(texture: Texture): void;
  52397. }
  52398. }
  52399. declare module "babylonjs/Misc/brdfTextureTools" {
  52400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52401. import { Scene } from "babylonjs/scene";
  52402. /**
  52403. * Class used to host texture specific utilities
  52404. */
  52405. export class BRDFTextureTools {
  52406. /**
  52407. * Prevents texture cache collision
  52408. */
  52409. private static _instanceNumber;
  52410. /**
  52411. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52412. * @param scene defines the hosting scene
  52413. * @returns the environment BRDF texture
  52414. */
  52415. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52416. private static _environmentBRDFBase64Texture;
  52417. }
  52418. }
  52419. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52420. import { Nullable } from "babylonjs/types";
  52421. import { Color3 } from "babylonjs/Maths/math.color";
  52422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52423. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52424. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52425. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52426. import { Engine } from "babylonjs/Engines/engine";
  52427. import { Scene } from "babylonjs/scene";
  52428. /**
  52429. * @hidden
  52430. */
  52431. export interface IMaterialClearCoatDefines {
  52432. CLEARCOAT: boolean;
  52433. CLEARCOAT_DEFAULTIOR: boolean;
  52434. CLEARCOAT_TEXTURE: boolean;
  52435. CLEARCOAT_TEXTUREDIRECTUV: number;
  52436. CLEARCOAT_BUMP: boolean;
  52437. CLEARCOAT_BUMPDIRECTUV: number;
  52438. CLEARCOAT_TINT: boolean;
  52439. CLEARCOAT_TINT_TEXTURE: boolean;
  52440. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52441. /** @hidden */
  52442. _areTexturesDirty: boolean;
  52443. }
  52444. /**
  52445. * Define the code related to the clear coat parameters of the pbr material.
  52446. */
  52447. export class PBRClearCoatConfiguration {
  52448. /**
  52449. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52450. * The default fits with a polyurethane material.
  52451. */
  52452. private static readonly _DefaultIndexOfRefraction;
  52453. private _isEnabled;
  52454. /**
  52455. * Defines if the clear coat is enabled in the material.
  52456. */
  52457. isEnabled: boolean;
  52458. /**
  52459. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52460. */
  52461. intensity: number;
  52462. /**
  52463. * Defines the clear coat layer roughness.
  52464. */
  52465. roughness: number;
  52466. private _indexOfRefraction;
  52467. /**
  52468. * Defines the index of refraction of the clear coat.
  52469. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52470. * The default fits with a polyurethane material.
  52471. * Changing the default value is more performance intensive.
  52472. */
  52473. indexOfRefraction: number;
  52474. private _texture;
  52475. /**
  52476. * Stores the clear coat values in a texture.
  52477. */
  52478. texture: Nullable<BaseTexture>;
  52479. private _bumpTexture;
  52480. /**
  52481. * Define the clear coat specific bump texture.
  52482. */
  52483. bumpTexture: Nullable<BaseTexture>;
  52484. private _isTintEnabled;
  52485. /**
  52486. * Defines if the clear coat tint is enabled in the material.
  52487. */
  52488. isTintEnabled: boolean;
  52489. /**
  52490. * Defines the clear coat tint of the material.
  52491. * This is only use if tint is enabled
  52492. */
  52493. tintColor: Color3;
  52494. /**
  52495. * Defines the distance at which the tint color should be found in the
  52496. * clear coat media.
  52497. * This is only use if tint is enabled
  52498. */
  52499. tintColorAtDistance: number;
  52500. /**
  52501. * Defines the clear coat layer thickness.
  52502. * This is only use if tint is enabled
  52503. */
  52504. tintThickness: number;
  52505. private _tintTexture;
  52506. /**
  52507. * Stores the clear tint values in a texture.
  52508. * rgb is tint
  52509. * a is a thickness factor
  52510. */
  52511. tintTexture: Nullable<BaseTexture>;
  52512. /** @hidden */
  52513. private _internalMarkAllSubMeshesAsTexturesDirty;
  52514. /** @hidden */
  52515. _markAllSubMeshesAsTexturesDirty(): void;
  52516. /**
  52517. * Instantiate a new istance of clear coat configuration.
  52518. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52519. */
  52520. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52521. /**
  52522. * Gets wehter the submesh is ready to be used or not.
  52523. * @param defines the list of "defines" to update.
  52524. * @param scene defines the scene the material belongs to.
  52525. * @param engine defines the engine the material belongs to.
  52526. * @param disableBumpMap defines wether the material disables bump or not.
  52527. * @returns - boolean indicating that the submesh is ready or not.
  52528. */
  52529. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52530. /**
  52531. * Checks to see if a texture is used in the material.
  52532. * @param defines the list of "defines" to update.
  52533. * @param scene defines the scene to the material belongs to.
  52534. */
  52535. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52536. /**
  52537. * Binds the material data.
  52538. * @param uniformBuffer defines the Uniform buffer to fill in.
  52539. * @param scene defines the scene the material belongs to.
  52540. * @param engine defines the engine the material belongs to.
  52541. * @param disableBumpMap defines wether the material disables bump or not.
  52542. * @param isFrozen defines wether the material is frozen or not.
  52543. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52544. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52545. */
  52546. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52547. /**
  52548. * Checks to see if a texture is used in the material.
  52549. * @param texture - Base texture to use.
  52550. * @returns - Boolean specifying if a texture is used in the material.
  52551. */
  52552. hasTexture(texture: BaseTexture): boolean;
  52553. /**
  52554. * Returns an array of the actively used textures.
  52555. * @param activeTextures Array of BaseTextures
  52556. */
  52557. getActiveTextures(activeTextures: BaseTexture[]): void;
  52558. /**
  52559. * Returns the animatable textures.
  52560. * @param animatables Array of animatable textures.
  52561. */
  52562. getAnimatables(animatables: IAnimatable[]): void;
  52563. /**
  52564. * Disposes the resources of the material.
  52565. * @param forceDisposeTextures - Forces the disposal of all textures.
  52566. */
  52567. dispose(forceDisposeTextures?: boolean): void;
  52568. /**
  52569. * Get the current class name of the texture useful for serialization or dynamic coding.
  52570. * @returns "PBRClearCoatConfiguration"
  52571. */
  52572. getClassName(): string;
  52573. /**
  52574. * Add fallbacks to the effect fallbacks list.
  52575. * @param defines defines the Base texture to use.
  52576. * @param fallbacks defines the current fallback list.
  52577. * @param currentRank defines the current fallback rank.
  52578. * @returns the new fallback rank.
  52579. */
  52580. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52581. /**
  52582. * Add the required uniforms to the current list.
  52583. * @param uniforms defines the current uniform list.
  52584. */
  52585. static AddUniforms(uniforms: string[]): void;
  52586. /**
  52587. * Add the required samplers to the current list.
  52588. * @param samplers defines the current sampler list.
  52589. */
  52590. static AddSamplers(samplers: string[]): void;
  52591. /**
  52592. * Add the required uniforms to the current buffer.
  52593. * @param uniformBuffer defines the current uniform buffer.
  52594. */
  52595. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52596. /**
  52597. * Makes a duplicate of the current configuration into another one.
  52598. * @param clearCoatConfiguration define the config where to copy the info
  52599. */
  52600. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52601. /**
  52602. * Serializes this clear coat configuration.
  52603. * @returns - An object with the serialized config.
  52604. */
  52605. serialize(): any;
  52606. /**
  52607. * Parses a anisotropy Configuration from a serialized object.
  52608. * @param source - Serialized object.
  52609. * @param scene Defines the scene we are parsing for
  52610. * @param rootUrl Defines the rootUrl to load from
  52611. */
  52612. parse(source: any, scene: Scene, rootUrl: string): void;
  52613. }
  52614. }
  52615. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52616. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52618. import { Vector2 } from "babylonjs/Maths/math.vector";
  52619. import { Scene } from "babylonjs/scene";
  52620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52621. import { Nullable } from "babylonjs/types";
  52622. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52623. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52624. /**
  52625. * @hidden
  52626. */
  52627. export interface IMaterialAnisotropicDefines {
  52628. ANISOTROPIC: boolean;
  52629. ANISOTROPIC_TEXTURE: boolean;
  52630. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52631. MAINUV1: boolean;
  52632. _areTexturesDirty: boolean;
  52633. _needUVs: boolean;
  52634. }
  52635. /**
  52636. * Define the code related to the anisotropic parameters of the pbr material.
  52637. */
  52638. export class PBRAnisotropicConfiguration {
  52639. private _isEnabled;
  52640. /**
  52641. * Defines if the anisotropy is enabled in the material.
  52642. */
  52643. isEnabled: boolean;
  52644. /**
  52645. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52646. */
  52647. intensity: number;
  52648. /**
  52649. * Defines if the effect is along the tangents, bitangents or in between.
  52650. * By default, the effect is "strectching" the highlights along the tangents.
  52651. */
  52652. direction: Vector2;
  52653. private _texture;
  52654. /**
  52655. * Stores the anisotropy values in a texture.
  52656. * rg is direction (like normal from -1 to 1)
  52657. * b is a intensity
  52658. */
  52659. texture: Nullable<BaseTexture>;
  52660. /** @hidden */
  52661. private _internalMarkAllSubMeshesAsTexturesDirty;
  52662. /** @hidden */
  52663. _markAllSubMeshesAsTexturesDirty(): void;
  52664. /**
  52665. * Instantiate a new istance of anisotropy configuration.
  52666. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52667. */
  52668. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52669. /**
  52670. * Specifies that the submesh is ready to be used.
  52671. * @param defines the list of "defines" to update.
  52672. * @param scene defines the scene the material belongs to.
  52673. * @returns - boolean indicating that the submesh is ready or not.
  52674. */
  52675. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52676. /**
  52677. * Checks to see if a texture is used in the material.
  52678. * @param defines the list of "defines" to update.
  52679. * @param mesh the mesh we are preparing the defines for.
  52680. * @param scene defines the scene the material belongs to.
  52681. */
  52682. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52683. /**
  52684. * Binds the material data.
  52685. * @param uniformBuffer defines the Uniform buffer to fill in.
  52686. * @param scene defines the scene the material belongs to.
  52687. * @param isFrozen defines wether the material is frozen or not.
  52688. */
  52689. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52690. /**
  52691. * Checks to see if a texture is used in the material.
  52692. * @param texture - Base texture to use.
  52693. * @returns - Boolean specifying if a texture is used in the material.
  52694. */
  52695. hasTexture(texture: BaseTexture): boolean;
  52696. /**
  52697. * Returns an array of the actively used textures.
  52698. * @param activeTextures Array of BaseTextures
  52699. */
  52700. getActiveTextures(activeTextures: BaseTexture[]): void;
  52701. /**
  52702. * Returns the animatable textures.
  52703. * @param animatables Array of animatable textures.
  52704. */
  52705. getAnimatables(animatables: IAnimatable[]): void;
  52706. /**
  52707. * Disposes the resources of the material.
  52708. * @param forceDisposeTextures - Forces the disposal of all textures.
  52709. */
  52710. dispose(forceDisposeTextures?: boolean): void;
  52711. /**
  52712. * Get the current class name of the texture useful for serialization or dynamic coding.
  52713. * @returns "PBRAnisotropicConfiguration"
  52714. */
  52715. getClassName(): string;
  52716. /**
  52717. * Add fallbacks to the effect fallbacks list.
  52718. * @param defines defines the Base texture to use.
  52719. * @param fallbacks defines the current fallback list.
  52720. * @param currentRank defines the current fallback rank.
  52721. * @returns the new fallback rank.
  52722. */
  52723. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52724. /**
  52725. * Add the required uniforms to the current list.
  52726. * @param uniforms defines the current uniform list.
  52727. */
  52728. static AddUniforms(uniforms: string[]): void;
  52729. /**
  52730. * Add the required uniforms to the current buffer.
  52731. * @param uniformBuffer defines the current uniform buffer.
  52732. */
  52733. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52734. /**
  52735. * Add the required samplers to the current list.
  52736. * @param samplers defines the current sampler list.
  52737. */
  52738. static AddSamplers(samplers: string[]): void;
  52739. /**
  52740. * Makes a duplicate of the current configuration into another one.
  52741. * @param anisotropicConfiguration define the config where to copy the info
  52742. */
  52743. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52744. /**
  52745. * Serializes this anisotropy configuration.
  52746. * @returns - An object with the serialized config.
  52747. */
  52748. serialize(): any;
  52749. /**
  52750. * Parses a anisotropy Configuration from a serialized object.
  52751. * @param source - Serialized object.
  52752. * @param scene Defines the scene we are parsing for
  52753. * @param rootUrl Defines the rootUrl to load from
  52754. */
  52755. parse(source: any, scene: Scene, rootUrl: string): void;
  52756. }
  52757. }
  52758. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52759. import { Scene } from "babylonjs/scene";
  52760. /**
  52761. * @hidden
  52762. */
  52763. export interface IMaterialBRDFDefines {
  52764. BRDF_V_HEIGHT_CORRELATED: boolean;
  52765. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52766. SPHERICAL_HARMONICS: boolean;
  52767. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52768. /** @hidden */
  52769. _areMiscDirty: boolean;
  52770. }
  52771. /**
  52772. * Define the code related to the BRDF parameters of the pbr material.
  52773. */
  52774. export class PBRBRDFConfiguration {
  52775. /**
  52776. * Default value used for the energy conservation.
  52777. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52778. */
  52779. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52780. /**
  52781. * Default value used for the Smith Visibility Height Correlated mode.
  52782. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52783. */
  52784. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52785. /**
  52786. * Default value used for the IBL diffuse part.
  52787. * This can help switching back to the polynomials mode globally which is a tiny bit
  52788. * less GPU intensive at the drawback of a lower quality.
  52789. */
  52790. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52791. /**
  52792. * Default value used for activating energy conservation for the specular workflow.
  52793. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52794. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52795. */
  52796. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52797. private _useEnergyConservation;
  52798. /**
  52799. * Defines if the material uses energy conservation.
  52800. */
  52801. useEnergyConservation: boolean;
  52802. private _useSmithVisibilityHeightCorrelated;
  52803. /**
  52804. * LEGACY Mode set to false
  52805. * Defines if the material uses height smith correlated visibility term.
  52806. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52807. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52808. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52809. * Not relying on height correlated will also disable energy conservation.
  52810. */
  52811. useSmithVisibilityHeightCorrelated: boolean;
  52812. private _useSphericalHarmonics;
  52813. /**
  52814. * LEGACY Mode set to false
  52815. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52816. * diffuse part of the IBL.
  52817. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52818. * to the ground truth.
  52819. */
  52820. useSphericalHarmonics: boolean;
  52821. private _useSpecularGlossinessInputEnergyConservation;
  52822. /**
  52823. * Defines if the material uses energy conservation, when the specular workflow is active.
  52824. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52825. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52826. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52827. */
  52828. useSpecularGlossinessInputEnergyConservation: boolean;
  52829. /** @hidden */
  52830. private _internalMarkAllSubMeshesAsMiscDirty;
  52831. /** @hidden */
  52832. _markAllSubMeshesAsMiscDirty(): void;
  52833. /**
  52834. * Instantiate a new istance of clear coat configuration.
  52835. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52836. */
  52837. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52838. /**
  52839. * Checks to see if a texture is used in the material.
  52840. * @param defines the list of "defines" to update.
  52841. */
  52842. prepareDefines(defines: IMaterialBRDFDefines): void;
  52843. /**
  52844. * Get the current class name of the texture useful for serialization or dynamic coding.
  52845. * @returns "PBRClearCoatConfiguration"
  52846. */
  52847. getClassName(): string;
  52848. /**
  52849. * Makes a duplicate of the current configuration into another one.
  52850. * @param brdfConfiguration define the config where to copy the info
  52851. */
  52852. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52853. /**
  52854. * Serializes this BRDF configuration.
  52855. * @returns - An object with the serialized config.
  52856. */
  52857. serialize(): any;
  52858. /**
  52859. * Parses a anisotropy Configuration from a serialized object.
  52860. * @param source - Serialized object.
  52861. * @param scene Defines the scene we are parsing for
  52862. * @param rootUrl Defines the rootUrl to load from
  52863. */
  52864. parse(source: any, scene: Scene, rootUrl: string): void;
  52865. }
  52866. }
  52867. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52868. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52869. import { Color3 } from "babylonjs/Maths/math.color";
  52870. import { Scene } from "babylonjs/scene";
  52871. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52872. import { Nullable } from "babylonjs/types";
  52873. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52874. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52875. /**
  52876. * @hidden
  52877. */
  52878. export interface IMaterialSheenDefines {
  52879. SHEEN: boolean;
  52880. SHEEN_TEXTURE: boolean;
  52881. SHEEN_TEXTUREDIRECTUV: number;
  52882. SHEEN_LINKWITHALBEDO: boolean;
  52883. SHEEN_ROUGHNESS: boolean;
  52884. SHEEN_ALBEDOSCALING: boolean;
  52885. /** @hidden */
  52886. _areTexturesDirty: boolean;
  52887. }
  52888. /**
  52889. * Define the code related to the Sheen parameters of the pbr material.
  52890. */
  52891. export class PBRSheenConfiguration {
  52892. private _isEnabled;
  52893. /**
  52894. * Defines if the material uses sheen.
  52895. */
  52896. isEnabled: boolean;
  52897. private _linkSheenWithAlbedo;
  52898. /**
  52899. * Defines if the sheen is linked to the sheen color.
  52900. */
  52901. linkSheenWithAlbedo: boolean;
  52902. /**
  52903. * Defines the sheen intensity.
  52904. */
  52905. intensity: number;
  52906. /**
  52907. * Defines the sheen color.
  52908. */
  52909. color: Color3;
  52910. private _texture;
  52911. /**
  52912. * Stores the sheen tint values in a texture.
  52913. * rgb is tint
  52914. * a is a intensity
  52915. */
  52916. texture: Nullable<BaseTexture>;
  52917. private _roughness;
  52918. /**
  52919. * Defines the sheen roughness.
  52920. * It is not taken into account if linkSheenWithAlbedo is true.
  52921. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52922. */
  52923. roughness: Nullable<number>;
  52924. private _albedoScaling;
  52925. /**
  52926. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52927. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52928. * making it easier to setup and tweak the effect
  52929. */
  52930. albedoScaling: boolean;
  52931. /** @hidden */
  52932. private _internalMarkAllSubMeshesAsTexturesDirty;
  52933. /** @hidden */
  52934. _markAllSubMeshesAsTexturesDirty(): void;
  52935. /**
  52936. * Instantiate a new istance of clear coat configuration.
  52937. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52938. */
  52939. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52940. /**
  52941. * Specifies that the submesh is ready to be used.
  52942. * @param defines the list of "defines" to update.
  52943. * @param scene defines the scene the material belongs to.
  52944. * @returns - boolean indicating that the submesh is ready or not.
  52945. */
  52946. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52947. /**
  52948. * Checks to see if a texture is used in the material.
  52949. * @param defines the list of "defines" to update.
  52950. * @param scene defines the scene the material belongs to.
  52951. */
  52952. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52953. /**
  52954. * Binds the material data.
  52955. * @param uniformBuffer defines the Uniform buffer to fill in.
  52956. * @param scene defines the scene the material belongs to.
  52957. * @param isFrozen defines wether the material is frozen or not.
  52958. */
  52959. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52960. /**
  52961. * Checks to see if a texture is used in the material.
  52962. * @param texture - Base texture to use.
  52963. * @returns - Boolean specifying if a texture is used in the material.
  52964. */
  52965. hasTexture(texture: BaseTexture): boolean;
  52966. /**
  52967. * Returns an array of the actively used textures.
  52968. * @param activeTextures Array of BaseTextures
  52969. */
  52970. getActiveTextures(activeTextures: BaseTexture[]): void;
  52971. /**
  52972. * Returns the animatable textures.
  52973. * @param animatables Array of animatable textures.
  52974. */
  52975. getAnimatables(animatables: IAnimatable[]): void;
  52976. /**
  52977. * Disposes the resources of the material.
  52978. * @param forceDisposeTextures - Forces the disposal of all textures.
  52979. */
  52980. dispose(forceDisposeTextures?: boolean): void;
  52981. /**
  52982. * Get the current class name of the texture useful for serialization or dynamic coding.
  52983. * @returns "PBRSheenConfiguration"
  52984. */
  52985. getClassName(): string;
  52986. /**
  52987. * Add fallbacks to the effect fallbacks list.
  52988. * @param defines defines the Base texture to use.
  52989. * @param fallbacks defines the current fallback list.
  52990. * @param currentRank defines the current fallback rank.
  52991. * @returns the new fallback rank.
  52992. */
  52993. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52994. /**
  52995. * Add the required uniforms to the current list.
  52996. * @param uniforms defines the current uniform list.
  52997. */
  52998. static AddUniforms(uniforms: string[]): void;
  52999. /**
  53000. * Add the required uniforms to the current buffer.
  53001. * @param uniformBuffer defines the current uniform buffer.
  53002. */
  53003. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53004. /**
  53005. * Add the required samplers to the current list.
  53006. * @param samplers defines the current sampler list.
  53007. */
  53008. static AddSamplers(samplers: string[]): void;
  53009. /**
  53010. * Makes a duplicate of the current configuration into another one.
  53011. * @param sheenConfiguration define the config where to copy the info
  53012. */
  53013. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53014. /**
  53015. * Serializes this BRDF configuration.
  53016. * @returns - An object with the serialized config.
  53017. */
  53018. serialize(): any;
  53019. /**
  53020. * Parses a anisotropy Configuration from a serialized object.
  53021. * @param source - Serialized object.
  53022. * @param scene Defines the scene we are parsing for
  53023. * @param rootUrl Defines the rootUrl to load from
  53024. */
  53025. parse(source: any, scene: Scene, rootUrl: string): void;
  53026. }
  53027. }
  53028. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53029. import { Nullable } from "babylonjs/types";
  53030. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53031. import { Color3 } from "babylonjs/Maths/math.color";
  53032. import { SmartArray } from "babylonjs/Misc/smartArray";
  53033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53034. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53035. import { Effect } from "babylonjs/Materials/effect";
  53036. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53037. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53038. import { Engine } from "babylonjs/Engines/engine";
  53039. import { Scene } from "babylonjs/scene";
  53040. /**
  53041. * @hidden
  53042. */
  53043. export interface IMaterialSubSurfaceDefines {
  53044. SUBSURFACE: boolean;
  53045. SS_REFRACTION: boolean;
  53046. SS_TRANSLUCENCY: boolean;
  53047. SS_SCATERRING: boolean;
  53048. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53049. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53050. SS_REFRACTIONMAP_3D: boolean;
  53051. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53052. SS_LODINREFRACTIONALPHA: boolean;
  53053. SS_GAMMAREFRACTION: boolean;
  53054. SS_RGBDREFRACTION: boolean;
  53055. SS_LINEARSPECULARREFRACTION: boolean;
  53056. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53057. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53058. /** @hidden */
  53059. _areTexturesDirty: boolean;
  53060. }
  53061. /**
  53062. * Define the code related to the sub surface parameters of the pbr material.
  53063. */
  53064. export class PBRSubSurfaceConfiguration {
  53065. private _isRefractionEnabled;
  53066. /**
  53067. * Defines if the refraction is enabled in the material.
  53068. */
  53069. isRefractionEnabled: boolean;
  53070. private _isTranslucencyEnabled;
  53071. /**
  53072. * Defines if the translucency is enabled in the material.
  53073. */
  53074. isTranslucencyEnabled: boolean;
  53075. private _isScatteringEnabled;
  53076. /**
  53077. * Defines the refraction intensity of the material.
  53078. * The refraction when enabled replaces the Diffuse part of the material.
  53079. * The intensity helps transitionning between diffuse and refraction.
  53080. */
  53081. refractionIntensity: number;
  53082. /**
  53083. * Defines the translucency intensity of the material.
  53084. * When translucency has been enabled, this defines how much of the "translucency"
  53085. * is addded to the diffuse part of the material.
  53086. */
  53087. translucencyIntensity: number;
  53088. /**
  53089. * Defines the scattering intensity of the material.
  53090. * When scattering has been enabled, this defines how much of the "scattered light"
  53091. * is addded to the diffuse part of the material.
  53092. */
  53093. scatteringIntensity: number;
  53094. private _thicknessTexture;
  53095. /**
  53096. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53097. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53098. * 0 would mean minimumThickness
  53099. * 1 would mean maximumThickness
  53100. * The other channels might be use as a mask to vary the different effects intensity.
  53101. */
  53102. thicknessTexture: Nullable<BaseTexture>;
  53103. private _refractionTexture;
  53104. /**
  53105. * Defines the texture to use for refraction.
  53106. */
  53107. refractionTexture: Nullable<BaseTexture>;
  53108. private _indexOfRefraction;
  53109. /**
  53110. * Defines the index of refraction used in the material.
  53111. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53112. */
  53113. indexOfRefraction: number;
  53114. private _invertRefractionY;
  53115. /**
  53116. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53117. */
  53118. invertRefractionY: boolean;
  53119. private _linkRefractionWithTransparency;
  53120. /**
  53121. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53122. * Materials half opaque for instance using refraction could benefit from this control.
  53123. */
  53124. linkRefractionWithTransparency: boolean;
  53125. /**
  53126. * Defines the minimum thickness stored in the thickness map.
  53127. * If no thickness map is defined, this value will be used to simulate thickness.
  53128. */
  53129. minimumThickness: number;
  53130. /**
  53131. * Defines the maximum thickness stored in the thickness map.
  53132. */
  53133. maximumThickness: number;
  53134. /**
  53135. * Defines the volume tint of the material.
  53136. * This is used for both translucency and scattering.
  53137. */
  53138. tintColor: Color3;
  53139. /**
  53140. * Defines the distance at which the tint color should be found in the media.
  53141. * This is used for refraction only.
  53142. */
  53143. tintColorAtDistance: number;
  53144. /**
  53145. * Defines how far each channel transmit through the media.
  53146. * It is defined as a color to simplify it selection.
  53147. */
  53148. diffusionDistance: Color3;
  53149. private _useMaskFromThicknessTexture;
  53150. /**
  53151. * Stores the intensity of the different subsurface effects in the thickness texture.
  53152. * * the green channel is the translucency intensity.
  53153. * * the blue channel is the scattering intensity.
  53154. * * the alpha channel is the refraction intensity.
  53155. */
  53156. useMaskFromThicknessTexture: boolean;
  53157. /** @hidden */
  53158. private _internalMarkAllSubMeshesAsTexturesDirty;
  53159. /** @hidden */
  53160. _markAllSubMeshesAsTexturesDirty(): void;
  53161. /**
  53162. * Instantiate a new istance of sub surface configuration.
  53163. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53164. */
  53165. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53166. /**
  53167. * Gets wehter the submesh is ready to be used or not.
  53168. * @param defines the list of "defines" to update.
  53169. * @param scene defines the scene the material belongs to.
  53170. * @returns - boolean indicating that the submesh is ready or not.
  53171. */
  53172. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53173. /**
  53174. * Checks to see if a texture is used in the material.
  53175. * @param defines the list of "defines" to update.
  53176. * @param scene defines the scene to the material belongs to.
  53177. */
  53178. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53179. /**
  53180. * Binds the material data.
  53181. * @param uniformBuffer defines the Uniform buffer to fill in.
  53182. * @param scene defines the scene the material belongs to.
  53183. * @param engine defines the engine the material belongs to.
  53184. * @param isFrozen defines wether the material is frozen or not.
  53185. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53186. */
  53187. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53188. /**
  53189. * Unbinds the material from the mesh.
  53190. * @param activeEffect defines the effect that should be unbound from.
  53191. * @returns true if unbound, otherwise false
  53192. */
  53193. unbind(activeEffect: Effect): boolean;
  53194. /**
  53195. * Returns the texture used for refraction or null if none is used.
  53196. * @param scene defines the scene the material belongs to.
  53197. * @returns - Refraction texture if present. If no refraction texture and refraction
  53198. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53199. */
  53200. private _getRefractionTexture;
  53201. /**
  53202. * Returns true if alpha blending should be disabled.
  53203. */
  53204. get disableAlphaBlending(): boolean;
  53205. /**
  53206. * Fills the list of render target textures.
  53207. * @param renderTargets the list of render targets to update
  53208. */
  53209. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53210. /**
  53211. * Checks to see if a texture is used in the material.
  53212. * @param texture - Base texture to use.
  53213. * @returns - Boolean specifying if a texture is used in the material.
  53214. */
  53215. hasTexture(texture: BaseTexture): boolean;
  53216. /**
  53217. * Gets a boolean indicating that current material needs to register RTT
  53218. * @returns true if this uses a render target otherwise false.
  53219. */
  53220. hasRenderTargetTextures(): boolean;
  53221. /**
  53222. * Returns an array of the actively used textures.
  53223. * @param activeTextures Array of BaseTextures
  53224. */
  53225. getActiveTextures(activeTextures: BaseTexture[]): void;
  53226. /**
  53227. * Returns the animatable textures.
  53228. * @param animatables Array of animatable textures.
  53229. */
  53230. getAnimatables(animatables: IAnimatable[]): void;
  53231. /**
  53232. * Disposes the resources of the material.
  53233. * @param forceDisposeTextures - Forces the disposal of all textures.
  53234. */
  53235. dispose(forceDisposeTextures?: boolean): void;
  53236. /**
  53237. * Get the current class name of the texture useful for serialization or dynamic coding.
  53238. * @returns "PBRSubSurfaceConfiguration"
  53239. */
  53240. getClassName(): string;
  53241. /**
  53242. * Add fallbacks to the effect fallbacks list.
  53243. * @param defines defines the Base texture to use.
  53244. * @param fallbacks defines the current fallback list.
  53245. * @param currentRank defines the current fallback rank.
  53246. * @returns the new fallback rank.
  53247. */
  53248. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53249. /**
  53250. * Add the required uniforms to the current list.
  53251. * @param uniforms defines the current uniform list.
  53252. */
  53253. static AddUniforms(uniforms: string[]): void;
  53254. /**
  53255. * Add the required samplers to the current list.
  53256. * @param samplers defines the current sampler list.
  53257. */
  53258. static AddSamplers(samplers: string[]): void;
  53259. /**
  53260. * Add the required uniforms to the current buffer.
  53261. * @param uniformBuffer defines the current uniform buffer.
  53262. */
  53263. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53264. /**
  53265. * Makes a duplicate of the current configuration into another one.
  53266. * @param configuration define the config where to copy the info
  53267. */
  53268. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53269. /**
  53270. * Serializes this Sub Surface configuration.
  53271. * @returns - An object with the serialized config.
  53272. */
  53273. serialize(): any;
  53274. /**
  53275. * Parses a anisotropy Configuration from a serialized object.
  53276. * @param source - Serialized object.
  53277. * @param scene Defines the scene we are parsing for
  53278. * @param rootUrl Defines the rootUrl to load from
  53279. */
  53280. parse(source: any, scene: Scene, rootUrl: string): void;
  53281. }
  53282. }
  53283. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53284. /** @hidden */
  53285. export var pbrFragmentDeclaration: {
  53286. name: string;
  53287. shader: string;
  53288. };
  53289. }
  53290. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53291. /** @hidden */
  53292. export var pbrUboDeclaration: {
  53293. name: string;
  53294. shader: string;
  53295. };
  53296. }
  53297. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53298. /** @hidden */
  53299. export var pbrFragmentExtraDeclaration: {
  53300. name: string;
  53301. shader: string;
  53302. };
  53303. }
  53304. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53305. /** @hidden */
  53306. export var pbrFragmentSamplersDeclaration: {
  53307. name: string;
  53308. shader: string;
  53309. };
  53310. }
  53311. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53312. /** @hidden */
  53313. export var pbrHelperFunctions: {
  53314. name: string;
  53315. shader: string;
  53316. };
  53317. }
  53318. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53319. /** @hidden */
  53320. export var harmonicsFunctions: {
  53321. name: string;
  53322. shader: string;
  53323. };
  53324. }
  53325. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53326. /** @hidden */
  53327. export var pbrDirectLightingSetupFunctions: {
  53328. name: string;
  53329. shader: string;
  53330. };
  53331. }
  53332. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53333. /** @hidden */
  53334. export var pbrDirectLightingFalloffFunctions: {
  53335. name: string;
  53336. shader: string;
  53337. };
  53338. }
  53339. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53340. /** @hidden */
  53341. export var pbrBRDFFunctions: {
  53342. name: string;
  53343. shader: string;
  53344. };
  53345. }
  53346. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53347. /** @hidden */
  53348. export var pbrDirectLightingFunctions: {
  53349. name: string;
  53350. shader: string;
  53351. };
  53352. }
  53353. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53354. /** @hidden */
  53355. export var pbrIBLFunctions: {
  53356. name: string;
  53357. shader: string;
  53358. };
  53359. }
  53360. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53361. /** @hidden */
  53362. export var pbrBlockAlbedoOpacity: {
  53363. name: string;
  53364. shader: string;
  53365. };
  53366. }
  53367. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53368. /** @hidden */
  53369. export var pbrBlockReflectivity: {
  53370. name: string;
  53371. shader: string;
  53372. };
  53373. }
  53374. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53375. /** @hidden */
  53376. export var pbrBlockAmbientOcclusion: {
  53377. name: string;
  53378. shader: string;
  53379. };
  53380. }
  53381. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53382. /** @hidden */
  53383. export var pbrBlockAlphaFresnel: {
  53384. name: string;
  53385. shader: string;
  53386. };
  53387. }
  53388. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53389. /** @hidden */
  53390. export var pbrBlockAnisotropic: {
  53391. name: string;
  53392. shader: string;
  53393. };
  53394. }
  53395. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53396. /** @hidden */
  53397. export var pbrBlockReflection: {
  53398. name: string;
  53399. shader: string;
  53400. };
  53401. }
  53402. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53403. /** @hidden */
  53404. export var pbrBlockSheen: {
  53405. name: string;
  53406. shader: string;
  53407. };
  53408. }
  53409. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53410. /** @hidden */
  53411. export var pbrBlockClearcoat: {
  53412. name: string;
  53413. shader: string;
  53414. };
  53415. }
  53416. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53417. /** @hidden */
  53418. export var pbrBlockSubSurface: {
  53419. name: string;
  53420. shader: string;
  53421. };
  53422. }
  53423. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53424. /** @hidden */
  53425. export var pbrBlockNormalGeometric: {
  53426. name: string;
  53427. shader: string;
  53428. };
  53429. }
  53430. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53431. /** @hidden */
  53432. export var pbrBlockNormalFinal: {
  53433. name: string;
  53434. shader: string;
  53435. };
  53436. }
  53437. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53438. /** @hidden */
  53439. export var pbrBlockGeometryInfo: {
  53440. name: string;
  53441. shader: string;
  53442. };
  53443. }
  53444. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53445. /** @hidden */
  53446. export var pbrBlockReflectance0: {
  53447. name: string;
  53448. shader: string;
  53449. };
  53450. }
  53451. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53452. /** @hidden */
  53453. export var pbrBlockReflectance: {
  53454. name: string;
  53455. shader: string;
  53456. };
  53457. }
  53458. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53459. /** @hidden */
  53460. export var pbrBlockDirectLighting: {
  53461. name: string;
  53462. shader: string;
  53463. };
  53464. }
  53465. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53466. /** @hidden */
  53467. export var pbrBlockFinalLitComponents: {
  53468. name: string;
  53469. shader: string;
  53470. };
  53471. }
  53472. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53473. /** @hidden */
  53474. export var pbrBlockFinalUnlitComponents: {
  53475. name: string;
  53476. shader: string;
  53477. };
  53478. }
  53479. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53480. /** @hidden */
  53481. export var pbrBlockFinalColorComposition: {
  53482. name: string;
  53483. shader: string;
  53484. };
  53485. }
  53486. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53487. /** @hidden */
  53488. export var pbrBlockImageProcessing: {
  53489. name: string;
  53490. shader: string;
  53491. };
  53492. }
  53493. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53494. /** @hidden */
  53495. export var pbrDebug: {
  53496. name: string;
  53497. shader: string;
  53498. };
  53499. }
  53500. declare module "babylonjs/Shaders/pbr.fragment" {
  53501. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53502. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53503. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53504. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53505. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53506. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53507. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53508. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53509. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53510. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53511. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53512. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53513. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53514. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53515. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53516. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53517. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53518. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53519. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53520. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53521. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53522. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53523. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53524. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53525. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53526. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53527. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53528. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53529. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53530. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53531. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53532. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53533. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53534. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53535. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53536. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53537. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53538. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53539. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53540. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53541. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53542. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53543. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53544. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53545. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53546. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53547. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53548. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53549. /** @hidden */
  53550. export var pbrPixelShader: {
  53551. name: string;
  53552. shader: string;
  53553. };
  53554. }
  53555. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53556. /** @hidden */
  53557. export var pbrVertexDeclaration: {
  53558. name: string;
  53559. shader: string;
  53560. };
  53561. }
  53562. declare module "babylonjs/Shaders/pbr.vertex" {
  53563. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53564. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53565. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53566. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53567. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53568. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53569. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53570. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53571. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53572. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53573. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53575. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53576. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53577. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53578. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53579. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53580. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53581. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53582. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53583. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53584. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53585. /** @hidden */
  53586. export var pbrVertexShader: {
  53587. name: string;
  53588. shader: string;
  53589. };
  53590. }
  53591. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53592. import { Nullable } from "babylonjs/types";
  53593. import { Scene } from "babylonjs/scene";
  53594. import { Matrix } from "babylonjs/Maths/math.vector";
  53595. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53597. import { Mesh } from "babylonjs/Meshes/mesh";
  53598. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53599. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53600. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53601. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53602. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53603. import { Color3 } from "babylonjs/Maths/math.color";
  53604. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53605. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53606. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53607. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53608. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53609. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53610. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53611. import "babylonjs/Shaders/pbr.fragment";
  53612. import "babylonjs/Shaders/pbr.vertex";
  53613. /**
  53614. * Manages the defines for the PBR Material.
  53615. * @hidden
  53616. */
  53617. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53618. PBR: boolean;
  53619. MAINUV1: boolean;
  53620. MAINUV2: boolean;
  53621. UV1: boolean;
  53622. UV2: boolean;
  53623. ALBEDO: boolean;
  53624. GAMMAALBEDO: boolean;
  53625. ALBEDODIRECTUV: number;
  53626. VERTEXCOLOR: boolean;
  53627. AMBIENT: boolean;
  53628. AMBIENTDIRECTUV: number;
  53629. AMBIENTINGRAYSCALE: boolean;
  53630. OPACITY: boolean;
  53631. VERTEXALPHA: boolean;
  53632. OPACITYDIRECTUV: number;
  53633. OPACITYRGB: boolean;
  53634. ALPHATEST: boolean;
  53635. DEPTHPREPASS: boolean;
  53636. ALPHABLEND: boolean;
  53637. ALPHAFROMALBEDO: boolean;
  53638. ALPHATESTVALUE: string;
  53639. SPECULAROVERALPHA: boolean;
  53640. RADIANCEOVERALPHA: boolean;
  53641. ALPHAFRESNEL: boolean;
  53642. LINEARALPHAFRESNEL: boolean;
  53643. PREMULTIPLYALPHA: boolean;
  53644. EMISSIVE: boolean;
  53645. EMISSIVEDIRECTUV: number;
  53646. REFLECTIVITY: boolean;
  53647. REFLECTIVITYDIRECTUV: number;
  53648. SPECULARTERM: boolean;
  53649. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53650. MICROSURFACEAUTOMATIC: boolean;
  53651. LODBASEDMICROSFURACE: boolean;
  53652. MICROSURFACEMAP: boolean;
  53653. MICROSURFACEMAPDIRECTUV: number;
  53654. METALLICWORKFLOW: boolean;
  53655. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53656. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53657. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53658. AOSTOREINMETALMAPRED: boolean;
  53659. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53660. ENVIRONMENTBRDF: boolean;
  53661. ENVIRONMENTBRDF_RGBD: boolean;
  53662. NORMAL: boolean;
  53663. TANGENT: boolean;
  53664. BUMP: boolean;
  53665. BUMPDIRECTUV: number;
  53666. OBJECTSPACE_NORMALMAP: boolean;
  53667. PARALLAX: boolean;
  53668. PARALLAXOCCLUSION: boolean;
  53669. NORMALXYSCALE: boolean;
  53670. LIGHTMAP: boolean;
  53671. LIGHTMAPDIRECTUV: number;
  53672. USELIGHTMAPASSHADOWMAP: boolean;
  53673. GAMMALIGHTMAP: boolean;
  53674. RGBDLIGHTMAP: boolean;
  53675. REFLECTION: boolean;
  53676. REFLECTIONMAP_3D: boolean;
  53677. REFLECTIONMAP_SPHERICAL: boolean;
  53678. REFLECTIONMAP_PLANAR: boolean;
  53679. REFLECTIONMAP_CUBIC: boolean;
  53680. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53681. REFLECTIONMAP_PROJECTION: boolean;
  53682. REFLECTIONMAP_SKYBOX: boolean;
  53683. REFLECTIONMAP_EXPLICIT: boolean;
  53684. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53685. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53686. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53687. INVERTCUBICMAP: boolean;
  53688. USESPHERICALFROMREFLECTIONMAP: boolean;
  53689. USEIRRADIANCEMAP: boolean;
  53690. SPHERICAL_HARMONICS: boolean;
  53691. USESPHERICALINVERTEX: boolean;
  53692. REFLECTIONMAP_OPPOSITEZ: boolean;
  53693. LODINREFLECTIONALPHA: boolean;
  53694. GAMMAREFLECTION: boolean;
  53695. RGBDREFLECTION: boolean;
  53696. LINEARSPECULARREFLECTION: boolean;
  53697. RADIANCEOCCLUSION: boolean;
  53698. HORIZONOCCLUSION: boolean;
  53699. INSTANCES: boolean;
  53700. NUM_BONE_INFLUENCERS: number;
  53701. BonesPerMesh: number;
  53702. BONETEXTURE: boolean;
  53703. NONUNIFORMSCALING: boolean;
  53704. MORPHTARGETS: boolean;
  53705. MORPHTARGETS_NORMAL: boolean;
  53706. MORPHTARGETS_TANGENT: boolean;
  53707. MORPHTARGETS_UV: boolean;
  53708. NUM_MORPH_INFLUENCERS: number;
  53709. IMAGEPROCESSING: boolean;
  53710. VIGNETTE: boolean;
  53711. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53712. VIGNETTEBLENDMODEOPAQUE: boolean;
  53713. TONEMAPPING: boolean;
  53714. TONEMAPPING_ACES: boolean;
  53715. CONTRAST: boolean;
  53716. COLORCURVES: boolean;
  53717. COLORGRADING: boolean;
  53718. COLORGRADING3D: boolean;
  53719. SAMPLER3DGREENDEPTH: boolean;
  53720. SAMPLER3DBGRMAP: boolean;
  53721. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53722. EXPOSURE: boolean;
  53723. MULTIVIEW: boolean;
  53724. USEPHYSICALLIGHTFALLOFF: boolean;
  53725. USEGLTFLIGHTFALLOFF: boolean;
  53726. TWOSIDEDLIGHTING: boolean;
  53727. SHADOWFLOAT: boolean;
  53728. CLIPPLANE: boolean;
  53729. CLIPPLANE2: boolean;
  53730. CLIPPLANE3: boolean;
  53731. CLIPPLANE4: boolean;
  53732. CLIPPLANE5: boolean;
  53733. CLIPPLANE6: boolean;
  53734. POINTSIZE: boolean;
  53735. FOG: boolean;
  53736. LOGARITHMICDEPTH: boolean;
  53737. FORCENORMALFORWARD: boolean;
  53738. SPECULARAA: boolean;
  53739. CLEARCOAT: boolean;
  53740. CLEARCOAT_DEFAULTIOR: boolean;
  53741. CLEARCOAT_TEXTURE: boolean;
  53742. CLEARCOAT_TEXTUREDIRECTUV: number;
  53743. CLEARCOAT_BUMP: boolean;
  53744. CLEARCOAT_BUMPDIRECTUV: number;
  53745. CLEARCOAT_TINT: boolean;
  53746. CLEARCOAT_TINT_TEXTURE: boolean;
  53747. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53748. ANISOTROPIC: boolean;
  53749. ANISOTROPIC_TEXTURE: boolean;
  53750. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53751. BRDF_V_HEIGHT_CORRELATED: boolean;
  53752. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53753. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53754. SHEEN: boolean;
  53755. SHEEN_TEXTURE: boolean;
  53756. SHEEN_TEXTUREDIRECTUV: number;
  53757. SHEEN_LINKWITHALBEDO: boolean;
  53758. SHEEN_ROUGHNESS: boolean;
  53759. SHEEN_ALBEDOSCALING: boolean;
  53760. SUBSURFACE: boolean;
  53761. SS_REFRACTION: boolean;
  53762. SS_TRANSLUCENCY: boolean;
  53763. SS_SCATERRING: boolean;
  53764. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53765. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53766. SS_REFRACTIONMAP_3D: boolean;
  53767. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53768. SS_LODINREFRACTIONALPHA: boolean;
  53769. SS_GAMMAREFRACTION: boolean;
  53770. SS_RGBDREFRACTION: boolean;
  53771. SS_LINEARSPECULARREFRACTION: boolean;
  53772. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53773. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53774. UNLIT: boolean;
  53775. DEBUGMODE: number;
  53776. /**
  53777. * Initializes the PBR Material defines.
  53778. */
  53779. constructor();
  53780. /**
  53781. * Resets the PBR Material defines.
  53782. */
  53783. reset(): void;
  53784. }
  53785. /**
  53786. * The Physically based material base class of BJS.
  53787. *
  53788. * This offers the main features of a standard PBR material.
  53789. * For more information, please refer to the documentation :
  53790. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53791. */
  53792. export abstract class PBRBaseMaterial extends PushMaterial {
  53793. /**
  53794. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53795. */
  53796. static readonly PBRMATERIAL_OPAQUE: number;
  53797. /**
  53798. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53799. */
  53800. static readonly PBRMATERIAL_ALPHATEST: number;
  53801. /**
  53802. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53803. */
  53804. static readonly PBRMATERIAL_ALPHABLEND: number;
  53805. /**
  53806. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53807. * They are also discarded below the alpha cutoff threshold to improve performances.
  53808. */
  53809. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53810. /**
  53811. * Defines the default value of how much AO map is occluding the analytical lights
  53812. * (point spot...).
  53813. */
  53814. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53815. /**
  53816. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53817. */
  53818. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53819. /**
  53820. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53821. * to enhance interoperability with other engines.
  53822. */
  53823. static readonly LIGHTFALLOFF_GLTF: number;
  53824. /**
  53825. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53826. * to enhance interoperability with other materials.
  53827. */
  53828. static readonly LIGHTFALLOFF_STANDARD: number;
  53829. /**
  53830. * Intensity of the direct lights e.g. the four lights available in your scene.
  53831. * This impacts both the direct diffuse and specular highlights.
  53832. */
  53833. protected _directIntensity: number;
  53834. /**
  53835. * Intensity of the emissive part of the material.
  53836. * This helps controlling the emissive effect without modifying the emissive color.
  53837. */
  53838. protected _emissiveIntensity: number;
  53839. /**
  53840. * Intensity of the environment e.g. how much the environment will light the object
  53841. * either through harmonics for rough material or through the refelction for shiny ones.
  53842. */
  53843. protected _environmentIntensity: number;
  53844. /**
  53845. * This is a special control allowing the reduction of the specular highlights coming from the
  53846. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53847. */
  53848. protected _specularIntensity: number;
  53849. /**
  53850. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53851. */
  53852. private _lightingInfos;
  53853. /**
  53854. * Debug Control allowing disabling the bump map on this material.
  53855. */
  53856. protected _disableBumpMap: boolean;
  53857. /**
  53858. * AKA Diffuse Texture in standard nomenclature.
  53859. */
  53860. protected _albedoTexture: Nullable<BaseTexture>;
  53861. /**
  53862. * AKA Occlusion Texture in other nomenclature.
  53863. */
  53864. protected _ambientTexture: Nullable<BaseTexture>;
  53865. /**
  53866. * AKA Occlusion Texture Intensity in other nomenclature.
  53867. */
  53868. protected _ambientTextureStrength: number;
  53869. /**
  53870. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53871. * 1 means it completely occludes it
  53872. * 0 mean it has no impact
  53873. */
  53874. protected _ambientTextureImpactOnAnalyticalLights: number;
  53875. /**
  53876. * Stores the alpha values in a texture.
  53877. */
  53878. protected _opacityTexture: Nullable<BaseTexture>;
  53879. /**
  53880. * Stores the reflection values in a texture.
  53881. */
  53882. protected _reflectionTexture: Nullable<BaseTexture>;
  53883. /**
  53884. * Stores the emissive values in a texture.
  53885. */
  53886. protected _emissiveTexture: Nullable<BaseTexture>;
  53887. /**
  53888. * AKA Specular texture in other nomenclature.
  53889. */
  53890. protected _reflectivityTexture: Nullable<BaseTexture>;
  53891. /**
  53892. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53893. */
  53894. protected _metallicTexture: Nullable<BaseTexture>;
  53895. /**
  53896. * Specifies the metallic scalar of the metallic/roughness workflow.
  53897. * Can also be used to scale the metalness values of the metallic texture.
  53898. */
  53899. protected _metallic: Nullable<number>;
  53900. /**
  53901. * Specifies the roughness scalar of the metallic/roughness workflow.
  53902. * Can also be used to scale the roughness values of the metallic texture.
  53903. */
  53904. protected _roughness: Nullable<number>;
  53905. /**
  53906. * Specifies the an F0 factor to help configuring the material F0.
  53907. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53908. * to 0.5 the previously hard coded value stays the same.
  53909. * Can also be used to scale the F0 values of the metallic texture.
  53910. */
  53911. protected _metallicF0Factor: number;
  53912. /**
  53913. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53914. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53915. * your expectation as it multiplies with the texture data.
  53916. */
  53917. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53918. /**
  53919. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53920. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53921. */
  53922. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53923. /**
  53924. * Stores surface normal data used to displace a mesh in a texture.
  53925. */
  53926. protected _bumpTexture: Nullable<BaseTexture>;
  53927. /**
  53928. * Stores the pre-calculated light information of a mesh in a texture.
  53929. */
  53930. protected _lightmapTexture: Nullable<BaseTexture>;
  53931. /**
  53932. * The color of a material in ambient lighting.
  53933. */
  53934. protected _ambientColor: Color3;
  53935. /**
  53936. * AKA Diffuse Color in other nomenclature.
  53937. */
  53938. protected _albedoColor: Color3;
  53939. /**
  53940. * AKA Specular Color in other nomenclature.
  53941. */
  53942. protected _reflectivityColor: Color3;
  53943. /**
  53944. * The color applied when light is reflected from a material.
  53945. */
  53946. protected _reflectionColor: Color3;
  53947. /**
  53948. * The color applied when light is emitted from a material.
  53949. */
  53950. protected _emissiveColor: Color3;
  53951. /**
  53952. * AKA Glossiness in other nomenclature.
  53953. */
  53954. protected _microSurface: number;
  53955. /**
  53956. * Specifies that the material will use the light map as a show map.
  53957. */
  53958. protected _useLightmapAsShadowmap: boolean;
  53959. /**
  53960. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53961. * makes the reflect vector face the model (under horizon).
  53962. */
  53963. protected _useHorizonOcclusion: boolean;
  53964. /**
  53965. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53966. * too much the area relying on ambient texture to define their ambient occlusion.
  53967. */
  53968. protected _useRadianceOcclusion: boolean;
  53969. /**
  53970. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53971. */
  53972. protected _useAlphaFromAlbedoTexture: boolean;
  53973. /**
  53974. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53975. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53976. */
  53977. protected _useSpecularOverAlpha: boolean;
  53978. /**
  53979. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53980. */
  53981. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53982. /**
  53983. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53984. */
  53985. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53986. /**
  53987. * Specifies if the metallic texture contains the roughness information in its green channel.
  53988. */
  53989. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53990. /**
  53991. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53992. */
  53993. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53994. /**
  53995. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53996. */
  53997. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53998. /**
  53999. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54000. */
  54001. protected _useAmbientInGrayScale: boolean;
  54002. /**
  54003. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54004. * The material will try to infer what glossiness each pixel should be.
  54005. */
  54006. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54007. /**
  54008. * Defines the falloff type used in this material.
  54009. * It by default is Physical.
  54010. */
  54011. protected _lightFalloff: number;
  54012. /**
  54013. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54014. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54015. */
  54016. protected _useRadianceOverAlpha: boolean;
  54017. /**
  54018. * Allows using an object space normal map (instead of tangent space).
  54019. */
  54020. protected _useObjectSpaceNormalMap: boolean;
  54021. /**
  54022. * Allows using the bump map in parallax mode.
  54023. */
  54024. protected _useParallax: boolean;
  54025. /**
  54026. * Allows using the bump map in parallax occlusion mode.
  54027. */
  54028. protected _useParallaxOcclusion: boolean;
  54029. /**
  54030. * Controls the scale bias of the parallax mode.
  54031. */
  54032. protected _parallaxScaleBias: number;
  54033. /**
  54034. * If sets to true, disables all the lights affecting the material.
  54035. */
  54036. protected _disableLighting: boolean;
  54037. /**
  54038. * Number of Simultaneous lights allowed on the material.
  54039. */
  54040. protected _maxSimultaneousLights: number;
  54041. /**
  54042. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54043. */
  54044. protected _invertNormalMapX: boolean;
  54045. /**
  54046. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54047. */
  54048. protected _invertNormalMapY: boolean;
  54049. /**
  54050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54051. */
  54052. protected _twoSidedLighting: boolean;
  54053. /**
  54054. * Defines the alpha limits in alpha test mode.
  54055. */
  54056. protected _alphaCutOff: number;
  54057. /**
  54058. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54059. */
  54060. protected _forceAlphaTest: boolean;
  54061. /**
  54062. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54063. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54064. */
  54065. protected _useAlphaFresnel: boolean;
  54066. /**
  54067. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54068. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54069. */
  54070. protected _useLinearAlphaFresnel: boolean;
  54071. /**
  54072. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54073. * from cos thetav and roughness:
  54074. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54075. */
  54076. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54077. /**
  54078. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54079. */
  54080. protected _forceIrradianceInFragment: boolean;
  54081. /**
  54082. * Force normal to face away from face.
  54083. */
  54084. protected _forceNormalForward: boolean;
  54085. /**
  54086. * Enables specular anti aliasing in the PBR shader.
  54087. * It will both interacts on the Geometry for analytical and IBL lighting.
  54088. * It also prefilter the roughness map based on the bump values.
  54089. */
  54090. protected _enableSpecularAntiAliasing: boolean;
  54091. /**
  54092. * Default configuration related to image processing available in the PBR Material.
  54093. */
  54094. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54095. /**
  54096. * Keep track of the image processing observer to allow dispose and replace.
  54097. */
  54098. private _imageProcessingObserver;
  54099. /**
  54100. * Attaches a new image processing configuration to the PBR Material.
  54101. * @param configuration
  54102. */
  54103. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54104. /**
  54105. * Stores the available render targets.
  54106. */
  54107. private _renderTargets;
  54108. /**
  54109. * Sets the global ambient color for the material used in lighting calculations.
  54110. */
  54111. private _globalAmbientColor;
  54112. /**
  54113. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54114. */
  54115. private _useLogarithmicDepth;
  54116. /**
  54117. * If set to true, no lighting calculations will be applied.
  54118. */
  54119. private _unlit;
  54120. private _debugMode;
  54121. /**
  54122. * @hidden
  54123. * This is reserved for the inspector.
  54124. * Defines the material debug mode.
  54125. * It helps seeing only some components of the material while troubleshooting.
  54126. */
  54127. debugMode: number;
  54128. /**
  54129. * @hidden
  54130. * This is reserved for the inspector.
  54131. * Specify from where on screen the debug mode should start.
  54132. * The value goes from -1 (full screen) to 1 (not visible)
  54133. * It helps with side by side comparison against the final render
  54134. * This defaults to -1
  54135. */
  54136. private debugLimit;
  54137. /**
  54138. * @hidden
  54139. * This is reserved for the inspector.
  54140. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54141. * You can use the factor to better multiply the final value.
  54142. */
  54143. private debugFactor;
  54144. /**
  54145. * Defines the clear coat layer parameters for the material.
  54146. */
  54147. readonly clearCoat: PBRClearCoatConfiguration;
  54148. /**
  54149. * Defines the anisotropic parameters for the material.
  54150. */
  54151. readonly anisotropy: PBRAnisotropicConfiguration;
  54152. /**
  54153. * Defines the BRDF parameters for the material.
  54154. */
  54155. readonly brdf: PBRBRDFConfiguration;
  54156. /**
  54157. * Defines the Sheen parameters for the material.
  54158. */
  54159. readonly sheen: PBRSheenConfiguration;
  54160. /**
  54161. * Defines the SubSurface parameters for the material.
  54162. */
  54163. readonly subSurface: PBRSubSurfaceConfiguration;
  54164. /**
  54165. * Custom callback helping to override the default shader used in the material.
  54166. */
  54167. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  54168. protected _rebuildInParallel: boolean;
  54169. /**
  54170. * Instantiates a new PBRMaterial instance.
  54171. *
  54172. * @param name The material name
  54173. * @param scene The scene the material will be use in.
  54174. */
  54175. constructor(name: string, scene: Scene);
  54176. /**
  54177. * Gets a boolean indicating that current material needs to register RTT
  54178. */
  54179. get hasRenderTargetTextures(): boolean;
  54180. /**
  54181. * Gets the name of the material class.
  54182. */
  54183. getClassName(): string;
  54184. /**
  54185. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54186. */
  54187. get useLogarithmicDepth(): boolean;
  54188. /**
  54189. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54190. */
  54191. set useLogarithmicDepth(value: boolean);
  54192. /**
  54193. * Returns true if alpha blending should be disabled.
  54194. */
  54195. protected get _disableAlphaBlending(): boolean;
  54196. /**
  54197. * Specifies whether or not this material should be rendered in alpha blend mode.
  54198. */
  54199. needAlphaBlending(): boolean;
  54200. /**
  54201. * Specifies whether or not this material should be rendered in alpha test mode.
  54202. */
  54203. needAlphaTesting(): boolean;
  54204. /**
  54205. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54206. */
  54207. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54208. /**
  54209. * Gets the texture used for the alpha test.
  54210. */
  54211. getAlphaTestTexture(): Nullable<BaseTexture>;
  54212. /**
  54213. * Specifies that the submesh is ready to be used.
  54214. * @param mesh - BJS mesh.
  54215. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54216. * @param useInstances - Specifies that instances should be used.
  54217. * @returns - boolean indicating that the submesh is ready or not.
  54218. */
  54219. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54220. /**
  54221. * Specifies if the material uses metallic roughness workflow.
  54222. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54223. */
  54224. isMetallicWorkflow(): boolean;
  54225. private _prepareEffect;
  54226. private _prepareDefines;
  54227. /**
  54228. * Force shader compilation
  54229. */
  54230. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54231. /**
  54232. * Initializes the uniform buffer layout for the shader.
  54233. */
  54234. buildUniformLayout(): void;
  54235. /**
  54236. * Unbinds the material from the mesh
  54237. */
  54238. unbind(): void;
  54239. /**
  54240. * Binds the submesh data.
  54241. * @param world - The world matrix.
  54242. * @param mesh - The BJS mesh.
  54243. * @param subMesh - A submesh of the BJS mesh.
  54244. */
  54245. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54246. /**
  54247. * Returns the animatable textures.
  54248. * @returns - Array of animatable textures.
  54249. */
  54250. getAnimatables(): IAnimatable[];
  54251. /**
  54252. * Returns the texture used for reflections.
  54253. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54254. */
  54255. private _getReflectionTexture;
  54256. /**
  54257. * Returns an array of the actively used textures.
  54258. * @returns - Array of BaseTextures
  54259. */
  54260. getActiveTextures(): BaseTexture[];
  54261. /**
  54262. * Checks to see if a texture is used in the material.
  54263. * @param texture - Base texture to use.
  54264. * @returns - Boolean specifying if a texture is used in the material.
  54265. */
  54266. hasTexture(texture: BaseTexture): boolean;
  54267. /**
  54268. * Disposes the resources of the material.
  54269. * @param forceDisposeEffect - Forces the disposal of effects.
  54270. * @param forceDisposeTextures - Forces the disposal of all textures.
  54271. */
  54272. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54273. }
  54274. }
  54275. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54276. import { Nullable } from "babylonjs/types";
  54277. import { Scene } from "babylonjs/scene";
  54278. import { Color3 } from "babylonjs/Maths/math.color";
  54279. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54280. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54281. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54282. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54283. /**
  54284. * The Physically based material of BJS.
  54285. *
  54286. * This offers the main features of a standard PBR material.
  54287. * For more information, please refer to the documentation :
  54288. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54289. */
  54290. export class PBRMaterial extends PBRBaseMaterial {
  54291. /**
  54292. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54293. */
  54294. static readonly PBRMATERIAL_OPAQUE: number;
  54295. /**
  54296. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54297. */
  54298. static readonly PBRMATERIAL_ALPHATEST: number;
  54299. /**
  54300. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54301. */
  54302. static readonly PBRMATERIAL_ALPHABLEND: number;
  54303. /**
  54304. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54305. * They are also discarded below the alpha cutoff threshold to improve performances.
  54306. */
  54307. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54308. /**
  54309. * Defines the default value of how much AO map is occluding the analytical lights
  54310. * (point spot...).
  54311. */
  54312. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54313. /**
  54314. * Intensity of the direct lights e.g. the four lights available in your scene.
  54315. * This impacts both the direct diffuse and specular highlights.
  54316. */
  54317. directIntensity: number;
  54318. /**
  54319. * Intensity of the emissive part of the material.
  54320. * This helps controlling the emissive effect without modifying the emissive color.
  54321. */
  54322. emissiveIntensity: number;
  54323. /**
  54324. * Intensity of the environment e.g. how much the environment will light the object
  54325. * either through harmonics for rough material or through the refelction for shiny ones.
  54326. */
  54327. environmentIntensity: number;
  54328. /**
  54329. * This is a special control allowing the reduction of the specular highlights coming from the
  54330. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54331. */
  54332. specularIntensity: number;
  54333. /**
  54334. * Debug Control allowing disabling the bump map on this material.
  54335. */
  54336. disableBumpMap: boolean;
  54337. /**
  54338. * AKA Diffuse Texture in standard nomenclature.
  54339. */
  54340. albedoTexture: BaseTexture;
  54341. /**
  54342. * AKA Occlusion Texture in other nomenclature.
  54343. */
  54344. ambientTexture: BaseTexture;
  54345. /**
  54346. * AKA Occlusion Texture Intensity in other nomenclature.
  54347. */
  54348. ambientTextureStrength: number;
  54349. /**
  54350. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54351. * 1 means it completely occludes it
  54352. * 0 mean it has no impact
  54353. */
  54354. ambientTextureImpactOnAnalyticalLights: number;
  54355. /**
  54356. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54357. */
  54358. opacityTexture: BaseTexture;
  54359. /**
  54360. * Stores the reflection values in a texture.
  54361. */
  54362. reflectionTexture: Nullable<BaseTexture>;
  54363. /**
  54364. * Stores the emissive values in a texture.
  54365. */
  54366. emissiveTexture: BaseTexture;
  54367. /**
  54368. * AKA Specular texture in other nomenclature.
  54369. */
  54370. reflectivityTexture: BaseTexture;
  54371. /**
  54372. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54373. */
  54374. metallicTexture: BaseTexture;
  54375. /**
  54376. * Specifies the metallic scalar of the metallic/roughness workflow.
  54377. * Can also be used to scale the metalness values of the metallic texture.
  54378. */
  54379. metallic: Nullable<number>;
  54380. /**
  54381. * Specifies the roughness scalar of the metallic/roughness workflow.
  54382. * Can also be used to scale the roughness values of the metallic texture.
  54383. */
  54384. roughness: Nullable<number>;
  54385. /**
  54386. * Specifies the an F0 factor to help configuring the material F0.
  54387. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54388. * to 0.5 the previously hard coded value stays the same.
  54389. * Can also be used to scale the F0 values of the metallic texture.
  54390. */
  54391. metallicF0Factor: number;
  54392. /**
  54393. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54394. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54395. * your expectation as it multiplies with the texture data.
  54396. */
  54397. useMetallicF0FactorFromMetallicTexture: boolean;
  54398. /**
  54399. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54400. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54401. */
  54402. microSurfaceTexture: BaseTexture;
  54403. /**
  54404. * Stores surface normal data used to displace a mesh in a texture.
  54405. */
  54406. bumpTexture: BaseTexture;
  54407. /**
  54408. * Stores the pre-calculated light information of a mesh in a texture.
  54409. */
  54410. lightmapTexture: BaseTexture;
  54411. /**
  54412. * Stores the refracted light information in a texture.
  54413. */
  54414. get refractionTexture(): Nullable<BaseTexture>;
  54415. set refractionTexture(value: Nullable<BaseTexture>);
  54416. /**
  54417. * The color of a material in ambient lighting.
  54418. */
  54419. ambientColor: Color3;
  54420. /**
  54421. * AKA Diffuse Color in other nomenclature.
  54422. */
  54423. albedoColor: Color3;
  54424. /**
  54425. * AKA Specular Color in other nomenclature.
  54426. */
  54427. reflectivityColor: Color3;
  54428. /**
  54429. * The color reflected from the material.
  54430. */
  54431. reflectionColor: Color3;
  54432. /**
  54433. * The color emitted from the material.
  54434. */
  54435. emissiveColor: Color3;
  54436. /**
  54437. * AKA Glossiness in other nomenclature.
  54438. */
  54439. microSurface: number;
  54440. /**
  54441. * source material index of refraction (IOR)' / 'destination material IOR.
  54442. */
  54443. get indexOfRefraction(): number;
  54444. set indexOfRefraction(value: number);
  54445. /**
  54446. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54447. */
  54448. get invertRefractionY(): boolean;
  54449. set invertRefractionY(value: boolean);
  54450. /**
  54451. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54452. * Materials half opaque for instance using refraction could benefit from this control.
  54453. */
  54454. get linkRefractionWithTransparency(): boolean;
  54455. set linkRefractionWithTransparency(value: boolean);
  54456. /**
  54457. * If true, the light map contains occlusion information instead of lighting info.
  54458. */
  54459. useLightmapAsShadowmap: boolean;
  54460. /**
  54461. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54462. */
  54463. useAlphaFromAlbedoTexture: boolean;
  54464. /**
  54465. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54466. */
  54467. forceAlphaTest: boolean;
  54468. /**
  54469. * Defines the alpha limits in alpha test mode.
  54470. */
  54471. alphaCutOff: number;
  54472. /**
  54473. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54474. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54475. */
  54476. useSpecularOverAlpha: boolean;
  54477. /**
  54478. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54479. */
  54480. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54481. /**
  54482. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54483. */
  54484. useRoughnessFromMetallicTextureAlpha: boolean;
  54485. /**
  54486. * Specifies if the metallic texture contains the roughness information in its green channel.
  54487. */
  54488. useRoughnessFromMetallicTextureGreen: boolean;
  54489. /**
  54490. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54491. */
  54492. useMetallnessFromMetallicTextureBlue: boolean;
  54493. /**
  54494. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54495. */
  54496. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54497. /**
  54498. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54499. */
  54500. useAmbientInGrayScale: boolean;
  54501. /**
  54502. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54503. * The material will try to infer what glossiness each pixel should be.
  54504. */
  54505. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54506. /**
  54507. * BJS is using an harcoded light falloff based on a manually sets up range.
  54508. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54509. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54510. */
  54511. get usePhysicalLightFalloff(): boolean;
  54512. /**
  54513. * BJS is using an harcoded light falloff based on a manually sets up range.
  54514. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54515. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54516. */
  54517. set usePhysicalLightFalloff(value: boolean);
  54518. /**
  54519. * In order to support the falloff compatibility with gltf, a special mode has been added
  54520. * to reproduce the gltf light falloff.
  54521. */
  54522. get useGLTFLightFalloff(): boolean;
  54523. /**
  54524. * In order to support the falloff compatibility with gltf, a special mode has been added
  54525. * to reproduce the gltf light falloff.
  54526. */
  54527. set useGLTFLightFalloff(value: boolean);
  54528. /**
  54529. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54530. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54531. */
  54532. useRadianceOverAlpha: boolean;
  54533. /**
  54534. * Allows using an object space normal map (instead of tangent space).
  54535. */
  54536. useObjectSpaceNormalMap: boolean;
  54537. /**
  54538. * Allows using the bump map in parallax mode.
  54539. */
  54540. useParallax: boolean;
  54541. /**
  54542. * Allows using the bump map in parallax occlusion mode.
  54543. */
  54544. useParallaxOcclusion: boolean;
  54545. /**
  54546. * Controls the scale bias of the parallax mode.
  54547. */
  54548. parallaxScaleBias: number;
  54549. /**
  54550. * If sets to true, disables all the lights affecting the material.
  54551. */
  54552. disableLighting: boolean;
  54553. /**
  54554. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54555. */
  54556. forceIrradianceInFragment: boolean;
  54557. /**
  54558. * Number of Simultaneous lights allowed on the material.
  54559. */
  54560. maxSimultaneousLights: number;
  54561. /**
  54562. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54563. */
  54564. invertNormalMapX: boolean;
  54565. /**
  54566. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54567. */
  54568. invertNormalMapY: boolean;
  54569. /**
  54570. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54571. */
  54572. twoSidedLighting: boolean;
  54573. /**
  54574. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54575. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54576. */
  54577. useAlphaFresnel: boolean;
  54578. /**
  54579. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54580. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54581. */
  54582. useLinearAlphaFresnel: boolean;
  54583. /**
  54584. * Let user defines the brdf lookup texture used for IBL.
  54585. * A default 8bit version is embedded but you could point at :
  54586. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54587. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54588. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54589. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54590. */
  54591. environmentBRDFTexture: Nullable<BaseTexture>;
  54592. /**
  54593. * Force normal to face away from face.
  54594. */
  54595. forceNormalForward: boolean;
  54596. /**
  54597. * Enables specular anti aliasing in the PBR shader.
  54598. * It will both interacts on the Geometry for analytical and IBL lighting.
  54599. * It also prefilter the roughness map based on the bump values.
  54600. */
  54601. enableSpecularAntiAliasing: boolean;
  54602. /**
  54603. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54604. * makes the reflect vector face the model (under horizon).
  54605. */
  54606. useHorizonOcclusion: boolean;
  54607. /**
  54608. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54609. * too much the area relying on ambient texture to define their ambient occlusion.
  54610. */
  54611. useRadianceOcclusion: boolean;
  54612. /**
  54613. * If set to true, no lighting calculations will be applied.
  54614. */
  54615. unlit: boolean;
  54616. /**
  54617. * Gets the image processing configuration used either in this material.
  54618. */
  54619. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54620. /**
  54621. * Sets the Default image processing configuration used either in the this material.
  54622. *
  54623. * If sets to null, the scene one is in use.
  54624. */
  54625. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54626. /**
  54627. * Gets wether the color curves effect is enabled.
  54628. */
  54629. get cameraColorCurvesEnabled(): boolean;
  54630. /**
  54631. * Sets wether the color curves effect is enabled.
  54632. */
  54633. set cameraColorCurvesEnabled(value: boolean);
  54634. /**
  54635. * Gets wether the color grading effect is enabled.
  54636. */
  54637. get cameraColorGradingEnabled(): boolean;
  54638. /**
  54639. * Gets wether the color grading effect is enabled.
  54640. */
  54641. set cameraColorGradingEnabled(value: boolean);
  54642. /**
  54643. * Gets wether tonemapping is enabled or not.
  54644. */
  54645. get cameraToneMappingEnabled(): boolean;
  54646. /**
  54647. * Sets wether tonemapping is enabled or not
  54648. */
  54649. set cameraToneMappingEnabled(value: boolean);
  54650. /**
  54651. * The camera exposure used on this material.
  54652. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54653. * This corresponds to a photographic exposure.
  54654. */
  54655. get cameraExposure(): number;
  54656. /**
  54657. * The camera exposure used on this material.
  54658. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54659. * This corresponds to a photographic exposure.
  54660. */
  54661. set cameraExposure(value: number);
  54662. /**
  54663. * Gets The camera contrast used on this material.
  54664. */
  54665. get cameraContrast(): number;
  54666. /**
  54667. * Sets The camera contrast used on this material.
  54668. */
  54669. set cameraContrast(value: number);
  54670. /**
  54671. * Gets the Color Grading 2D Lookup Texture.
  54672. */
  54673. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54674. /**
  54675. * Sets the Color Grading 2D Lookup Texture.
  54676. */
  54677. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54678. /**
  54679. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54680. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54681. * 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;
  54682. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54683. */
  54684. get cameraColorCurves(): Nullable<ColorCurves>;
  54685. /**
  54686. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54687. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54688. * 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;
  54689. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54690. */
  54691. set cameraColorCurves(value: Nullable<ColorCurves>);
  54692. /**
  54693. * Instantiates a new PBRMaterial instance.
  54694. *
  54695. * @param name The material name
  54696. * @param scene The scene the material will be use in.
  54697. */
  54698. constructor(name: string, scene: Scene);
  54699. /**
  54700. * Returns the name of this material class.
  54701. */
  54702. getClassName(): string;
  54703. /**
  54704. * Makes a duplicate of the current material.
  54705. * @param name - name to use for the new material.
  54706. */
  54707. clone(name: string): PBRMaterial;
  54708. /**
  54709. * Serializes this PBR Material.
  54710. * @returns - An object with the serialized material.
  54711. */
  54712. serialize(): any;
  54713. /**
  54714. * Parses a PBR Material from a serialized object.
  54715. * @param source - Serialized object.
  54716. * @param scene - BJS scene instance.
  54717. * @param rootUrl - url for the scene object
  54718. * @returns - PBRMaterial
  54719. */
  54720. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54721. }
  54722. }
  54723. declare module "babylonjs/Misc/dds" {
  54724. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54725. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54726. import { Nullable } from "babylonjs/types";
  54727. import { Scene } from "babylonjs/scene";
  54728. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54729. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54730. /**
  54731. * Direct draw surface info
  54732. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54733. */
  54734. export interface DDSInfo {
  54735. /**
  54736. * Width of the texture
  54737. */
  54738. width: number;
  54739. /**
  54740. * Width of the texture
  54741. */
  54742. height: number;
  54743. /**
  54744. * Number of Mipmaps for the texture
  54745. * @see https://en.wikipedia.org/wiki/Mipmap
  54746. */
  54747. mipmapCount: number;
  54748. /**
  54749. * If the textures format is a known fourCC format
  54750. * @see https://www.fourcc.org/
  54751. */
  54752. isFourCC: boolean;
  54753. /**
  54754. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54755. */
  54756. isRGB: boolean;
  54757. /**
  54758. * If the texture is a lumincance format
  54759. */
  54760. isLuminance: boolean;
  54761. /**
  54762. * If this is a cube texture
  54763. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54764. */
  54765. isCube: boolean;
  54766. /**
  54767. * If the texture is a compressed format eg. FOURCC_DXT1
  54768. */
  54769. isCompressed: boolean;
  54770. /**
  54771. * The dxgiFormat of the texture
  54772. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54773. */
  54774. dxgiFormat: number;
  54775. /**
  54776. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54777. */
  54778. textureType: number;
  54779. /**
  54780. * Sphericle polynomial created for the dds texture
  54781. */
  54782. sphericalPolynomial?: SphericalPolynomial;
  54783. }
  54784. /**
  54785. * Class used to provide DDS decompression tools
  54786. */
  54787. export class DDSTools {
  54788. /**
  54789. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54790. */
  54791. static StoreLODInAlphaChannel: boolean;
  54792. /**
  54793. * Gets DDS information from an array buffer
  54794. * @param data defines the array buffer view to read data from
  54795. * @returns the DDS information
  54796. */
  54797. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54798. private static _FloatView;
  54799. private static _Int32View;
  54800. private static _ToHalfFloat;
  54801. private static _FromHalfFloat;
  54802. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54803. private static _GetHalfFloatRGBAArrayBuffer;
  54804. private static _GetFloatRGBAArrayBuffer;
  54805. private static _GetFloatAsUIntRGBAArrayBuffer;
  54806. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54807. private static _GetRGBAArrayBuffer;
  54808. private static _ExtractLongWordOrder;
  54809. private static _GetRGBArrayBuffer;
  54810. private static _GetLuminanceArrayBuffer;
  54811. /**
  54812. * Uploads DDS Levels to a Babylon Texture
  54813. * @hidden
  54814. */
  54815. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54816. }
  54817. module "babylonjs/Engines/thinEngine" {
  54818. interface ThinEngine {
  54819. /**
  54820. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54821. * @param rootUrl defines the url where the file to load is located
  54822. * @param scene defines the current scene
  54823. * @param lodScale defines scale to apply to the mip map selection
  54824. * @param lodOffset defines offset to apply to the mip map selection
  54825. * @param onLoad defines an optional callback raised when the texture is loaded
  54826. * @param onError defines an optional callback raised if there is an issue to load the texture
  54827. * @param format defines the format of the data
  54828. * @param forcedExtension defines the extension to use to pick the right loader
  54829. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54830. * @returns the cube texture as an InternalTexture
  54831. */
  54832. 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;
  54833. }
  54834. }
  54835. }
  54836. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54837. import { Nullable } from "babylonjs/types";
  54838. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54839. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54840. /**
  54841. * Implementation of the DDS Texture Loader.
  54842. * @hidden
  54843. */
  54844. export class _DDSTextureLoader implements IInternalTextureLoader {
  54845. /**
  54846. * Defines wether the loader supports cascade loading the different faces.
  54847. */
  54848. readonly supportCascades: boolean;
  54849. /**
  54850. * This returns if the loader support the current file information.
  54851. * @param extension defines the file extension of the file being loaded
  54852. * @returns true if the loader can load the specified file
  54853. */
  54854. canLoad(extension: string): boolean;
  54855. /**
  54856. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54857. * @param data contains the texture data
  54858. * @param texture defines the BabylonJS internal texture
  54859. * @param createPolynomials will be true if polynomials have been requested
  54860. * @param onLoad defines the callback to trigger once the texture is ready
  54861. * @param onError defines the callback to trigger in case of error
  54862. */
  54863. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54864. /**
  54865. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54866. * @param data contains the texture data
  54867. * @param texture defines the BabylonJS internal texture
  54868. * @param callback defines the method to call once ready to upload
  54869. */
  54870. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54871. }
  54872. }
  54873. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54874. import { Nullable } from "babylonjs/types";
  54875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54876. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54877. /**
  54878. * Implementation of the ENV Texture Loader.
  54879. * @hidden
  54880. */
  54881. export class _ENVTextureLoader implements IInternalTextureLoader {
  54882. /**
  54883. * Defines wether the loader supports cascade loading the different faces.
  54884. */
  54885. readonly supportCascades: boolean;
  54886. /**
  54887. * This returns if the loader support the current file information.
  54888. * @param extension defines the file extension of the file being loaded
  54889. * @returns true if the loader can load the specified file
  54890. */
  54891. canLoad(extension: string): boolean;
  54892. /**
  54893. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54894. * @param data contains the texture data
  54895. * @param texture defines the BabylonJS internal texture
  54896. * @param createPolynomials will be true if polynomials have been requested
  54897. * @param onLoad defines the callback to trigger once the texture is ready
  54898. * @param onError defines the callback to trigger in case of error
  54899. */
  54900. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54901. /**
  54902. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54903. * @param data contains the texture data
  54904. * @param texture defines the BabylonJS internal texture
  54905. * @param callback defines the method to call once ready to upload
  54906. */
  54907. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54908. }
  54909. }
  54910. declare module "babylonjs/Misc/khronosTextureContainer" {
  54911. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54912. /**
  54913. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54914. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54915. */
  54916. export class KhronosTextureContainer {
  54917. /** contents of the KTX container file */
  54918. data: ArrayBufferView;
  54919. private static HEADER_LEN;
  54920. private static COMPRESSED_2D;
  54921. private static COMPRESSED_3D;
  54922. private static TEX_2D;
  54923. private static TEX_3D;
  54924. /**
  54925. * Gets the openGL type
  54926. */
  54927. glType: number;
  54928. /**
  54929. * Gets the openGL type size
  54930. */
  54931. glTypeSize: number;
  54932. /**
  54933. * Gets the openGL format
  54934. */
  54935. glFormat: number;
  54936. /**
  54937. * Gets the openGL internal format
  54938. */
  54939. glInternalFormat: number;
  54940. /**
  54941. * Gets the base internal format
  54942. */
  54943. glBaseInternalFormat: number;
  54944. /**
  54945. * Gets image width in pixel
  54946. */
  54947. pixelWidth: number;
  54948. /**
  54949. * Gets image height in pixel
  54950. */
  54951. pixelHeight: number;
  54952. /**
  54953. * Gets image depth in pixels
  54954. */
  54955. pixelDepth: number;
  54956. /**
  54957. * Gets the number of array elements
  54958. */
  54959. numberOfArrayElements: number;
  54960. /**
  54961. * Gets the number of faces
  54962. */
  54963. numberOfFaces: number;
  54964. /**
  54965. * Gets the number of mipmap levels
  54966. */
  54967. numberOfMipmapLevels: number;
  54968. /**
  54969. * Gets the bytes of key value data
  54970. */
  54971. bytesOfKeyValueData: number;
  54972. /**
  54973. * Gets the load type
  54974. */
  54975. loadType: number;
  54976. /**
  54977. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54978. */
  54979. isInvalid: boolean;
  54980. /**
  54981. * Creates a new KhronosTextureContainer
  54982. * @param data contents of the KTX container file
  54983. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54984. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54985. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54986. */
  54987. constructor(
  54988. /** contents of the KTX container file */
  54989. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54990. /**
  54991. * Uploads KTX content to a Babylon Texture.
  54992. * It is assumed that the texture has already been created & is currently bound
  54993. * @hidden
  54994. */
  54995. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54996. private _upload2DCompressedLevels;
  54997. /**
  54998. * Checks if the given data starts with a KTX file identifier.
  54999. * @param data the data to check
  55000. * @returns true if the data is a KTX file or false otherwise
  55001. */
  55002. static IsValid(data: ArrayBufferView): boolean;
  55003. }
  55004. }
  55005. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55006. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55007. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55008. /**
  55009. * Class for loading KTX2 files
  55010. * !!! Experimental Extension Subject to Changes !!!
  55011. * @hidden
  55012. */
  55013. export class KhronosTextureContainer2 {
  55014. private static _ModulePromise;
  55015. private static _TranscodeFormat;
  55016. constructor(engine: ThinEngine);
  55017. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55018. private _determineTranscodeFormat;
  55019. /**
  55020. * Checks if the given data starts with a KTX2 file identifier.
  55021. * @param data the data to check
  55022. * @returns true if the data is a KTX2 file or false otherwise
  55023. */
  55024. static IsValid(data: ArrayBufferView): boolean;
  55025. }
  55026. }
  55027. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55028. import { Nullable } from "babylonjs/types";
  55029. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55030. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55031. /**
  55032. * Implementation of the KTX Texture Loader.
  55033. * @hidden
  55034. */
  55035. export class _KTXTextureLoader implements IInternalTextureLoader {
  55036. /**
  55037. * Defines wether the loader supports cascade loading the different faces.
  55038. */
  55039. readonly supportCascades: boolean;
  55040. /**
  55041. * This returns if the loader support the current file information.
  55042. * @param extension defines the file extension of the file being loaded
  55043. * @returns true if the loader can load the specified file
  55044. */
  55045. canLoad(extension: string): boolean;
  55046. /**
  55047. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55048. * @param data contains the texture data
  55049. * @param texture defines the BabylonJS internal texture
  55050. * @param createPolynomials will be true if polynomials have been requested
  55051. * @param onLoad defines the callback to trigger once the texture is ready
  55052. * @param onError defines the callback to trigger in case of error
  55053. */
  55054. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55055. /**
  55056. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55057. * @param data contains the texture data
  55058. * @param texture defines the BabylonJS internal texture
  55059. * @param callback defines the method to call once ready to upload
  55060. */
  55061. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55062. }
  55063. }
  55064. declare module "babylonjs/Helpers/sceneHelpers" {
  55065. import { Nullable } from "babylonjs/types";
  55066. import { Mesh } from "babylonjs/Meshes/mesh";
  55067. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55068. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55069. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55070. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55071. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55072. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55073. import "babylonjs/Meshes/Builders/boxBuilder";
  55074. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55075. /** @hidden */
  55076. export var _forceSceneHelpersToBundle: boolean;
  55077. module "babylonjs/scene" {
  55078. interface Scene {
  55079. /**
  55080. * Creates a default light for the scene.
  55081. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55082. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55083. */
  55084. createDefaultLight(replace?: boolean): void;
  55085. /**
  55086. * Creates a default camera for the scene.
  55087. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55088. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55089. * @param replace has default false, when true replaces the active camera in the scene
  55090. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55091. */
  55092. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55093. /**
  55094. * Creates a default camera and a default light.
  55095. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55096. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55097. * @param replace has the default false, when true replaces the active camera/light in the scene
  55098. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55099. */
  55100. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55101. /**
  55102. * Creates a new sky box
  55103. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55104. * @param environmentTexture defines the texture to use as environment texture
  55105. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55106. * @param scale defines the overall scale of the skybox
  55107. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55108. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55109. * @returns a new mesh holding the sky box
  55110. */
  55111. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55112. /**
  55113. * Creates a new environment
  55114. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55115. * @param options defines the options you can use to configure the environment
  55116. * @returns the new EnvironmentHelper
  55117. */
  55118. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55119. /**
  55120. * Creates a new VREXperienceHelper
  55121. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55122. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55123. * @returns a new VREXperienceHelper
  55124. */
  55125. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55126. /**
  55127. * Creates a new WebXRDefaultExperience
  55128. * @see http://doc.babylonjs.com/how_to/webxr
  55129. * @param options experience options
  55130. * @returns a promise for a new WebXRDefaultExperience
  55131. */
  55132. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55133. }
  55134. }
  55135. }
  55136. declare module "babylonjs/Helpers/videoDome" {
  55137. import { Scene } from "babylonjs/scene";
  55138. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55139. import { Mesh } from "babylonjs/Meshes/mesh";
  55140. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55141. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55142. import "babylonjs/Meshes/Builders/sphereBuilder";
  55143. /**
  55144. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55145. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55146. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55147. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55148. */
  55149. export class VideoDome extends TransformNode {
  55150. /**
  55151. * Define the video source as a Monoscopic panoramic 360 video.
  55152. */
  55153. static readonly MODE_MONOSCOPIC: number;
  55154. /**
  55155. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55156. */
  55157. static readonly MODE_TOPBOTTOM: number;
  55158. /**
  55159. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55160. */
  55161. static readonly MODE_SIDEBYSIDE: number;
  55162. private _halfDome;
  55163. private _useDirectMapping;
  55164. /**
  55165. * The video texture being displayed on the sphere
  55166. */
  55167. protected _videoTexture: VideoTexture;
  55168. /**
  55169. * Gets the video texture being displayed on the sphere
  55170. */
  55171. get videoTexture(): VideoTexture;
  55172. /**
  55173. * The skybox material
  55174. */
  55175. protected _material: BackgroundMaterial;
  55176. /**
  55177. * The surface used for the skybox
  55178. */
  55179. protected _mesh: Mesh;
  55180. /**
  55181. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55182. */
  55183. private _halfDomeMask;
  55184. /**
  55185. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55186. * Also see the options.resolution property.
  55187. */
  55188. get fovMultiplier(): number;
  55189. set fovMultiplier(value: number);
  55190. private _videoMode;
  55191. /**
  55192. * Gets or set the current video mode for the video. It can be:
  55193. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55194. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55195. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55196. */
  55197. get videoMode(): number;
  55198. set videoMode(value: number);
  55199. /**
  55200. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55201. *
  55202. */
  55203. get halfDome(): boolean;
  55204. /**
  55205. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55206. */
  55207. set halfDome(enabled: boolean);
  55208. /**
  55209. * Oberserver used in Stereoscopic VR Mode.
  55210. */
  55211. private _onBeforeCameraRenderObserver;
  55212. /**
  55213. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55214. * @param name Element's name, child elements will append suffixes for their own names.
  55215. * @param urlsOrVideo defines the url(s) or the video element to use
  55216. * @param options An object containing optional or exposed sub element properties
  55217. */
  55218. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55219. resolution?: number;
  55220. clickToPlay?: boolean;
  55221. autoPlay?: boolean;
  55222. loop?: boolean;
  55223. size?: number;
  55224. poster?: string;
  55225. faceForward?: boolean;
  55226. useDirectMapping?: boolean;
  55227. halfDomeMode?: boolean;
  55228. }, scene: Scene);
  55229. private _changeVideoMode;
  55230. /**
  55231. * Releases resources associated with this node.
  55232. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55233. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55234. */
  55235. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55236. }
  55237. }
  55238. declare module "babylonjs/Helpers/index" {
  55239. export * from "babylonjs/Helpers/environmentHelper";
  55240. export * from "babylonjs/Helpers/photoDome";
  55241. export * from "babylonjs/Helpers/sceneHelpers";
  55242. export * from "babylonjs/Helpers/videoDome";
  55243. }
  55244. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55245. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55246. import { IDisposable } from "babylonjs/scene";
  55247. import { Engine } from "babylonjs/Engines/engine";
  55248. /**
  55249. * This class can be used to get instrumentation data from a Babylon engine
  55250. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55251. */
  55252. export class EngineInstrumentation implements IDisposable {
  55253. /**
  55254. * Define the instrumented engine.
  55255. */
  55256. engine: Engine;
  55257. private _captureGPUFrameTime;
  55258. private _gpuFrameTimeToken;
  55259. private _gpuFrameTime;
  55260. private _captureShaderCompilationTime;
  55261. private _shaderCompilationTime;
  55262. private _onBeginFrameObserver;
  55263. private _onEndFrameObserver;
  55264. private _onBeforeShaderCompilationObserver;
  55265. private _onAfterShaderCompilationObserver;
  55266. /**
  55267. * Gets the perf counter used for GPU frame time
  55268. */
  55269. get gpuFrameTimeCounter(): PerfCounter;
  55270. /**
  55271. * Gets the GPU frame time capture status
  55272. */
  55273. get captureGPUFrameTime(): boolean;
  55274. /**
  55275. * Enable or disable the GPU frame time capture
  55276. */
  55277. set captureGPUFrameTime(value: boolean);
  55278. /**
  55279. * Gets the perf counter used for shader compilation time
  55280. */
  55281. get shaderCompilationTimeCounter(): PerfCounter;
  55282. /**
  55283. * Gets the shader compilation time capture status
  55284. */
  55285. get captureShaderCompilationTime(): boolean;
  55286. /**
  55287. * Enable or disable the shader compilation time capture
  55288. */
  55289. set captureShaderCompilationTime(value: boolean);
  55290. /**
  55291. * Instantiates a new engine instrumentation.
  55292. * This class can be used to get instrumentation data from a Babylon engine
  55293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55294. * @param engine Defines the engine to instrument
  55295. */
  55296. constructor(
  55297. /**
  55298. * Define the instrumented engine.
  55299. */
  55300. engine: Engine);
  55301. /**
  55302. * Dispose and release associated resources.
  55303. */
  55304. dispose(): void;
  55305. }
  55306. }
  55307. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55308. import { Scene, IDisposable } from "babylonjs/scene";
  55309. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55310. /**
  55311. * This class can be used to get instrumentation data from a Babylon engine
  55312. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55313. */
  55314. export class SceneInstrumentation implements IDisposable {
  55315. /**
  55316. * Defines the scene to instrument
  55317. */
  55318. scene: Scene;
  55319. private _captureActiveMeshesEvaluationTime;
  55320. private _activeMeshesEvaluationTime;
  55321. private _captureRenderTargetsRenderTime;
  55322. private _renderTargetsRenderTime;
  55323. private _captureFrameTime;
  55324. private _frameTime;
  55325. private _captureRenderTime;
  55326. private _renderTime;
  55327. private _captureInterFrameTime;
  55328. private _interFrameTime;
  55329. private _captureParticlesRenderTime;
  55330. private _particlesRenderTime;
  55331. private _captureSpritesRenderTime;
  55332. private _spritesRenderTime;
  55333. private _capturePhysicsTime;
  55334. private _physicsTime;
  55335. private _captureAnimationsTime;
  55336. private _animationsTime;
  55337. private _captureCameraRenderTime;
  55338. private _cameraRenderTime;
  55339. private _onBeforeActiveMeshesEvaluationObserver;
  55340. private _onAfterActiveMeshesEvaluationObserver;
  55341. private _onBeforeRenderTargetsRenderObserver;
  55342. private _onAfterRenderTargetsRenderObserver;
  55343. private _onAfterRenderObserver;
  55344. private _onBeforeDrawPhaseObserver;
  55345. private _onAfterDrawPhaseObserver;
  55346. private _onBeforeAnimationsObserver;
  55347. private _onBeforeParticlesRenderingObserver;
  55348. private _onAfterParticlesRenderingObserver;
  55349. private _onBeforeSpritesRenderingObserver;
  55350. private _onAfterSpritesRenderingObserver;
  55351. private _onBeforePhysicsObserver;
  55352. private _onAfterPhysicsObserver;
  55353. private _onAfterAnimationsObserver;
  55354. private _onBeforeCameraRenderObserver;
  55355. private _onAfterCameraRenderObserver;
  55356. /**
  55357. * Gets the perf counter used for active meshes evaluation time
  55358. */
  55359. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55360. /**
  55361. * Gets the active meshes evaluation time capture status
  55362. */
  55363. get captureActiveMeshesEvaluationTime(): boolean;
  55364. /**
  55365. * Enable or disable the active meshes evaluation time capture
  55366. */
  55367. set captureActiveMeshesEvaluationTime(value: boolean);
  55368. /**
  55369. * Gets the perf counter used for render targets render time
  55370. */
  55371. get renderTargetsRenderTimeCounter(): PerfCounter;
  55372. /**
  55373. * Gets the render targets render time capture status
  55374. */
  55375. get captureRenderTargetsRenderTime(): boolean;
  55376. /**
  55377. * Enable or disable the render targets render time capture
  55378. */
  55379. set captureRenderTargetsRenderTime(value: boolean);
  55380. /**
  55381. * Gets the perf counter used for particles render time
  55382. */
  55383. get particlesRenderTimeCounter(): PerfCounter;
  55384. /**
  55385. * Gets the particles render time capture status
  55386. */
  55387. get captureParticlesRenderTime(): boolean;
  55388. /**
  55389. * Enable or disable the particles render time capture
  55390. */
  55391. set captureParticlesRenderTime(value: boolean);
  55392. /**
  55393. * Gets the perf counter used for sprites render time
  55394. */
  55395. get spritesRenderTimeCounter(): PerfCounter;
  55396. /**
  55397. * Gets the sprites render time capture status
  55398. */
  55399. get captureSpritesRenderTime(): boolean;
  55400. /**
  55401. * Enable or disable the sprites render time capture
  55402. */
  55403. set captureSpritesRenderTime(value: boolean);
  55404. /**
  55405. * Gets the perf counter used for physics time
  55406. */
  55407. get physicsTimeCounter(): PerfCounter;
  55408. /**
  55409. * Gets the physics time capture status
  55410. */
  55411. get capturePhysicsTime(): boolean;
  55412. /**
  55413. * Enable or disable the physics time capture
  55414. */
  55415. set capturePhysicsTime(value: boolean);
  55416. /**
  55417. * Gets the perf counter used for animations time
  55418. */
  55419. get animationsTimeCounter(): PerfCounter;
  55420. /**
  55421. * Gets the animations time capture status
  55422. */
  55423. get captureAnimationsTime(): boolean;
  55424. /**
  55425. * Enable or disable the animations time capture
  55426. */
  55427. set captureAnimationsTime(value: boolean);
  55428. /**
  55429. * Gets the perf counter used for frame time capture
  55430. */
  55431. get frameTimeCounter(): PerfCounter;
  55432. /**
  55433. * Gets the frame time capture status
  55434. */
  55435. get captureFrameTime(): boolean;
  55436. /**
  55437. * Enable or disable the frame time capture
  55438. */
  55439. set captureFrameTime(value: boolean);
  55440. /**
  55441. * Gets the perf counter used for inter-frames time capture
  55442. */
  55443. get interFrameTimeCounter(): PerfCounter;
  55444. /**
  55445. * Gets the inter-frames time capture status
  55446. */
  55447. get captureInterFrameTime(): boolean;
  55448. /**
  55449. * Enable or disable the inter-frames time capture
  55450. */
  55451. set captureInterFrameTime(value: boolean);
  55452. /**
  55453. * Gets the perf counter used for render time capture
  55454. */
  55455. get renderTimeCounter(): PerfCounter;
  55456. /**
  55457. * Gets the render time capture status
  55458. */
  55459. get captureRenderTime(): boolean;
  55460. /**
  55461. * Enable or disable the render time capture
  55462. */
  55463. set captureRenderTime(value: boolean);
  55464. /**
  55465. * Gets the perf counter used for camera render time capture
  55466. */
  55467. get cameraRenderTimeCounter(): PerfCounter;
  55468. /**
  55469. * Gets the camera render time capture status
  55470. */
  55471. get captureCameraRenderTime(): boolean;
  55472. /**
  55473. * Enable or disable the camera render time capture
  55474. */
  55475. set captureCameraRenderTime(value: boolean);
  55476. /**
  55477. * Gets the perf counter used for draw calls
  55478. */
  55479. get drawCallsCounter(): PerfCounter;
  55480. /**
  55481. * Instantiates a new scene instrumentation.
  55482. * This class can be used to get instrumentation data from a Babylon engine
  55483. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55484. * @param scene Defines the scene to instrument
  55485. */
  55486. constructor(
  55487. /**
  55488. * Defines the scene to instrument
  55489. */
  55490. scene: Scene);
  55491. /**
  55492. * Dispose and release associated resources.
  55493. */
  55494. dispose(): void;
  55495. }
  55496. }
  55497. declare module "babylonjs/Instrumentation/index" {
  55498. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55499. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55500. export * from "babylonjs/Instrumentation/timeToken";
  55501. }
  55502. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55503. /** @hidden */
  55504. export var glowMapGenerationPixelShader: {
  55505. name: string;
  55506. shader: string;
  55507. };
  55508. }
  55509. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55510. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55511. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55512. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55513. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55514. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55515. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55516. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55517. /** @hidden */
  55518. export var glowMapGenerationVertexShader: {
  55519. name: string;
  55520. shader: string;
  55521. };
  55522. }
  55523. declare module "babylonjs/Layers/effectLayer" {
  55524. import { Observable } from "babylonjs/Misc/observable";
  55525. import { Nullable } from "babylonjs/types";
  55526. import { Camera } from "babylonjs/Cameras/camera";
  55527. import { Scene } from "babylonjs/scene";
  55528. import { ISize } from "babylonjs/Maths/math.size";
  55529. import { Color4 } from "babylonjs/Maths/math.color";
  55530. import { Engine } from "babylonjs/Engines/engine";
  55531. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55533. import { Mesh } from "babylonjs/Meshes/mesh";
  55534. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55536. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55537. import { Effect } from "babylonjs/Materials/effect";
  55538. import { Material } from "babylonjs/Materials/material";
  55539. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55540. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55541. /**
  55542. * Effect layer options. This helps customizing the behaviour
  55543. * of the effect layer.
  55544. */
  55545. export interface IEffectLayerOptions {
  55546. /**
  55547. * Multiplication factor apply to the canvas size to compute the render target size
  55548. * used to generated the objects (the smaller the faster).
  55549. */
  55550. mainTextureRatio: number;
  55551. /**
  55552. * Enforces a fixed size texture to ensure effect stability across devices.
  55553. */
  55554. mainTextureFixedSize?: number;
  55555. /**
  55556. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55557. */
  55558. alphaBlendingMode: number;
  55559. /**
  55560. * The camera attached to the layer.
  55561. */
  55562. camera: Nullable<Camera>;
  55563. /**
  55564. * The rendering group to draw the layer in.
  55565. */
  55566. renderingGroupId: number;
  55567. }
  55568. /**
  55569. * The effect layer Helps adding post process effect blended with the main pass.
  55570. *
  55571. * This can be for instance use to generate glow or higlight effects on the scene.
  55572. *
  55573. * The effect layer class can not be used directly and is intented to inherited from to be
  55574. * customized per effects.
  55575. */
  55576. export abstract class EffectLayer {
  55577. private _vertexBuffers;
  55578. private _indexBuffer;
  55579. private _cachedDefines;
  55580. private _effectLayerMapGenerationEffect;
  55581. private _effectLayerOptions;
  55582. private _mergeEffect;
  55583. protected _scene: Scene;
  55584. protected _engine: Engine;
  55585. protected _maxSize: number;
  55586. protected _mainTextureDesiredSize: ISize;
  55587. protected _mainTexture: RenderTargetTexture;
  55588. protected _shouldRender: boolean;
  55589. protected _postProcesses: PostProcess[];
  55590. protected _textures: BaseTexture[];
  55591. protected _emissiveTextureAndColor: {
  55592. texture: Nullable<BaseTexture>;
  55593. color: Color4;
  55594. };
  55595. /**
  55596. * The name of the layer
  55597. */
  55598. name: string;
  55599. /**
  55600. * The clear color of the texture used to generate the glow map.
  55601. */
  55602. neutralColor: Color4;
  55603. /**
  55604. * Specifies whether the highlight layer is enabled or not.
  55605. */
  55606. isEnabled: boolean;
  55607. /**
  55608. * Gets the camera attached to the layer.
  55609. */
  55610. get camera(): Nullable<Camera>;
  55611. /**
  55612. * Gets the rendering group id the layer should render in.
  55613. */
  55614. get renderingGroupId(): number;
  55615. set renderingGroupId(renderingGroupId: number);
  55616. /**
  55617. * An event triggered when the effect layer has been disposed.
  55618. */
  55619. onDisposeObservable: Observable<EffectLayer>;
  55620. /**
  55621. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55622. */
  55623. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55624. /**
  55625. * An event triggered when the generated texture is being merged in the scene.
  55626. */
  55627. onBeforeComposeObservable: Observable<EffectLayer>;
  55628. /**
  55629. * An event triggered when the mesh is rendered into the effect render target.
  55630. */
  55631. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55632. /**
  55633. * An event triggered after the mesh has been rendered into the effect render target.
  55634. */
  55635. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55636. /**
  55637. * An event triggered when the generated texture has been merged in the scene.
  55638. */
  55639. onAfterComposeObservable: Observable<EffectLayer>;
  55640. /**
  55641. * An event triggered when the efffect layer changes its size.
  55642. */
  55643. onSizeChangedObservable: Observable<EffectLayer>;
  55644. /** @hidden */
  55645. static _SceneComponentInitialization: (scene: Scene) => void;
  55646. /**
  55647. * Instantiates a new effect Layer and references it in the scene.
  55648. * @param name The name of the layer
  55649. * @param scene The scene to use the layer in
  55650. */
  55651. constructor(
  55652. /** The Friendly of the effect in the scene */
  55653. name: string, scene: Scene);
  55654. /**
  55655. * Get the effect name of the layer.
  55656. * @return The effect name
  55657. */
  55658. abstract getEffectName(): string;
  55659. /**
  55660. * Checks for the readiness of the element composing the layer.
  55661. * @param subMesh the mesh to check for
  55662. * @param useInstances specify whether or not to use instances to render the mesh
  55663. * @return true if ready otherwise, false
  55664. */
  55665. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55666. /**
  55667. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55668. * @returns true if the effect requires stencil during the main canvas render pass.
  55669. */
  55670. abstract needStencil(): boolean;
  55671. /**
  55672. * Create the merge effect. This is the shader use to blit the information back
  55673. * to the main canvas at the end of the scene rendering.
  55674. * @returns The effect containing the shader used to merge the effect on the main canvas
  55675. */
  55676. protected abstract _createMergeEffect(): Effect;
  55677. /**
  55678. * Creates the render target textures and post processes used in the effect layer.
  55679. */
  55680. protected abstract _createTextureAndPostProcesses(): void;
  55681. /**
  55682. * Implementation specific of rendering the generating effect on the main canvas.
  55683. * @param effect The effect used to render through
  55684. */
  55685. protected abstract _internalRender(effect: Effect): void;
  55686. /**
  55687. * Sets the required values for both the emissive texture and and the main color.
  55688. */
  55689. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55690. /**
  55691. * Free any resources and references associated to a mesh.
  55692. * Internal use
  55693. * @param mesh The mesh to free.
  55694. */
  55695. abstract _disposeMesh(mesh: Mesh): void;
  55696. /**
  55697. * Serializes this layer (Glow or Highlight for example)
  55698. * @returns a serialized layer object
  55699. */
  55700. abstract serialize?(): any;
  55701. /**
  55702. * Initializes the effect layer with the required options.
  55703. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55704. */
  55705. protected _init(options: Partial<IEffectLayerOptions>): void;
  55706. /**
  55707. * Generates the index buffer of the full screen quad blending to the main canvas.
  55708. */
  55709. private _generateIndexBuffer;
  55710. /**
  55711. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55712. */
  55713. private _generateVertexBuffer;
  55714. /**
  55715. * Sets the main texture desired size which is the closest power of two
  55716. * of the engine canvas size.
  55717. */
  55718. private _setMainTextureSize;
  55719. /**
  55720. * Creates the main texture for the effect layer.
  55721. */
  55722. protected _createMainTexture(): void;
  55723. /**
  55724. * Adds specific effects defines.
  55725. * @param defines The defines to add specifics to.
  55726. */
  55727. protected _addCustomEffectDefines(defines: string[]): void;
  55728. /**
  55729. * Checks for the readiness of the element composing the layer.
  55730. * @param subMesh the mesh to check for
  55731. * @param useInstances specify whether or not to use instances to render the mesh
  55732. * @param emissiveTexture the associated emissive texture used to generate the glow
  55733. * @return true if ready otherwise, false
  55734. */
  55735. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55736. /**
  55737. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55738. */
  55739. render(): void;
  55740. /**
  55741. * Determine if a given mesh will be used in the current effect.
  55742. * @param mesh mesh to test
  55743. * @returns true if the mesh will be used
  55744. */
  55745. hasMesh(mesh: AbstractMesh): boolean;
  55746. /**
  55747. * Returns true if the layer contains information to display, otherwise false.
  55748. * @returns true if the glow layer should be rendered
  55749. */
  55750. shouldRender(): boolean;
  55751. /**
  55752. * Returns true if the mesh should render, otherwise false.
  55753. * @param mesh The mesh to render
  55754. * @returns true if it should render otherwise false
  55755. */
  55756. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55757. /**
  55758. * Returns true if the mesh can be rendered, otherwise false.
  55759. * @param mesh The mesh to render
  55760. * @param material The material used on the mesh
  55761. * @returns true if it can be rendered otherwise false
  55762. */
  55763. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55764. /**
  55765. * Returns true if the mesh should render, otherwise false.
  55766. * @param mesh The mesh to render
  55767. * @returns true if it should render otherwise false
  55768. */
  55769. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55770. /**
  55771. * Renders the submesh passed in parameter to the generation map.
  55772. */
  55773. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55774. /**
  55775. * Defines whether the current material of the mesh should be use to render the effect.
  55776. * @param mesh defines the current mesh to render
  55777. */
  55778. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55779. /**
  55780. * Rebuild the required buffers.
  55781. * @hidden Internal use only.
  55782. */
  55783. _rebuild(): void;
  55784. /**
  55785. * Dispose only the render target textures and post process.
  55786. */
  55787. private _disposeTextureAndPostProcesses;
  55788. /**
  55789. * Dispose the highlight layer and free resources.
  55790. */
  55791. dispose(): void;
  55792. /**
  55793. * Gets the class name of the effect layer
  55794. * @returns the string with the class name of the effect layer
  55795. */
  55796. getClassName(): string;
  55797. /**
  55798. * Creates an effect layer from parsed effect layer data
  55799. * @param parsedEffectLayer defines effect layer data
  55800. * @param scene defines the current scene
  55801. * @param rootUrl defines the root URL containing the effect layer information
  55802. * @returns a parsed effect Layer
  55803. */
  55804. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55805. }
  55806. }
  55807. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55808. import { Scene } from "babylonjs/scene";
  55809. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55810. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55811. import { AbstractScene } from "babylonjs/abstractScene";
  55812. module "babylonjs/abstractScene" {
  55813. interface AbstractScene {
  55814. /**
  55815. * The list of effect layers (highlights/glow) added to the scene
  55816. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55817. * @see http://doc.babylonjs.com/how_to/glow_layer
  55818. */
  55819. effectLayers: Array<EffectLayer>;
  55820. /**
  55821. * Removes the given effect layer from this scene.
  55822. * @param toRemove defines the effect layer to remove
  55823. * @returns the index of the removed effect layer
  55824. */
  55825. removeEffectLayer(toRemove: EffectLayer): number;
  55826. /**
  55827. * Adds the given effect layer to this scene
  55828. * @param newEffectLayer defines the effect layer to add
  55829. */
  55830. addEffectLayer(newEffectLayer: EffectLayer): void;
  55831. }
  55832. }
  55833. /**
  55834. * Defines the layer scene component responsible to manage any effect layers
  55835. * in a given scene.
  55836. */
  55837. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55838. /**
  55839. * The component name helpfull to identify the component in the list of scene components.
  55840. */
  55841. readonly name: string;
  55842. /**
  55843. * The scene the component belongs to.
  55844. */
  55845. scene: Scene;
  55846. private _engine;
  55847. private _renderEffects;
  55848. private _needStencil;
  55849. private _previousStencilState;
  55850. /**
  55851. * Creates a new instance of the component for the given scene
  55852. * @param scene Defines the scene to register the component in
  55853. */
  55854. constructor(scene: Scene);
  55855. /**
  55856. * Registers the component in a given scene
  55857. */
  55858. register(): void;
  55859. /**
  55860. * Rebuilds the elements related to this component in case of
  55861. * context lost for instance.
  55862. */
  55863. rebuild(): void;
  55864. /**
  55865. * Serializes the component data to the specified json object
  55866. * @param serializationObject The object to serialize to
  55867. */
  55868. serialize(serializationObject: any): void;
  55869. /**
  55870. * Adds all the elements from the container to the scene
  55871. * @param container the container holding the elements
  55872. */
  55873. addFromContainer(container: AbstractScene): void;
  55874. /**
  55875. * Removes all the elements in the container from the scene
  55876. * @param container contains the elements to remove
  55877. * @param dispose if the removed element should be disposed (default: false)
  55878. */
  55879. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55880. /**
  55881. * Disposes the component and the associated ressources.
  55882. */
  55883. dispose(): void;
  55884. private _isReadyForMesh;
  55885. private _renderMainTexture;
  55886. private _setStencil;
  55887. private _setStencilBack;
  55888. private _draw;
  55889. private _drawCamera;
  55890. private _drawRenderingGroup;
  55891. }
  55892. }
  55893. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55894. /** @hidden */
  55895. export var glowMapMergePixelShader: {
  55896. name: string;
  55897. shader: string;
  55898. };
  55899. }
  55900. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55901. /** @hidden */
  55902. export var glowMapMergeVertexShader: {
  55903. name: string;
  55904. shader: string;
  55905. };
  55906. }
  55907. declare module "babylonjs/Layers/glowLayer" {
  55908. import { Nullable } from "babylonjs/types";
  55909. import { Camera } from "babylonjs/Cameras/camera";
  55910. import { Scene } from "babylonjs/scene";
  55911. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55913. import { Mesh } from "babylonjs/Meshes/mesh";
  55914. import { Texture } from "babylonjs/Materials/Textures/texture";
  55915. import { Effect } from "babylonjs/Materials/effect";
  55916. import { Material } from "babylonjs/Materials/material";
  55917. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55918. import { Color4 } from "babylonjs/Maths/math.color";
  55919. import "babylonjs/Shaders/glowMapMerge.fragment";
  55920. import "babylonjs/Shaders/glowMapMerge.vertex";
  55921. import "babylonjs/Layers/effectLayerSceneComponent";
  55922. module "babylonjs/abstractScene" {
  55923. interface AbstractScene {
  55924. /**
  55925. * Return a the first highlight layer of the scene with a given name.
  55926. * @param name The name of the highlight layer to look for.
  55927. * @return The highlight layer if found otherwise null.
  55928. */
  55929. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55930. }
  55931. }
  55932. /**
  55933. * Glow layer options. This helps customizing the behaviour
  55934. * of the glow layer.
  55935. */
  55936. export interface IGlowLayerOptions {
  55937. /**
  55938. * Multiplication factor apply to the canvas size to compute the render target size
  55939. * used to generated the glowing objects (the smaller the faster).
  55940. */
  55941. mainTextureRatio: number;
  55942. /**
  55943. * Enforces a fixed size texture to ensure resize independant blur.
  55944. */
  55945. mainTextureFixedSize?: number;
  55946. /**
  55947. * How big is the kernel of the blur texture.
  55948. */
  55949. blurKernelSize: number;
  55950. /**
  55951. * The camera attached to the layer.
  55952. */
  55953. camera: Nullable<Camera>;
  55954. /**
  55955. * Enable MSAA by chosing the number of samples.
  55956. */
  55957. mainTextureSamples?: number;
  55958. /**
  55959. * The rendering group to draw the layer in.
  55960. */
  55961. renderingGroupId: number;
  55962. }
  55963. /**
  55964. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55965. *
  55966. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55967. *
  55968. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55969. */
  55970. export class GlowLayer extends EffectLayer {
  55971. /**
  55972. * Effect Name of the layer.
  55973. */
  55974. static readonly EffectName: string;
  55975. /**
  55976. * The default blur kernel size used for the glow.
  55977. */
  55978. static DefaultBlurKernelSize: number;
  55979. /**
  55980. * The default texture size ratio used for the glow.
  55981. */
  55982. static DefaultTextureRatio: number;
  55983. /**
  55984. * Sets the kernel size of the blur.
  55985. */
  55986. set blurKernelSize(value: number);
  55987. /**
  55988. * Gets the kernel size of the blur.
  55989. */
  55990. get blurKernelSize(): number;
  55991. /**
  55992. * Sets the glow intensity.
  55993. */
  55994. set intensity(value: number);
  55995. /**
  55996. * Gets the glow intensity.
  55997. */
  55998. get intensity(): number;
  55999. private _options;
  56000. private _intensity;
  56001. private _horizontalBlurPostprocess1;
  56002. private _verticalBlurPostprocess1;
  56003. private _horizontalBlurPostprocess2;
  56004. private _verticalBlurPostprocess2;
  56005. private _blurTexture1;
  56006. private _blurTexture2;
  56007. private _postProcesses1;
  56008. private _postProcesses2;
  56009. private _includedOnlyMeshes;
  56010. private _excludedMeshes;
  56011. private _meshesUsingTheirOwnMaterials;
  56012. /**
  56013. * Callback used to let the user override the color selection on a per mesh basis
  56014. */
  56015. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56016. /**
  56017. * Callback used to let the user override the texture selection on a per mesh basis
  56018. */
  56019. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56020. /**
  56021. * Instantiates a new glow Layer and references it to the scene.
  56022. * @param name The name of the layer
  56023. * @param scene The scene to use the layer in
  56024. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56025. */
  56026. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56027. /**
  56028. * Get the effect name of the layer.
  56029. * @return The effect name
  56030. */
  56031. getEffectName(): string;
  56032. /**
  56033. * Create the merge effect. This is the shader use to blit the information back
  56034. * to the main canvas at the end of the scene rendering.
  56035. */
  56036. protected _createMergeEffect(): Effect;
  56037. /**
  56038. * Creates the render target textures and post processes used in the glow layer.
  56039. */
  56040. protected _createTextureAndPostProcesses(): void;
  56041. /**
  56042. * Checks for the readiness of the element composing the layer.
  56043. * @param subMesh the mesh to check for
  56044. * @param useInstances specify wether or not to use instances to render the mesh
  56045. * @param emissiveTexture the associated emissive texture used to generate the glow
  56046. * @return true if ready otherwise, false
  56047. */
  56048. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56049. /**
  56050. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56051. */
  56052. needStencil(): boolean;
  56053. /**
  56054. * Returns true if the mesh can be rendered, otherwise false.
  56055. * @param mesh The mesh to render
  56056. * @param material The material used on the mesh
  56057. * @returns true if it can be rendered otherwise false
  56058. */
  56059. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56060. /**
  56061. * Implementation specific of rendering the generating effect on the main canvas.
  56062. * @param effect The effect used to render through
  56063. */
  56064. protected _internalRender(effect: Effect): void;
  56065. /**
  56066. * Sets the required values for both the emissive texture and and the main color.
  56067. */
  56068. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56069. /**
  56070. * Returns true if the mesh should render, otherwise false.
  56071. * @param mesh The mesh to render
  56072. * @returns true if it should render otherwise false
  56073. */
  56074. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56075. /**
  56076. * Adds specific effects defines.
  56077. * @param defines The defines to add specifics to.
  56078. */
  56079. protected _addCustomEffectDefines(defines: string[]): void;
  56080. /**
  56081. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56082. * @param mesh The mesh to exclude from the glow layer
  56083. */
  56084. addExcludedMesh(mesh: Mesh): void;
  56085. /**
  56086. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56087. * @param mesh The mesh to remove
  56088. */
  56089. removeExcludedMesh(mesh: Mesh): void;
  56090. /**
  56091. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56092. * @param mesh The mesh to include in the glow layer
  56093. */
  56094. addIncludedOnlyMesh(mesh: Mesh): void;
  56095. /**
  56096. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56097. * @param mesh The mesh to remove
  56098. */
  56099. removeIncludedOnlyMesh(mesh: Mesh): void;
  56100. /**
  56101. * Determine if a given mesh will be used in the glow layer
  56102. * @param mesh The mesh to test
  56103. * @returns true if the mesh will be highlighted by the current glow layer
  56104. */
  56105. hasMesh(mesh: AbstractMesh): boolean;
  56106. /**
  56107. * Defines whether the current material of the mesh should be use to render the effect.
  56108. * @param mesh defines the current mesh to render
  56109. */
  56110. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56111. /**
  56112. * Add a mesh to be rendered through its own material and not with emissive only.
  56113. * @param mesh The mesh for which we need to use its material
  56114. */
  56115. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56116. /**
  56117. * Remove a mesh from being rendered through its own material and not with emissive only.
  56118. * @param mesh The mesh for which we need to not use its material
  56119. */
  56120. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56121. /**
  56122. * Free any resources and references associated to a mesh.
  56123. * Internal use
  56124. * @param mesh The mesh to free.
  56125. * @hidden
  56126. */
  56127. _disposeMesh(mesh: Mesh): void;
  56128. /**
  56129. * Gets the class name of the effect layer
  56130. * @returns the string with the class name of the effect layer
  56131. */
  56132. getClassName(): string;
  56133. /**
  56134. * Serializes this glow layer
  56135. * @returns a serialized glow layer object
  56136. */
  56137. serialize(): any;
  56138. /**
  56139. * Creates a Glow Layer from parsed glow layer data
  56140. * @param parsedGlowLayer defines glow layer data
  56141. * @param scene defines the current scene
  56142. * @param rootUrl defines the root URL containing the glow layer information
  56143. * @returns a parsed Glow Layer
  56144. */
  56145. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56146. }
  56147. }
  56148. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56149. /** @hidden */
  56150. export var glowBlurPostProcessPixelShader: {
  56151. name: string;
  56152. shader: string;
  56153. };
  56154. }
  56155. declare module "babylonjs/Layers/highlightLayer" {
  56156. import { Observable } from "babylonjs/Misc/observable";
  56157. import { Nullable } from "babylonjs/types";
  56158. import { Camera } from "babylonjs/Cameras/camera";
  56159. import { Scene } from "babylonjs/scene";
  56160. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56161. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56162. import { Mesh } from "babylonjs/Meshes/mesh";
  56163. import { Effect } from "babylonjs/Materials/effect";
  56164. import { Material } from "babylonjs/Materials/material";
  56165. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56166. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56167. import "babylonjs/Shaders/glowMapMerge.fragment";
  56168. import "babylonjs/Shaders/glowMapMerge.vertex";
  56169. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56170. module "babylonjs/abstractScene" {
  56171. interface AbstractScene {
  56172. /**
  56173. * Return a the first highlight layer of the scene with a given name.
  56174. * @param name The name of the highlight layer to look for.
  56175. * @return The highlight layer if found otherwise null.
  56176. */
  56177. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56178. }
  56179. }
  56180. /**
  56181. * Highlight layer options. This helps customizing the behaviour
  56182. * of the highlight layer.
  56183. */
  56184. export interface IHighlightLayerOptions {
  56185. /**
  56186. * Multiplication factor apply to the canvas size to compute the render target size
  56187. * used to generated the glowing objects (the smaller the faster).
  56188. */
  56189. mainTextureRatio: number;
  56190. /**
  56191. * Enforces a fixed size texture to ensure resize independant blur.
  56192. */
  56193. mainTextureFixedSize?: number;
  56194. /**
  56195. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56196. * of the picture to blur (the smaller the faster).
  56197. */
  56198. blurTextureSizeRatio: number;
  56199. /**
  56200. * How big in texel of the blur texture is the vertical blur.
  56201. */
  56202. blurVerticalSize: number;
  56203. /**
  56204. * How big in texel of the blur texture is the horizontal blur.
  56205. */
  56206. blurHorizontalSize: number;
  56207. /**
  56208. * Alpha blending mode used to apply the blur. Default is combine.
  56209. */
  56210. alphaBlendingMode: number;
  56211. /**
  56212. * The camera attached to the layer.
  56213. */
  56214. camera: Nullable<Camera>;
  56215. /**
  56216. * Should we display highlight as a solid stroke?
  56217. */
  56218. isStroke?: boolean;
  56219. /**
  56220. * The rendering group to draw the layer in.
  56221. */
  56222. renderingGroupId: number;
  56223. }
  56224. /**
  56225. * The highlight layer Helps adding a glow effect around a mesh.
  56226. *
  56227. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56228. * glowy meshes to your scene.
  56229. *
  56230. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56231. */
  56232. export class HighlightLayer extends EffectLayer {
  56233. name: string;
  56234. /**
  56235. * Effect Name of the highlight layer.
  56236. */
  56237. static readonly EffectName: string;
  56238. /**
  56239. * The neutral color used during the preparation of the glow effect.
  56240. * This is black by default as the blend operation is a blend operation.
  56241. */
  56242. static NeutralColor: Color4;
  56243. /**
  56244. * Stencil value used for glowing meshes.
  56245. */
  56246. static GlowingMeshStencilReference: number;
  56247. /**
  56248. * Stencil value used for the other meshes in the scene.
  56249. */
  56250. static NormalMeshStencilReference: number;
  56251. /**
  56252. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56253. */
  56254. innerGlow: boolean;
  56255. /**
  56256. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56257. */
  56258. outerGlow: boolean;
  56259. /**
  56260. * Specifies the horizontal size of the blur.
  56261. */
  56262. set blurHorizontalSize(value: number);
  56263. /**
  56264. * Specifies the vertical size of the blur.
  56265. */
  56266. set blurVerticalSize(value: number);
  56267. /**
  56268. * Gets the horizontal size of the blur.
  56269. */
  56270. get blurHorizontalSize(): number;
  56271. /**
  56272. * Gets the vertical size of the blur.
  56273. */
  56274. get blurVerticalSize(): number;
  56275. /**
  56276. * An event triggered when the highlight layer is being blurred.
  56277. */
  56278. onBeforeBlurObservable: Observable<HighlightLayer>;
  56279. /**
  56280. * An event triggered when the highlight layer has been blurred.
  56281. */
  56282. onAfterBlurObservable: Observable<HighlightLayer>;
  56283. private _instanceGlowingMeshStencilReference;
  56284. private _options;
  56285. private _downSamplePostprocess;
  56286. private _horizontalBlurPostprocess;
  56287. private _verticalBlurPostprocess;
  56288. private _blurTexture;
  56289. private _meshes;
  56290. private _excludedMeshes;
  56291. /**
  56292. * Instantiates a new highlight Layer and references it to the scene..
  56293. * @param name The name of the layer
  56294. * @param scene The scene to use the layer in
  56295. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56296. */
  56297. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56298. /**
  56299. * Get the effect name of the layer.
  56300. * @return The effect name
  56301. */
  56302. getEffectName(): string;
  56303. /**
  56304. * Create the merge effect. This is the shader use to blit the information back
  56305. * to the main canvas at the end of the scene rendering.
  56306. */
  56307. protected _createMergeEffect(): Effect;
  56308. /**
  56309. * Creates the render target textures and post processes used in the highlight layer.
  56310. */
  56311. protected _createTextureAndPostProcesses(): void;
  56312. /**
  56313. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56314. */
  56315. needStencil(): boolean;
  56316. /**
  56317. * Checks for the readiness of the element composing the layer.
  56318. * @param subMesh the mesh to check for
  56319. * @param useInstances specify wether or not to use instances to render the mesh
  56320. * @param emissiveTexture the associated emissive texture used to generate the glow
  56321. * @return true if ready otherwise, false
  56322. */
  56323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56324. /**
  56325. * Implementation specific of rendering the generating effect on the main canvas.
  56326. * @param effect The effect used to render through
  56327. */
  56328. protected _internalRender(effect: Effect): void;
  56329. /**
  56330. * Returns true if the layer contains information to display, otherwise false.
  56331. */
  56332. shouldRender(): boolean;
  56333. /**
  56334. * Returns true if the mesh should render, otherwise false.
  56335. * @param mesh The mesh to render
  56336. * @returns true if it should render otherwise false
  56337. */
  56338. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56339. /**
  56340. * Adds specific effects defines.
  56341. * @param defines The defines to add specifics to.
  56342. */
  56343. protected _addCustomEffectDefines(defines: string[]): void;
  56344. /**
  56345. * Sets the required values for both the emissive texture and and the main color.
  56346. */
  56347. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56348. /**
  56349. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56350. * @param mesh The mesh to exclude from the highlight layer
  56351. */
  56352. addExcludedMesh(mesh: Mesh): void;
  56353. /**
  56354. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56355. * @param mesh The mesh to highlight
  56356. */
  56357. removeExcludedMesh(mesh: Mesh): void;
  56358. /**
  56359. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56360. * @param mesh mesh to test
  56361. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56362. */
  56363. hasMesh(mesh: AbstractMesh): boolean;
  56364. /**
  56365. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56366. * @param mesh The mesh to highlight
  56367. * @param color The color of the highlight
  56368. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56369. */
  56370. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56371. /**
  56372. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56373. * @param mesh The mesh to highlight
  56374. */
  56375. removeMesh(mesh: Mesh): void;
  56376. /**
  56377. * Remove all the meshes currently referenced in the highlight layer
  56378. */
  56379. removeAllMeshes(): void;
  56380. /**
  56381. * Force the stencil to the normal expected value for none glowing parts
  56382. */
  56383. private _defaultStencilReference;
  56384. /**
  56385. * Free any resources and references associated to a mesh.
  56386. * Internal use
  56387. * @param mesh The mesh to free.
  56388. * @hidden
  56389. */
  56390. _disposeMesh(mesh: Mesh): void;
  56391. /**
  56392. * Dispose the highlight layer and free resources.
  56393. */
  56394. dispose(): void;
  56395. /**
  56396. * Gets the class name of the effect layer
  56397. * @returns the string with the class name of the effect layer
  56398. */
  56399. getClassName(): string;
  56400. /**
  56401. * Serializes this Highlight layer
  56402. * @returns a serialized Highlight layer object
  56403. */
  56404. serialize(): any;
  56405. /**
  56406. * Creates a Highlight layer from parsed Highlight layer data
  56407. * @param parsedHightlightLayer defines the Highlight layer data
  56408. * @param scene defines the current scene
  56409. * @param rootUrl defines the root URL containing the Highlight layer information
  56410. * @returns a parsed Highlight layer
  56411. */
  56412. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56413. }
  56414. }
  56415. declare module "babylonjs/Layers/layerSceneComponent" {
  56416. import { Scene } from "babylonjs/scene";
  56417. import { ISceneComponent } from "babylonjs/sceneComponent";
  56418. import { Layer } from "babylonjs/Layers/layer";
  56419. import { AbstractScene } from "babylonjs/abstractScene";
  56420. module "babylonjs/abstractScene" {
  56421. interface AbstractScene {
  56422. /**
  56423. * The list of layers (background and foreground) of the scene
  56424. */
  56425. layers: Array<Layer>;
  56426. }
  56427. }
  56428. /**
  56429. * Defines the layer scene component responsible to manage any layers
  56430. * in a given scene.
  56431. */
  56432. export class LayerSceneComponent implements ISceneComponent {
  56433. /**
  56434. * The component name helpfull to identify the component in the list of scene components.
  56435. */
  56436. readonly name: string;
  56437. /**
  56438. * The scene the component belongs to.
  56439. */
  56440. scene: Scene;
  56441. private _engine;
  56442. /**
  56443. * Creates a new instance of the component for the given scene
  56444. * @param scene Defines the scene to register the component in
  56445. */
  56446. constructor(scene: Scene);
  56447. /**
  56448. * Registers the component in a given scene
  56449. */
  56450. register(): void;
  56451. /**
  56452. * Rebuilds the elements related to this component in case of
  56453. * context lost for instance.
  56454. */
  56455. rebuild(): void;
  56456. /**
  56457. * Disposes the component and the associated ressources.
  56458. */
  56459. dispose(): void;
  56460. private _draw;
  56461. private _drawCameraPredicate;
  56462. private _drawCameraBackground;
  56463. private _drawCameraForeground;
  56464. private _drawRenderTargetPredicate;
  56465. private _drawRenderTargetBackground;
  56466. private _drawRenderTargetForeground;
  56467. /**
  56468. * Adds all the elements from the container to the scene
  56469. * @param container the container holding the elements
  56470. */
  56471. addFromContainer(container: AbstractScene): void;
  56472. /**
  56473. * Removes all the elements in the container from the scene
  56474. * @param container contains the elements to remove
  56475. * @param dispose if the removed element should be disposed (default: false)
  56476. */
  56477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56478. }
  56479. }
  56480. declare module "babylonjs/Shaders/layer.fragment" {
  56481. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56482. /** @hidden */
  56483. export var layerPixelShader: {
  56484. name: string;
  56485. shader: string;
  56486. };
  56487. }
  56488. declare module "babylonjs/Shaders/layer.vertex" {
  56489. /** @hidden */
  56490. export var layerVertexShader: {
  56491. name: string;
  56492. shader: string;
  56493. };
  56494. }
  56495. declare module "babylonjs/Layers/layer" {
  56496. import { Observable } from "babylonjs/Misc/observable";
  56497. import { Nullable } from "babylonjs/types";
  56498. import { Scene } from "babylonjs/scene";
  56499. import { Vector2 } from "babylonjs/Maths/math.vector";
  56500. import { Color4 } from "babylonjs/Maths/math.color";
  56501. import { Texture } from "babylonjs/Materials/Textures/texture";
  56502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56503. import "babylonjs/Shaders/layer.fragment";
  56504. import "babylonjs/Shaders/layer.vertex";
  56505. /**
  56506. * This represents a full screen 2d layer.
  56507. * This can be useful to display a picture in the background of your scene for instance.
  56508. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56509. */
  56510. export class Layer {
  56511. /**
  56512. * Define the name of the layer.
  56513. */
  56514. name: string;
  56515. /**
  56516. * Define the texture the layer should display.
  56517. */
  56518. texture: Nullable<Texture>;
  56519. /**
  56520. * Is the layer in background or foreground.
  56521. */
  56522. isBackground: boolean;
  56523. /**
  56524. * Define the color of the layer (instead of texture).
  56525. */
  56526. color: Color4;
  56527. /**
  56528. * Define the scale of the layer in order to zoom in out of the texture.
  56529. */
  56530. scale: Vector2;
  56531. /**
  56532. * Define an offset for the layer in order to shift the texture.
  56533. */
  56534. offset: Vector2;
  56535. /**
  56536. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56537. */
  56538. alphaBlendingMode: number;
  56539. /**
  56540. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56541. * Alpha test will not mix with the background color in case of transparency.
  56542. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56543. */
  56544. alphaTest: boolean;
  56545. /**
  56546. * Define a mask to restrict the layer to only some of the scene cameras.
  56547. */
  56548. layerMask: number;
  56549. /**
  56550. * Define the list of render target the layer is visible into.
  56551. */
  56552. renderTargetTextures: RenderTargetTexture[];
  56553. /**
  56554. * Define if the layer is only used in renderTarget or if it also
  56555. * renders in the main frame buffer of the canvas.
  56556. */
  56557. renderOnlyInRenderTargetTextures: boolean;
  56558. private _scene;
  56559. private _vertexBuffers;
  56560. private _indexBuffer;
  56561. private _effect;
  56562. private _previousDefines;
  56563. /**
  56564. * An event triggered when the layer is disposed.
  56565. */
  56566. onDisposeObservable: Observable<Layer>;
  56567. private _onDisposeObserver;
  56568. /**
  56569. * Back compatibility with callback before the onDisposeObservable existed.
  56570. * The set callback will be triggered when the layer has been disposed.
  56571. */
  56572. set onDispose(callback: () => void);
  56573. /**
  56574. * An event triggered before rendering the scene
  56575. */
  56576. onBeforeRenderObservable: Observable<Layer>;
  56577. private _onBeforeRenderObserver;
  56578. /**
  56579. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56580. * The set callback will be triggered just before rendering the layer.
  56581. */
  56582. set onBeforeRender(callback: () => void);
  56583. /**
  56584. * An event triggered after rendering the scene
  56585. */
  56586. onAfterRenderObservable: Observable<Layer>;
  56587. private _onAfterRenderObserver;
  56588. /**
  56589. * Back compatibility with callback before the onAfterRenderObservable existed.
  56590. * The set callback will be triggered just after rendering the layer.
  56591. */
  56592. set onAfterRender(callback: () => void);
  56593. /**
  56594. * Instantiates a new layer.
  56595. * This represents a full screen 2d layer.
  56596. * This can be useful to display a picture in the background of your scene for instance.
  56597. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56598. * @param name Define the name of the layer in the scene
  56599. * @param imgUrl Define the url of the texture to display in the layer
  56600. * @param scene Define the scene the layer belongs to
  56601. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56602. * @param color Defines a color for the layer
  56603. */
  56604. constructor(
  56605. /**
  56606. * Define the name of the layer.
  56607. */
  56608. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56609. private _createIndexBuffer;
  56610. /** @hidden */
  56611. _rebuild(): void;
  56612. /**
  56613. * Renders the layer in the scene.
  56614. */
  56615. render(): void;
  56616. /**
  56617. * Disposes and releases the associated ressources.
  56618. */
  56619. dispose(): void;
  56620. }
  56621. }
  56622. declare module "babylonjs/Layers/index" {
  56623. export * from "babylonjs/Layers/effectLayer";
  56624. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56625. export * from "babylonjs/Layers/glowLayer";
  56626. export * from "babylonjs/Layers/highlightLayer";
  56627. export * from "babylonjs/Layers/layer";
  56628. export * from "babylonjs/Layers/layerSceneComponent";
  56629. }
  56630. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56631. /** @hidden */
  56632. export var lensFlarePixelShader: {
  56633. name: string;
  56634. shader: string;
  56635. };
  56636. }
  56637. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56638. /** @hidden */
  56639. export var lensFlareVertexShader: {
  56640. name: string;
  56641. shader: string;
  56642. };
  56643. }
  56644. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56645. import { Scene } from "babylonjs/scene";
  56646. import { Vector3 } from "babylonjs/Maths/math.vector";
  56647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56648. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56649. import "babylonjs/Shaders/lensFlare.fragment";
  56650. import "babylonjs/Shaders/lensFlare.vertex";
  56651. import { Viewport } from "babylonjs/Maths/math.viewport";
  56652. /**
  56653. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56654. * It is usually composed of several `lensFlare`.
  56655. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56656. */
  56657. export class LensFlareSystem {
  56658. /**
  56659. * Define the name of the lens flare system
  56660. */
  56661. name: string;
  56662. /**
  56663. * List of lens flares used in this system.
  56664. */
  56665. lensFlares: LensFlare[];
  56666. /**
  56667. * Define a limit from the border the lens flare can be visible.
  56668. */
  56669. borderLimit: number;
  56670. /**
  56671. * Define a viewport border we do not want to see the lens flare in.
  56672. */
  56673. viewportBorder: number;
  56674. /**
  56675. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56676. */
  56677. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56678. /**
  56679. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56680. */
  56681. layerMask: number;
  56682. /**
  56683. * Define the id of the lens flare system in the scene.
  56684. * (equal to name by default)
  56685. */
  56686. id: string;
  56687. private _scene;
  56688. private _emitter;
  56689. private _vertexBuffers;
  56690. private _indexBuffer;
  56691. private _effect;
  56692. private _positionX;
  56693. private _positionY;
  56694. private _isEnabled;
  56695. /** @hidden */
  56696. static _SceneComponentInitialization: (scene: Scene) => void;
  56697. /**
  56698. * Instantiates a lens flare system.
  56699. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56700. * It is usually composed of several `lensFlare`.
  56701. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56702. * @param name Define the name of the lens flare system in the scene
  56703. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56704. * @param scene Define the scene the lens flare system belongs to
  56705. */
  56706. constructor(
  56707. /**
  56708. * Define the name of the lens flare system
  56709. */
  56710. name: string, emitter: any, scene: Scene);
  56711. /**
  56712. * Define if the lens flare system is enabled.
  56713. */
  56714. get isEnabled(): boolean;
  56715. set isEnabled(value: boolean);
  56716. /**
  56717. * Get the scene the effects belongs to.
  56718. * @returns the scene holding the lens flare system
  56719. */
  56720. getScene(): Scene;
  56721. /**
  56722. * Get the emitter of the lens flare system.
  56723. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56724. * @returns the emitter of the lens flare system
  56725. */
  56726. getEmitter(): any;
  56727. /**
  56728. * Set the emitter of the lens flare system.
  56729. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56730. * @param newEmitter Define the new emitter of the system
  56731. */
  56732. setEmitter(newEmitter: any): void;
  56733. /**
  56734. * Get the lens flare system emitter position.
  56735. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56736. * @returns the position
  56737. */
  56738. getEmitterPosition(): Vector3;
  56739. /**
  56740. * @hidden
  56741. */
  56742. computeEffectivePosition(globalViewport: Viewport): boolean;
  56743. /** @hidden */
  56744. _isVisible(): boolean;
  56745. /**
  56746. * @hidden
  56747. */
  56748. render(): boolean;
  56749. /**
  56750. * Dispose and release the lens flare with its associated resources.
  56751. */
  56752. dispose(): void;
  56753. /**
  56754. * Parse a lens flare system from a JSON repressentation
  56755. * @param parsedLensFlareSystem Define the JSON to parse
  56756. * @param scene Define the scene the parsed system should be instantiated in
  56757. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56758. * @returns the parsed system
  56759. */
  56760. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56761. /**
  56762. * Serialize the current Lens Flare System into a JSON representation.
  56763. * @returns the serialized JSON
  56764. */
  56765. serialize(): any;
  56766. }
  56767. }
  56768. declare module "babylonjs/LensFlares/lensFlare" {
  56769. import { Nullable } from "babylonjs/types";
  56770. import { Color3 } from "babylonjs/Maths/math.color";
  56771. import { Texture } from "babylonjs/Materials/Textures/texture";
  56772. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56773. /**
  56774. * This represents one of the lens effect in a `lensFlareSystem`.
  56775. * It controls one of the indiviual texture used in the effect.
  56776. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56777. */
  56778. export class LensFlare {
  56779. /**
  56780. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56781. */
  56782. size: number;
  56783. /**
  56784. * 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.
  56785. */
  56786. position: number;
  56787. /**
  56788. * Define the lens color.
  56789. */
  56790. color: Color3;
  56791. /**
  56792. * Define the lens texture.
  56793. */
  56794. texture: Nullable<Texture>;
  56795. /**
  56796. * Define the alpha mode to render this particular lens.
  56797. */
  56798. alphaMode: number;
  56799. private _system;
  56800. /**
  56801. * Creates a new Lens Flare.
  56802. * This represents one of the lens effect in a `lensFlareSystem`.
  56803. * It controls one of the indiviual texture used in the effect.
  56804. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56805. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56806. * @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.
  56807. * @param color Define the lens color
  56808. * @param imgUrl Define the lens texture url
  56809. * @param system Define the `lensFlareSystem` this flare is part of
  56810. * @returns The newly created Lens Flare
  56811. */
  56812. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56813. /**
  56814. * Instantiates a new Lens Flare.
  56815. * This represents one of the lens effect in a `lensFlareSystem`.
  56816. * It controls one of the indiviual texture used in the effect.
  56817. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56818. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56819. * @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.
  56820. * @param color Define the lens color
  56821. * @param imgUrl Define the lens texture url
  56822. * @param system Define the `lensFlareSystem` this flare is part of
  56823. */
  56824. constructor(
  56825. /**
  56826. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56827. */
  56828. size: number,
  56829. /**
  56830. * 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.
  56831. */
  56832. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56833. /**
  56834. * Dispose and release the lens flare with its associated resources.
  56835. */
  56836. dispose(): void;
  56837. }
  56838. }
  56839. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56840. import { Nullable } from "babylonjs/types";
  56841. import { Scene } from "babylonjs/scene";
  56842. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56843. import { AbstractScene } from "babylonjs/abstractScene";
  56844. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56845. module "babylonjs/abstractScene" {
  56846. interface AbstractScene {
  56847. /**
  56848. * The list of lens flare system added to the scene
  56849. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56850. */
  56851. lensFlareSystems: Array<LensFlareSystem>;
  56852. /**
  56853. * Removes the given lens flare system from this scene.
  56854. * @param toRemove The lens flare system to remove
  56855. * @returns The index of the removed lens flare system
  56856. */
  56857. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56858. /**
  56859. * Adds the given lens flare system to this scene
  56860. * @param newLensFlareSystem The lens flare system to add
  56861. */
  56862. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56863. /**
  56864. * Gets a lens flare system using its name
  56865. * @param name defines the name to look for
  56866. * @returns the lens flare system or null if not found
  56867. */
  56868. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56869. /**
  56870. * Gets a lens flare system using its id
  56871. * @param id defines the id to look for
  56872. * @returns the lens flare system or null if not found
  56873. */
  56874. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56875. }
  56876. }
  56877. /**
  56878. * Defines the lens flare scene component responsible to manage any lens flares
  56879. * in a given scene.
  56880. */
  56881. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56882. /**
  56883. * The component name helpfull to identify the component in the list of scene components.
  56884. */
  56885. readonly name: string;
  56886. /**
  56887. * The scene the component belongs to.
  56888. */
  56889. scene: Scene;
  56890. /**
  56891. * Creates a new instance of the component for the given scene
  56892. * @param scene Defines the scene to register the component in
  56893. */
  56894. constructor(scene: Scene);
  56895. /**
  56896. * Registers the component in a given scene
  56897. */
  56898. register(): void;
  56899. /**
  56900. * Rebuilds the elements related to this component in case of
  56901. * context lost for instance.
  56902. */
  56903. rebuild(): void;
  56904. /**
  56905. * Adds all the elements from the container to the scene
  56906. * @param container the container holding the elements
  56907. */
  56908. addFromContainer(container: AbstractScene): void;
  56909. /**
  56910. * Removes all the elements in the container from the scene
  56911. * @param container contains the elements to remove
  56912. * @param dispose if the removed element should be disposed (default: false)
  56913. */
  56914. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56915. /**
  56916. * Serializes the component data to the specified json object
  56917. * @param serializationObject The object to serialize to
  56918. */
  56919. serialize(serializationObject: any): void;
  56920. /**
  56921. * Disposes the component and the associated ressources.
  56922. */
  56923. dispose(): void;
  56924. private _draw;
  56925. }
  56926. }
  56927. declare module "babylonjs/LensFlares/index" {
  56928. export * from "babylonjs/LensFlares/lensFlare";
  56929. export * from "babylonjs/LensFlares/lensFlareSystem";
  56930. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56931. }
  56932. declare module "babylonjs/Shaders/depth.fragment" {
  56933. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56934. /** @hidden */
  56935. export var depthPixelShader: {
  56936. name: string;
  56937. shader: string;
  56938. };
  56939. }
  56940. declare module "babylonjs/Shaders/depth.vertex" {
  56941. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56944. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56946. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56947. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56948. /** @hidden */
  56949. export var depthVertexShader: {
  56950. name: string;
  56951. shader: string;
  56952. };
  56953. }
  56954. declare module "babylonjs/Rendering/depthRenderer" {
  56955. import { Nullable } from "babylonjs/types";
  56956. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56957. import { Scene } from "babylonjs/scene";
  56958. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56959. import { Camera } from "babylonjs/Cameras/camera";
  56960. import "babylonjs/Shaders/depth.fragment";
  56961. import "babylonjs/Shaders/depth.vertex";
  56962. /**
  56963. * This represents a depth renderer in Babylon.
  56964. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56965. */
  56966. export class DepthRenderer {
  56967. private _scene;
  56968. private _depthMap;
  56969. private _effect;
  56970. private readonly _storeNonLinearDepth;
  56971. private readonly _clearColor;
  56972. /** Get if the depth renderer is using packed depth or not */
  56973. readonly isPacked: boolean;
  56974. private _cachedDefines;
  56975. private _camera;
  56976. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56977. enabled: boolean;
  56978. /**
  56979. * Specifiess that the depth renderer will only be used within
  56980. * the camera it is created for.
  56981. * This can help forcing its rendering during the camera processing.
  56982. */
  56983. useOnlyInActiveCamera: boolean;
  56984. /** @hidden */
  56985. static _SceneComponentInitialization: (scene: Scene) => void;
  56986. /**
  56987. * Instantiates a depth renderer
  56988. * @param scene The scene the renderer belongs to
  56989. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56990. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56991. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56992. */
  56993. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56994. /**
  56995. * Creates the depth rendering effect and checks if the effect is ready.
  56996. * @param subMesh The submesh to be used to render the depth map of
  56997. * @param useInstances If multiple world instances should be used
  56998. * @returns if the depth renderer is ready to render the depth map
  56999. */
  57000. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57001. /**
  57002. * Gets the texture which the depth map will be written to.
  57003. * @returns The depth map texture
  57004. */
  57005. getDepthMap(): RenderTargetTexture;
  57006. /**
  57007. * Disposes of the depth renderer.
  57008. */
  57009. dispose(): void;
  57010. }
  57011. }
  57012. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57013. /** @hidden */
  57014. export var minmaxReduxPixelShader: {
  57015. name: string;
  57016. shader: string;
  57017. };
  57018. }
  57019. declare module "babylonjs/Misc/minMaxReducer" {
  57020. import { Nullable } from "babylonjs/types";
  57021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57022. import { Camera } from "babylonjs/Cameras/camera";
  57023. import { Observer } from "babylonjs/Misc/observable";
  57024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57025. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57026. import { Observable } from "babylonjs/Misc/observable";
  57027. import "babylonjs/Shaders/minmaxRedux.fragment";
  57028. /**
  57029. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57030. * and maximum values from all values of the texture.
  57031. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57032. * The source values are read from the red channel of the texture.
  57033. */
  57034. export class MinMaxReducer {
  57035. /**
  57036. * Observable triggered when the computation has been performed
  57037. */
  57038. onAfterReductionPerformed: Observable<{
  57039. min: number;
  57040. max: number;
  57041. }>;
  57042. protected _camera: Camera;
  57043. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57044. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57045. protected _postProcessManager: PostProcessManager;
  57046. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57047. protected _forceFullscreenViewport: boolean;
  57048. /**
  57049. * Creates a min/max reducer
  57050. * @param camera The camera to use for the post processes
  57051. */
  57052. constructor(camera: Camera);
  57053. /**
  57054. * Gets the texture used to read the values from.
  57055. */
  57056. get sourceTexture(): Nullable<RenderTargetTexture>;
  57057. /**
  57058. * Sets the source texture to read the values from.
  57059. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57060. * because in such textures '1' value must not be taken into account to compute the maximum
  57061. * as this value is used to clear the texture.
  57062. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57063. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57064. * @param depthRedux Indicates if the texture is a depth texture or not
  57065. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57066. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57067. */
  57068. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57069. /**
  57070. * Defines the refresh rate of the computation.
  57071. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57072. */
  57073. get refreshRate(): number;
  57074. set refreshRate(value: number);
  57075. protected _activated: boolean;
  57076. /**
  57077. * Gets the activation status of the reducer
  57078. */
  57079. get activated(): boolean;
  57080. /**
  57081. * Activates the reduction computation.
  57082. * When activated, the observers registered in onAfterReductionPerformed are
  57083. * called after the compuation is performed
  57084. */
  57085. activate(): void;
  57086. /**
  57087. * Deactivates the reduction computation.
  57088. */
  57089. deactivate(): void;
  57090. /**
  57091. * Disposes the min/max reducer
  57092. * @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.
  57093. */
  57094. dispose(disposeAll?: boolean): void;
  57095. }
  57096. }
  57097. declare module "babylonjs/Misc/depthReducer" {
  57098. import { Nullable } from "babylonjs/types";
  57099. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57100. import { Camera } from "babylonjs/Cameras/camera";
  57101. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57102. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57103. /**
  57104. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57105. */
  57106. export class DepthReducer extends MinMaxReducer {
  57107. private _depthRenderer;
  57108. private _depthRendererId;
  57109. /**
  57110. * Gets the depth renderer used for the computation.
  57111. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57112. */
  57113. get depthRenderer(): Nullable<DepthRenderer>;
  57114. /**
  57115. * Creates a depth reducer
  57116. * @param camera The camera used to render the depth texture
  57117. */
  57118. constructor(camera: Camera);
  57119. /**
  57120. * Sets the depth renderer to use to generate the depth map
  57121. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57122. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57123. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57124. */
  57125. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57126. /** @hidden */
  57127. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57128. /**
  57129. * Activates the reduction computation.
  57130. * When activated, the observers registered in onAfterReductionPerformed are
  57131. * called after the compuation is performed
  57132. */
  57133. activate(): void;
  57134. /**
  57135. * Deactivates the reduction computation.
  57136. */
  57137. deactivate(): void;
  57138. /**
  57139. * Disposes the depth reducer
  57140. * @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.
  57141. */
  57142. dispose(disposeAll?: boolean): void;
  57143. }
  57144. }
  57145. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57146. import { Nullable } from "babylonjs/types";
  57147. import { Scene } from "babylonjs/scene";
  57148. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57149. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57150. import { Effect } from "babylonjs/Materials/effect";
  57151. import "babylonjs/Shaders/shadowMap.fragment";
  57152. import "babylonjs/Shaders/shadowMap.vertex";
  57153. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57154. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57155. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57156. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57157. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57158. /**
  57159. * A CSM implementation allowing casting shadows on large scenes.
  57160. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57161. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57162. */
  57163. export class CascadedShadowGenerator extends ShadowGenerator {
  57164. private static readonly frustumCornersNDCSpace;
  57165. /**
  57166. * Name of the CSM class
  57167. */
  57168. static CLASSNAME: string;
  57169. /**
  57170. * Defines the default number of cascades used by the CSM.
  57171. */
  57172. static readonly DEFAULT_CASCADES_COUNT: number;
  57173. /**
  57174. * Defines the minimum number of cascades used by the CSM.
  57175. */
  57176. static readonly MIN_CASCADES_COUNT: number;
  57177. /**
  57178. * Defines the maximum number of cascades used by the CSM.
  57179. */
  57180. static readonly MAX_CASCADES_COUNT: number;
  57181. protected _validateFilter(filter: number): number;
  57182. /**
  57183. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57184. */
  57185. penumbraDarkness: number;
  57186. private _numCascades;
  57187. /**
  57188. * Gets or set the number of cascades used by the CSM.
  57189. */
  57190. get numCascades(): number;
  57191. set numCascades(value: number);
  57192. /**
  57193. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57194. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57195. */
  57196. stabilizeCascades: boolean;
  57197. private _freezeShadowCastersBoundingInfo;
  57198. private _freezeShadowCastersBoundingInfoObservable;
  57199. /**
  57200. * Enables or disables the shadow casters bounding info computation.
  57201. * If your shadow casters don't move, you can disable this feature.
  57202. * If it is enabled, the bounding box computation is done every frame.
  57203. */
  57204. get freezeShadowCastersBoundingInfo(): boolean;
  57205. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57206. private _scbiMin;
  57207. private _scbiMax;
  57208. protected _computeShadowCastersBoundingInfo(): void;
  57209. protected _shadowCastersBoundingInfo: BoundingInfo;
  57210. /**
  57211. * Gets or sets the shadow casters bounding info.
  57212. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57213. * so that the system won't overwrite the bounds you provide
  57214. */
  57215. get shadowCastersBoundingInfo(): BoundingInfo;
  57216. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57217. protected _breaksAreDirty: boolean;
  57218. protected _minDistance: number;
  57219. protected _maxDistance: number;
  57220. /**
  57221. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57222. *
  57223. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57224. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57225. * @param min minimal distance for the breaks (default to 0.)
  57226. * @param max maximal distance for the breaks (default to 1.)
  57227. */
  57228. setMinMaxDistance(min: number, max: number): void;
  57229. /** Gets the minimal distance used in the cascade break computation */
  57230. get minDistance(): number;
  57231. /** Gets the maximal distance used in the cascade break computation */
  57232. get maxDistance(): number;
  57233. /**
  57234. * Gets the class name of that object
  57235. * @returns "CascadedShadowGenerator"
  57236. */
  57237. getClassName(): string;
  57238. private _cascadeMinExtents;
  57239. private _cascadeMaxExtents;
  57240. /**
  57241. * Gets a cascade minimum extents
  57242. * @param cascadeIndex index of the cascade
  57243. * @returns the minimum cascade extents
  57244. */
  57245. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57246. /**
  57247. * Gets a cascade maximum extents
  57248. * @param cascadeIndex index of the cascade
  57249. * @returns the maximum cascade extents
  57250. */
  57251. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57252. private _cascades;
  57253. private _currentLayer;
  57254. private _viewSpaceFrustumsZ;
  57255. private _viewMatrices;
  57256. private _projectionMatrices;
  57257. private _transformMatrices;
  57258. private _transformMatricesAsArray;
  57259. private _frustumLengths;
  57260. private _lightSizeUVCorrection;
  57261. private _depthCorrection;
  57262. private _frustumCornersWorldSpace;
  57263. private _frustumCenter;
  57264. private _shadowCameraPos;
  57265. private _shadowMaxZ;
  57266. /**
  57267. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57268. * It defaults to camera.maxZ
  57269. */
  57270. get shadowMaxZ(): number;
  57271. /**
  57272. * Sets the shadow max z distance.
  57273. */
  57274. set shadowMaxZ(value: number);
  57275. protected _debug: boolean;
  57276. /**
  57277. * Gets or sets the debug flag.
  57278. * When enabled, the cascades are materialized by different colors on the screen.
  57279. */
  57280. get debug(): boolean;
  57281. set debug(dbg: boolean);
  57282. private _depthClamp;
  57283. /**
  57284. * Gets or sets the depth clamping value.
  57285. *
  57286. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57287. * to account for the shadow casters far away.
  57288. *
  57289. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57290. */
  57291. get depthClamp(): boolean;
  57292. set depthClamp(value: boolean);
  57293. private _cascadeBlendPercentage;
  57294. /**
  57295. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57296. * It defaults to 0.1 (10% blending).
  57297. */
  57298. get cascadeBlendPercentage(): number;
  57299. set cascadeBlendPercentage(value: number);
  57300. private _lambda;
  57301. /**
  57302. * Gets or set the lambda parameter.
  57303. * This parameter is used to split the camera frustum and create the cascades.
  57304. * 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.
  57305. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57306. */
  57307. get lambda(): number;
  57308. set lambda(value: number);
  57309. /**
  57310. * Gets the view matrix corresponding to a given cascade
  57311. * @param cascadeNum cascade to retrieve the view matrix from
  57312. * @returns the cascade view matrix
  57313. */
  57314. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57315. /**
  57316. * Gets the projection matrix corresponding to a given cascade
  57317. * @param cascadeNum cascade to retrieve the projection matrix from
  57318. * @returns the cascade projection matrix
  57319. */
  57320. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57321. /**
  57322. * Gets the transformation matrix corresponding to a given cascade
  57323. * @param cascadeNum cascade to retrieve the transformation matrix from
  57324. * @returns the cascade transformation matrix
  57325. */
  57326. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57327. private _depthRenderer;
  57328. /**
  57329. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57330. *
  57331. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57332. *
  57333. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57334. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57335. * @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
  57336. */
  57337. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57338. private _depthReducer;
  57339. private _autoCalcDepthBounds;
  57340. /**
  57341. * Gets or sets the autoCalcDepthBounds property.
  57342. *
  57343. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57344. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57345. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57346. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57347. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57348. */
  57349. get autoCalcDepthBounds(): boolean;
  57350. set autoCalcDepthBounds(value: boolean);
  57351. /**
  57352. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57353. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57354. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57355. * for setting the refresh rate on the renderer yourself!
  57356. */
  57357. get autoCalcDepthBoundsRefreshRate(): number;
  57358. set autoCalcDepthBoundsRefreshRate(value: number);
  57359. /**
  57360. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57361. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57362. * you change the camera near/far planes!
  57363. */
  57364. splitFrustum(): void;
  57365. private _splitFrustum;
  57366. private _computeMatrices;
  57367. private _computeFrustumInWorldSpace;
  57368. private _computeCascadeFrustum;
  57369. /**
  57370. * Support test.
  57371. */
  57372. static get IsSupported(): boolean;
  57373. /** @hidden */
  57374. static _SceneComponentInitialization: (scene: Scene) => void;
  57375. /**
  57376. * Creates a Cascaded Shadow Generator object.
  57377. * A ShadowGenerator is the required tool to use the shadows.
  57378. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57379. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57380. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57381. * @param light The directional light object generating the shadows.
  57382. * @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.
  57383. */
  57384. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57385. protected _initializeGenerator(): void;
  57386. protected _createTargetRenderTexture(): void;
  57387. protected _initializeShadowMap(): void;
  57388. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  57389. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57390. /**
  57391. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57392. * @param defines Defines of the material we want to update
  57393. * @param lightIndex Index of the light in the enabled light list of the material
  57394. */
  57395. prepareDefines(defines: any, lightIndex: number): void;
  57396. /**
  57397. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57398. * defined in the generator but impacting the effect).
  57399. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57400. * @param effect The effect we are binfing the information for
  57401. */
  57402. bindShadowLight(lightIndex: string, effect: Effect): void;
  57403. /**
  57404. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57405. * (eq to view projection * shadow projection matrices)
  57406. * @returns The transform matrix used to create the shadow map
  57407. */
  57408. getTransformMatrix(): Matrix;
  57409. /**
  57410. * Disposes the ShadowGenerator.
  57411. * Returns nothing.
  57412. */
  57413. dispose(): void;
  57414. /**
  57415. * Serializes the shadow generator setup to a json object.
  57416. * @returns The serialized JSON object
  57417. */
  57418. serialize(): any;
  57419. /**
  57420. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57421. * @param parsedShadowGenerator The JSON object to parse
  57422. * @param scene The scene to create the shadow map for
  57423. * @returns The parsed shadow generator
  57424. */
  57425. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57426. }
  57427. }
  57428. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57429. import { Scene } from "babylonjs/scene";
  57430. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57431. import { AbstractScene } from "babylonjs/abstractScene";
  57432. /**
  57433. * Defines the shadow generator component responsible to manage any shadow generators
  57434. * in a given scene.
  57435. */
  57436. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57437. /**
  57438. * The component name helpfull to identify the component in the list of scene components.
  57439. */
  57440. readonly name: string;
  57441. /**
  57442. * The scene the component belongs to.
  57443. */
  57444. scene: Scene;
  57445. /**
  57446. * Creates a new instance of the component for the given scene
  57447. * @param scene Defines the scene to register the component in
  57448. */
  57449. constructor(scene: Scene);
  57450. /**
  57451. * Registers the component in a given scene
  57452. */
  57453. register(): void;
  57454. /**
  57455. * Rebuilds the elements related to this component in case of
  57456. * context lost for instance.
  57457. */
  57458. rebuild(): void;
  57459. /**
  57460. * Serializes the component data to the specified json object
  57461. * @param serializationObject The object to serialize to
  57462. */
  57463. serialize(serializationObject: any): void;
  57464. /**
  57465. * Adds all the elements from the container to the scene
  57466. * @param container the container holding the elements
  57467. */
  57468. addFromContainer(container: AbstractScene): void;
  57469. /**
  57470. * Removes all the elements in the container from the scene
  57471. * @param container contains the elements to remove
  57472. * @param dispose if the removed element should be disposed (default: false)
  57473. */
  57474. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57475. /**
  57476. * Rebuilds the elements related to this component in case of
  57477. * context lost for instance.
  57478. */
  57479. dispose(): void;
  57480. private _gatherRenderTargets;
  57481. }
  57482. }
  57483. declare module "babylonjs/Lights/Shadows/index" {
  57484. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57485. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57486. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57487. }
  57488. declare module "babylonjs/Lights/pointLight" {
  57489. import { Scene } from "babylonjs/scene";
  57490. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57492. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57493. import { Effect } from "babylonjs/Materials/effect";
  57494. /**
  57495. * A point light is a light defined by an unique point in world space.
  57496. * The light is emitted in every direction from this point.
  57497. * A good example of a point light is a standard light bulb.
  57498. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57499. */
  57500. export class PointLight extends ShadowLight {
  57501. private _shadowAngle;
  57502. /**
  57503. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57504. * This specifies what angle the shadow will use to be created.
  57505. *
  57506. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57507. */
  57508. get shadowAngle(): number;
  57509. /**
  57510. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57511. * This specifies what angle the shadow will use to be created.
  57512. *
  57513. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57514. */
  57515. set shadowAngle(value: number);
  57516. /**
  57517. * Gets the direction if it has been set.
  57518. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57519. */
  57520. get direction(): Vector3;
  57521. /**
  57522. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57523. */
  57524. set direction(value: Vector3);
  57525. /**
  57526. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57527. * A PointLight emits the light in every direction.
  57528. * It can cast shadows.
  57529. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57530. * ```javascript
  57531. * var pointLight = new PointLight("pl", camera.position, scene);
  57532. * ```
  57533. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57534. * @param name The light friendly name
  57535. * @param position The position of the point light in the scene
  57536. * @param scene The scene the lights belongs to
  57537. */
  57538. constructor(name: string, position: Vector3, scene: Scene);
  57539. /**
  57540. * Returns the string "PointLight"
  57541. * @returns the class name
  57542. */
  57543. getClassName(): string;
  57544. /**
  57545. * Returns the integer 0.
  57546. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57547. */
  57548. getTypeID(): number;
  57549. /**
  57550. * Specifies wether or not the shadowmap should be a cube texture.
  57551. * @returns true if the shadowmap needs to be a cube texture.
  57552. */
  57553. needCube(): boolean;
  57554. /**
  57555. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57556. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57557. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57558. */
  57559. getShadowDirection(faceIndex?: number): Vector3;
  57560. /**
  57561. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57562. * - fov = PI / 2
  57563. * - aspect ratio : 1.0
  57564. * - z-near and far equal to the active camera minZ and maxZ.
  57565. * Returns the PointLight.
  57566. */
  57567. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57568. protected _buildUniformLayout(): void;
  57569. /**
  57570. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57571. * @param effect The effect to update
  57572. * @param lightIndex The index of the light in the effect to update
  57573. * @returns The point light
  57574. */
  57575. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57576. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57577. /**
  57578. * Prepares the list of defines specific to the light type.
  57579. * @param defines the list of defines
  57580. * @param lightIndex defines the index of the light for the effect
  57581. */
  57582. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57583. }
  57584. }
  57585. declare module "babylonjs/Lights/index" {
  57586. export * from "babylonjs/Lights/light";
  57587. export * from "babylonjs/Lights/shadowLight";
  57588. export * from "babylonjs/Lights/Shadows/index";
  57589. export * from "babylonjs/Lights/directionalLight";
  57590. export * from "babylonjs/Lights/hemisphericLight";
  57591. export * from "babylonjs/Lights/pointLight";
  57592. export * from "babylonjs/Lights/spotLight";
  57593. }
  57594. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57595. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57596. /**
  57597. * Header information of HDR texture files.
  57598. */
  57599. export interface HDRInfo {
  57600. /**
  57601. * The height of the texture in pixels.
  57602. */
  57603. height: number;
  57604. /**
  57605. * The width of the texture in pixels.
  57606. */
  57607. width: number;
  57608. /**
  57609. * The index of the beginning of the data in the binary file.
  57610. */
  57611. dataPosition: number;
  57612. }
  57613. /**
  57614. * This groups tools to convert HDR texture to native colors array.
  57615. */
  57616. export class HDRTools {
  57617. private static Ldexp;
  57618. private static Rgbe2float;
  57619. private static readStringLine;
  57620. /**
  57621. * Reads header information from an RGBE texture stored in a native array.
  57622. * More information on this format are available here:
  57623. * https://en.wikipedia.org/wiki/RGBE_image_format
  57624. *
  57625. * @param uint8array The binary file stored in native array.
  57626. * @return The header information.
  57627. */
  57628. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57629. /**
  57630. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57631. * This RGBE texture needs to store the information as a panorama.
  57632. *
  57633. * More information on this format are available here:
  57634. * https://en.wikipedia.org/wiki/RGBE_image_format
  57635. *
  57636. * @param buffer The binary file stored in an array buffer.
  57637. * @param size The expected size of the extracted cubemap.
  57638. * @return The Cube Map information.
  57639. */
  57640. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57641. /**
  57642. * Returns the pixels data extracted from an RGBE texture.
  57643. * This pixels will be stored left to right up to down in the R G B order in one array.
  57644. *
  57645. * More information on this format are available here:
  57646. * https://en.wikipedia.org/wiki/RGBE_image_format
  57647. *
  57648. * @param uint8array The binary file stored in an array buffer.
  57649. * @param hdrInfo The header information of the file.
  57650. * @return The pixels data in RGB right to left up to down order.
  57651. */
  57652. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57653. private static RGBE_ReadPixels_RLE;
  57654. }
  57655. }
  57656. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57657. import { Nullable } from "babylonjs/types";
  57658. import { Scene } from "babylonjs/scene";
  57659. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57660. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57661. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57662. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57663. /**
  57664. * This represents a texture coming from an HDR input.
  57665. *
  57666. * The only supported format is currently panorama picture stored in RGBE format.
  57667. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57668. */
  57669. export class HDRCubeTexture extends BaseTexture {
  57670. private static _facesMapping;
  57671. private _generateHarmonics;
  57672. private _noMipmap;
  57673. private _textureMatrix;
  57674. private _size;
  57675. private _onLoad;
  57676. private _onError;
  57677. /**
  57678. * The texture URL.
  57679. */
  57680. url: string;
  57681. /**
  57682. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57683. */
  57684. coordinatesMode: number;
  57685. protected _isBlocking: boolean;
  57686. /**
  57687. * Sets wether or not the texture is blocking during loading.
  57688. */
  57689. set isBlocking(value: boolean);
  57690. /**
  57691. * Gets wether or not the texture is blocking during loading.
  57692. */
  57693. get isBlocking(): boolean;
  57694. protected _rotationY: number;
  57695. /**
  57696. * Sets texture matrix rotation angle around Y axis in radians.
  57697. */
  57698. set rotationY(value: number);
  57699. /**
  57700. * Gets texture matrix rotation angle around Y axis radians.
  57701. */
  57702. get rotationY(): number;
  57703. /**
  57704. * Gets or sets the center of the bounding box associated with the cube texture
  57705. * It must define where the camera used to render the texture was set
  57706. */
  57707. boundingBoxPosition: Vector3;
  57708. private _boundingBoxSize;
  57709. /**
  57710. * Gets or sets the size of the bounding box associated with the cube texture
  57711. * When defined, the cubemap will switch to local mode
  57712. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57713. * @example https://www.babylonjs-playground.com/#RNASML
  57714. */
  57715. set boundingBoxSize(value: Vector3);
  57716. get boundingBoxSize(): Vector3;
  57717. /**
  57718. * Instantiates an HDRTexture from the following parameters.
  57719. *
  57720. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57721. * @param scene The scene the texture will be used in
  57722. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57723. * @param noMipmap Forces to not generate the mipmap if true
  57724. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57725. * @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)
  57726. * @param reserved Reserved flag for internal use.
  57727. */
  57728. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  57729. /**
  57730. * Get the current class name of the texture useful for serialization or dynamic coding.
  57731. * @returns "HDRCubeTexture"
  57732. */
  57733. getClassName(): string;
  57734. /**
  57735. * Occurs when the file is raw .hdr file.
  57736. */
  57737. private loadTexture;
  57738. clone(): HDRCubeTexture;
  57739. delayLoad(): void;
  57740. /**
  57741. * Get the texture reflection matrix used to rotate/transform the reflection.
  57742. * @returns the reflection matrix
  57743. */
  57744. getReflectionTextureMatrix(): Matrix;
  57745. /**
  57746. * Set the texture reflection matrix used to rotate/transform the reflection.
  57747. * @param value Define the reflection matrix to set
  57748. */
  57749. setReflectionTextureMatrix(value: Matrix): void;
  57750. /**
  57751. * Parses a JSON representation of an HDR Texture in order to create the texture
  57752. * @param parsedTexture Define the JSON representation
  57753. * @param scene Define the scene the texture should be created in
  57754. * @param rootUrl Define the root url in case we need to load relative dependencies
  57755. * @returns the newly created texture after parsing
  57756. */
  57757. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57758. serialize(): any;
  57759. }
  57760. }
  57761. declare module "babylonjs/Physics/physicsEngine" {
  57762. import { Nullable } from "babylonjs/types";
  57763. import { Vector3 } from "babylonjs/Maths/math.vector";
  57764. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57765. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57766. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57767. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57768. /**
  57769. * Class used to control physics engine
  57770. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57771. */
  57772. export class PhysicsEngine implements IPhysicsEngine {
  57773. private _physicsPlugin;
  57774. /**
  57775. * Global value used to control the smallest number supported by the simulation
  57776. */
  57777. static Epsilon: number;
  57778. private _impostors;
  57779. private _joints;
  57780. private _subTimeStep;
  57781. /**
  57782. * Gets the gravity vector used by the simulation
  57783. */
  57784. gravity: Vector3;
  57785. /**
  57786. * Factory used to create the default physics plugin.
  57787. * @returns The default physics plugin
  57788. */
  57789. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57790. /**
  57791. * Creates a new Physics Engine
  57792. * @param gravity defines the gravity vector used by the simulation
  57793. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57794. */
  57795. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57796. /**
  57797. * Sets the gravity vector used by the simulation
  57798. * @param gravity defines the gravity vector to use
  57799. */
  57800. setGravity(gravity: Vector3): void;
  57801. /**
  57802. * Set the time step of the physics engine.
  57803. * Default is 1/60.
  57804. * To slow it down, enter 1/600 for example.
  57805. * To speed it up, 1/30
  57806. * @param newTimeStep defines the new timestep to apply to this world.
  57807. */
  57808. setTimeStep(newTimeStep?: number): void;
  57809. /**
  57810. * Get the time step of the physics engine.
  57811. * @returns the current time step
  57812. */
  57813. getTimeStep(): number;
  57814. /**
  57815. * Set the sub time step of the physics engine.
  57816. * Default is 0 meaning there is no sub steps
  57817. * To increase physics resolution precision, set a small value (like 1 ms)
  57818. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57819. */
  57820. setSubTimeStep(subTimeStep?: number): void;
  57821. /**
  57822. * Get the sub time step of the physics engine.
  57823. * @returns the current sub time step
  57824. */
  57825. getSubTimeStep(): number;
  57826. /**
  57827. * Release all resources
  57828. */
  57829. dispose(): void;
  57830. /**
  57831. * Gets the name of the current physics plugin
  57832. * @returns the name of the plugin
  57833. */
  57834. getPhysicsPluginName(): string;
  57835. /**
  57836. * Adding a new impostor for the impostor tracking.
  57837. * This will be done by the impostor itself.
  57838. * @param impostor the impostor to add
  57839. */
  57840. addImpostor(impostor: PhysicsImpostor): void;
  57841. /**
  57842. * Remove an impostor from the engine.
  57843. * This impostor and its mesh will not longer be updated by the physics engine.
  57844. * @param impostor the impostor to remove
  57845. */
  57846. removeImpostor(impostor: PhysicsImpostor): void;
  57847. /**
  57848. * Add a joint to the physics engine
  57849. * @param mainImpostor defines the main impostor to which the joint is added.
  57850. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57851. * @param joint defines the joint that will connect both impostors.
  57852. */
  57853. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57854. /**
  57855. * Removes a joint from the simulation
  57856. * @param mainImpostor defines the impostor used with the joint
  57857. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57858. * @param joint defines the joint to remove
  57859. */
  57860. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57861. /**
  57862. * Called by the scene. No need to call it.
  57863. * @param delta defines the timespam between frames
  57864. */
  57865. _step(delta: number): void;
  57866. /**
  57867. * Gets the current plugin used to run the simulation
  57868. * @returns current plugin
  57869. */
  57870. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57871. /**
  57872. * Gets the list of physic impostors
  57873. * @returns an array of PhysicsImpostor
  57874. */
  57875. getImpostors(): Array<PhysicsImpostor>;
  57876. /**
  57877. * Gets the impostor for a physics enabled object
  57878. * @param object defines the object impersonated by the impostor
  57879. * @returns the PhysicsImpostor or null if not found
  57880. */
  57881. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57882. /**
  57883. * Gets the impostor for a physics body object
  57884. * @param body defines physics body used by the impostor
  57885. * @returns the PhysicsImpostor or null if not found
  57886. */
  57887. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57888. /**
  57889. * Does a raycast in the physics world
  57890. * @param from when should the ray start?
  57891. * @param to when should the ray end?
  57892. * @returns PhysicsRaycastResult
  57893. */
  57894. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57895. }
  57896. }
  57897. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57898. import { Nullable } from "babylonjs/types";
  57899. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57900. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57901. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57902. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57903. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57904. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57905. /** @hidden */
  57906. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57907. private _useDeltaForWorldStep;
  57908. world: any;
  57909. name: string;
  57910. private _physicsMaterials;
  57911. private _fixedTimeStep;
  57912. private _cannonRaycastResult;
  57913. private _raycastResult;
  57914. private _physicsBodysToRemoveAfterStep;
  57915. BJSCANNON: any;
  57916. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57917. setGravity(gravity: Vector3): void;
  57918. setTimeStep(timeStep: number): void;
  57919. getTimeStep(): number;
  57920. executeStep(delta: number): void;
  57921. private _removeMarkedPhysicsBodiesFromWorld;
  57922. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57923. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57924. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57925. private _processChildMeshes;
  57926. removePhysicsBody(impostor: PhysicsImpostor): void;
  57927. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57928. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57929. private _addMaterial;
  57930. private _checkWithEpsilon;
  57931. private _createShape;
  57932. private _createHeightmap;
  57933. private _minus90X;
  57934. private _plus90X;
  57935. private _tmpPosition;
  57936. private _tmpDeltaPosition;
  57937. private _tmpUnityRotation;
  57938. private _updatePhysicsBodyTransformation;
  57939. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57940. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57941. isSupported(): boolean;
  57942. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57943. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57944. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57945. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57946. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57947. getBodyMass(impostor: PhysicsImpostor): number;
  57948. getBodyFriction(impostor: PhysicsImpostor): number;
  57949. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57950. getBodyRestitution(impostor: PhysicsImpostor): number;
  57951. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57952. sleepBody(impostor: PhysicsImpostor): void;
  57953. wakeUpBody(impostor: PhysicsImpostor): void;
  57954. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57955. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57956. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57957. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57958. getRadius(impostor: PhysicsImpostor): number;
  57959. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57960. dispose(): void;
  57961. private _extendNamespace;
  57962. /**
  57963. * Does a raycast in the physics world
  57964. * @param from when should the ray start?
  57965. * @param to when should the ray end?
  57966. * @returns PhysicsRaycastResult
  57967. */
  57968. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57969. }
  57970. }
  57971. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57972. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57973. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57974. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57976. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57977. import { Nullable } from "babylonjs/types";
  57978. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57979. /** @hidden */
  57980. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57981. world: any;
  57982. name: string;
  57983. BJSOIMO: any;
  57984. private _raycastResult;
  57985. constructor(iterations?: number, oimoInjection?: any);
  57986. setGravity(gravity: Vector3): void;
  57987. setTimeStep(timeStep: number): void;
  57988. getTimeStep(): number;
  57989. private _tmpImpostorsArray;
  57990. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57991. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57992. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57993. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57994. private _tmpPositionVector;
  57995. removePhysicsBody(impostor: PhysicsImpostor): void;
  57996. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57997. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57998. isSupported(): boolean;
  57999. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58000. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58001. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58002. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58003. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58004. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58005. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58006. getBodyMass(impostor: PhysicsImpostor): number;
  58007. getBodyFriction(impostor: PhysicsImpostor): number;
  58008. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58009. getBodyRestitution(impostor: PhysicsImpostor): number;
  58010. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58011. sleepBody(impostor: PhysicsImpostor): void;
  58012. wakeUpBody(impostor: PhysicsImpostor): void;
  58013. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58014. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58015. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58016. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58017. getRadius(impostor: PhysicsImpostor): number;
  58018. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58019. dispose(): void;
  58020. /**
  58021. * Does a raycast in the physics world
  58022. * @param from when should the ray start?
  58023. * @param to when should the ray end?
  58024. * @returns PhysicsRaycastResult
  58025. */
  58026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58027. }
  58028. }
  58029. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58030. import { Nullable } from "babylonjs/types";
  58031. import { Scene } from "babylonjs/scene";
  58032. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58033. import { Color4 } from "babylonjs/Maths/math.color";
  58034. import { Mesh } from "babylonjs/Meshes/mesh";
  58035. /**
  58036. * Class containing static functions to help procedurally build meshes
  58037. */
  58038. export class RibbonBuilder {
  58039. /**
  58040. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58041. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58042. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58043. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58044. * * 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
  58045. * * 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
  58046. * * 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
  58047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58049. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58050. * * 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
  58051. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58052. * * 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
  58053. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58055. * @param name defines the name of the mesh
  58056. * @param options defines the options used to create the mesh
  58057. * @param scene defines the hosting scene
  58058. * @returns the ribbon mesh
  58059. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58060. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58061. */
  58062. static CreateRibbon(name: string, options: {
  58063. pathArray: Vector3[][];
  58064. closeArray?: boolean;
  58065. closePath?: boolean;
  58066. offset?: number;
  58067. updatable?: boolean;
  58068. sideOrientation?: number;
  58069. frontUVs?: Vector4;
  58070. backUVs?: Vector4;
  58071. instance?: Mesh;
  58072. invertUV?: boolean;
  58073. uvs?: Vector2[];
  58074. colors?: Color4[];
  58075. }, scene?: Nullable<Scene>): Mesh;
  58076. }
  58077. }
  58078. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58079. import { Nullable } from "babylonjs/types";
  58080. import { Scene } from "babylonjs/scene";
  58081. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58082. import { Mesh } from "babylonjs/Meshes/mesh";
  58083. /**
  58084. * Class containing static functions to help procedurally build meshes
  58085. */
  58086. export class ShapeBuilder {
  58087. /**
  58088. * 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.
  58089. * * 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.
  58090. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58091. * * 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.
  58092. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58093. * * 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
  58094. * * 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
  58095. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58098. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58100. * @param name defines the name of the mesh
  58101. * @param options defines the options used to create the mesh
  58102. * @param scene defines the hosting scene
  58103. * @returns the extruded shape mesh
  58104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58105. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58106. */
  58107. static ExtrudeShape(name: string, options: {
  58108. shape: Vector3[];
  58109. path: Vector3[];
  58110. scale?: number;
  58111. rotation?: number;
  58112. cap?: number;
  58113. updatable?: boolean;
  58114. sideOrientation?: number;
  58115. frontUVs?: Vector4;
  58116. backUVs?: Vector4;
  58117. instance?: Mesh;
  58118. invertUV?: boolean;
  58119. }, scene?: Nullable<Scene>): Mesh;
  58120. /**
  58121. * Creates an custom extruded shape mesh.
  58122. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58123. * * 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.
  58124. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58125. * * 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
  58126. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58127. * * 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
  58128. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58129. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58130. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58131. * * 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
  58132. * * 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
  58133. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58136. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58138. * @param name defines the name of the mesh
  58139. * @param options defines the options used to create the mesh
  58140. * @param scene defines the hosting scene
  58141. * @returns the custom extruded shape mesh
  58142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58143. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58145. */
  58146. static ExtrudeShapeCustom(name: string, options: {
  58147. shape: Vector3[];
  58148. path: Vector3[];
  58149. scaleFunction?: any;
  58150. rotationFunction?: any;
  58151. ribbonCloseArray?: boolean;
  58152. ribbonClosePath?: boolean;
  58153. cap?: number;
  58154. updatable?: boolean;
  58155. sideOrientation?: number;
  58156. frontUVs?: Vector4;
  58157. backUVs?: Vector4;
  58158. instance?: Mesh;
  58159. invertUV?: boolean;
  58160. }, scene?: Nullable<Scene>): Mesh;
  58161. private static _ExtrudeShapeGeneric;
  58162. }
  58163. }
  58164. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58165. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58166. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58167. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58168. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58169. import { Nullable } from "babylonjs/types";
  58170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58171. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58172. /**
  58173. * AmmoJS Physics plugin
  58174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58175. * @see https://github.com/kripken/ammo.js/
  58176. */
  58177. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58178. private _useDeltaForWorldStep;
  58179. /**
  58180. * Reference to the Ammo library
  58181. */
  58182. bjsAMMO: any;
  58183. /**
  58184. * Created ammoJS world which physics bodies are added to
  58185. */
  58186. world: any;
  58187. /**
  58188. * Name of the plugin
  58189. */
  58190. name: string;
  58191. private _timeStep;
  58192. private _fixedTimeStep;
  58193. private _maxSteps;
  58194. private _tmpQuaternion;
  58195. private _tmpAmmoTransform;
  58196. private _tmpAmmoQuaternion;
  58197. private _tmpAmmoConcreteContactResultCallback;
  58198. private _collisionConfiguration;
  58199. private _dispatcher;
  58200. private _overlappingPairCache;
  58201. private _solver;
  58202. private _softBodySolver;
  58203. private _tmpAmmoVectorA;
  58204. private _tmpAmmoVectorB;
  58205. private _tmpAmmoVectorC;
  58206. private _tmpAmmoVectorD;
  58207. private _tmpContactCallbackResult;
  58208. private _tmpAmmoVectorRCA;
  58209. private _tmpAmmoVectorRCB;
  58210. private _raycastResult;
  58211. private static readonly DISABLE_COLLISION_FLAG;
  58212. private static readonly KINEMATIC_FLAG;
  58213. private static readonly DISABLE_DEACTIVATION_FLAG;
  58214. /**
  58215. * Initializes the ammoJS plugin
  58216. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58217. * @param ammoInjection can be used to inject your own ammo reference
  58218. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58219. */
  58220. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58221. /**
  58222. * Sets the gravity of the physics world (m/(s^2))
  58223. * @param gravity Gravity to set
  58224. */
  58225. setGravity(gravity: Vector3): void;
  58226. /**
  58227. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58228. * @param timeStep timestep to use in seconds
  58229. */
  58230. setTimeStep(timeStep: number): void;
  58231. /**
  58232. * 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)
  58233. * @param fixedTimeStep fixedTimeStep to use in seconds
  58234. */
  58235. setFixedTimeStep(fixedTimeStep: number): void;
  58236. /**
  58237. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58238. * @param maxSteps the maximum number of steps by the physics engine per frame
  58239. */
  58240. setMaxSteps(maxSteps: number): void;
  58241. /**
  58242. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58243. * @returns the current timestep in seconds
  58244. */
  58245. getTimeStep(): number;
  58246. /**
  58247. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58248. */
  58249. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58250. private _isImpostorInContact;
  58251. private _isImpostorPairInContact;
  58252. private _stepSimulation;
  58253. /**
  58254. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58255. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58256. * After the step the babylon meshes are set to the position of the physics imposters
  58257. * @param delta amount of time to step forward
  58258. * @param impostors array of imposters to update before/after the step
  58259. */
  58260. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58261. /**
  58262. * Update babylon mesh to match physics world object
  58263. * @param impostor imposter to match
  58264. */
  58265. private _afterSoftStep;
  58266. /**
  58267. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58268. * @param impostor imposter to match
  58269. */
  58270. private _ropeStep;
  58271. /**
  58272. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58273. * @param impostor imposter to match
  58274. */
  58275. private _softbodyOrClothStep;
  58276. private _tmpMatrix;
  58277. /**
  58278. * Applies an impulse on the imposter
  58279. * @param impostor imposter to apply impulse to
  58280. * @param force amount of force to be applied to the imposter
  58281. * @param contactPoint the location to apply the impulse on the imposter
  58282. */
  58283. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58284. /**
  58285. * Applies a force on the imposter
  58286. * @param impostor imposter to apply force
  58287. * @param force amount of force to be applied to the imposter
  58288. * @param contactPoint the location to apply the force on the imposter
  58289. */
  58290. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58291. /**
  58292. * Creates a physics body using the plugin
  58293. * @param impostor the imposter to create the physics body on
  58294. */
  58295. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58296. /**
  58297. * Removes the physics body from the imposter and disposes of the body's memory
  58298. * @param impostor imposter to remove the physics body from
  58299. */
  58300. removePhysicsBody(impostor: PhysicsImpostor): void;
  58301. /**
  58302. * Generates a joint
  58303. * @param impostorJoint the imposter joint to create the joint with
  58304. */
  58305. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58306. /**
  58307. * Removes a joint
  58308. * @param impostorJoint the imposter joint to remove the joint from
  58309. */
  58310. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58311. private _addMeshVerts;
  58312. /**
  58313. * Initialise the soft body vertices to match its object's (mesh) vertices
  58314. * Softbody vertices (nodes) are in world space and to match this
  58315. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58316. * @param impostor to create the softbody for
  58317. */
  58318. private _softVertexData;
  58319. /**
  58320. * Create an impostor's soft body
  58321. * @param impostor to create the softbody for
  58322. */
  58323. private _createSoftbody;
  58324. /**
  58325. * Create cloth for an impostor
  58326. * @param impostor to create the softbody for
  58327. */
  58328. private _createCloth;
  58329. /**
  58330. * Create rope for an impostor
  58331. * @param impostor to create the softbody for
  58332. */
  58333. private _createRope;
  58334. /**
  58335. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58336. * @param impostor to create the custom physics shape for
  58337. */
  58338. private _createCustom;
  58339. private _addHullVerts;
  58340. private _createShape;
  58341. /**
  58342. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58343. * @param impostor imposter containing the physics body and babylon object
  58344. */
  58345. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58346. /**
  58347. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58348. * @param impostor imposter containing the physics body and babylon object
  58349. * @param newPosition new position
  58350. * @param newRotation new rotation
  58351. */
  58352. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58353. /**
  58354. * If this plugin is supported
  58355. * @returns true if its supported
  58356. */
  58357. isSupported(): boolean;
  58358. /**
  58359. * Sets the linear velocity of the physics body
  58360. * @param impostor imposter to set the velocity on
  58361. * @param velocity velocity to set
  58362. */
  58363. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58364. /**
  58365. * Sets the angular velocity of the physics body
  58366. * @param impostor imposter to set the velocity on
  58367. * @param velocity velocity to set
  58368. */
  58369. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58370. /**
  58371. * gets the linear velocity
  58372. * @param impostor imposter to get linear velocity from
  58373. * @returns linear velocity
  58374. */
  58375. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58376. /**
  58377. * gets the angular velocity
  58378. * @param impostor imposter to get angular velocity from
  58379. * @returns angular velocity
  58380. */
  58381. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58382. /**
  58383. * Sets the mass of physics body
  58384. * @param impostor imposter to set the mass on
  58385. * @param mass mass to set
  58386. */
  58387. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58388. /**
  58389. * Gets the mass of the physics body
  58390. * @param impostor imposter to get the mass from
  58391. * @returns mass
  58392. */
  58393. getBodyMass(impostor: PhysicsImpostor): number;
  58394. /**
  58395. * Gets friction of the impostor
  58396. * @param impostor impostor to get friction from
  58397. * @returns friction value
  58398. */
  58399. getBodyFriction(impostor: PhysicsImpostor): number;
  58400. /**
  58401. * Sets friction of the impostor
  58402. * @param impostor impostor to set friction on
  58403. * @param friction friction value
  58404. */
  58405. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58406. /**
  58407. * Gets restitution of the impostor
  58408. * @param impostor impostor to get restitution from
  58409. * @returns restitution value
  58410. */
  58411. getBodyRestitution(impostor: PhysicsImpostor): number;
  58412. /**
  58413. * Sets resitution of the impostor
  58414. * @param impostor impostor to set resitution on
  58415. * @param restitution resitution value
  58416. */
  58417. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58418. /**
  58419. * Gets pressure inside the impostor
  58420. * @param impostor impostor to get pressure from
  58421. * @returns pressure value
  58422. */
  58423. getBodyPressure(impostor: PhysicsImpostor): number;
  58424. /**
  58425. * Sets pressure inside a soft body impostor
  58426. * Cloth and rope must remain 0 pressure
  58427. * @param impostor impostor to set pressure on
  58428. * @param pressure pressure value
  58429. */
  58430. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58431. /**
  58432. * Gets stiffness of the impostor
  58433. * @param impostor impostor to get stiffness from
  58434. * @returns pressure value
  58435. */
  58436. getBodyStiffness(impostor: PhysicsImpostor): number;
  58437. /**
  58438. * Sets stiffness of the impostor
  58439. * @param impostor impostor to set stiffness on
  58440. * @param stiffness stiffness value from 0 to 1
  58441. */
  58442. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58443. /**
  58444. * Gets velocityIterations of the impostor
  58445. * @param impostor impostor to get velocity iterations from
  58446. * @returns velocityIterations value
  58447. */
  58448. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58449. /**
  58450. * Sets velocityIterations of the impostor
  58451. * @param impostor impostor to set velocity iterations on
  58452. * @param velocityIterations velocityIterations value
  58453. */
  58454. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58455. /**
  58456. * Gets positionIterations of the impostor
  58457. * @param impostor impostor to get position iterations from
  58458. * @returns positionIterations value
  58459. */
  58460. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58461. /**
  58462. * Sets positionIterations of the impostor
  58463. * @param impostor impostor to set position on
  58464. * @param positionIterations positionIterations value
  58465. */
  58466. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58467. /**
  58468. * Append an anchor to a cloth object
  58469. * @param impostor is the cloth impostor to add anchor to
  58470. * @param otherImpostor is the rigid impostor to anchor to
  58471. * @param width ratio across width from 0 to 1
  58472. * @param height ratio up height from 0 to 1
  58473. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58474. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58475. */
  58476. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58477. /**
  58478. * Append an hook to a rope object
  58479. * @param impostor is the rope impostor to add hook to
  58480. * @param otherImpostor is the rigid impostor to hook to
  58481. * @param length ratio along the rope from 0 to 1
  58482. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58483. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58484. */
  58485. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58486. /**
  58487. * Sleeps the physics body and stops it from being active
  58488. * @param impostor impostor to sleep
  58489. */
  58490. sleepBody(impostor: PhysicsImpostor): void;
  58491. /**
  58492. * Activates the physics body
  58493. * @param impostor impostor to activate
  58494. */
  58495. wakeUpBody(impostor: PhysicsImpostor): void;
  58496. /**
  58497. * Updates the distance parameters of the joint
  58498. * @param joint joint to update
  58499. * @param maxDistance maximum distance of the joint
  58500. * @param minDistance minimum distance of the joint
  58501. */
  58502. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58503. /**
  58504. * Sets a motor on the joint
  58505. * @param joint joint to set motor on
  58506. * @param speed speed of the motor
  58507. * @param maxForce maximum force of the motor
  58508. * @param motorIndex index of the motor
  58509. */
  58510. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58511. /**
  58512. * Sets the motors limit
  58513. * @param joint joint to set limit on
  58514. * @param upperLimit upper limit
  58515. * @param lowerLimit lower limit
  58516. */
  58517. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58518. /**
  58519. * Syncs the position and rotation of a mesh with the impostor
  58520. * @param mesh mesh to sync
  58521. * @param impostor impostor to update the mesh with
  58522. */
  58523. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58524. /**
  58525. * Gets the radius of the impostor
  58526. * @param impostor impostor to get radius from
  58527. * @returns the radius
  58528. */
  58529. getRadius(impostor: PhysicsImpostor): number;
  58530. /**
  58531. * Gets the box size of the impostor
  58532. * @param impostor impostor to get box size from
  58533. * @param result the resulting box size
  58534. */
  58535. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58536. /**
  58537. * Disposes of the impostor
  58538. */
  58539. dispose(): void;
  58540. /**
  58541. * Does a raycast in the physics world
  58542. * @param from when should the ray start?
  58543. * @param to when should the ray end?
  58544. * @returns PhysicsRaycastResult
  58545. */
  58546. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58547. }
  58548. }
  58549. declare module "babylonjs/Probes/reflectionProbe" {
  58550. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58551. import { Vector3 } from "babylonjs/Maths/math.vector";
  58552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58553. import { Nullable } from "babylonjs/types";
  58554. import { Scene } from "babylonjs/scene";
  58555. module "babylonjs/abstractScene" {
  58556. interface AbstractScene {
  58557. /**
  58558. * The list of reflection probes added to the scene
  58559. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58560. */
  58561. reflectionProbes: Array<ReflectionProbe>;
  58562. /**
  58563. * Removes the given reflection probe from this scene.
  58564. * @param toRemove The reflection probe to remove
  58565. * @returns The index of the removed reflection probe
  58566. */
  58567. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58568. /**
  58569. * Adds the given reflection probe to this scene.
  58570. * @param newReflectionProbe The reflection probe to add
  58571. */
  58572. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58573. }
  58574. }
  58575. /**
  58576. * Class used to generate realtime reflection / refraction cube textures
  58577. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58578. */
  58579. export class ReflectionProbe {
  58580. /** defines the name of the probe */
  58581. name: string;
  58582. private _scene;
  58583. private _renderTargetTexture;
  58584. private _projectionMatrix;
  58585. private _viewMatrix;
  58586. private _target;
  58587. private _add;
  58588. private _attachedMesh;
  58589. private _invertYAxis;
  58590. /** Gets or sets probe position (center of the cube map) */
  58591. position: Vector3;
  58592. /**
  58593. * Creates a new reflection probe
  58594. * @param name defines the name of the probe
  58595. * @param size defines the texture resolution (for each face)
  58596. * @param scene defines the hosting scene
  58597. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58598. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58599. */
  58600. constructor(
  58601. /** defines the name of the probe */
  58602. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58603. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58604. get samples(): number;
  58605. set samples(value: number);
  58606. /** Gets or sets the refresh rate to use (on every frame by default) */
  58607. get refreshRate(): number;
  58608. set refreshRate(value: number);
  58609. /**
  58610. * Gets the hosting scene
  58611. * @returns a Scene
  58612. */
  58613. getScene(): Scene;
  58614. /** Gets the internal CubeTexture used to render to */
  58615. get cubeTexture(): RenderTargetTexture;
  58616. /** Gets the list of meshes to render */
  58617. get renderList(): Nullable<AbstractMesh[]>;
  58618. /**
  58619. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58620. * @param mesh defines the mesh to attach to
  58621. */
  58622. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58623. /**
  58624. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58625. * @param renderingGroupId The rendering group id corresponding to its index
  58626. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58627. */
  58628. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58629. /**
  58630. * Clean all associated resources
  58631. */
  58632. dispose(): void;
  58633. /**
  58634. * Converts the reflection probe information to a readable string for debug purpose.
  58635. * @param fullDetails Supports for multiple levels of logging within scene loading
  58636. * @returns the human readable reflection probe info
  58637. */
  58638. toString(fullDetails?: boolean): string;
  58639. /**
  58640. * Get the class name of the relfection probe.
  58641. * @returns "ReflectionProbe"
  58642. */
  58643. getClassName(): string;
  58644. /**
  58645. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58646. * @returns The JSON representation of the texture
  58647. */
  58648. serialize(): any;
  58649. /**
  58650. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58651. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58652. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58653. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58654. * @returns The parsed reflection probe if successful
  58655. */
  58656. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58657. }
  58658. }
  58659. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58660. /** @hidden */
  58661. export var _BabylonLoaderRegistered: boolean;
  58662. /**
  58663. * Helps setting up some configuration for the babylon file loader.
  58664. */
  58665. export class BabylonFileLoaderConfiguration {
  58666. /**
  58667. * The loader does not allow injecting custom physix engine into the plugins.
  58668. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58669. * So you could set this variable to your engine import to make it work.
  58670. */
  58671. static LoaderInjectedPhysicsEngine: any;
  58672. }
  58673. }
  58674. declare module "babylonjs/Loading/Plugins/index" {
  58675. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58676. }
  58677. declare module "babylonjs/Loading/index" {
  58678. export * from "babylonjs/Loading/loadingScreen";
  58679. export * from "babylonjs/Loading/Plugins/index";
  58680. export * from "babylonjs/Loading/sceneLoader";
  58681. export * from "babylonjs/Loading/sceneLoaderFlags";
  58682. }
  58683. declare module "babylonjs/Materials/Background/index" {
  58684. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58685. }
  58686. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58687. import { Scene } from "babylonjs/scene";
  58688. import { Color3 } from "babylonjs/Maths/math.color";
  58689. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58690. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58691. /**
  58692. * The Physically based simple base material of BJS.
  58693. *
  58694. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58695. * It is used as the base class for both the specGloss and metalRough conventions.
  58696. */
  58697. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58698. /**
  58699. * Number of Simultaneous lights allowed on the material.
  58700. */
  58701. maxSimultaneousLights: number;
  58702. /**
  58703. * If sets to true, disables all the lights affecting the material.
  58704. */
  58705. disableLighting: boolean;
  58706. /**
  58707. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58708. */
  58709. environmentTexture: BaseTexture;
  58710. /**
  58711. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58712. */
  58713. invertNormalMapX: boolean;
  58714. /**
  58715. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58716. */
  58717. invertNormalMapY: boolean;
  58718. /**
  58719. * Normal map used in the model.
  58720. */
  58721. normalTexture: BaseTexture;
  58722. /**
  58723. * Emissivie color used to self-illuminate the model.
  58724. */
  58725. emissiveColor: Color3;
  58726. /**
  58727. * Emissivie texture used to self-illuminate the model.
  58728. */
  58729. emissiveTexture: BaseTexture;
  58730. /**
  58731. * Occlusion Channel Strenght.
  58732. */
  58733. occlusionStrength: number;
  58734. /**
  58735. * Occlusion Texture of the material (adding extra occlusion effects).
  58736. */
  58737. occlusionTexture: BaseTexture;
  58738. /**
  58739. * Defines the alpha limits in alpha test mode.
  58740. */
  58741. alphaCutOff: number;
  58742. /**
  58743. * Gets the current double sided mode.
  58744. */
  58745. get doubleSided(): boolean;
  58746. /**
  58747. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58748. */
  58749. set doubleSided(value: boolean);
  58750. /**
  58751. * Stores the pre-calculated light information of a mesh in a texture.
  58752. */
  58753. lightmapTexture: BaseTexture;
  58754. /**
  58755. * If true, the light map contains occlusion information instead of lighting info.
  58756. */
  58757. useLightmapAsShadowmap: boolean;
  58758. /**
  58759. * Instantiates a new PBRMaterial instance.
  58760. *
  58761. * @param name The material name
  58762. * @param scene The scene the material will be use in.
  58763. */
  58764. constructor(name: string, scene: Scene);
  58765. getClassName(): string;
  58766. }
  58767. }
  58768. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58769. import { Scene } from "babylonjs/scene";
  58770. import { Color3 } from "babylonjs/Maths/math.color";
  58771. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58772. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58773. /**
  58774. * The PBR material of BJS following the metal roughness convention.
  58775. *
  58776. * This fits to the PBR convention in the GLTF definition:
  58777. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58778. */
  58779. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58780. /**
  58781. * The base color has two different interpretations depending on the value of metalness.
  58782. * When the material is a metal, the base color is the specific measured reflectance value
  58783. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58784. * of the material.
  58785. */
  58786. baseColor: Color3;
  58787. /**
  58788. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58789. * well as opacity information in the alpha channel.
  58790. */
  58791. baseTexture: BaseTexture;
  58792. /**
  58793. * Specifies the metallic scalar value of the material.
  58794. * Can also be used to scale the metalness values of the metallic texture.
  58795. */
  58796. metallic: number;
  58797. /**
  58798. * Specifies the roughness scalar value of the material.
  58799. * Can also be used to scale the roughness values of the metallic texture.
  58800. */
  58801. roughness: number;
  58802. /**
  58803. * Texture containing both the metallic value in the B channel and the
  58804. * roughness value in the G channel to keep better precision.
  58805. */
  58806. metallicRoughnessTexture: BaseTexture;
  58807. /**
  58808. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58809. *
  58810. * @param name The material name
  58811. * @param scene The scene the material will be use in.
  58812. */
  58813. constructor(name: string, scene: Scene);
  58814. /**
  58815. * Return the currrent class name of the material.
  58816. */
  58817. getClassName(): string;
  58818. /**
  58819. * Makes a duplicate of the current material.
  58820. * @param name - name to use for the new material.
  58821. */
  58822. clone(name: string): PBRMetallicRoughnessMaterial;
  58823. /**
  58824. * Serialize the material to a parsable JSON object.
  58825. */
  58826. serialize(): any;
  58827. /**
  58828. * Parses a JSON object correponding to the serialize function.
  58829. */
  58830. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58831. }
  58832. }
  58833. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58834. import { Scene } from "babylonjs/scene";
  58835. import { Color3 } from "babylonjs/Maths/math.color";
  58836. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58837. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58838. /**
  58839. * The PBR material of BJS following the specular glossiness convention.
  58840. *
  58841. * This fits to the PBR convention in the GLTF definition:
  58842. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58843. */
  58844. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58845. /**
  58846. * Specifies the diffuse color of the material.
  58847. */
  58848. diffuseColor: Color3;
  58849. /**
  58850. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58851. * channel.
  58852. */
  58853. diffuseTexture: BaseTexture;
  58854. /**
  58855. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58856. */
  58857. specularColor: Color3;
  58858. /**
  58859. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58860. */
  58861. glossiness: number;
  58862. /**
  58863. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58864. */
  58865. specularGlossinessTexture: BaseTexture;
  58866. /**
  58867. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58868. *
  58869. * @param name The material name
  58870. * @param scene The scene the material will be use in.
  58871. */
  58872. constructor(name: string, scene: Scene);
  58873. /**
  58874. * Return the currrent class name of the material.
  58875. */
  58876. getClassName(): string;
  58877. /**
  58878. * Makes a duplicate of the current material.
  58879. * @param name - name to use for the new material.
  58880. */
  58881. clone(name: string): PBRSpecularGlossinessMaterial;
  58882. /**
  58883. * Serialize the material to a parsable JSON object.
  58884. */
  58885. serialize(): any;
  58886. /**
  58887. * Parses a JSON object correponding to the serialize function.
  58888. */
  58889. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58890. }
  58891. }
  58892. declare module "babylonjs/Materials/PBR/index" {
  58893. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58894. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58895. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58896. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58897. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58898. }
  58899. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58900. import { Nullable } from "babylonjs/types";
  58901. import { Scene } from "babylonjs/scene";
  58902. import { Matrix } from "babylonjs/Maths/math.vector";
  58903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58904. /**
  58905. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58906. * It can help converting any input color in a desired output one. This can then be used to create effects
  58907. * from sepia, black and white to sixties or futuristic rendering...
  58908. *
  58909. * The only supported format is currently 3dl.
  58910. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58911. */
  58912. export class ColorGradingTexture extends BaseTexture {
  58913. /**
  58914. * The current texture matrix. (will always be identity in color grading texture)
  58915. */
  58916. private _textureMatrix;
  58917. /**
  58918. * The texture URL.
  58919. */
  58920. url: string;
  58921. /**
  58922. * Empty line regex stored for GC.
  58923. */
  58924. private static _noneEmptyLineRegex;
  58925. private _engine;
  58926. /**
  58927. * Instantiates a ColorGradingTexture from the following parameters.
  58928. *
  58929. * @param url The location of the color gradind data (currently only supporting 3dl)
  58930. * @param scene The scene the texture will be used in
  58931. */
  58932. constructor(url: string, scene: Scene);
  58933. /**
  58934. * Returns the texture matrix used in most of the material.
  58935. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58936. */
  58937. getTextureMatrix(): Matrix;
  58938. /**
  58939. * Occurs when the file being loaded is a .3dl LUT file.
  58940. */
  58941. private load3dlTexture;
  58942. /**
  58943. * Starts the loading process of the texture.
  58944. */
  58945. private loadTexture;
  58946. /**
  58947. * Clones the color gradind texture.
  58948. */
  58949. clone(): ColorGradingTexture;
  58950. /**
  58951. * Called during delayed load for textures.
  58952. */
  58953. delayLoad(): void;
  58954. /**
  58955. * Parses a color grading texture serialized by Babylon.
  58956. * @param parsedTexture The texture information being parsedTexture
  58957. * @param scene The scene to load the texture in
  58958. * @param rootUrl The root url of the data assets to load
  58959. * @return A color gradind texture
  58960. */
  58961. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58962. /**
  58963. * Serializes the LUT texture to json format.
  58964. */
  58965. serialize(): any;
  58966. }
  58967. }
  58968. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58969. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58970. import { Scene } from "babylonjs/scene";
  58971. import { Nullable } from "babylonjs/types";
  58972. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58973. /**
  58974. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58975. */
  58976. export class EquiRectangularCubeTexture extends BaseTexture {
  58977. /** The six faces of the cube. */
  58978. private static _FacesMapping;
  58979. private _noMipmap;
  58980. private _onLoad;
  58981. private _onError;
  58982. /** The size of the cubemap. */
  58983. private _size;
  58984. /** The buffer of the image. */
  58985. private _buffer;
  58986. /** The width of the input image. */
  58987. private _width;
  58988. /** The height of the input image. */
  58989. private _height;
  58990. /** The URL to the image. */
  58991. url: string;
  58992. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58993. coordinatesMode: number;
  58994. /**
  58995. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58996. * @param url The location of the image
  58997. * @param scene The scene the texture will be used in
  58998. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58999. * @param noMipmap Forces to not generate the mipmap if true
  59000. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59001. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59002. * @param onLoad — defines a callback called when texture is loaded
  59003. * @param onError — defines a callback called if there is an error
  59004. */
  59005. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59006. /**
  59007. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59008. */
  59009. private loadImage;
  59010. /**
  59011. * Convert the image buffer into a cubemap and create a CubeTexture.
  59012. */
  59013. private loadTexture;
  59014. /**
  59015. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59016. * @param buffer The ArrayBuffer that should be converted.
  59017. * @returns The buffer as Float32Array.
  59018. */
  59019. private getFloat32ArrayFromArrayBuffer;
  59020. /**
  59021. * Get the current class name of the texture useful for serialization or dynamic coding.
  59022. * @returns "EquiRectangularCubeTexture"
  59023. */
  59024. getClassName(): string;
  59025. /**
  59026. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59027. * @returns A clone of the current EquiRectangularCubeTexture.
  59028. */
  59029. clone(): EquiRectangularCubeTexture;
  59030. }
  59031. }
  59032. declare module "babylonjs/Misc/tga" {
  59033. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59034. /**
  59035. * Based on jsTGALoader - Javascript loader for TGA file
  59036. * By Vincent Thibault
  59037. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59038. */
  59039. export class TGATools {
  59040. private static _TYPE_INDEXED;
  59041. private static _TYPE_RGB;
  59042. private static _TYPE_GREY;
  59043. private static _TYPE_RLE_INDEXED;
  59044. private static _TYPE_RLE_RGB;
  59045. private static _TYPE_RLE_GREY;
  59046. private static _ORIGIN_MASK;
  59047. private static _ORIGIN_SHIFT;
  59048. private static _ORIGIN_BL;
  59049. private static _ORIGIN_BR;
  59050. private static _ORIGIN_UL;
  59051. private static _ORIGIN_UR;
  59052. /**
  59053. * Gets the header of a TGA file
  59054. * @param data defines the TGA data
  59055. * @returns the header
  59056. */
  59057. static GetTGAHeader(data: Uint8Array): any;
  59058. /**
  59059. * Uploads TGA content to a Babylon Texture
  59060. * @hidden
  59061. */
  59062. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59063. /** @hidden */
  59064. 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;
  59065. /** @hidden */
  59066. 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;
  59067. /** @hidden */
  59068. 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;
  59069. /** @hidden */
  59070. 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;
  59071. /** @hidden */
  59072. 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;
  59073. /** @hidden */
  59074. 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;
  59075. }
  59076. }
  59077. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59078. import { Nullable } from "babylonjs/types";
  59079. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59080. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59081. /**
  59082. * Implementation of the TGA Texture Loader.
  59083. * @hidden
  59084. */
  59085. export class _TGATextureLoader implements IInternalTextureLoader {
  59086. /**
  59087. * Defines wether the loader supports cascade loading the different faces.
  59088. */
  59089. readonly supportCascades: boolean;
  59090. /**
  59091. * This returns if the loader support the current file information.
  59092. * @param extension defines the file extension of the file being loaded
  59093. * @returns true if the loader can load the specified file
  59094. */
  59095. canLoad(extension: string): boolean;
  59096. /**
  59097. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59098. * @param data contains the texture data
  59099. * @param texture defines the BabylonJS internal texture
  59100. * @param createPolynomials will be true if polynomials have been requested
  59101. * @param onLoad defines the callback to trigger once the texture is ready
  59102. * @param onError defines the callback to trigger in case of error
  59103. */
  59104. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59105. /**
  59106. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59107. * @param data contains the texture data
  59108. * @param texture defines the BabylonJS internal texture
  59109. * @param callback defines the method to call once ready to upload
  59110. */
  59111. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59112. }
  59113. }
  59114. declare module "babylonjs/Misc/basis" {
  59115. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59116. /**
  59117. * Info about the .basis files
  59118. */
  59119. class BasisFileInfo {
  59120. /**
  59121. * If the file has alpha
  59122. */
  59123. hasAlpha: boolean;
  59124. /**
  59125. * Info about each image of the basis file
  59126. */
  59127. images: Array<{
  59128. levels: Array<{
  59129. width: number;
  59130. height: number;
  59131. transcodedPixels: ArrayBufferView;
  59132. }>;
  59133. }>;
  59134. }
  59135. /**
  59136. * Result of transcoding a basis file
  59137. */
  59138. class TranscodeResult {
  59139. /**
  59140. * Info about the .basis file
  59141. */
  59142. fileInfo: BasisFileInfo;
  59143. /**
  59144. * Format to use when loading the file
  59145. */
  59146. format: number;
  59147. }
  59148. /**
  59149. * Configuration options for the Basis transcoder
  59150. */
  59151. export class BasisTranscodeConfiguration {
  59152. /**
  59153. * Supported compression formats used to determine the supported output format of the transcoder
  59154. */
  59155. supportedCompressionFormats?: {
  59156. /**
  59157. * etc1 compression format
  59158. */
  59159. etc1?: boolean;
  59160. /**
  59161. * s3tc compression format
  59162. */
  59163. s3tc?: boolean;
  59164. /**
  59165. * pvrtc compression format
  59166. */
  59167. pvrtc?: boolean;
  59168. /**
  59169. * etc2 compression format
  59170. */
  59171. etc2?: boolean;
  59172. };
  59173. /**
  59174. * If mipmap levels should be loaded for transcoded images (Default: true)
  59175. */
  59176. loadMipmapLevels?: boolean;
  59177. /**
  59178. * Index of a single image to load (Default: all images)
  59179. */
  59180. loadSingleImage?: number;
  59181. }
  59182. /**
  59183. * Used to load .Basis files
  59184. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59185. */
  59186. export class BasisTools {
  59187. private static _IgnoreSupportedFormats;
  59188. /**
  59189. * URL to use when loading the basis transcoder
  59190. */
  59191. static JSModuleURL: string;
  59192. /**
  59193. * URL to use when loading the wasm module for the transcoder
  59194. */
  59195. static WasmModuleURL: string;
  59196. /**
  59197. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59198. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59199. * @returns internal format corresponding to the Basis format
  59200. */
  59201. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59202. private static _WorkerPromise;
  59203. private static _Worker;
  59204. private static _actionId;
  59205. private static _CreateWorkerAsync;
  59206. /**
  59207. * Transcodes a loaded image file to compressed pixel data
  59208. * @param data image data to transcode
  59209. * @param config configuration options for the transcoding
  59210. * @returns a promise resulting in the transcoded image
  59211. */
  59212. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59213. /**
  59214. * Loads a texture from the transcode result
  59215. * @param texture texture load to
  59216. * @param transcodeResult the result of transcoding the basis file to load from
  59217. */
  59218. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59219. }
  59220. }
  59221. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59222. import { Nullable } from "babylonjs/types";
  59223. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59224. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59225. /**
  59226. * Loader for .basis file format
  59227. */
  59228. export class _BasisTextureLoader implements IInternalTextureLoader {
  59229. /**
  59230. * Defines whether the loader supports cascade loading the different faces.
  59231. */
  59232. readonly supportCascades: boolean;
  59233. /**
  59234. * This returns if the loader support the current file information.
  59235. * @param extension defines the file extension of the file being loaded
  59236. * @returns true if the loader can load the specified file
  59237. */
  59238. canLoad(extension: string): boolean;
  59239. /**
  59240. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59241. * @param data contains the texture data
  59242. * @param texture defines the BabylonJS internal texture
  59243. * @param createPolynomials will be true if polynomials have been requested
  59244. * @param onLoad defines the callback to trigger once the texture is ready
  59245. * @param onError defines the callback to trigger in case of error
  59246. */
  59247. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59248. /**
  59249. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59250. * @param data contains the texture data
  59251. * @param texture defines the BabylonJS internal texture
  59252. * @param callback defines the method to call once ready to upload
  59253. */
  59254. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59255. }
  59256. }
  59257. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59258. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59259. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59260. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59261. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59262. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59263. }
  59264. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59265. import { Scene } from "babylonjs/scene";
  59266. import { Texture } from "babylonjs/Materials/Textures/texture";
  59267. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59268. /**
  59269. * 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.
  59270. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59271. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59272. */
  59273. export class CustomProceduralTexture extends ProceduralTexture {
  59274. private _animate;
  59275. private _time;
  59276. private _config;
  59277. private _texturePath;
  59278. /**
  59279. * Instantiates a new Custom Procedural Texture.
  59280. * 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.
  59281. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59282. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59283. * @param name Define the name of the texture
  59284. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59285. * @param size Define the size of the texture to create
  59286. * @param scene Define the scene the texture belongs to
  59287. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59288. * @param generateMipMaps Define if the texture should creates mip maps or not
  59289. */
  59290. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59291. private _loadJson;
  59292. /**
  59293. * Is the texture ready to be used ? (rendered at least once)
  59294. * @returns true if ready, otherwise, false.
  59295. */
  59296. isReady(): boolean;
  59297. /**
  59298. * Render the texture to its associated render target.
  59299. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59300. */
  59301. render(useCameraPostProcess?: boolean): void;
  59302. /**
  59303. * Update the list of dependant textures samplers in the shader.
  59304. */
  59305. updateTextures(): void;
  59306. /**
  59307. * Update the uniform values of the procedural texture in the shader.
  59308. */
  59309. updateShaderUniforms(): void;
  59310. /**
  59311. * Define if the texture animates or not.
  59312. */
  59313. get animate(): boolean;
  59314. set animate(value: boolean);
  59315. }
  59316. }
  59317. declare module "babylonjs/Shaders/noise.fragment" {
  59318. /** @hidden */
  59319. export var noisePixelShader: {
  59320. name: string;
  59321. shader: string;
  59322. };
  59323. }
  59324. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59325. import { Nullable } from "babylonjs/types";
  59326. import { Scene } from "babylonjs/scene";
  59327. import { Texture } from "babylonjs/Materials/Textures/texture";
  59328. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59329. import "babylonjs/Shaders/noise.fragment";
  59330. /**
  59331. * Class used to generate noise procedural textures
  59332. */
  59333. export class NoiseProceduralTexture extends ProceduralTexture {
  59334. private _time;
  59335. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59336. brightness: number;
  59337. /** Defines the number of octaves to process */
  59338. octaves: number;
  59339. /** Defines the level of persistence (0.8 by default) */
  59340. persistence: number;
  59341. /** Gets or sets animation speed factor (default is 1) */
  59342. animationSpeedFactor: number;
  59343. /**
  59344. * Creates a new NoiseProceduralTexture
  59345. * @param name defines the name fo the texture
  59346. * @param size defines the size of the texture (default is 256)
  59347. * @param scene defines the hosting scene
  59348. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59349. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59350. */
  59351. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59352. private _updateShaderUniforms;
  59353. protected _getDefines(): string;
  59354. /** Generate the current state of the procedural texture */
  59355. render(useCameraPostProcess?: boolean): void;
  59356. /**
  59357. * Serializes this noise procedural texture
  59358. * @returns a serialized noise procedural texture object
  59359. */
  59360. serialize(): any;
  59361. /**
  59362. * Clone the texture.
  59363. * @returns the cloned texture
  59364. */
  59365. clone(): NoiseProceduralTexture;
  59366. /**
  59367. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59368. * @param parsedTexture defines parsed texture data
  59369. * @param scene defines the current scene
  59370. * @param rootUrl defines the root URL containing noise procedural texture information
  59371. * @returns a parsed NoiseProceduralTexture
  59372. */
  59373. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59374. }
  59375. }
  59376. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59377. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59378. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59379. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59380. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59381. }
  59382. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59383. import { Nullable } from "babylonjs/types";
  59384. import { Scene } from "babylonjs/scene";
  59385. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59386. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59387. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59388. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59389. /**
  59390. * Raw cube texture where the raw buffers are passed in
  59391. */
  59392. export class RawCubeTexture extends CubeTexture {
  59393. /**
  59394. * Creates a cube texture where the raw buffers are passed in.
  59395. * @param scene defines the scene the texture is attached to
  59396. * @param data defines the array of data to use to create each face
  59397. * @param size defines the size of the textures
  59398. * @param format defines the format of the data
  59399. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59400. * @param generateMipMaps defines if the engine should generate the mip levels
  59401. * @param invertY defines if data must be stored with Y axis inverted
  59402. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59403. * @param compression defines the compression used (null by default)
  59404. */
  59405. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59406. /**
  59407. * Updates the raw cube texture.
  59408. * @param data defines the data to store
  59409. * @param format defines the data format
  59410. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59411. * @param invertY defines if data must be stored with Y axis inverted
  59412. * @param compression defines the compression used (null by default)
  59413. * @param level defines which level of the texture to update
  59414. */
  59415. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59416. /**
  59417. * Updates a raw cube texture with RGBD encoded data.
  59418. * @param data defines the array of data [mipmap][face] to use to create each face
  59419. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59420. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59421. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59422. * @returns a promsie that resolves when the operation is complete
  59423. */
  59424. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59425. /**
  59426. * Clones the raw cube texture.
  59427. * @return a new cube texture
  59428. */
  59429. clone(): CubeTexture;
  59430. /** @hidden */
  59431. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59432. }
  59433. }
  59434. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59435. import { Scene } from "babylonjs/scene";
  59436. import { Texture } from "babylonjs/Materials/Textures/texture";
  59437. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59438. /**
  59439. * Class used to store 3D textures containing user data
  59440. */
  59441. export class RawTexture3D extends Texture {
  59442. /** Gets or sets the texture format to use */
  59443. format: number;
  59444. private _engine;
  59445. /**
  59446. * Create a new RawTexture3D
  59447. * @param data defines the data of the texture
  59448. * @param width defines the width of the texture
  59449. * @param height defines the height of the texture
  59450. * @param depth defines the depth of the texture
  59451. * @param format defines the texture format to use
  59452. * @param scene defines the hosting scene
  59453. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59454. * @param invertY defines if texture must be stored with Y axis inverted
  59455. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59456. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59457. */
  59458. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59459. /** Gets or sets the texture format to use */
  59460. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59461. /**
  59462. * Update the texture with new data
  59463. * @param data defines the data to store in the texture
  59464. */
  59465. update(data: ArrayBufferView): void;
  59466. }
  59467. }
  59468. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59469. import { Scene } from "babylonjs/scene";
  59470. import { Texture } from "babylonjs/Materials/Textures/texture";
  59471. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59472. /**
  59473. * Class used to store 2D array textures containing user data
  59474. */
  59475. export class RawTexture2DArray extends Texture {
  59476. /** Gets or sets the texture format to use */
  59477. format: number;
  59478. private _engine;
  59479. /**
  59480. * Create a new RawTexture2DArray
  59481. * @param data defines the data of the texture
  59482. * @param width defines the width of the texture
  59483. * @param height defines the height of the texture
  59484. * @param depth defines the number of layers of the texture
  59485. * @param format defines the texture format to use
  59486. * @param scene defines the hosting scene
  59487. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59488. * @param invertY defines if texture must be stored with Y axis inverted
  59489. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59490. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59491. */
  59492. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59493. /** Gets or sets the texture format to use */
  59494. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59495. /**
  59496. * Update the texture with new data
  59497. * @param data defines the data to store in the texture
  59498. */
  59499. update(data: ArrayBufferView): void;
  59500. }
  59501. }
  59502. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59503. import { Scene } from "babylonjs/scene";
  59504. import { Plane } from "babylonjs/Maths/math.plane";
  59505. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59506. /**
  59507. * Creates a refraction texture used by refraction channel of the standard material.
  59508. * It is like a mirror but to see through a material.
  59509. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59510. */
  59511. export class RefractionTexture extends RenderTargetTexture {
  59512. /**
  59513. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59514. * 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.
  59515. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59516. */
  59517. refractionPlane: Plane;
  59518. /**
  59519. * Define how deep under the surface we should see.
  59520. */
  59521. depth: number;
  59522. /**
  59523. * Creates a refraction texture used by refraction channel of the standard material.
  59524. * It is like a mirror but to see through a material.
  59525. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59526. * @param name Define the texture name
  59527. * @param size Define the size of the underlying texture
  59528. * @param scene Define the scene the refraction belongs to
  59529. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59530. */
  59531. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59532. /**
  59533. * Clone the refraction texture.
  59534. * @returns the cloned texture
  59535. */
  59536. clone(): RefractionTexture;
  59537. /**
  59538. * Serialize the texture to a JSON representation you could use in Parse later on
  59539. * @returns the serialized JSON representation
  59540. */
  59541. serialize(): any;
  59542. }
  59543. }
  59544. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59545. import { Nullable } from "babylonjs/types";
  59546. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59547. import { Matrix } from "babylonjs/Maths/math.vector";
  59548. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59549. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59550. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59551. import { Scene } from "babylonjs/scene";
  59552. /**
  59553. * Defines the options related to the creation of an HtmlElementTexture
  59554. */
  59555. export interface IHtmlElementTextureOptions {
  59556. /**
  59557. * Defines wether mip maps should be created or not.
  59558. */
  59559. generateMipMaps?: boolean;
  59560. /**
  59561. * Defines the sampling mode of the texture.
  59562. */
  59563. samplingMode?: number;
  59564. /**
  59565. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59566. */
  59567. engine: Nullable<ThinEngine>;
  59568. /**
  59569. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59570. */
  59571. scene: Nullable<Scene>;
  59572. }
  59573. /**
  59574. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59575. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59576. * is automatically managed.
  59577. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59578. * in your application.
  59579. *
  59580. * As the update is not automatic, you need to call them manually.
  59581. */
  59582. export class HtmlElementTexture extends BaseTexture {
  59583. /**
  59584. * The texture URL.
  59585. */
  59586. element: HTMLVideoElement | HTMLCanvasElement;
  59587. private static readonly DefaultOptions;
  59588. private _textureMatrix;
  59589. private _engine;
  59590. private _isVideo;
  59591. private _generateMipMaps;
  59592. private _samplingMode;
  59593. /**
  59594. * Instantiates a HtmlElementTexture from the following parameters.
  59595. *
  59596. * @param name Defines the name of the texture
  59597. * @param element Defines the video or canvas the texture is filled with
  59598. * @param options Defines the other none mandatory texture creation options
  59599. */
  59600. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59601. private _createInternalTexture;
  59602. /**
  59603. * Returns the texture matrix used in most of the material.
  59604. */
  59605. getTextureMatrix(): Matrix;
  59606. /**
  59607. * Updates the content of the texture.
  59608. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59609. */
  59610. update(invertY?: Nullable<boolean>): void;
  59611. }
  59612. }
  59613. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59614. import { Vector2 } from "babylonjs/Maths/math.vector";
  59615. /**
  59616. * Defines the basic options interface of a TexturePacker Frame
  59617. */
  59618. export interface ITexturePackerFrame {
  59619. /**
  59620. * The frame ID
  59621. */
  59622. id: number;
  59623. /**
  59624. * The frames Scale
  59625. */
  59626. scale: Vector2;
  59627. /**
  59628. * The Frames offset
  59629. */
  59630. offset: Vector2;
  59631. }
  59632. /**
  59633. * This is a support class for frame Data on texture packer sets.
  59634. */
  59635. export class TexturePackerFrame implements ITexturePackerFrame {
  59636. /**
  59637. * The frame ID
  59638. */
  59639. id: number;
  59640. /**
  59641. * The frames Scale
  59642. */
  59643. scale: Vector2;
  59644. /**
  59645. * The Frames offset
  59646. */
  59647. offset: Vector2;
  59648. /**
  59649. * Initializes a texture package frame.
  59650. * @param id The numerical frame identifier
  59651. * @param scale Scalar Vector2 for UV frame
  59652. * @param offset Vector2 for the frame position in UV units.
  59653. * @returns TexturePackerFrame
  59654. */
  59655. constructor(id: number, scale: Vector2, offset: Vector2);
  59656. }
  59657. }
  59658. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59660. import { Scene } from "babylonjs/scene";
  59661. import { Nullable } from "babylonjs/types";
  59662. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59663. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59664. /**
  59665. * Defines the basic options interface of a TexturePacker
  59666. */
  59667. export interface ITexturePackerOptions {
  59668. /**
  59669. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59670. */
  59671. map?: string[];
  59672. /**
  59673. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59674. */
  59675. uvsIn?: string;
  59676. /**
  59677. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59678. */
  59679. uvsOut?: string;
  59680. /**
  59681. * number representing the layout style. Defaults to LAYOUT_STRIP
  59682. */
  59683. layout?: number;
  59684. /**
  59685. * number of columns if using custom column count layout(2). This defaults to 4.
  59686. */
  59687. colnum?: number;
  59688. /**
  59689. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59690. */
  59691. updateInputMeshes?: boolean;
  59692. /**
  59693. * boolean flag to dispose all the source textures. Defaults to true.
  59694. */
  59695. disposeSources?: boolean;
  59696. /**
  59697. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59698. */
  59699. fillBlanks?: boolean;
  59700. /**
  59701. * string value representing the context fill style color. Defaults to 'black'.
  59702. */
  59703. customFillColor?: string;
  59704. /**
  59705. * Width and Height Value of each Frame in the TexturePacker Sets
  59706. */
  59707. frameSize?: number;
  59708. /**
  59709. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59710. */
  59711. paddingRatio?: number;
  59712. /**
  59713. * Number that declares the fill method for the padding gutter.
  59714. */
  59715. paddingMode?: number;
  59716. /**
  59717. * If in SUBUV_COLOR padding mode what color to use.
  59718. */
  59719. paddingColor?: Color3 | Color4;
  59720. }
  59721. /**
  59722. * Defines the basic interface of a TexturePacker JSON File
  59723. */
  59724. export interface ITexturePackerJSON {
  59725. /**
  59726. * The frame ID
  59727. */
  59728. name: string;
  59729. /**
  59730. * The base64 channel data
  59731. */
  59732. sets: any;
  59733. /**
  59734. * The options of the Packer
  59735. */
  59736. options: ITexturePackerOptions;
  59737. /**
  59738. * The frame data of the Packer
  59739. */
  59740. frames: Array<number>;
  59741. }
  59742. /**
  59743. * This is a support class that generates a series of packed texture sets.
  59744. * @see https://doc.babylonjs.com/babylon101/materials
  59745. */
  59746. export class TexturePacker {
  59747. /** Packer Layout Constant 0 */
  59748. static readonly LAYOUT_STRIP: number;
  59749. /** Packer Layout Constant 1 */
  59750. static readonly LAYOUT_POWER2: number;
  59751. /** Packer Layout Constant 2 */
  59752. static readonly LAYOUT_COLNUM: number;
  59753. /** Packer Layout Constant 0 */
  59754. static readonly SUBUV_WRAP: number;
  59755. /** Packer Layout Constant 1 */
  59756. static readonly SUBUV_EXTEND: number;
  59757. /** Packer Layout Constant 2 */
  59758. static readonly SUBUV_COLOR: number;
  59759. /** The Name of the Texture Package */
  59760. name: string;
  59761. /** The scene scope of the TexturePacker */
  59762. scene: Scene;
  59763. /** The Meshes to target */
  59764. meshes: AbstractMesh[];
  59765. /** Arguments passed with the Constructor */
  59766. options: ITexturePackerOptions;
  59767. /** The promise that is started upon initialization */
  59768. promise: Nullable<Promise<TexturePacker | string>>;
  59769. /** The Container object for the channel sets that are generated */
  59770. sets: object;
  59771. /** The Container array for the frames that are generated */
  59772. frames: TexturePackerFrame[];
  59773. /** The expected number of textures the system is parsing. */
  59774. private _expecting;
  59775. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59776. private _paddingValue;
  59777. /**
  59778. * Initializes a texture package series from an array of meshes or a single mesh.
  59779. * @param name The name of the package
  59780. * @param meshes The target meshes to compose the package from
  59781. * @param options The arguments that texture packer should follow while building.
  59782. * @param scene The scene which the textures are scoped to.
  59783. * @returns TexturePacker
  59784. */
  59785. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59786. /**
  59787. * Starts the package process
  59788. * @param resolve The promises resolution function
  59789. * @returns TexturePacker
  59790. */
  59791. private _createFrames;
  59792. /**
  59793. * Calculates the Size of the Channel Sets
  59794. * @returns Vector2
  59795. */
  59796. private _calculateSize;
  59797. /**
  59798. * Calculates the UV data for the frames.
  59799. * @param baseSize the base frameSize
  59800. * @param padding the base frame padding
  59801. * @param dtSize size of the Dynamic Texture for that channel
  59802. * @param dtUnits is 1/dtSize
  59803. * @param update flag to update the input meshes
  59804. */
  59805. private _calculateMeshUVFrames;
  59806. /**
  59807. * Calculates the frames Offset.
  59808. * @param index of the frame
  59809. * @returns Vector2
  59810. */
  59811. private _getFrameOffset;
  59812. /**
  59813. * Updates a Mesh to the frame data
  59814. * @param mesh that is the target
  59815. * @param frameID or the frame index
  59816. */
  59817. private _updateMeshUV;
  59818. /**
  59819. * Updates a Meshes materials to use the texture packer channels
  59820. * @param m is the mesh to target
  59821. * @param force all channels on the packer to be set.
  59822. */
  59823. private _updateTextureReferences;
  59824. /**
  59825. * Public method to set a Mesh to a frame
  59826. * @param m that is the target
  59827. * @param frameID or the frame index
  59828. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59829. */
  59830. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59831. /**
  59832. * Starts the async promise to compile the texture packer.
  59833. * @returns Promise<void>
  59834. */
  59835. processAsync(): Promise<void>;
  59836. /**
  59837. * Disposes all textures associated with this packer
  59838. */
  59839. dispose(): void;
  59840. /**
  59841. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59842. * @param imageType is the image type to use.
  59843. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59844. */
  59845. download(imageType?: string, quality?: number): void;
  59846. /**
  59847. * Public method to load a texturePacker JSON file.
  59848. * @param data of the JSON file in string format.
  59849. */
  59850. updateFromJSON(data: string): void;
  59851. }
  59852. }
  59853. declare module "babylonjs/Materials/Textures/Packer/index" {
  59854. export * from "babylonjs/Materials/Textures/Packer/packer";
  59855. export * from "babylonjs/Materials/Textures/Packer/frame";
  59856. }
  59857. declare module "babylonjs/Materials/Textures/index" {
  59858. export * from "babylonjs/Materials/Textures/baseTexture";
  59859. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59860. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59861. export * from "babylonjs/Materials/Textures/cubeTexture";
  59862. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59863. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59864. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59865. export * from "babylonjs/Materials/Textures/internalTexture";
  59866. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59867. export * from "babylonjs/Materials/Textures/Loaders/index";
  59868. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59869. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59870. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59871. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59872. export * from "babylonjs/Materials/Textures/rawTexture";
  59873. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59874. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59875. export * from "babylonjs/Materials/Textures/refractionTexture";
  59876. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59877. export * from "babylonjs/Materials/Textures/texture";
  59878. export * from "babylonjs/Materials/Textures/videoTexture";
  59879. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59880. export * from "babylonjs/Materials/Textures/Packer/index";
  59881. }
  59882. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59883. /**
  59884. * Enum used to define the target of a block
  59885. */
  59886. export enum NodeMaterialBlockTargets {
  59887. /** Vertex shader */
  59888. Vertex = 1,
  59889. /** Fragment shader */
  59890. Fragment = 2,
  59891. /** Neutral */
  59892. Neutral = 4,
  59893. /** Vertex and Fragment */
  59894. VertexAndFragment = 3
  59895. }
  59896. }
  59897. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59898. /**
  59899. * Defines the kind of connection point for node based material
  59900. */
  59901. export enum NodeMaterialBlockConnectionPointTypes {
  59902. /** Float */
  59903. Float = 1,
  59904. /** Int */
  59905. Int = 2,
  59906. /** Vector2 */
  59907. Vector2 = 4,
  59908. /** Vector3 */
  59909. Vector3 = 8,
  59910. /** Vector4 */
  59911. Vector4 = 16,
  59912. /** Color3 */
  59913. Color3 = 32,
  59914. /** Color4 */
  59915. Color4 = 64,
  59916. /** Matrix */
  59917. Matrix = 128,
  59918. /** Detect type based on connection */
  59919. AutoDetect = 1024,
  59920. /** Output type that will be defined by input type */
  59921. BasedOnInput = 2048
  59922. }
  59923. }
  59924. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59925. /**
  59926. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59927. */
  59928. export enum NodeMaterialBlockConnectionPointMode {
  59929. /** Value is an uniform */
  59930. Uniform = 0,
  59931. /** Value is a mesh attribute */
  59932. Attribute = 1,
  59933. /** Value is a varying between vertex and fragment shaders */
  59934. Varying = 2,
  59935. /** Mode is undefined */
  59936. Undefined = 3
  59937. }
  59938. }
  59939. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59940. /**
  59941. * Enum used to define system values e.g. values automatically provided by the system
  59942. */
  59943. export enum NodeMaterialSystemValues {
  59944. /** World */
  59945. World = 1,
  59946. /** View */
  59947. View = 2,
  59948. /** Projection */
  59949. Projection = 3,
  59950. /** ViewProjection */
  59951. ViewProjection = 4,
  59952. /** WorldView */
  59953. WorldView = 5,
  59954. /** WorldViewProjection */
  59955. WorldViewProjection = 6,
  59956. /** CameraPosition */
  59957. CameraPosition = 7,
  59958. /** Fog Color */
  59959. FogColor = 8,
  59960. /** Delta time */
  59961. DeltaTime = 9
  59962. }
  59963. }
  59964. declare module "babylonjs/Materials/Node/Enums/index" {
  59965. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59966. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59967. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59968. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59969. }
  59970. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59972. /**
  59973. * Root class for all node material optimizers
  59974. */
  59975. export class NodeMaterialOptimizer {
  59976. /**
  59977. * Function used to optimize a NodeMaterial graph
  59978. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59979. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59980. */
  59981. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59982. }
  59983. }
  59984. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59988. import { Scene } from "babylonjs/scene";
  59989. /**
  59990. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59991. */
  59992. export class TransformBlock extends NodeMaterialBlock {
  59993. /**
  59994. * Defines the value to use to complement W value to transform it to a Vector4
  59995. */
  59996. complementW: number;
  59997. /**
  59998. * Defines the value to use to complement z value to transform it to a Vector4
  59999. */
  60000. complementZ: number;
  60001. /**
  60002. * Creates a new TransformBlock
  60003. * @param name defines the block name
  60004. */
  60005. constructor(name: string);
  60006. /**
  60007. * Gets the current class name
  60008. * @returns the class name
  60009. */
  60010. getClassName(): string;
  60011. /**
  60012. * Gets the vector input
  60013. */
  60014. get vector(): NodeMaterialConnectionPoint;
  60015. /**
  60016. * Gets the output component
  60017. */
  60018. get output(): NodeMaterialConnectionPoint;
  60019. /**
  60020. * Gets the xyz output component
  60021. */
  60022. get xyz(): NodeMaterialConnectionPoint;
  60023. /**
  60024. * Gets the matrix transform input
  60025. */
  60026. get transform(): NodeMaterialConnectionPoint;
  60027. protected _buildBlock(state: NodeMaterialBuildState): this;
  60028. serialize(): any;
  60029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60030. protected _dumpPropertiesCode(): string;
  60031. }
  60032. }
  60033. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60037. /**
  60038. * Block used to output the vertex position
  60039. */
  60040. export class VertexOutputBlock extends NodeMaterialBlock {
  60041. /**
  60042. * Creates a new VertexOutputBlock
  60043. * @param name defines the block name
  60044. */
  60045. constructor(name: string);
  60046. /**
  60047. * Gets the current class name
  60048. * @returns the class name
  60049. */
  60050. getClassName(): string;
  60051. /**
  60052. * Gets the vector input component
  60053. */
  60054. get vector(): NodeMaterialConnectionPoint;
  60055. protected _buildBlock(state: NodeMaterialBuildState): this;
  60056. }
  60057. }
  60058. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60062. /**
  60063. * Block used to output the final color
  60064. */
  60065. export class FragmentOutputBlock extends NodeMaterialBlock {
  60066. /**
  60067. * Create a new FragmentOutputBlock
  60068. * @param name defines the block name
  60069. */
  60070. constructor(name: string);
  60071. /**
  60072. * Gets the current class name
  60073. * @returns the class name
  60074. */
  60075. getClassName(): string;
  60076. /**
  60077. * Gets the rgba input component
  60078. */
  60079. get rgba(): NodeMaterialConnectionPoint;
  60080. /**
  60081. * Gets the rgb input component
  60082. */
  60083. get rgb(): NodeMaterialConnectionPoint;
  60084. /**
  60085. * Gets the a input component
  60086. */
  60087. get a(): NodeMaterialConnectionPoint;
  60088. protected _buildBlock(state: NodeMaterialBuildState): this;
  60089. }
  60090. }
  60091. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  60092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60095. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60097. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60098. import { Effect } from "babylonjs/Materials/effect";
  60099. import { Mesh } from "babylonjs/Meshes/mesh";
  60100. import { Nullable } from "babylonjs/types";
  60101. import { Scene } from "babylonjs/scene";
  60102. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60103. /**
  60104. * Block used to read a reflection texture from a sampler
  60105. */
  60106. export class ReflectionTextureBlock extends NodeMaterialBlock {
  60107. private _define3DName;
  60108. private _defineCubicName;
  60109. private _defineExplicitName;
  60110. private _defineProjectionName;
  60111. private _defineLocalCubicName;
  60112. private _defineSphericalName;
  60113. private _definePlanarName;
  60114. private _defineEquirectangularName;
  60115. private _defineMirroredEquirectangularFixedName;
  60116. private _defineEquirectangularFixedName;
  60117. private _defineSkyboxName;
  60118. private _cubeSamplerName;
  60119. private _2DSamplerName;
  60120. private _positionUVWName;
  60121. private _directionWName;
  60122. private _reflectionCoordsName;
  60123. private _reflection2DCoordsName;
  60124. private _reflectionColorName;
  60125. private _reflectionMatrixName;
  60126. /**
  60127. * Gets or sets the texture associated with the node
  60128. */
  60129. texture: Nullable<BaseTexture>;
  60130. /**
  60131. * Create a new TextureBlock
  60132. * @param name defines the block name
  60133. */
  60134. constructor(name: string);
  60135. /**
  60136. * Gets the current class name
  60137. * @returns the class name
  60138. */
  60139. getClassName(): string;
  60140. /**
  60141. * Gets the world position input component
  60142. */
  60143. get position(): NodeMaterialConnectionPoint;
  60144. /**
  60145. * Gets the world position input component
  60146. */
  60147. get worldPosition(): NodeMaterialConnectionPoint;
  60148. /**
  60149. * Gets the world normal input component
  60150. */
  60151. get worldNormal(): NodeMaterialConnectionPoint;
  60152. /**
  60153. * Gets the world input component
  60154. */
  60155. get world(): NodeMaterialConnectionPoint;
  60156. /**
  60157. * Gets the camera (or eye) position component
  60158. */
  60159. get cameraPosition(): NodeMaterialConnectionPoint;
  60160. /**
  60161. * Gets the view input component
  60162. */
  60163. get view(): NodeMaterialConnectionPoint;
  60164. /**
  60165. * Gets the rgb output component
  60166. */
  60167. get rgb(): NodeMaterialConnectionPoint;
  60168. /**
  60169. * Gets the r output component
  60170. */
  60171. get r(): NodeMaterialConnectionPoint;
  60172. /**
  60173. * Gets the g output component
  60174. */
  60175. get g(): NodeMaterialConnectionPoint;
  60176. /**
  60177. * Gets the b output component
  60178. */
  60179. get b(): NodeMaterialConnectionPoint;
  60180. autoConfigure(material: NodeMaterial): void;
  60181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60182. isReady(): boolean;
  60183. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60184. private _injectVertexCode;
  60185. private _writeOutput;
  60186. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60187. protected _dumpPropertiesCode(): string;
  60188. serialize(): any;
  60189. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60190. }
  60191. }
  60192. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60194. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60195. import { Scene } from "babylonjs/scene";
  60196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60197. import { Matrix } from "babylonjs/Maths/math.vector";
  60198. import { Mesh } from "babylonjs/Meshes/mesh";
  60199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60200. import { Observable } from "babylonjs/Misc/observable";
  60201. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60202. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60203. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60204. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60205. import { Nullable } from "babylonjs/types";
  60206. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60207. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60208. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60209. /**
  60210. * Interface used to configure the node material editor
  60211. */
  60212. export interface INodeMaterialEditorOptions {
  60213. /** Define the URl to load node editor script */
  60214. editorURL?: string;
  60215. }
  60216. /** @hidden */
  60217. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60218. NORMAL: boolean;
  60219. TANGENT: boolean;
  60220. UV1: boolean;
  60221. /** BONES */
  60222. NUM_BONE_INFLUENCERS: number;
  60223. BonesPerMesh: number;
  60224. BONETEXTURE: boolean;
  60225. /** MORPH TARGETS */
  60226. MORPHTARGETS: boolean;
  60227. MORPHTARGETS_NORMAL: boolean;
  60228. MORPHTARGETS_TANGENT: boolean;
  60229. MORPHTARGETS_UV: boolean;
  60230. NUM_MORPH_INFLUENCERS: number;
  60231. /** IMAGE PROCESSING */
  60232. IMAGEPROCESSING: boolean;
  60233. VIGNETTE: boolean;
  60234. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60235. VIGNETTEBLENDMODEOPAQUE: boolean;
  60236. TONEMAPPING: boolean;
  60237. TONEMAPPING_ACES: boolean;
  60238. CONTRAST: boolean;
  60239. EXPOSURE: boolean;
  60240. COLORCURVES: boolean;
  60241. COLORGRADING: boolean;
  60242. COLORGRADING3D: boolean;
  60243. SAMPLER3DGREENDEPTH: boolean;
  60244. SAMPLER3DBGRMAP: boolean;
  60245. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60246. /** MISC. */
  60247. BUMPDIRECTUV: number;
  60248. constructor();
  60249. setValue(name: string, value: boolean): void;
  60250. }
  60251. /**
  60252. * Class used to configure NodeMaterial
  60253. */
  60254. export interface INodeMaterialOptions {
  60255. /**
  60256. * Defines if blocks should emit comments
  60257. */
  60258. emitComments: boolean;
  60259. }
  60260. /**
  60261. * Class used to create a node based material built by assembling shader blocks
  60262. */
  60263. export class NodeMaterial extends PushMaterial {
  60264. private static _BuildIdGenerator;
  60265. private _options;
  60266. private _vertexCompilationState;
  60267. private _fragmentCompilationState;
  60268. private _sharedData;
  60269. private _buildId;
  60270. private _buildWasSuccessful;
  60271. private _cachedWorldViewMatrix;
  60272. private _cachedWorldViewProjectionMatrix;
  60273. private _optimizers;
  60274. private _animationFrame;
  60275. /** Define the Url to load node editor script */
  60276. static EditorURL: string;
  60277. /** Define the Url to load snippets */
  60278. static SnippetUrl: string;
  60279. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  60280. static IgnoreTexturesAtLoadTime: boolean;
  60281. private BJSNODEMATERIALEDITOR;
  60282. /** Get the inspector from bundle or global */
  60283. private _getGlobalNodeMaterialEditor;
  60284. /**
  60285. * Snippet ID if the material was created from the snippet server
  60286. */
  60287. snippetId: string;
  60288. /**
  60289. * Gets or sets data used by visual editor
  60290. * @see https://nme.babylonjs.com
  60291. */
  60292. editorData: any;
  60293. /**
  60294. * 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)
  60295. */
  60296. ignoreAlpha: boolean;
  60297. /**
  60298. * Defines the maximum number of lights that can be used in the material
  60299. */
  60300. maxSimultaneousLights: number;
  60301. /**
  60302. * Observable raised when the material is built
  60303. */
  60304. onBuildObservable: Observable<NodeMaterial>;
  60305. /**
  60306. * Gets or sets the root nodes of the material vertex shader
  60307. */
  60308. _vertexOutputNodes: NodeMaterialBlock[];
  60309. /**
  60310. * Gets or sets the root nodes of the material fragment (pixel) shader
  60311. */
  60312. _fragmentOutputNodes: NodeMaterialBlock[];
  60313. /** Gets or sets options to control the node material overall behavior */
  60314. get options(): INodeMaterialOptions;
  60315. set options(options: INodeMaterialOptions);
  60316. /**
  60317. * Default configuration related to image processing available in the standard Material.
  60318. */
  60319. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60320. /**
  60321. * Gets the image processing configuration used either in this material.
  60322. */
  60323. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60324. /**
  60325. * Sets the Default image processing configuration used either in the this material.
  60326. *
  60327. * If sets to null, the scene one is in use.
  60328. */
  60329. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60330. /**
  60331. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60332. */
  60333. attachedBlocks: NodeMaterialBlock[];
  60334. /**
  60335. * Create a new node based material
  60336. * @param name defines the material name
  60337. * @param scene defines the hosting scene
  60338. * @param options defines creation option
  60339. */
  60340. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60341. /**
  60342. * Gets the current class name of the material e.g. "NodeMaterial"
  60343. * @returns the class name
  60344. */
  60345. getClassName(): string;
  60346. /**
  60347. * Keep track of the image processing observer to allow dispose and replace.
  60348. */
  60349. private _imageProcessingObserver;
  60350. /**
  60351. * Attaches a new image processing configuration to the Standard Material.
  60352. * @param configuration
  60353. */
  60354. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60355. /**
  60356. * Get a block by its name
  60357. * @param name defines the name of the block to retrieve
  60358. * @returns the required block or null if not found
  60359. */
  60360. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60361. /**
  60362. * Get a block by its name
  60363. * @param predicate defines the predicate used to find the good candidate
  60364. * @returns the required block or null if not found
  60365. */
  60366. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60367. /**
  60368. * Get an input block by its name
  60369. * @param predicate defines the predicate used to find the good candidate
  60370. * @returns the required input block or null if not found
  60371. */
  60372. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60373. /**
  60374. * Gets the list of input blocks attached to this material
  60375. * @returns an array of InputBlocks
  60376. */
  60377. getInputBlocks(): InputBlock[];
  60378. /**
  60379. * Adds a new optimizer to the list of optimizers
  60380. * @param optimizer defines the optimizers to add
  60381. * @returns the current material
  60382. */
  60383. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60384. /**
  60385. * Remove an optimizer from the list of optimizers
  60386. * @param optimizer defines the optimizers to remove
  60387. * @returns the current material
  60388. */
  60389. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60390. /**
  60391. * Add a new block to the list of output nodes
  60392. * @param node defines the node to add
  60393. * @returns the current material
  60394. */
  60395. addOutputNode(node: NodeMaterialBlock): this;
  60396. /**
  60397. * Remove a block from the list of root nodes
  60398. * @param node defines the node to remove
  60399. * @returns the current material
  60400. */
  60401. removeOutputNode(node: NodeMaterialBlock): this;
  60402. private _addVertexOutputNode;
  60403. private _removeVertexOutputNode;
  60404. private _addFragmentOutputNode;
  60405. private _removeFragmentOutputNode;
  60406. /**
  60407. * Specifies if the material will require alpha blending
  60408. * @returns a boolean specifying if alpha blending is needed
  60409. */
  60410. needAlphaBlending(): boolean;
  60411. /**
  60412. * Specifies if this material should be rendered in alpha test mode
  60413. * @returns a boolean specifying if an alpha test is needed.
  60414. */
  60415. needAlphaTesting(): boolean;
  60416. private _initializeBlock;
  60417. private _resetDualBlocks;
  60418. /**
  60419. * Remove a block from the current node material
  60420. * @param block defines the block to remove
  60421. */
  60422. removeBlock(block: NodeMaterialBlock): void;
  60423. /**
  60424. * Build the material and generates the inner effect
  60425. * @param verbose defines if the build should log activity
  60426. */
  60427. build(verbose?: boolean): void;
  60428. /**
  60429. * Runs an otpimization phase to try to improve the shader code
  60430. */
  60431. optimize(): void;
  60432. private _prepareDefinesForAttributes;
  60433. /**
  60434. * Get if the submesh is ready to be used and all its information available.
  60435. * Child classes can use it to update shaders
  60436. * @param mesh defines the mesh to check
  60437. * @param subMesh defines which submesh to check
  60438. * @param useInstances specifies that instances should be used
  60439. * @returns a boolean indicating that the submesh is ready or not
  60440. */
  60441. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60442. /**
  60443. * Get a string representing the shaders built by the current node graph
  60444. */
  60445. get compiledShaders(): string;
  60446. /**
  60447. * Binds the world matrix to the material
  60448. * @param world defines the world transformation matrix
  60449. */
  60450. bindOnlyWorldMatrix(world: Matrix): void;
  60451. /**
  60452. * Binds the submesh to this material by preparing the effect and shader to draw
  60453. * @param world defines the world transformation matrix
  60454. * @param mesh defines the mesh containing the submesh
  60455. * @param subMesh defines the submesh to bind the material to
  60456. */
  60457. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60458. /**
  60459. * Gets the active textures from the material
  60460. * @returns an array of textures
  60461. */
  60462. getActiveTextures(): BaseTexture[];
  60463. /**
  60464. * Gets the list of texture blocks
  60465. * @returns an array of texture blocks
  60466. */
  60467. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60468. /**
  60469. * Specifies if the material uses a texture
  60470. * @param texture defines the texture to check against the material
  60471. * @returns a boolean specifying if the material uses the texture
  60472. */
  60473. hasTexture(texture: BaseTexture): boolean;
  60474. /**
  60475. * Disposes the material
  60476. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60477. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60478. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60479. */
  60480. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60481. /** Creates the node editor window. */
  60482. private _createNodeEditor;
  60483. /**
  60484. * Launch the node material editor
  60485. * @param config Define the configuration of the editor
  60486. * @return a promise fulfilled when the node editor is visible
  60487. */
  60488. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60489. /**
  60490. * Clear the current material
  60491. */
  60492. clear(): void;
  60493. /**
  60494. * Clear the current material and set it to a default state
  60495. */
  60496. setToDefault(): void;
  60497. /**
  60498. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60499. * @param url defines the url to load from
  60500. * @returns a promise that will fullfil when the material is fully loaded
  60501. */
  60502. loadAsync(url: string): Promise<void>;
  60503. private _gatherBlocks;
  60504. /**
  60505. * Generate a string containing the code declaration required to create an equivalent of this material
  60506. * @returns a string
  60507. */
  60508. generateCode(): string;
  60509. /**
  60510. * Serializes this material in a JSON representation
  60511. * @returns the serialized material object
  60512. */
  60513. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60514. private _restoreConnections;
  60515. /**
  60516. * Clear the current graph and load a new one from a serialization object
  60517. * @param source defines the JSON representation of the material
  60518. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60519. */
  60520. loadFromSerialization(source: any, rootUrl?: string): void;
  60521. /**
  60522. * Makes a duplicate of the current material.
  60523. * @param name - name to use for the new material.
  60524. */
  60525. clone(name: string): NodeMaterial;
  60526. /**
  60527. * Creates a node material from parsed material data
  60528. * @param source defines the JSON representation of the material
  60529. * @param scene defines the hosting scene
  60530. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60531. * @returns a new node material
  60532. */
  60533. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60534. /**
  60535. * Creates a node material from a snippet saved in a remote file
  60536. * @param name defines the name of the material to create
  60537. * @param url defines the url to load from
  60538. * @param scene defines the hosting scene
  60539. * @returns a promise that will resolve to the new node material
  60540. */
  60541. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60542. /**
  60543. * Creates a node material from a snippet saved by the node material editor
  60544. * @param snippetId defines the snippet to load
  60545. * @param scene defines the hosting scene
  60546. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60547. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  60548. * @returns a promise that will resolve to the new node material
  60549. */
  60550. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  60551. /**
  60552. * Creates a new node material set to default basic configuration
  60553. * @param name defines the name of the material
  60554. * @param scene defines the hosting scene
  60555. * @returns a new NodeMaterial
  60556. */
  60557. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60558. }
  60559. }
  60560. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60563. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60566. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60567. import { Effect } from "babylonjs/Materials/effect";
  60568. import { Mesh } from "babylonjs/Meshes/mesh";
  60569. import { Nullable } from "babylonjs/types";
  60570. import { Texture } from "babylonjs/Materials/Textures/texture";
  60571. import { Scene } from "babylonjs/scene";
  60572. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60573. /**
  60574. * Block used to read a texture from a sampler
  60575. */
  60576. export class TextureBlock extends NodeMaterialBlock {
  60577. private _defineName;
  60578. private _linearDefineName;
  60579. private _tempTextureRead;
  60580. private _samplerName;
  60581. private _transformedUVName;
  60582. private _textureTransformName;
  60583. private _textureInfoName;
  60584. private _mainUVName;
  60585. private _mainUVDefineName;
  60586. /**
  60587. * Gets or sets the texture associated with the node
  60588. */
  60589. texture: Nullable<Texture>;
  60590. /**
  60591. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60592. */
  60593. convertToGammaSpace: boolean;
  60594. /**
  60595. * Create a new TextureBlock
  60596. * @param name defines the block name
  60597. */
  60598. constructor(name: string);
  60599. /**
  60600. * Gets the current class name
  60601. * @returns the class name
  60602. */
  60603. getClassName(): string;
  60604. /**
  60605. * Gets the uv input component
  60606. */
  60607. get uv(): NodeMaterialConnectionPoint;
  60608. /**
  60609. * Gets the rgba output component
  60610. */
  60611. get rgba(): NodeMaterialConnectionPoint;
  60612. /**
  60613. * Gets the rgb output component
  60614. */
  60615. get rgb(): NodeMaterialConnectionPoint;
  60616. /**
  60617. * Gets the r output component
  60618. */
  60619. get r(): NodeMaterialConnectionPoint;
  60620. /**
  60621. * Gets the g output component
  60622. */
  60623. get g(): NodeMaterialConnectionPoint;
  60624. /**
  60625. * Gets the b output component
  60626. */
  60627. get b(): NodeMaterialConnectionPoint;
  60628. /**
  60629. * Gets the a output component
  60630. */
  60631. get a(): NodeMaterialConnectionPoint;
  60632. get target(): NodeMaterialBlockTargets;
  60633. autoConfigure(material: NodeMaterial): void;
  60634. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60636. isReady(): boolean;
  60637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60638. private get _isMixed();
  60639. private _injectVertexCode;
  60640. private _writeTextureRead;
  60641. private _writeOutput;
  60642. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60643. protected _dumpPropertiesCode(): string;
  60644. serialize(): any;
  60645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60646. }
  60647. }
  60648. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60649. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60651. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60652. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60653. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60654. import { Scene } from "babylonjs/scene";
  60655. /**
  60656. * Class used to store shared data between 2 NodeMaterialBuildState
  60657. */
  60658. export class NodeMaterialBuildStateSharedData {
  60659. /**
  60660. * Gets the list of emitted varyings
  60661. */
  60662. temps: string[];
  60663. /**
  60664. * Gets the list of emitted varyings
  60665. */
  60666. varyings: string[];
  60667. /**
  60668. * Gets the varying declaration string
  60669. */
  60670. varyingDeclaration: string;
  60671. /**
  60672. * Input blocks
  60673. */
  60674. inputBlocks: InputBlock[];
  60675. /**
  60676. * Input blocks
  60677. */
  60678. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60679. /**
  60680. * Bindable blocks (Blocks that need to set data to the effect)
  60681. */
  60682. bindableBlocks: NodeMaterialBlock[];
  60683. /**
  60684. * List of blocks that can provide a compilation fallback
  60685. */
  60686. blocksWithFallbacks: NodeMaterialBlock[];
  60687. /**
  60688. * List of blocks that can provide a define update
  60689. */
  60690. blocksWithDefines: NodeMaterialBlock[];
  60691. /**
  60692. * List of blocks that can provide a repeatable content
  60693. */
  60694. repeatableContentBlocks: NodeMaterialBlock[];
  60695. /**
  60696. * List of blocks that can provide a dynamic list of uniforms
  60697. */
  60698. dynamicUniformBlocks: NodeMaterialBlock[];
  60699. /**
  60700. * List of blocks that can block the isReady function for the material
  60701. */
  60702. blockingBlocks: NodeMaterialBlock[];
  60703. /**
  60704. * Gets the list of animated inputs
  60705. */
  60706. animatedInputs: InputBlock[];
  60707. /**
  60708. * Build Id used to avoid multiple recompilations
  60709. */
  60710. buildId: number;
  60711. /** List of emitted variables */
  60712. variableNames: {
  60713. [key: string]: number;
  60714. };
  60715. /** List of emitted defines */
  60716. defineNames: {
  60717. [key: string]: number;
  60718. };
  60719. /** Should emit comments? */
  60720. emitComments: boolean;
  60721. /** Emit build activity */
  60722. verbose: boolean;
  60723. /** Gets or sets the hosting scene */
  60724. scene: Scene;
  60725. /**
  60726. * Gets the compilation hints emitted at compilation time
  60727. */
  60728. hints: {
  60729. needWorldViewMatrix: boolean;
  60730. needWorldViewProjectionMatrix: boolean;
  60731. needAlphaBlending: boolean;
  60732. needAlphaTesting: boolean;
  60733. };
  60734. /**
  60735. * List of compilation checks
  60736. */
  60737. checks: {
  60738. emitVertex: boolean;
  60739. emitFragment: boolean;
  60740. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60741. };
  60742. /** Creates a new shared data */
  60743. constructor();
  60744. /**
  60745. * Emits console errors and exceptions if there is a failing check
  60746. */
  60747. emitErrors(): void;
  60748. }
  60749. }
  60750. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60751. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60752. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60753. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60754. /**
  60755. * Class used to store node based material build state
  60756. */
  60757. export class NodeMaterialBuildState {
  60758. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60759. supportUniformBuffers: boolean;
  60760. /**
  60761. * Gets the list of emitted attributes
  60762. */
  60763. attributes: string[];
  60764. /**
  60765. * Gets the list of emitted uniforms
  60766. */
  60767. uniforms: string[];
  60768. /**
  60769. * Gets the list of emitted constants
  60770. */
  60771. constants: string[];
  60772. /**
  60773. * Gets the list of emitted samplers
  60774. */
  60775. samplers: string[];
  60776. /**
  60777. * Gets the list of emitted functions
  60778. */
  60779. functions: {
  60780. [key: string]: string;
  60781. };
  60782. /**
  60783. * Gets the list of emitted extensions
  60784. */
  60785. extensions: {
  60786. [key: string]: string;
  60787. };
  60788. /**
  60789. * Gets the target of the compilation state
  60790. */
  60791. target: NodeMaterialBlockTargets;
  60792. /**
  60793. * Gets the list of emitted counters
  60794. */
  60795. counters: {
  60796. [key: string]: number;
  60797. };
  60798. /**
  60799. * Shared data between multiple NodeMaterialBuildState instances
  60800. */
  60801. sharedData: NodeMaterialBuildStateSharedData;
  60802. /** @hidden */
  60803. _vertexState: NodeMaterialBuildState;
  60804. /** @hidden */
  60805. _attributeDeclaration: string;
  60806. /** @hidden */
  60807. _uniformDeclaration: string;
  60808. /** @hidden */
  60809. _constantDeclaration: string;
  60810. /** @hidden */
  60811. _samplerDeclaration: string;
  60812. /** @hidden */
  60813. _varyingTransfer: string;
  60814. private _repeatableContentAnchorIndex;
  60815. /** @hidden */
  60816. _builtCompilationString: string;
  60817. /**
  60818. * Gets the emitted compilation strings
  60819. */
  60820. compilationString: string;
  60821. /**
  60822. * Finalize the compilation strings
  60823. * @param state defines the current compilation state
  60824. */
  60825. finalize(state: NodeMaterialBuildState): void;
  60826. /** @hidden */
  60827. get _repeatableContentAnchor(): string;
  60828. /** @hidden */
  60829. _getFreeVariableName(prefix: string): string;
  60830. /** @hidden */
  60831. _getFreeDefineName(prefix: string): string;
  60832. /** @hidden */
  60833. _excludeVariableName(name: string): void;
  60834. /** @hidden */
  60835. _emit2DSampler(name: string): void;
  60836. /** @hidden */
  60837. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60838. /** @hidden */
  60839. _emitExtension(name: string, extension: string): void;
  60840. /** @hidden */
  60841. _emitFunction(name: string, code: string, comments: string): void;
  60842. /** @hidden */
  60843. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60844. replaceStrings?: {
  60845. search: RegExp;
  60846. replace: string;
  60847. }[];
  60848. repeatKey?: string;
  60849. }): string;
  60850. /** @hidden */
  60851. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60852. repeatKey?: string;
  60853. removeAttributes?: boolean;
  60854. removeUniforms?: boolean;
  60855. removeVaryings?: boolean;
  60856. removeIfDef?: boolean;
  60857. replaceStrings?: {
  60858. search: RegExp;
  60859. replace: string;
  60860. }[];
  60861. }, storeKey?: string): void;
  60862. /** @hidden */
  60863. _registerTempVariable(name: string): boolean;
  60864. /** @hidden */
  60865. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60866. /** @hidden */
  60867. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60868. /** @hidden */
  60869. _emitFloat(value: number): string;
  60870. }
  60871. }
  60872. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60873. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60874. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60875. import { Nullable } from "babylonjs/types";
  60876. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60877. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60878. import { Effect } from "babylonjs/Materials/effect";
  60879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60880. import { Mesh } from "babylonjs/Meshes/mesh";
  60881. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60882. import { Scene } from "babylonjs/scene";
  60883. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60884. /**
  60885. * Defines a block that can be used inside a node based material
  60886. */
  60887. export class NodeMaterialBlock {
  60888. private _buildId;
  60889. private _buildTarget;
  60890. private _target;
  60891. private _isFinalMerger;
  60892. private _isInput;
  60893. protected _isUnique: boolean;
  60894. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60895. inputsAreExclusive: boolean;
  60896. /** @hidden */
  60897. _codeVariableName: string;
  60898. /** @hidden */
  60899. _inputs: NodeMaterialConnectionPoint[];
  60900. /** @hidden */
  60901. _outputs: NodeMaterialConnectionPoint[];
  60902. /** @hidden */
  60903. _preparationId: number;
  60904. /**
  60905. * Gets or sets the name of the block
  60906. */
  60907. name: string;
  60908. /**
  60909. * Gets or sets the unique id of the node
  60910. */
  60911. uniqueId: number;
  60912. /**
  60913. * Gets or sets the comments associated with this block
  60914. */
  60915. comments: string;
  60916. /**
  60917. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60918. */
  60919. get isUnique(): boolean;
  60920. /**
  60921. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60922. */
  60923. get isFinalMerger(): boolean;
  60924. /**
  60925. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60926. */
  60927. get isInput(): boolean;
  60928. /**
  60929. * Gets or sets the build Id
  60930. */
  60931. get buildId(): number;
  60932. set buildId(value: number);
  60933. /**
  60934. * Gets or sets the target of the block
  60935. */
  60936. get target(): NodeMaterialBlockTargets;
  60937. set target(value: NodeMaterialBlockTargets);
  60938. /**
  60939. * Gets the list of input points
  60940. */
  60941. get inputs(): NodeMaterialConnectionPoint[];
  60942. /** Gets the list of output points */
  60943. get outputs(): NodeMaterialConnectionPoint[];
  60944. /**
  60945. * Find an input by its name
  60946. * @param name defines the name of the input to look for
  60947. * @returns the input or null if not found
  60948. */
  60949. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60950. /**
  60951. * Find an output by its name
  60952. * @param name defines the name of the outputto look for
  60953. * @returns the output or null if not found
  60954. */
  60955. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60956. /**
  60957. * Creates a new NodeMaterialBlock
  60958. * @param name defines the block name
  60959. * @param target defines the target of that block (Vertex by default)
  60960. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60961. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60962. */
  60963. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60964. /**
  60965. * Initialize the block and prepare the context for build
  60966. * @param state defines the state that will be used for the build
  60967. */
  60968. initialize(state: NodeMaterialBuildState): void;
  60969. /**
  60970. * Bind data to effect. Will only be called for blocks with isBindable === true
  60971. * @param effect defines the effect to bind data to
  60972. * @param nodeMaterial defines the hosting NodeMaterial
  60973. * @param mesh defines the mesh that will be rendered
  60974. */
  60975. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60976. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60977. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60978. protected _writeFloat(value: number): string;
  60979. /**
  60980. * Gets the current class name e.g. "NodeMaterialBlock"
  60981. * @returns the class name
  60982. */
  60983. getClassName(): string;
  60984. /**
  60985. * Register a new input. Must be called inside a block constructor
  60986. * @param name defines the connection point name
  60987. * @param type defines the connection point type
  60988. * @param isOptional defines a boolean indicating that this input can be omitted
  60989. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60990. * @returns the current block
  60991. */
  60992. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60993. /**
  60994. * Register a new output. Must be called inside a block constructor
  60995. * @param name defines the connection point name
  60996. * @param type defines the connection point type
  60997. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60998. * @returns the current block
  60999. */
  61000. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  61001. /**
  61002. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61003. * @param forOutput defines an optional connection point to check compatibility with
  61004. * @returns the first available input or null
  61005. */
  61006. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61007. /**
  61008. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61009. * @param forBlock defines an optional block to check compatibility with
  61010. * @returns the first available input or null
  61011. */
  61012. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61013. /**
  61014. * Gets the sibling of the given output
  61015. * @param current defines the current output
  61016. * @returns the next output in the list or null
  61017. */
  61018. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61019. /**
  61020. * Connect current block with another block
  61021. * @param other defines the block to connect with
  61022. * @param options define the various options to help pick the right connections
  61023. * @returns the current block
  61024. */
  61025. connectTo(other: NodeMaterialBlock, options?: {
  61026. input?: string;
  61027. output?: string;
  61028. outputSwizzle?: string;
  61029. }): this | undefined;
  61030. protected _buildBlock(state: NodeMaterialBuildState): void;
  61031. /**
  61032. * Add uniforms, samplers and uniform buffers at compilation time
  61033. * @param state defines the state to update
  61034. * @param nodeMaterial defines the node material requesting the update
  61035. * @param defines defines the material defines to update
  61036. * @param uniformBuffers defines the list of uniform buffer names
  61037. */
  61038. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61039. /**
  61040. * Add potential fallbacks if shader compilation fails
  61041. * @param mesh defines the mesh to be rendered
  61042. * @param fallbacks defines the current prioritized list of fallbacks
  61043. */
  61044. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61045. /**
  61046. * Initialize defines for shader compilation
  61047. * @param mesh defines the mesh to be rendered
  61048. * @param nodeMaterial defines the node material requesting the update
  61049. * @param defines defines the material defines to update
  61050. * @param useInstances specifies that instances should be used
  61051. */
  61052. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61053. /**
  61054. * Update defines for shader compilation
  61055. * @param mesh defines the mesh to be rendered
  61056. * @param nodeMaterial defines the node material requesting the update
  61057. * @param defines defines the material defines to update
  61058. * @param useInstances specifies that instances should be used
  61059. */
  61060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61061. /**
  61062. * Lets the block try to connect some inputs automatically
  61063. * @param material defines the hosting NodeMaterial
  61064. */
  61065. autoConfigure(material: NodeMaterial): void;
  61066. /**
  61067. * Function called when a block is declared as repeatable content generator
  61068. * @param vertexShaderState defines the current compilation state for the vertex shader
  61069. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61070. * @param mesh defines the mesh to be rendered
  61071. * @param defines defines the material defines to update
  61072. */
  61073. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61074. /**
  61075. * Checks if the block is ready
  61076. * @param mesh defines the mesh to be rendered
  61077. * @param nodeMaterial defines the node material requesting the update
  61078. * @param defines defines the material defines to update
  61079. * @param useInstances specifies that instances should be used
  61080. * @returns true if the block is ready
  61081. */
  61082. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61083. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61084. private _processBuild;
  61085. /**
  61086. * Compile the current node and generate the shader code
  61087. * @param state defines the current compilation state (uniforms, samplers, current string)
  61088. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61089. * @returns true if already built
  61090. */
  61091. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61092. protected _inputRename(name: string): string;
  61093. protected _outputRename(name: string): string;
  61094. protected _dumpPropertiesCode(): string;
  61095. /** @hidden */
  61096. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61097. /** @hidden */
  61098. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61099. /**
  61100. * Clone the current block to a new identical block
  61101. * @param scene defines the hosting scene
  61102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61103. * @returns a copy of the current block
  61104. */
  61105. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61106. /**
  61107. * Serializes this block in a JSON representation
  61108. * @returns the serialized block object
  61109. */
  61110. serialize(): any;
  61111. /** @hidden */
  61112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61113. /**
  61114. * Release resources
  61115. */
  61116. dispose(): void;
  61117. }
  61118. }
  61119. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61120. /**
  61121. * Enum defining the type of animations supported by InputBlock
  61122. */
  61123. export enum AnimatedInputBlockTypes {
  61124. /** No animation */
  61125. None = 0,
  61126. /** Time based animation. Will only work for floats */
  61127. Time = 1
  61128. }
  61129. }
  61130. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61131. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61132. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61133. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61134. import { Nullable } from "babylonjs/types";
  61135. import { Effect } from "babylonjs/Materials/effect";
  61136. import { Matrix } from "babylonjs/Maths/math.vector";
  61137. import { Scene } from "babylonjs/scene";
  61138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61140. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61141. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61142. import { Observable } from "babylonjs/Misc/observable";
  61143. /**
  61144. * Block used to expose an input value
  61145. */
  61146. export class InputBlock extends NodeMaterialBlock {
  61147. private _mode;
  61148. private _associatedVariableName;
  61149. private _storedValue;
  61150. private _valueCallback;
  61151. private _type;
  61152. private _animationType;
  61153. /** Gets or set a value used to limit the range of float values */
  61154. min: number;
  61155. /** Gets or set a value used to limit the range of float values */
  61156. max: number;
  61157. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61158. isBoolean: boolean;
  61159. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61160. matrixMode: number;
  61161. /** @hidden */
  61162. _systemValue: Nullable<NodeMaterialSystemValues>;
  61163. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61164. visibleInInspector: boolean;
  61165. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61166. isConstant: boolean;
  61167. /** Gets or sets the group to use to display this block in the Inspector */
  61168. groupInInspector: string;
  61169. /** Gets an observable raised when the value is changed */
  61170. onValueChangedObservable: Observable<InputBlock>;
  61171. /**
  61172. * Gets or sets the connection point type (default is float)
  61173. */
  61174. get type(): NodeMaterialBlockConnectionPointTypes;
  61175. /**
  61176. * Creates a new InputBlock
  61177. * @param name defines the block name
  61178. * @param target defines the target of that block (Vertex by default)
  61179. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61180. */
  61181. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61182. /**
  61183. * Gets the output component
  61184. */
  61185. get output(): NodeMaterialConnectionPoint;
  61186. /**
  61187. * Set the source of this connection point to a vertex attribute
  61188. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61189. * @returns the current connection point
  61190. */
  61191. setAsAttribute(attributeName?: string): InputBlock;
  61192. /**
  61193. * Set the source of this connection point to a system value
  61194. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61195. * @returns the current connection point
  61196. */
  61197. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61198. /**
  61199. * Gets or sets the value of that point.
  61200. * Please note that this value will be ignored if valueCallback is defined
  61201. */
  61202. get value(): any;
  61203. set value(value: any);
  61204. /**
  61205. * Gets or sets a callback used to get the value of that point.
  61206. * Please note that setting this value will force the connection point to ignore the value property
  61207. */
  61208. get valueCallback(): () => any;
  61209. set valueCallback(value: () => any);
  61210. /**
  61211. * Gets or sets the associated variable name in the shader
  61212. */
  61213. get associatedVariableName(): string;
  61214. set associatedVariableName(value: string);
  61215. /** Gets or sets the type of animation applied to the input */
  61216. get animationType(): AnimatedInputBlockTypes;
  61217. set animationType(value: AnimatedInputBlockTypes);
  61218. /**
  61219. * Gets a boolean indicating that this connection point not defined yet
  61220. */
  61221. get isUndefined(): boolean;
  61222. /**
  61223. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61224. * In this case the connection point name must be the name of the uniform to use.
  61225. * Can only be set on inputs
  61226. */
  61227. get isUniform(): boolean;
  61228. set isUniform(value: boolean);
  61229. /**
  61230. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61231. * In this case the connection point name must be the name of the attribute to use
  61232. * Can only be set on inputs
  61233. */
  61234. get isAttribute(): boolean;
  61235. set isAttribute(value: boolean);
  61236. /**
  61237. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61238. * Can only be set on exit points
  61239. */
  61240. get isVarying(): boolean;
  61241. set isVarying(value: boolean);
  61242. /**
  61243. * Gets a boolean indicating that the current connection point is a system value
  61244. */
  61245. get isSystemValue(): boolean;
  61246. /**
  61247. * Gets or sets the current well known value or null if not defined as a system value
  61248. */
  61249. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61250. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61251. /**
  61252. * Gets the current class name
  61253. * @returns the class name
  61254. */
  61255. getClassName(): string;
  61256. /**
  61257. * Animate the input if animationType !== None
  61258. * @param scene defines the rendering scene
  61259. */
  61260. animate(scene: Scene): void;
  61261. private _emitDefine;
  61262. initialize(state: NodeMaterialBuildState): void;
  61263. /**
  61264. * Set the input block to its default value (based on its type)
  61265. */
  61266. setDefaultValue(): void;
  61267. private _emitConstant;
  61268. private _emit;
  61269. /** @hidden */
  61270. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61271. /** @hidden */
  61272. _transmit(effect: Effect, scene: Scene): void;
  61273. protected _buildBlock(state: NodeMaterialBuildState): void;
  61274. protected _dumpPropertiesCode(): string;
  61275. dispose(): void;
  61276. serialize(): any;
  61277. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61278. }
  61279. }
  61280. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61281. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61282. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61283. import { Nullable } from "babylonjs/types";
  61284. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61285. import { Observable } from "babylonjs/Misc/observable";
  61286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61287. /**
  61288. * Enum used to define the compatibility state between two connection points
  61289. */
  61290. export enum NodeMaterialConnectionPointCompatibilityStates {
  61291. /** Points are compatibles */
  61292. Compatible = 0,
  61293. /** Points are incompatible because of their types */
  61294. TypeIncompatible = 1,
  61295. /** Points are incompatible because of their targets (vertex vs fragment) */
  61296. TargetIncompatible = 2
  61297. }
  61298. /**
  61299. * Defines the direction of a connection point
  61300. */
  61301. export enum NodeMaterialConnectionPointDirection {
  61302. /** Input */
  61303. Input = 0,
  61304. /** Output */
  61305. Output = 1
  61306. }
  61307. /**
  61308. * Defines a connection point for a block
  61309. */
  61310. export class NodeMaterialConnectionPoint {
  61311. /** @hidden */
  61312. _ownerBlock: NodeMaterialBlock;
  61313. /** @hidden */
  61314. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61315. private _endpoints;
  61316. private _associatedVariableName;
  61317. private _direction;
  61318. /** @hidden */
  61319. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61320. /** @hidden */
  61321. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61322. private _type;
  61323. /** @hidden */
  61324. _enforceAssociatedVariableName: boolean;
  61325. /** Gets the direction of the point */
  61326. get direction(): NodeMaterialConnectionPointDirection;
  61327. /**
  61328. * Gets or sets the additional types supported by this connection point
  61329. */
  61330. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61331. /**
  61332. * Gets or sets the additional types excluded by this connection point
  61333. */
  61334. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61335. /**
  61336. * Observable triggered when this point is connected
  61337. */
  61338. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61339. /**
  61340. * Gets or sets the associated variable name in the shader
  61341. */
  61342. get associatedVariableName(): string;
  61343. set associatedVariableName(value: string);
  61344. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61345. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61346. /**
  61347. * Gets or sets the connection point type (default is float)
  61348. */
  61349. get type(): NodeMaterialBlockConnectionPointTypes;
  61350. set type(value: NodeMaterialBlockConnectionPointTypes);
  61351. /**
  61352. * Gets or sets the connection point name
  61353. */
  61354. name: string;
  61355. /**
  61356. * Gets or sets a boolean indicating that this connection point can be omitted
  61357. */
  61358. isOptional: boolean;
  61359. /**
  61360. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61361. */
  61362. define: string;
  61363. /** @hidden */
  61364. _prioritizeVertex: boolean;
  61365. private _target;
  61366. /** Gets or sets the target of that connection point */
  61367. get target(): NodeMaterialBlockTargets;
  61368. set target(value: NodeMaterialBlockTargets);
  61369. /**
  61370. * Gets a boolean indicating that the current point is connected
  61371. */
  61372. get isConnected(): boolean;
  61373. /**
  61374. * Gets a boolean indicating that the current point is connected to an input block
  61375. */
  61376. get isConnectedToInputBlock(): boolean;
  61377. /**
  61378. * Gets a the connected input block (if any)
  61379. */
  61380. get connectInputBlock(): Nullable<InputBlock>;
  61381. /** Get the other side of the connection (if any) */
  61382. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61383. /** Get the block that owns this connection point */
  61384. get ownerBlock(): NodeMaterialBlock;
  61385. /** Get the block connected on the other side of this connection (if any) */
  61386. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61387. /** Get the block connected on the endpoints of this connection (if any) */
  61388. get connectedBlocks(): Array<NodeMaterialBlock>;
  61389. /** Gets the list of connected endpoints */
  61390. get endpoints(): NodeMaterialConnectionPoint[];
  61391. /** Gets a boolean indicating if that output point is connected to at least one input */
  61392. get hasEndpoints(): boolean;
  61393. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61394. get isConnectedInVertexShader(): boolean;
  61395. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61396. get isConnectedInFragmentShader(): boolean;
  61397. /**
  61398. * Creates a new connection point
  61399. * @param name defines the connection point name
  61400. * @param ownerBlock defines the block hosting this connection point
  61401. * @param direction defines the direction of the connection point
  61402. */
  61403. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61404. /**
  61405. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61406. * @returns the class name
  61407. */
  61408. getClassName(): string;
  61409. /**
  61410. * Gets a boolean indicating if the current point can be connected to another point
  61411. * @param connectionPoint defines the other connection point
  61412. * @returns a boolean
  61413. */
  61414. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61415. /**
  61416. * Gets a number indicating if the current point can be connected to another point
  61417. * @param connectionPoint defines the other connection point
  61418. * @returns a number defining the compatibility state
  61419. */
  61420. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61421. /**
  61422. * Connect this point to another connection point
  61423. * @param connectionPoint defines the other connection point
  61424. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61425. * @returns the current connection point
  61426. */
  61427. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61428. /**
  61429. * Disconnect this point from one of his endpoint
  61430. * @param endpoint defines the other connection point
  61431. * @returns the current connection point
  61432. */
  61433. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61434. /**
  61435. * Serializes this point in a JSON representation
  61436. * @returns the serialized point object
  61437. */
  61438. serialize(): any;
  61439. /**
  61440. * Release resources
  61441. */
  61442. dispose(): void;
  61443. }
  61444. }
  61445. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61449. import { Mesh } from "babylonjs/Meshes/mesh";
  61450. import { Effect } from "babylonjs/Materials/effect";
  61451. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61452. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61453. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61454. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61455. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61456. /**
  61457. * Block used to add support for vertex skinning (bones)
  61458. */
  61459. export class BonesBlock extends NodeMaterialBlock {
  61460. /**
  61461. * Creates a new BonesBlock
  61462. * @param name defines the block name
  61463. */
  61464. constructor(name: string);
  61465. /**
  61466. * Initialize the block and prepare the context for build
  61467. * @param state defines the state that will be used for the build
  61468. */
  61469. initialize(state: NodeMaterialBuildState): void;
  61470. /**
  61471. * Gets the current class name
  61472. * @returns the class name
  61473. */
  61474. getClassName(): string;
  61475. /**
  61476. * Gets the matrix indices input component
  61477. */
  61478. get matricesIndices(): NodeMaterialConnectionPoint;
  61479. /**
  61480. * Gets the matrix weights input component
  61481. */
  61482. get matricesWeights(): NodeMaterialConnectionPoint;
  61483. /**
  61484. * Gets the extra matrix indices input component
  61485. */
  61486. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61487. /**
  61488. * Gets the extra matrix weights input component
  61489. */
  61490. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61491. /**
  61492. * Gets the world input component
  61493. */
  61494. get world(): NodeMaterialConnectionPoint;
  61495. /**
  61496. * Gets the output component
  61497. */
  61498. get output(): NodeMaterialConnectionPoint;
  61499. autoConfigure(material: NodeMaterial): void;
  61500. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61501. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61502. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61503. protected _buildBlock(state: NodeMaterialBuildState): this;
  61504. }
  61505. }
  61506. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61508. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61509. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61511. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61512. /**
  61513. * Block used to add support for instances
  61514. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61515. */
  61516. export class InstancesBlock extends NodeMaterialBlock {
  61517. /**
  61518. * Creates a new InstancesBlock
  61519. * @param name defines the block name
  61520. */
  61521. constructor(name: string);
  61522. /**
  61523. * Gets the current class name
  61524. * @returns the class name
  61525. */
  61526. getClassName(): string;
  61527. /**
  61528. * Gets the first world row input component
  61529. */
  61530. get world0(): NodeMaterialConnectionPoint;
  61531. /**
  61532. * Gets the second world row input component
  61533. */
  61534. get world1(): NodeMaterialConnectionPoint;
  61535. /**
  61536. * Gets the third world row input component
  61537. */
  61538. get world2(): NodeMaterialConnectionPoint;
  61539. /**
  61540. * Gets the forth world row input component
  61541. */
  61542. get world3(): NodeMaterialConnectionPoint;
  61543. /**
  61544. * Gets the world input component
  61545. */
  61546. get world(): NodeMaterialConnectionPoint;
  61547. /**
  61548. * Gets the output component
  61549. */
  61550. get output(): NodeMaterialConnectionPoint;
  61551. /**
  61552. * Gets the isntanceID component
  61553. */
  61554. get instanceID(): NodeMaterialConnectionPoint;
  61555. autoConfigure(material: NodeMaterial): void;
  61556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61557. protected _buildBlock(state: NodeMaterialBuildState): this;
  61558. }
  61559. }
  61560. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61565. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61566. import { Effect } from "babylonjs/Materials/effect";
  61567. import { Mesh } from "babylonjs/Meshes/mesh";
  61568. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61569. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61570. /**
  61571. * Block used to add morph targets support to vertex shader
  61572. */
  61573. export class MorphTargetsBlock extends NodeMaterialBlock {
  61574. private _repeatableContentAnchor;
  61575. /**
  61576. * Create a new MorphTargetsBlock
  61577. * @param name defines the block name
  61578. */
  61579. constructor(name: string);
  61580. /**
  61581. * Gets the current class name
  61582. * @returns the class name
  61583. */
  61584. getClassName(): string;
  61585. /**
  61586. * Gets the position input component
  61587. */
  61588. get position(): NodeMaterialConnectionPoint;
  61589. /**
  61590. * Gets the normal input component
  61591. */
  61592. get normal(): NodeMaterialConnectionPoint;
  61593. /**
  61594. * Gets the tangent input component
  61595. */
  61596. get tangent(): NodeMaterialConnectionPoint;
  61597. /**
  61598. * Gets the tangent input component
  61599. */
  61600. get uv(): NodeMaterialConnectionPoint;
  61601. /**
  61602. * Gets the position output component
  61603. */
  61604. get positionOutput(): NodeMaterialConnectionPoint;
  61605. /**
  61606. * Gets the normal output component
  61607. */
  61608. get normalOutput(): NodeMaterialConnectionPoint;
  61609. /**
  61610. * Gets the tangent output component
  61611. */
  61612. get tangentOutput(): NodeMaterialConnectionPoint;
  61613. /**
  61614. * Gets the tangent output component
  61615. */
  61616. get uvOutput(): NodeMaterialConnectionPoint;
  61617. initialize(state: NodeMaterialBuildState): void;
  61618. autoConfigure(material: NodeMaterial): void;
  61619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61620. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61621. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61622. protected _buildBlock(state: NodeMaterialBuildState): this;
  61623. }
  61624. }
  61625. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61629. import { Nullable } from "babylonjs/types";
  61630. import { Scene } from "babylonjs/scene";
  61631. import { Effect } from "babylonjs/Materials/effect";
  61632. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61633. import { Mesh } from "babylonjs/Meshes/mesh";
  61634. import { Light } from "babylonjs/Lights/light";
  61635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61636. /**
  61637. * Block used to get data information from a light
  61638. */
  61639. export class LightInformationBlock extends NodeMaterialBlock {
  61640. private _lightDataUniformName;
  61641. private _lightColorUniformName;
  61642. private _lightTypeDefineName;
  61643. /**
  61644. * Gets or sets the light associated with this block
  61645. */
  61646. light: Nullable<Light>;
  61647. /**
  61648. * Creates a new LightInformationBlock
  61649. * @param name defines the block name
  61650. */
  61651. constructor(name: string);
  61652. /**
  61653. * Gets the current class name
  61654. * @returns the class name
  61655. */
  61656. getClassName(): string;
  61657. /**
  61658. * Gets the world position input component
  61659. */
  61660. get worldPosition(): NodeMaterialConnectionPoint;
  61661. /**
  61662. * Gets the direction output component
  61663. */
  61664. get direction(): NodeMaterialConnectionPoint;
  61665. /**
  61666. * Gets the direction output component
  61667. */
  61668. get color(): NodeMaterialConnectionPoint;
  61669. /**
  61670. * Gets the direction output component
  61671. */
  61672. get intensity(): NodeMaterialConnectionPoint;
  61673. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61675. protected _buildBlock(state: NodeMaterialBuildState): this;
  61676. serialize(): any;
  61677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61678. }
  61679. }
  61680. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61681. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61682. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61683. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61684. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61685. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61686. }
  61687. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61692. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61693. import { Effect } from "babylonjs/Materials/effect";
  61694. import { Mesh } from "babylonjs/Meshes/mesh";
  61695. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61696. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61697. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61698. /**
  61699. * Block used to add image processing support to fragment shader
  61700. */
  61701. export class ImageProcessingBlock extends NodeMaterialBlock {
  61702. /**
  61703. * Create a new ImageProcessingBlock
  61704. * @param name defines the block name
  61705. */
  61706. constructor(name: string);
  61707. /**
  61708. * Gets the current class name
  61709. * @returns the class name
  61710. */
  61711. getClassName(): string;
  61712. /**
  61713. * Gets the color input component
  61714. */
  61715. get color(): NodeMaterialConnectionPoint;
  61716. /**
  61717. * Gets the output component
  61718. */
  61719. get output(): NodeMaterialConnectionPoint;
  61720. /**
  61721. * Initialize the block and prepare the context for build
  61722. * @param state defines the state that will be used for the build
  61723. */
  61724. initialize(state: NodeMaterialBuildState): void;
  61725. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61726. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61727. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61728. protected _buildBlock(state: NodeMaterialBuildState): this;
  61729. }
  61730. }
  61731. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61732. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61733. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61734. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61735. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61737. import { Effect } from "babylonjs/Materials/effect";
  61738. import { Mesh } from "babylonjs/Meshes/mesh";
  61739. import { Scene } from "babylonjs/scene";
  61740. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61741. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61742. /**
  61743. * Block used to pertub normals based on a normal map
  61744. */
  61745. export class PerturbNormalBlock extends NodeMaterialBlock {
  61746. private _tangentSpaceParameterName;
  61747. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61748. invertX: boolean;
  61749. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61750. invertY: boolean;
  61751. /**
  61752. * Create a new PerturbNormalBlock
  61753. * @param name defines the block name
  61754. */
  61755. constructor(name: string);
  61756. /**
  61757. * Gets the current class name
  61758. * @returns the class name
  61759. */
  61760. getClassName(): string;
  61761. /**
  61762. * Gets the world position input component
  61763. */
  61764. get worldPosition(): NodeMaterialConnectionPoint;
  61765. /**
  61766. * Gets the world normal input component
  61767. */
  61768. get worldNormal(): NodeMaterialConnectionPoint;
  61769. /**
  61770. * Gets the world tangent input component
  61771. */
  61772. get worldTangent(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the uv input component
  61775. */
  61776. get uv(): NodeMaterialConnectionPoint;
  61777. /**
  61778. * Gets the normal map color input component
  61779. */
  61780. get normalMapColor(): NodeMaterialConnectionPoint;
  61781. /**
  61782. * Gets the strength input component
  61783. */
  61784. get strength(): NodeMaterialConnectionPoint;
  61785. /**
  61786. * Gets the output component
  61787. */
  61788. get output(): NodeMaterialConnectionPoint;
  61789. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61790. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61791. autoConfigure(material: NodeMaterial): void;
  61792. protected _buildBlock(state: NodeMaterialBuildState): this;
  61793. protected _dumpPropertiesCode(): string;
  61794. serialize(): any;
  61795. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61796. }
  61797. }
  61798. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61801. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61802. /**
  61803. * Block used to discard a pixel if a value is smaller than a cutoff
  61804. */
  61805. export class DiscardBlock extends NodeMaterialBlock {
  61806. /**
  61807. * Create a new DiscardBlock
  61808. * @param name defines the block name
  61809. */
  61810. constructor(name: string);
  61811. /**
  61812. * Gets the current class name
  61813. * @returns the class name
  61814. */
  61815. getClassName(): string;
  61816. /**
  61817. * Gets the color input component
  61818. */
  61819. get value(): NodeMaterialConnectionPoint;
  61820. /**
  61821. * Gets the cutoff input component
  61822. */
  61823. get cutoff(): NodeMaterialConnectionPoint;
  61824. protected _buildBlock(state: NodeMaterialBuildState): this;
  61825. }
  61826. }
  61827. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61828. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61829. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61830. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61831. /**
  61832. * Block used to test if the fragment shader is front facing
  61833. */
  61834. export class FrontFacingBlock extends NodeMaterialBlock {
  61835. /**
  61836. * Creates a new FrontFacingBlock
  61837. * @param name defines the block name
  61838. */
  61839. constructor(name: string);
  61840. /**
  61841. * Gets the current class name
  61842. * @returns the class name
  61843. */
  61844. getClassName(): string;
  61845. /**
  61846. * Gets the output component
  61847. */
  61848. get output(): NodeMaterialConnectionPoint;
  61849. protected _buildBlock(state: NodeMaterialBuildState): this;
  61850. }
  61851. }
  61852. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61853. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61854. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61855. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61856. /**
  61857. * Block used to get the derivative value on x and y of a given input
  61858. */
  61859. export class DerivativeBlock extends NodeMaterialBlock {
  61860. /**
  61861. * Create a new DerivativeBlock
  61862. * @param name defines the block name
  61863. */
  61864. constructor(name: string);
  61865. /**
  61866. * Gets the current class name
  61867. * @returns the class name
  61868. */
  61869. getClassName(): string;
  61870. /**
  61871. * Gets the input component
  61872. */
  61873. get input(): NodeMaterialConnectionPoint;
  61874. /**
  61875. * Gets the derivative output on x
  61876. */
  61877. get dx(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the derivative output on y
  61880. */
  61881. get dy(): NodeMaterialConnectionPoint;
  61882. protected _buildBlock(state: NodeMaterialBuildState): this;
  61883. }
  61884. }
  61885. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61886. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61887. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61888. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61889. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61890. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61891. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61892. }
  61893. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61896. import { Mesh } from "babylonjs/Meshes/mesh";
  61897. import { Effect } from "babylonjs/Materials/effect";
  61898. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61900. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61901. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61902. /**
  61903. * Block used to add support for scene fog
  61904. */
  61905. export class FogBlock extends NodeMaterialBlock {
  61906. private _fogDistanceName;
  61907. private _fogParameters;
  61908. /**
  61909. * Create a new FogBlock
  61910. * @param name defines the block name
  61911. */
  61912. constructor(name: string);
  61913. /**
  61914. * Gets the current class name
  61915. * @returns the class name
  61916. */
  61917. getClassName(): string;
  61918. /**
  61919. * Gets the world position input component
  61920. */
  61921. get worldPosition(): NodeMaterialConnectionPoint;
  61922. /**
  61923. * Gets the view input component
  61924. */
  61925. get view(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the color input component
  61928. */
  61929. get input(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the fog color input component
  61932. */
  61933. get fogColor(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the output component
  61936. */
  61937. get output(): NodeMaterialConnectionPoint;
  61938. autoConfigure(material: NodeMaterial): void;
  61939. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61941. protected _buildBlock(state: NodeMaterialBuildState): this;
  61942. }
  61943. }
  61944. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61945. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61946. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61947. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61949. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61950. import { Effect } from "babylonjs/Materials/effect";
  61951. import { Mesh } from "babylonjs/Meshes/mesh";
  61952. import { Light } from "babylonjs/Lights/light";
  61953. import { Nullable } from "babylonjs/types";
  61954. import { Scene } from "babylonjs/scene";
  61955. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61956. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61957. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61958. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61959. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61960. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61961. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61962. /**
  61963. * Block used to add light in the fragment shader
  61964. */
  61965. export class LightBlock extends NodeMaterialBlock {
  61966. private _lightId;
  61967. /**
  61968. * Gets or sets the light associated with this block
  61969. */
  61970. light: Nullable<Light>;
  61971. /**
  61972. * Create a new LightBlock
  61973. * @param name defines the block name
  61974. */
  61975. constructor(name: string);
  61976. /**
  61977. * Gets the current class name
  61978. * @returns the class name
  61979. */
  61980. getClassName(): string;
  61981. /**
  61982. * Gets the world position input component
  61983. */
  61984. get worldPosition(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the world normal input component
  61987. */
  61988. get worldNormal(): NodeMaterialConnectionPoint;
  61989. /**
  61990. * Gets the camera (or eye) position component
  61991. */
  61992. get cameraPosition(): NodeMaterialConnectionPoint;
  61993. /**
  61994. * Gets the glossiness component
  61995. */
  61996. get glossiness(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the glossinness power component
  61999. */
  62000. get glossPower(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the diffuse color component
  62003. */
  62004. get diffuseColor(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the specular color component
  62007. */
  62008. get specularColor(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the diffuse output component
  62011. */
  62012. get diffuseOutput(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the specular output component
  62015. */
  62016. get specularOutput(): NodeMaterialConnectionPoint;
  62017. /**
  62018. * Gets the shadow output component
  62019. */
  62020. get shadow(): NodeMaterialConnectionPoint;
  62021. autoConfigure(material: NodeMaterial): void;
  62022. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62023. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62024. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62025. private _injectVertexCode;
  62026. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62027. serialize(): any;
  62028. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62029. }
  62030. }
  62031. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62032. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62033. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62034. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62035. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62036. }
  62037. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62038. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62039. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62040. }
  62041. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62042. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62043. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62044. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62045. /**
  62046. * Block used to multiply 2 values
  62047. */
  62048. export class MultiplyBlock extends NodeMaterialBlock {
  62049. /**
  62050. * Creates a new MultiplyBlock
  62051. * @param name defines the block name
  62052. */
  62053. constructor(name: string);
  62054. /**
  62055. * Gets the current class name
  62056. * @returns the class name
  62057. */
  62058. getClassName(): string;
  62059. /**
  62060. * Gets the left operand input component
  62061. */
  62062. get left(): NodeMaterialConnectionPoint;
  62063. /**
  62064. * Gets the right operand input component
  62065. */
  62066. get right(): NodeMaterialConnectionPoint;
  62067. /**
  62068. * Gets the output component
  62069. */
  62070. get output(): NodeMaterialConnectionPoint;
  62071. protected _buildBlock(state: NodeMaterialBuildState): this;
  62072. }
  62073. }
  62074. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62078. /**
  62079. * Block used to add 2 vectors
  62080. */
  62081. export class AddBlock extends NodeMaterialBlock {
  62082. /**
  62083. * Creates a new AddBlock
  62084. * @param name defines the block name
  62085. */
  62086. constructor(name: string);
  62087. /**
  62088. * Gets the current class name
  62089. * @returns the class name
  62090. */
  62091. getClassName(): string;
  62092. /**
  62093. * Gets the left operand input component
  62094. */
  62095. get left(): NodeMaterialConnectionPoint;
  62096. /**
  62097. * Gets the right operand input component
  62098. */
  62099. get right(): NodeMaterialConnectionPoint;
  62100. /**
  62101. * Gets the output component
  62102. */
  62103. get output(): NodeMaterialConnectionPoint;
  62104. protected _buildBlock(state: NodeMaterialBuildState): this;
  62105. }
  62106. }
  62107. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62111. /**
  62112. * Block used to scale a vector by a float
  62113. */
  62114. export class ScaleBlock extends NodeMaterialBlock {
  62115. /**
  62116. * Creates a new ScaleBlock
  62117. * @param name defines the block name
  62118. */
  62119. constructor(name: string);
  62120. /**
  62121. * Gets the current class name
  62122. * @returns the class name
  62123. */
  62124. getClassName(): string;
  62125. /**
  62126. * Gets the input component
  62127. */
  62128. get input(): NodeMaterialConnectionPoint;
  62129. /**
  62130. * Gets the factor input component
  62131. */
  62132. get factor(): NodeMaterialConnectionPoint;
  62133. /**
  62134. * Gets the output component
  62135. */
  62136. get output(): NodeMaterialConnectionPoint;
  62137. protected _buildBlock(state: NodeMaterialBuildState): this;
  62138. }
  62139. }
  62140. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62142. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62144. import { Scene } from "babylonjs/scene";
  62145. /**
  62146. * Block used to clamp a float
  62147. */
  62148. export class ClampBlock extends NodeMaterialBlock {
  62149. /** Gets or sets the minimum range */
  62150. minimum: number;
  62151. /** Gets or sets the maximum range */
  62152. maximum: number;
  62153. /**
  62154. * Creates a new ClampBlock
  62155. * @param name defines the block name
  62156. */
  62157. constructor(name: string);
  62158. /**
  62159. * Gets the current class name
  62160. * @returns the class name
  62161. */
  62162. getClassName(): string;
  62163. /**
  62164. * Gets the value input component
  62165. */
  62166. get value(): NodeMaterialConnectionPoint;
  62167. /**
  62168. * Gets the output component
  62169. */
  62170. get output(): NodeMaterialConnectionPoint;
  62171. protected _buildBlock(state: NodeMaterialBuildState): this;
  62172. protected _dumpPropertiesCode(): string;
  62173. serialize(): any;
  62174. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62175. }
  62176. }
  62177. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62181. /**
  62182. * Block used to apply a cross product between 2 vectors
  62183. */
  62184. export class CrossBlock extends NodeMaterialBlock {
  62185. /**
  62186. * Creates a new CrossBlock
  62187. * @param name defines the block name
  62188. */
  62189. constructor(name: string);
  62190. /**
  62191. * Gets the current class name
  62192. * @returns the class name
  62193. */
  62194. getClassName(): string;
  62195. /**
  62196. * Gets the left operand input component
  62197. */
  62198. get left(): NodeMaterialConnectionPoint;
  62199. /**
  62200. * Gets the right operand input component
  62201. */
  62202. get right(): NodeMaterialConnectionPoint;
  62203. /**
  62204. * Gets the output component
  62205. */
  62206. get output(): NodeMaterialConnectionPoint;
  62207. protected _buildBlock(state: NodeMaterialBuildState): this;
  62208. }
  62209. }
  62210. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62214. /**
  62215. * Block used to apply a dot product between 2 vectors
  62216. */
  62217. export class DotBlock extends NodeMaterialBlock {
  62218. /**
  62219. * Creates a new DotBlock
  62220. * @param name defines the block name
  62221. */
  62222. constructor(name: string);
  62223. /**
  62224. * Gets the current class name
  62225. * @returns the class name
  62226. */
  62227. getClassName(): string;
  62228. /**
  62229. * Gets the left operand input component
  62230. */
  62231. get left(): NodeMaterialConnectionPoint;
  62232. /**
  62233. * Gets the right operand input component
  62234. */
  62235. get right(): NodeMaterialConnectionPoint;
  62236. /**
  62237. * Gets the output component
  62238. */
  62239. get output(): NodeMaterialConnectionPoint;
  62240. protected _buildBlock(state: NodeMaterialBuildState): this;
  62241. }
  62242. }
  62243. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62247. import { Vector2 } from "babylonjs/Maths/math.vector";
  62248. import { Scene } from "babylonjs/scene";
  62249. /**
  62250. * Block used to remap a float from a range to a new one
  62251. */
  62252. export class RemapBlock extends NodeMaterialBlock {
  62253. /**
  62254. * Gets or sets the source range
  62255. */
  62256. sourceRange: Vector2;
  62257. /**
  62258. * Gets or sets the target range
  62259. */
  62260. targetRange: Vector2;
  62261. /**
  62262. * Creates a new RemapBlock
  62263. * @param name defines the block name
  62264. */
  62265. constructor(name: string);
  62266. /**
  62267. * Gets the current class name
  62268. * @returns the class name
  62269. */
  62270. getClassName(): string;
  62271. /**
  62272. * Gets the input component
  62273. */
  62274. get input(): NodeMaterialConnectionPoint;
  62275. /**
  62276. * Gets the source min input component
  62277. */
  62278. get sourceMin(): NodeMaterialConnectionPoint;
  62279. /**
  62280. * Gets the source max input component
  62281. */
  62282. get sourceMax(): NodeMaterialConnectionPoint;
  62283. /**
  62284. * Gets the target min input component
  62285. */
  62286. get targetMin(): NodeMaterialConnectionPoint;
  62287. /**
  62288. * Gets the target max input component
  62289. */
  62290. get targetMax(): NodeMaterialConnectionPoint;
  62291. /**
  62292. * Gets the output component
  62293. */
  62294. get output(): NodeMaterialConnectionPoint;
  62295. protected _buildBlock(state: NodeMaterialBuildState): this;
  62296. protected _dumpPropertiesCode(): string;
  62297. serialize(): any;
  62298. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62299. }
  62300. }
  62301. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62302. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62303. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62305. /**
  62306. * Block used to normalize a vector
  62307. */
  62308. export class NormalizeBlock extends NodeMaterialBlock {
  62309. /**
  62310. * Creates a new NormalizeBlock
  62311. * @param name defines the block name
  62312. */
  62313. constructor(name: string);
  62314. /**
  62315. * Gets the current class name
  62316. * @returns the class name
  62317. */
  62318. getClassName(): string;
  62319. /**
  62320. * Gets the input component
  62321. */
  62322. get input(): NodeMaterialConnectionPoint;
  62323. /**
  62324. * Gets the output component
  62325. */
  62326. get output(): NodeMaterialConnectionPoint;
  62327. protected _buildBlock(state: NodeMaterialBuildState): this;
  62328. }
  62329. }
  62330. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62331. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62332. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62333. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62334. import { Scene } from "babylonjs/scene";
  62335. /**
  62336. * Operations supported by the Trigonometry block
  62337. */
  62338. export enum TrigonometryBlockOperations {
  62339. /** Cos */
  62340. Cos = 0,
  62341. /** Sin */
  62342. Sin = 1,
  62343. /** Abs */
  62344. Abs = 2,
  62345. /** Exp */
  62346. Exp = 3,
  62347. /** Exp2 */
  62348. Exp2 = 4,
  62349. /** Round */
  62350. Round = 5,
  62351. /** Floor */
  62352. Floor = 6,
  62353. /** Ceiling */
  62354. Ceiling = 7,
  62355. /** Square root */
  62356. Sqrt = 8,
  62357. /** Log */
  62358. Log = 9,
  62359. /** Tangent */
  62360. Tan = 10,
  62361. /** Arc tangent */
  62362. ArcTan = 11,
  62363. /** Arc cosinus */
  62364. ArcCos = 12,
  62365. /** Arc sinus */
  62366. ArcSin = 13,
  62367. /** Fraction */
  62368. Fract = 14,
  62369. /** Sign */
  62370. Sign = 15,
  62371. /** To radians (from degrees) */
  62372. Radians = 16,
  62373. /** To degrees (from radians) */
  62374. Degrees = 17
  62375. }
  62376. /**
  62377. * Block used to apply trigonometry operation to floats
  62378. */
  62379. export class TrigonometryBlock extends NodeMaterialBlock {
  62380. /**
  62381. * Gets or sets the operation applied by the block
  62382. */
  62383. operation: TrigonometryBlockOperations;
  62384. /**
  62385. * Creates a new TrigonometryBlock
  62386. * @param name defines the block name
  62387. */
  62388. constructor(name: string);
  62389. /**
  62390. * Gets the current class name
  62391. * @returns the class name
  62392. */
  62393. getClassName(): string;
  62394. /**
  62395. * Gets the input component
  62396. */
  62397. get input(): NodeMaterialConnectionPoint;
  62398. /**
  62399. * Gets the output component
  62400. */
  62401. get output(): NodeMaterialConnectionPoint;
  62402. protected _buildBlock(state: NodeMaterialBuildState): this;
  62403. serialize(): any;
  62404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62405. protected _dumpPropertiesCode(): string;
  62406. }
  62407. }
  62408. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62411. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62412. /**
  62413. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62414. */
  62415. export class ColorMergerBlock extends NodeMaterialBlock {
  62416. /**
  62417. * Create a new ColorMergerBlock
  62418. * @param name defines the block name
  62419. */
  62420. constructor(name: string);
  62421. /**
  62422. * Gets the current class name
  62423. * @returns the class name
  62424. */
  62425. getClassName(): string;
  62426. /**
  62427. * Gets the rgb component (input)
  62428. */
  62429. get rgbIn(): NodeMaterialConnectionPoint;
  62430. /**
  62431. * Gets the r component (input)
  62432. */
  62433. get r(): NodeMaterialConnectionPoint;
  62434. /**
  62435. * Gets the g component (input)
  62436. */
  62437. get g(): NodeMaterialConnectionPoint;
  62438. /**
  62439. * Gets the b component (input)
  62440. */
  62441. get b(): NodeMaterialConnectionPoint;
  62442. /**
  62443. * Gets the a component (input)
  62444. */
  62445. get a(): NodeMaterialConnectionPoint;
  62446. /**
  62447. * Gets the rgba component (output)
  62448. */
  62449. get rgba(): NodeMaterialConnectionPoint;
  62450. /**
  62451. * Gets the rgb component (output)
  62452. */
  62453. get rgbOut(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the rgb component (output)
  62456. * @deprecated Please use rgbOut instead.
  62457. */
  62458. get rgb(): NodeMaterialConnectionPoint;
  62459. protected _buildBlock(state: NodeMaterialBuildState): this;
  62460. }
  62461. }
  62462. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62466. /**
  62467. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62468. */
  62469. export class VectorMergerBlock extends NodeMaterialBlock {
  62470. /**
  62471. * Create a new VectorMergerBlock
  62472. * @param name defines the block name
  62473. */
  62474. constructor(name: string);
  62475. /**
  62476. * Gets the current class name
  62477. * @returns the class name
  62478. */
  62479. getClassName(): string;
  62480. /**
  62481. * Gets the xyz component (input)
  62482. */
  62483. get xyzIn(): NodeMaterialConnectionPoint;
  62484. /**
  62485. * Gets the xy component (input)
  62486. */
  62487. get xyIn(): NodeMaterialConnectionPoint;
  62488. /**
  62489. * Gets the x component (input)
  62490. */
  62491. get x(): NodeMaterialConnectionPoint;
  62492. /**
  62493. * Gets the y component (input)
  62494. */
  62495. get y(): NodeMaterialConnectionPoint;
  62496. /**
  62497. * Gets the z component (input)
  62498. */
  62499. get z(): NodeMaterialConnectionPoint;
  62500. /**
  62501. * Gets the w component (input)
  62502. */
  62503. get w(): NodeMaterialConnectionPoint;
  62504. /**
  62505. * Gets the xyzw component (output)
  62506. */
  62507. get xyzw(): NodeMaterialConnectionPoint;
  62508. /**
  62509. * Gets the xyz component (output)
  62510. */
  62511. get xyzOut(): NodeMaterialConnectionPoint;
  62512. /**
  62513. * Gets the xy component (output)
  62514. */
  62515. get xyOut(): NodeMaterialConnectionPoint;
  62516. /**
  62517. * Gets the xy component (output)
  62518. * @deprecated Please use xyOut instead.
  62519. */
  62520. get xy(): NodeMaterialConnectionPoint;
  62521. /**
  62522. * Gets the xyz component (output)
  62523. * @deprecated Please use xyzOut instead.
  62524. */
  62525. get xyz(): NodeMaterialConnectionPoint;
  62526. protected _buildBlock(state: NodeMaterialBuildState): this;
  62527. }
  62528. }
  62529. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62531. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62532. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62533. /**
  62534. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62535. */
  62536. export class ColorSplitterBlock extends NodeMaterialBlock {
  62537. /**
  62538. * Create a new ColorSplitterBlock
  62539. * @param name defines the block name
  62540. */
  62541. constructor(name: string);
  62542. /**
  62543. * Gets the current class name
  62544. * @returns the class name
  62545. */
  62546. getClassName(): string;
  62547. /**
  62548. * Gets the rgba component (input)
  62549. */
  62550. get rgba(): NodeMaterialConnectionPoint;
  62551. /**
  62552. * Gets the rgb component (input)
  62553. */
  62554. get rgbIn(): NodeMaterialConnectionPoint;
  62555. /**
  62556. * Gets the rgb component (output)
  62557. */
  62558. get rgbOut(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the r component (output)
  62561. */
  62562. get r(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the g component (output)
  62565. */
  62566. get g(): NodeMaterialConnectionPoint;
  62567. /**
  62568. * Gets the b component (output)
  62569. */
  62570. get b(): NodeMaterialConnectionPoint;
  62571. /**
  62572. * Gets the a component (output)
  62573. */
  62574. get a(): NodeMaterialConnectionPoint;
  62575. protected _inputRename(name: string): string;
  62576. protected _outputRename(name: string): string;
  62577. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62578. }
  62579. }
  62580. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62584. /**
  62585. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62586. */
  62587. export class VectorSplitterBlock extends NodeMaterialBlock {
  62588. /**
  62589. * Create a new VectorSplitterBlock
  62590. * @param name defines the block name
  62591. */
  62592. constructor(name: string);
  62593. /**
  62594. * Gets the current class name
  62595. * @returns the class name
  62596. */
  62597. getClassName(): string;
  62598. /**
  62599. * Gets the xyzw component (input)
  62600. */
  62601. get xyzw(): NodeMaterialConnectionPoint;
  62602. /**
  62603. * Gets the xyz component (input)
  62604. */
  62605. get xyzIn(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the xy component (input)
  62608. */
  62609. get xyIn(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the xyz component (output)
  62612. */
  62613. get xyzOut(): NodeMaterialConnectionPoint;
  62614. /**
  62615. * Gets the xy component (output)
  62616. */
  62617. get xyOut(): NodeMaterialConnectionPoint;
  62618. /**
  62619. * Gets the x component (output)
  62620. */
  62621. get x(): NodeMaterialConnectionPoint;
  62622. /**
  62623. * Gets the y component (output)
  62624. */
  62625. get y(): NodeMaterialConnectionPoint;
  62626. /**
  62627. * Gets the z component (output)
  62628. */
  62629. get z(): NodeMaterialConnectionPoint;
  62630. /**
  62631. * Gets the w component (output)
  62632. */
  62633. get w(): NodeMaterialConnectionPoint;
  62634. protected _inputRename(name: string): string;
  62635. protected _outputRename(name: string): string;
  62636. protected _buildBlock(state: NodeMaterialBuildState): this;
  62637. }
  62638. }
  62639. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62643. /**
  62644. * Block used to lerp between 2 values
  62645. */
  62646. export class LerpBlock extends NodeMaterialBlock {
  62647. /**
  62648. * Creates a new LerpBlock
  62649. * @param name defines the block name
  62650. */
  62651. constructor(name: string);
  62652. /**
  62653. * Gets the current class name
  62654. * @returns the class name
  62655. */
  62656. getClassName(): string;
  62657. /**
  62658. * Gets the left operand input component
  62659. */
  62660. get left(): NodeMaterialConnectionPoint;
  62661. /**
  62662. * Gets the right operand input component
  62663. */
  62664. get right(): NodeMaterialConnectionPoint;
  62665. /**
  62666. * Gets the gradient operand input component
  62667. */
  62668. get gradient(): NodeMaterialConnectionPoint;
  62669. /**
  62670. * Gets the output component
  62671. */
  62672. get output(): NodeMaterialConnectionPoint;
  62673. protected _buildBlock(state: NodeMaterialBuildState): this;
  62674. }
  62675. }
  62676. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62677. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62678. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62679. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62680. /**
  62681. * Block used to divide 2 vectors
  62682. */
  62683. export class DivideBlock extends NodeMaterialBlock {
  62684. /**
  62685. * Creates a new DivideBlock
  62686. * @param name defines the block name
  62687. */
  62688. constructor(name: string);
  62689. /**
  62690. * Gets the current class name
  62691. * @returns the class name
  62692. */
  62693. getClassName(): string;
  62694. /**
  62695. * Gets the left operand input component
  62696. */
  62697. get left(): NodeMaterialConnectionPoint;
  62698. /**
  62699. * Gets the right operand input component
  62700. */
  62701. get right(): NodeMaterialConnectionPoint;
  62702. /**
  62703. * Gets the output component
  62704. */
  62705. get output(): NodeMaterialConnectionPoint;
  62706. protected _buildBlock(state: NodeMaterialBuildState): this;
  62707. }
  62708. }
  62709. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62711. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62712. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62713. /**
  62714. * Block used to subtract 2 vectors
  62715. */
  62716. export class SubtractBlock extends NodeMaterialBlock {
  62717. /**
  62718. * Creates a new SubtractBlock
  62719. * @param name defines the block name
  62720. */
  62721. constructor(name: string);
  62722. /**
  62723. * Gets the current class name
  62724. * @returns the class name
  62725. */
  62726. getClassName(): string;
  62727. /**
  62728. * Gets the left operand input component
  62729. */
  62730. get left(): NodeMaterialConnectionPoint;
  62731. /**
  62732. * Gets the right operand input component
  62733. */
  62734. get right(): NodeMaterialConnectionPoint;
  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/stepBlock" {
  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 step a value
  62748. */
  62749. export class StepBlock extends NodeMaterialBlock {
  62750. /**
  62751. * Creates a new StepBlock
  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 value operand input component
  62762. */
  62763. get value(): NodeMaterialConnectionPoint;
  62764. /**
  62765. * Gets the edge operand input component
  62766. */
  62767. get edge(): NodeMaterialConnectionPoint;
  62768. /**
  62769. * Gets the output component
  62770. */
  62771. get output(): NodeMaterialConnectionPoint;
  62772. protected _buildBlock(state: NodeMaterialBuildState): this;
  62773. }
  62774. }
  62775. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62776. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62777. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62778. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62779. /**
  62780. * Block used to get the opposite (1 - x) of a value
  62781. */
  62782. export class OneMinusBlock extends NodeMaterialBlock {
  62783. /**
  62784. * Creates a new OneMinusBlock
  62785. * @param name defines the block name
  62786. */
  62787. constructor(name: string);
  62788. /**
  62789. * Gets the current class name
  62790. * @returns the class name
  62791. */
  62792. getClassName(): string;
  62793. /**
  62794. * Gets the input component
  62795. */
  62796. get input(): NodeMaterialConnectionPoint;
  62797. /**
  62798. * Gets the output component
  62799. */
  62800. get output(): NodeMaterialConnectionPoint;
  62801. protected _buildBlock(state: NodeMaterialBuildState): this;
  62802. }
  62803. }
  62804. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62808. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62809. /**
  62810. * Block used to get the view direction
  62811. */
  62812. export class ViewDirectionBlock extends NodeMaterialBlock {
  62813. /**
  62814. * Creates a new ViewDirectionBlock
  62815. * @param name defines the block name
  62816. */
  62817. constructor(name: string);
  62818. /**
  62819. * Gets the current class name
  62820. * @returns the class name
  62821. */
  62822. getClassName(): string;
  62823. /**
  62824. * Gets the world position component
  62825. */
  62826. get worldPosition(): NodeMaterialConnectionPoint;
  62827. /**
  62828. * Gets the camera position component
  62829. */
  62830. get cameraPosition(): NodeMaterialConnectionPoint;
  62831. /**
  62832. * Gets the output component
  62833. */
  62834. get output(): NodeMaterialConnectionPoint;
  62835. autoConfigure(material: NodeMaterial): void;
  62836. protected _buildBlock(state: NodeMaterialBuildState): this;
  62837. }
  62838. }
  62839. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62840. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62841. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62842. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62843. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62844. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62845. /**
  62846. * Block used to compute fresnel value
  62847. */
  62848. export class FresnelBlock extends NodeMaterialBlock {
  62849. /**
  62850. * Create a new FresnelBlock
  62851. * @param name defines the block name
  62852. */
  62853. constructor(name: string);
  62854. /**
  62855. * Gets the current class name
  62856. * @returns the class name
  62857. */
  62858. getClassName(): string;
  62859. /**
  62860. * Gets the world normal input component
  62861. */
  62862. get worldNormal(): NodeMaterialConnectionPoint;
  62863. /**
  62864. * Gets the view direction input component
  62865. */
  62866. get viewDirection(): NodeMaterialConnectionPoint;
  62867. /**
  62868. * Gets the bias input component
  62869. */
  62870. get bias(): NodeMaterialConnectionPoint;
  62871. /**
  62872. * Gets the camera (or eye) position component
  62873. */
  62874. get power(): NodeMaterialConnectionPoint;
  62875. /**
  62876. * Gets the fresnel output component
  62877. */
  62878. get fresnel(): NodeMaterialConnectionPoint;
  62879. autoConfigure(material: NodeMaterial): void;
  62880. protected _buildBlock(state: NodeMaterialBuildState): this;
  62881. }
  62882. }
  62883. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62887. /**
  62888. * Block used to get the max of 2 values
  62889. */
  62890. export class MaxBlock extends NodeMaterialBlock {
  62891. /**
  62892. * Creates a new MaxBlock
  62893. * @param name defines the block name
  62894. */
  62895. constructor(name: string);
  62896. /**
  62897. * Gets the current class name
  62898. * @returns the class name
  62899. */
  62900. getClassName(): string;
  62901. /**
  62902. * Gets the left operand input component
  62903. */
  62904. get left(): NodeMaterialConnectionPoint;
  62905. /**
  62906. * Gets the right operand input component
  62907. */
  62908. get right(): NodeMaterialConnectionPoint;
  62909. /**
  62910. * Gets the output component
  62911. */
  62912. get output(): NodeMaterialConnectionPoint;
  62913. protected _buildBlock(state: NodeMaterialBuildState): this;
  62914. }
  62915. }
  62916. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62917. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62918. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62919. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62920. /**
  62921. * Block used to get the min of 2 values
  62922. */
  62923. export class MinBlock extends NodeMaterialBlock {
  62924. /**
  62925. * Creates a new MinBlock
  62926. * @param name defines the block name
  62927. */
  62928. constructor(name: string);
  62929. /**
  62930. * Gets the current class name
  62931. * @returns the class name
  62932. */
  62933. getClassName(): string;
  62934. /**
  62935. * Gets the left operand input component
  62936. */
  62937. get left(): NodeMaterialConnectionPoint;
  62938. /**
  62939. * Gets the right operand input component
  62940. */
  62941. get right(): NodeMaterialConnectionPoint;
  62942. /**
  62943. * Gets the output component
  62944. */
  62945. get output(): NodeMaterialConnectionPoint;
  62946. protected _buildBlock(state: NodeMaterialBuildState): this;
  62947. }
  62948. }
  62949. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62953. /**
  62954. * Block used to get the distance between 2 values
  62955. */
  62956. export class DistanceBlock extends NodeMaterialBlock {
  62957. /**
  62958. * Creates a new DistanceBlock
  62959. * @param name defines the block name
  62960. */
  62961. constructor(name: string);
  62962. /**
  62963. * Gets the current class name
  62964. * @returns the class name
  62965. */
  62966. getClassName(): string;
  62967. /**
  62968. * Gets the left operand input component
  62969. */
  62970. get left(): NodeMaterialConnectionPoint;
  62971. /**
  62972. * Gets the right operand input component
  62973. */
  62974. get right(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the output component
  62977. */
  62978. get output(): NodeMaterialConnectionPoint;
  62979. protected _buildBlock(state: NodeMaterialBuildState): this;
  62980. }
  62981. }
  62982. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62983. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62984. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62985. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62986. /**
  62987. * Block used to get the length of a vector
  62988. */
  62989. export class LengthBlock extends NodeMaterialBlock {
  62990. /**
  62991. * Creates a new LengthBlock
  62992. * @param name defines the block name
  62993. */
  62994. constructor(name: string);
  62995. /**
  62996. * Gets the current class name
  62997. * @returns the class name
  62998. */
  62999. getClassName(): string;
  63000. /**
  63001. * Gets the value input component
  63002. */
  63003. get value(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the output component
  63006. */
  63007. get output(): NodeMaterialConnectionPoint;
  63008. protected _buildBlock(state: NodeMaterialBuildState): this;
  63009. }
  63010. }
  63011. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63012. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63013. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63014. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63015. /**
  63016. * Block used to get negative version of a value (i.e. x * -1)
  63017. */
  63018. export class NegateBlock extends NodeMaterialBlock {
  63019. /**
  63020. * Creates a new NegateBlock
  63021. * @param name defines the block name
  63022. */
  63023. constructor(name: string);
  63024. /**
  63025. * Gets the current class name
  63026. * @returns the class name
  63027. */
  63028. getClassName(): string;
  63029. /**
  63030. * Gets the value input component
  63031. */
  63032. get value(): NodeMaterialConnectionPoint;
  63033. /**
  63034. * Gets the output component
  63035. */
  63036. get output(): NodeMaterialConnectionPoint;
  63037. protected _buildBlock(state: NodeMaterialBuildState): this;
  63038. }
  63039. }
  63040. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63044. /**
  63045. * Block used to get the value of the first parameter raised to the power of the second
  63046. */
  63047. export class PowBlock extends NodeMaterialBlock {
  63048. /**
  63049. * Creates a new PowBlock
  63050. * @param name defines the block name
  63051. */
  63052. constructor(name: string);
  63053. /**
  63054. * Gets the current class name
  63055. * @returns the class name
  63056. */
  63057. getClassName(): string;
  63058. /**
  63059. * Gets the value operand input component
  63060. */
  63061. get value(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the power operand input component
  63064. */
  63065. get power(): NodeMaterialConnectionPoint;
  63066. /**
  63067. * Gets the output component
  63068. */
  63069. get output(): NodeMaterialConnectionPoint;
  63070. protected _buildBlock(state: NodeMaterialBuildState): this;
  63071. }
  63072. }
  63073. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63077. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63078. /**
  63079. * Block used to get a random number
  63080. */
  63081. export class RandomNumberBlock extends NodeMaterialBlock {
  63082. /**
  63083. * Creates a new RandomNumberBlock
  63084. * @param name defines the block name
  63085. */
  63086. constructor(name: string);
  63087. /**
  63088. * Gets the current class name
  63089. * @returns the class name
  63090. */
  63091. getClassName(): string;
  63092. /**
  63093. * Gets the seed input component
  63094. */
  63095. get seed(): NodeMaterialConnectionPoint;
  63096. /**
  63097. * Gets the output component
  63098. */
  63099. get output(): NodeMaterialConnectionPoint;
  63100. protected _buildBlock(state: NodeMaterialBuildState): this;
  63101. }
  63102. }
  63103. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63104. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63105. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63106. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63107. /**
  63108. * Block used to compute arc tangent of 2 values
  63109. */
  63110. export class ArcTan2Block extends NodeMaterialBlock {
  63111. /**
  63112. * Creates a new ArcTan2Block
  63113. * @param name defines the block name
  63114. */
  63115. constructor(name: string);
  63116. /**
  63117. * Gets the current class name
  63118. * @returns the class name
  63119. */
  63120. getClassName(): string;
  63121. /**
  63122. * Gets the x operand input component
  63123. */
  63124. get x(): NodeMaterialConnectionPoint;
  63125. /**
  63126. * Gets the y operand input component
  63127. */
  63128. get y(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the output component
  63131. */
  63132. get output(): NodeMaterialConnectionPoint;
  63133. protected _buildBlock(state: NodeMaterialBuildState): this;
  63134. }
  63135. }
  63136. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63137. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63138. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63140. /**
  63141. * Block used to smooth step a value
  63142. */
  63143. export class SmoothStepBlock extends NodeMaterialBlock {
  63144. /**
  63145. * Creates a new SmoothStepBlock
  63146. * @param name defines the block name
  63147. */
  63148. constructor(name: string);
  63149. /**
  63150. * Gets the current class name
  63151. * @returns the class name
  63152. */
  63153. getClassName(): string;
  63154. /**
  63155. * Gets the value operand input component
  63156. */
  63157. get value(): NodeMaterialConnectionPoint;
  63158. /**
  63159. * Gets the first edge operand input component
  63160. */
  63161. get edge0(): NodeMaterialConnectionPoint;
  63162. /**
  63163. * Gets the second edge operand input component
  63164. */
  63165. get edge1(): NodeMaterialConnectionPoint;
  63166. /**
  63167. * Gets the output component
  63168. */
  63169. get output(): NodeMaterialConnectionPoint;
  63170. protected _buildBlock(state: NodeMaterialBuildState): this;
  63171. }
  63172. }
  63173. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63177. /**
  63178. * Block used to get the reciprocal (1 / x) of a value
  63179. */
  63180. export class ReciprocalBlock extends NodeMaterialBlock {
  63181. /**
  63182. * Creates a new ReciprocalBlock
  63183. * @param name defines the block name
  63184. */
  63185. constructor(name: string);
  63186. /**
  63187. * Gets the current class name
  63188. * @returns the class name
  63189. */
  63190. getClassName(): string;
  63191. /**
  63192. * Gets the input component
  63193. */
  63194. get input(): NodeMaterialConnectionPoint;
  63195. /**
  63196. * Gets the output component
  63197. */
  63198. get output(): NodeMaterialConnectionPoint;
  63199. protected _buildBlock(state: NodeMaterialBuildState): this;
  63200. }
  63201. }
  63202. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63204. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63205. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63206. /**
  63207. * Block used to replace a color by another one
  63208. */
  63209. export class ReplaceColorBlock extends NodeMaterialBlock {
  63210. /**
  63211. * Creates a new ReplaceColorBlock
  63212. * @param name defines the block name
  63213. */
  63214. constructor(name: string);
  63215. /**
  63216. * Gets the current class name
  63217. * @returns the class name
  63218. */
  63219. getClassName(): string;
  63220. /**
  63221. * Gets the value input component
  63222. */
  63223. get value(): NodeMaterialConnectionPoint;
  63224. /**
  63225. * Gets the reference input component
  63226. */
  63227. get reference(): NodeMaterialConnectionPoint;
  63228. /**
  63229. * Gets the distance input component
  63230. */
  63231. get distance(): NodeMaterialConnectionPoint;
  63232. /**
  63233. * Gets the replacement input component
  63234. */
  63235. get replacement(): NodeMaterialConnectionPoint;
  63236. /**
  63237. * Gets the output component
  63238. */
  63239. get output(): NodeMaterialConnectionPoint;
  63240. protected _buildBlock(state: NodeMaterialBuildState): this;
  63241. }
  63242. }
  63243. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63247. /**
  63248. * Block used to posterize a value
  63249. * @see https://en.wikipedia.org/wiki/Posterization
  63250. */
  63251. export class PosterizeBlock extends NodeMaterialBlock {
  63252. /**
  63253. * Creates a new PosterizeBlock
  63254. * @param name defines the block name
  63255. */
  63256. constructor(name: string);
  63257. /**
  63258. * Gets the current class name
  63259. * @returns the class name
  63260. */
  63261. getClassName(): string;
  63262. /**
  63263. * Gets the value input component
  63264. */
  63265. get value(): NodeMaterialConnectionPoint;
  63266. /**
  63267. * Gets the steps input component
  63268. */
  63269. get steps(): NodeMaterialConnectionPoint;
  63270. /**
  63271. * Gets the output component
  63272. */
  63273. get output(): NodeMaterialConnectionPoint;
  63274. protected _buildBlock(state: NodeMaterialBuildState): this;
  63275. }
  63276. }
  63277. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63281. import { Scene } from "babylonjs/scene";
  63282. /**
  63283. * Operations supported by the Wave block
  63284. */
  63285. export enum WaveBlockKind {
  63286. /** SawTooth */
  63287. SawTooth = 0,
  63288. /** Square */
  63289. Square = 1,
  63290. /** Triangle */
  63291. Triangle = 2
  63292. }
  63293. /**
  63294. * Block used to apply wave operation to floats
  63295. */
  63296. export class WaveBlock extends NodeMaterialBlock {
  63297. /**
  63298. * Gets or sets the kibnd of wave to be applied by the block
  63299. */
  63300. kind: WaveBlockKind;
  63301. /**
  63302. * Creates a new WaveBlock
  63303. * @param name defines the block name
  63304. */
  63305. constructor(name: string);
  63306. /**
  63307. * Gets the current class name
  63308. * @returns the class name
  63309. */
  63310. getClassName(): string;
  63311. /**
  63312. * Gets the input component
  63313. */
  63314. get input(): NodeMaterialConnectionPoint;
  63315. /**
  63316. * Gets the output component
  63317. */
  63318. get output(): NodeMaterialConnectionPoint;
  63319. protected _buildBlock(state: NodeMaterialBuildState): this;
  63320. serialize(): any;
  63321. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63322. }
  63323. }
  63324. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63325. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63326. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63327. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63328. import { Color3 } from "babylonjs/Maths/math.color";
  63329. import { Scene } from "babylonjs/scene";
  63330. /**
  63331. * Class used to store a color step for the GradientBlock
  63332. */
  63333. export class GradientBlockColorStep {
  63334. /**
  63335. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63336. */
  63337. step: number;
  63338. /**
  63339. * Gets or sets the color associated with this step
  63340. */
  63341. color: Color3;
  63342. /**
  63343. * Creates a new GradientBlockColorStep
  63344. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63345. * @param color defines the color associated with this step
  63346. */
  63347. constructor(
  63348. /**
  63349. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63350. */
  63351. step: number,
  63352. /**
  63353. * Gets or sets the color associated with this step
  63354. */
  63355. color: Color3);
  63356. }
  63357. /**
  63358. * Block used to return a color from a gradient based on an input value between 0 and 1
  63359. */
  63360. export class GradientBlock extends NodeMaterialBlock {
  63361. /**
  63362. * Gets or sets the list of color steps
  63363. */
  63364. colorSteps: GradientBlockColorStep[];
  63365. /**
  63366. * Creates a new GradientBlock
  63367. * @param name defines the block name
  63368. */
  63369. constructor(name: string);
  63370. /**
  63371. * Gets the current class name
  63372. * @returns the class name
  63373. */
  63374. getClassName(): string;
  63375. /**
  63376. * Gets the gradient input component
  63377. */
  63378. get gradient(): NodeMaterialConnectionPoint;
  63379. /**
  63380. * Gets the output component
  63381. */
  63382. get output(): NodeMaterialConnectionPoint;
  63383. private _writeColorConstant;
  63384. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63385. serialize(): any;
  63386. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63387. protected _dumpPropertiesCode(): string;
  63388. }
  63389. }
  63390. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63392. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63393. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63394. /**
  63395. * Block used to normalize lerp between 2 values
  63396. */
  63397. export class NLerpBlock extends NodeMaterialBlock {
  63398. /**
  63399. * Creates a new NLerpBlock
  63400. * @param name defines the block name
  63401. */
  63402. constructor(name: string);
  63403. /**
  63404. * Gets the current class name
  63405. * @returns the class name
  63406. */
  63407. getClassName(): string;
  63408. /**
  63409. * Gets the left operand input component
  63410. */
  63411. get left(): NodeMaterialConnectionPoint;
  63412. /**
  63413. * Gets the right operand input component
  63414. */
  63415. get right(): NodeMaterialConnectionPoint;
  63416. /**
  63417. * Gets the gradient operand input component
  63418. */
  63419. get gradient(): NodeMaterialConnectionPoint;
  63420. /**
  63421. * Gets the output component
  63422. */
  63423. get output(): NodeMaterialConnectionPoint;
  63424. protected _buildBlock(state: NodeMaterialBuildState): this;
  63425. }
  63426. }
  63427. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63430. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63431. import { Scene } from "babylonjs/scene";
  63432. /**
  63433. * block used to Generate a Worley Noise 3D Noise Pattern
  63434. */
  63435. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63436. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63437. manhattanDistance: boolean;
  63438. /**
  63439. * Creates a new WorleyNoise3DBlock
  63440. * @param name defines the block name
  63441. */
  63442. constructor(name: string);
  63443. /**
  63444. * Gets the current class name
  63445. * @returns the class name
  63446. */
  63447. getClassName(): string;
  63448. /**
  63449. * Gets the seed input component
  63450. */
  63451. get seed(): NodeMaterialConnectionPoint;
  63452. /**
  63453. * Gets the jitter input component
  63454. */
  63455. get jitter(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the output component
  63458. */
  63459. get output(): NodeMaterialConnectionPoint;
  63460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63461. /**
  63462. * Exposes the properties to the UI?
  63463. */
  63464. protected _dumpPropertiesCode(): string;
  63465. /**
  63466. * Exposes the properties to the Seralize?
  63467. */
  63468. serialize(): any;
  63469. /**
  63470. * Exposes the properties to the deseralize?
  63471. */
  63472. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63473. }
  63474. }
  63475. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63476. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63477. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63478. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63479. /**
  63480. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63481. */
  63482. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63483. /**
  63484. * Creates a new SimplexPerlin3DBlock
  63485. * @param name defines the block name
  63486. */
  63487. constructor(name: string);
  63488. /**
  63489. * Gets the current class name
  63490. * @returns the class name
  63491. */
  63492. getClassName(): string;
  63493. /**
  63494. * Gets the seed operand input component
  63495. */
  63496. get seed(): NodeMaterialConnectionPoint;
  63497. /**
  63498. * Gets the output component
  63499. */
  63500. get output(): NodeMaterialConnectionPoint;
  63501. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63502. }
  63503. }
  63504. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63508. /**
  63509. * Block used to blend normals
  63510. */
  63511. export class NormalBlendBlock extends NodeMaterialBlock {
  63512. /**
  63513. * Creates a new NormalBlendBlock
  63514. * @param name defines the block name
  63515. */
  63516. constructor(name: string);
  63517. /**
  63518. * Gets the current class name
  63519. * @returns the class name
  63520. */
  63521. getClassName(): string;
  63522. /**
  63523. * Gets the first input component
  63524. */
  63525. get normalMap0(): NodeMaterialConnectionPoint;
  63526. /**
  63527. * Gets the second input component
  63528. */
  63529. get normalMap1(): NodeMaterialConnectionPoint;
  63530. /**
  63531. * Gets the output component
  63532. */
  63533. get output(): NodeMaterialConnectionPoint;
  63534. protected _buildBlock(state: NodeMaterialBuildState): this;
  63535. }
  63536. }
  63537. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63541. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63542. /**
  63543. * Block used to rotate a 2d vector by a given angle
  63544. */
  63545. export class Rotate2dBlock extends NodeMaterialBlock {
  63546. /**
  63547. * Creates a new Rotate2dBlock
  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 input vector
  63558. */
  63559. get input(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the input angle
  63562. */
  63563. get angle(): NodeMaterialConnectionPoint;
  63564. /**
  63565. * Gets the output component
  63566. */
  63567. get output(): NodeMaterialConnectionPoint;
  63568. autoConfigure(material: NodeMaterial): void;
  63569. protected _buildBlock(state: NodeMaterialBuildState): this;
  63570. }
  63571. }
  63572. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63576. /**
  63577. * Block used to get the reflected vector from a direction and a normal
  63578. */
  63579. export class ReflectBlock extends NodeMaterialBlock {
  63580. /**
  63581. * Creates a new ReflectBlock
  63582. * @param name defines the block name
  63583. */
  63584. constructor(name: string);
  63585. /**
  63586. * Gets the current class name
  63587. * @returns the class name
  63588. */
  63589. getClassName(): string;
  63590. /**
  63591. * Gets the incident component
  63592. */
  63593. get incident(): NodeMaterialConnectionPoint;
  63594. /**
  63595. * Gets the normal component
  63596. */
  63597. get normal(): NodeMaterialConnectionPoint;
  63598. /**
  63599. * Gets the output component
  63600. */
  63601. get output(): NodeMaterialConnectionPoint;
  63602. protected _buildBlock(state: NodeMaterialBuildState): this;
  63603. }
  63604. }
  63605. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63609. /**
  63610. * Block used to get the refracted vector from a direction and a normal
  63611. */
  63612. export class RefractBlock extends NodeMaterialBlock {
  63613. /**
  63614. * Creates a new RefractBlock
  63615. * @param name defines the block name
  63616. */
  63617. constructor(name: string);
  63618. /**
  63619. * Gets the current class name
  63620. * @returns the class name
  63621. */
  63622. getClassName(): string;
  63623. /**
  63624. * Gets the incident component
  63625. */
  63626. get incident(): NodeMaterialConnectionPoint;
  63627. /**
  63628. * Gets the normal component
  63629. */
  63630. get normal(): NodeMaterialConnectionPoint;
  63631. /**
  63632. * Gets the index of refraction component
  63633. */
  63634. get ior(): NodeMaterialConnectionPoint;
  63635. /**
  63636. * Gets the output component
  63637. */
  63638. get output(): NodeMaterialConnectionPoint;
  63639. protected _buildBlock(state: NodeMaterialBuildState): this;
  63640. }
  63641. }
  63642. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63646. /**
  63647. * Block used to desaturate a color
  63648. */
  63649. export class DesaturateBlock extends NodeMaterialBlock {
  63650. /**
  63651. * Creates a new DesaturateBlock
  63652. * @param name defines the block name
  63653. */
  63654. constructor(name: string);
  63655. /**
  63656. * Gets the current class name
  63657. * @returns the class name
  63658. */
  63659. getClassName(): string;
  63660. /**
  63661. * Gets the color operand input component
  63662. */
  63663. get color(): NodeMaterialConnectionPoint;
  63664. /**
  63665. * Gets the level operand input component
  63666. */
  63667. get level(): NodeMaterialConnectionPoint;
  63668. /**
  63669. * Gets the output component
  63670. */
  63671. get output(): NodeMaterialConnectionPoint;
  63672. protected _buildBlock(state: NodeMaterialBuildState): this;
  63673. }
  63674. }
  63675. declare module "babylonjs/Materials/Node/Blocks/index" {
  63676. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63677. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63678. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63679. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63680. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63681. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63682. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63683. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63684. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63685. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63686. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63687. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63688. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63689. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63690. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63691. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63692. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63693. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63694. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63695. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63696. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63697. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63698. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63699. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63700. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63701. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63702. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63703. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63704. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63705. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63706. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63707. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63708. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63709. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63710. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63711. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63712. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63713. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63714. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63715. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63716. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63717. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63718. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63719. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63720. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63721. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63722. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63723. }
  63724. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63725. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63726. }
  63727. declare module "babylonjs/Materials/Node/index" {
  63728. export * from "babylonjs/Materials/Node/Enums/index";
  63729. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63730. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63731. export * from "babylonjs/Materials/Node/nodeMaterial";
  63732. export * from "babylonjs/Materials/Node/Blocks/index";
  63733. export * from "babylonjs/Materials/Node/Optimizers/index";
  63734. }
  63735. declare module "babylonjs/Materials/effectRenderer" {
  63736. import { Nullable } from "babylonjs/types";
  63737. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63738. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63739. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63740. import { Viewport } from "babylonjs/Maths/math.viewport";
  63741. import { Observable } from "babylonjs/Misc/observable";
  63742. import { Effect } from "babylonjs/Materials/effect";
  63743. import "babylonjs/Shaders/postprocess.vertex";
  63744. /**
  63745. * Effect Render Options
  63746. */
  63747. export interface IEffectRendererOptions {
  63748. /**
  63749. * Defines the vertices positions.
  63750. */
  63751. positions?: number[];
  63752. /**
  63753. * Defines the indices.
  63754. */
  63755. indices?: number[];
  63756. }
  63757. /**
  63758. * Helper class to render one or more effects.
  63759. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63760. */
  63761. export class EffectRenderer {
  63762. private engine;
  63763. private static _DefaultOptions;
  63764. private _vertexBuffers;
  63765. private _indexBuffer;
  63766. private _fullscreenViewport;
  63767. /**
  63768. * Creates an effect renderer
  63769. * @param engine the engine to use for rendering
  63770. * @param options defines the options of the effect renderer
  63771. */
  63772. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63773. /**
  63774. * Sets the current viewport in normalized coordinates 0-1
  63775. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63776. */
  63777. setViewport(viewport?: Viewport): void;
  63778. /**
  63779. * Binds the embedded attributes buffer to the effect.
  63780. * @param effect Defines the effect to bind the attributes for
  63781. */
  63782. bindBuffers(effect: Effect): void;
  63783. /**
  63784. * Sets the current effect wrapper to use during draw.
  63785. * The effect needs to be ready before calling this api.
  63786. * This also sets the default full screen position attribute.
  63787. * @param effectWrapper Defines the effect to draw with
  63788. */
  63789. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63790. /**
  63791. * Draws a full screen quad.
  63792. */
  63793. draw(): void;
  63794. private isRenderTargetTexture;
  63795. /**
  63796. * renders one or more effects to a specified texture
  63797. * @param effectWrapper the effect to renderer
  63798. * @param outputTexture texture to draw to, if null it will render to the screen.
  63799. */
  63800. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63801. /**
  63802. * Disposes of the effect renderer
  63803. */
  63804. dispose(): void;
  63805. }
  63806. /**
  63807. * Options to create an EffectWrapper
  63808. */
  63809. interface EffectWrapperCreationOptions {
  63810. /**
  63811. * Engine to use to create the effect
  63812. */
  63813. engine: ThinEngine;
  63814. /**
  63815. * Fragment shader for the effect
  63816. */
  63817. fragmentShader: string;
  63818. /**
  63819. * Vertex shader for the effect
  63820. */
  63821. vertexShader?: string;
  63822. /**
  63823. * Attributes to use in the shader
  63824. */
  63825. attributeNames?: Array<string>;
  63826. /**
  63827. * Uniforms to use in the shader
  63828. */
  63829. uniformNames?: Array<string>;
  63830. /**
  63831. * Texture sampler names to use in the shader
  63832. */
  63833. samplerNames?: Array<string>;
  63834. /**
  63835. * The friendly name of the effect displayed in Spector.
  63836. */
  63837. name?: string;
  63838. }
  63839. /**
  63840. * Wraps an effect to be used for rendering
  63841. */
  63842. export class EffectWrapper {
  63843. /**
  63844. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63845. */
  63846. onApplyObservable: Observable<{}>;
  63847. /**
  63848. * The underlying effect
  63849. */
  63850. effect: Effect;
  63851. /**
  63852. * Creates an effect to be renderer
  63853. * @param creationOptions options to create the effect
  63854. */
  63855. constructor(creationOptions: EffectWrapperCreationOptions);
  63856. /**
  63857. * Disposes of the effect wrapper
  63858. */
  63859. dispose(): void;
  63860. }
  63861. }
  63862. declare module "babylonjs/Materials/index" {
  63863. export * from "babylonjs/Materials/Background/index";
  63864. export * from "babylonjs/Materials/colorCurves";
  63865. export * from "babylonjs/Materials/iEffectFallbacks";
  63866. export * from "babylonjs/Materials/effectFallbacks";
  63867. export * from "babylonjs/Materials/effect";
  63868. export * from "babylonjs/Materials/fresnelParameters";
  63869. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63870. export * from "babylonjs/Materials/material";
  63871. export * from "babylonjs/Materials/materialDefines";
  63872. export * from "babylonjs/Materials/materialHelper";
  63873. export * from "babylonjs/Materials/multiMaterial";
  63874. export * from "babylonjs/Materials/PBR/index";
  63875. export * from "babylonjs/Materials/pushMaterial";
  63876. export * from "babylonjs/Materials/shaderMaterial";
  63877. export * from "babylonjs/Materials/standardMaterial";
  63878. export * from "babylonjs/Materials/Textures/index";
  63879. export * from "babylonjs/Materials/uniformBuffer";
  63880. export * from "babylonjs/Materials/materialFlags";
  63881. export * from "babylonjs/Materials/Node/index";
  63882. export * from "babylonjs/Materials/effectRenderer";
  63883. }
  63884. declare module "babylonjs/Maths/index" {
  63885. export * from "babylonjs/Maths/math.scalar";
  63886. export * from "babylonjs/Maths/math";
  63887. export * from "babylonjs/Maths/sphericalPolynomial";
  63888. }
  63889. declare module "babylonjs/Misc/workerPool" {
  63890. import { IDisposable } from "babylonjs/scene";
  63891. /**
  63892. * Helper class to push actions to a pool of workers.
  63893. */
  63894. export class WorkerPool implements IDisposable {
  63895. private _workerInfos;
  63896. private _pendingActions;
  63897. /**
  63898. * Constructor
  63899. * @param workers Array of workers to use for actions
  63900. */
  63901. constructor(workers: Array<Worker>);
  63902. /**
  63903. * Terminates all workers and clears any pending actions.
  63904. */
  63905. dispose(): void;
  63906. /**
  63907. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63908. * pended until a worker has completed its action.
  63909. * @param action The action to perform. Call onComplete when the action is complete.
  63910. */
  63911. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63912. private _execute;
  63913. }
  63914. }
  63915. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63916. import { IDisposable } from "babylonjs/scene";
  63917. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63918. /**
  63919. * Configuration for Draco compression
  63920. */
  63921. export interface IDracoCompressionConfiguration {
  63922. /**
  63923. * Configuration for the decoder.
  63924. */
  63925. decoder: {
  63926. /**
  63927. * The url to the WebAssembly module.
  63928. */
  63929. wasmUrl?: string;
  63930. /**
  63931. * The url to the WebAssembly binary.
  63932. */
  63933. wasmBinaryUrl?: string;
  63934. /**
  63935. * The url to the fallback JavaScript module.
  63936. */
  63937. fallbackUrl?: string;
  63938. };
  63939. }
  63940. /**
  63941. * Draco compression (https://google.github.io/draco/)
  63942. *
  63943. * This class wraps the Draco module.
  63944. *
  63945. * **Encoder**
  63946. *
  63947. * The encoder is not currently implemented.
  63948. *
  63949. * **Decoder**
  63950. *
  63951. * 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.
  63952. *
  63953. * To update the configuration, use the following code:
  63954. * ```javascript
  63955. * DracoCompression.Configuration = {
  63956. * decoder: {
  63957. * wasmUrl: "<url to the WebAssembly library>",
  63958. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63959. * fallbackUrl: "<url to the fallback JavaScript library>",
  63960. * }
  63961. * };
  63962. * ```
  63963. *
  63964. * 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.
  63965. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63966. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63967. *
  63968. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63969. * ```javascript
  63970. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63971. * ```
  63972. *
  63973. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63974. */
  63975. export class DracoCompression implements IDisposable {
  63976. private _workerPoolPromise?;
  63977. private _decoderModulePromise?;
  63978. /**
  63979. * The configuration. Defaults to the following urls:
  63980. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63981. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63982. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63983. */
  63984. static Configuration: IDracoCompressionConfiguration;
  63985. /**
  63986. * Returns true if the decoder configuration is available.
  63987. */
  63988. static get DecoderAvailable(): boolean;
  63989. /**
  63990. * Default number of workers to create when creating the draco compression object.
  63991. */
  63992. static DefaultNumWorkers: number;
  63993. private static GetDefaultNumWorkers;
  63994. private static _Default;
  63995. /**
  63996. * Default instance for the draco compression object.
  63997. */
  63998. static get Default(): DracoCompression;
  63999. /**
  64000. * Constructor
  64001. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64002. */
  64003. constructor(numWorkers?: number);
  64004. /**
  64005. * Stop all async operations and release resources.
  64006. */
  64007. dispose(): void;
  64008. /**
  64009. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64010. * @returns a promise that resolves when ready
  64011. */
  64012. whenReadyAsync(): Promise<void>;
  64013. /**
  64014. * Decode Draco compressed mesh data to vertex data.
  64015. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64016. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64017. * @returns A promise that resolves with the decoded vertex data
  64018. */
  64019. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64020. [kind: string]: number;
  64021. }): Promise<VertexData>;
  64022. }
  64023. }
  64024. declare module "babylonjs/Meshes/Compression/index" {
  64025. export * from "babylonjs/Meshes/Compression/dracoCompression";
  64026. }
  64027. declare module "babylonjs/Meshes/csg" {
  64028. import { Nullable } from "babylonjs/types";
  64029. import { Scene } from "babylonjs/scene";
  64030. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64031. import { Mesh } from "babylonjs/Meshes/mesh";
  64032. import { Material } from "babylonjs/Materials/material";
  64033. /**
  64034. * Class for building Constructive Solid Geometry
  64035. */
  64036. export class CSG {
  64037. private polygons;
  64038. /**
  64039. * The world matrix
  64040. */
  64041. matrix: Matrix;
  64042. /**
  64043. * Stores the position
  64044. */
  64045. position: Vector3;
  64046. /**
  64047. * Stores the rotation
  64048. */
  64049. rotation: Vector3;
  64050. /**
  64051. * Stores the rotation quaternion
  64052. */
  64053. rotationQuaternion: Nullable<Quaternion>;
  64054. /**
  64055. * Stores the scaling vector
  64056. */
  64057. scaling: Vector3;
  64058. /**
  64059. * Convert the Mesh to CSG
  64060. * @param mesh The Mesh to convert to CSG
  64061. * @returns A new CSG from the Mesh
  64062. */
  64063. static FromMesh(mesh: Mesh): CSG;
  64064. /**
  64065. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64066. * @param polygons Polygons used to construct a CSG solid
  64067. */
  64068. private static FromPolygons;
  64069. /**
  64070. * Clones, or makes a deep copy, of the CSG
  64071. * @returns A new CSG
  64072. */
  64073. clone(): CSG;
  64074. /**
  64075. * Unions this CSG with another CSG
  64076. * @param csg The CSG to union against this CSG
  64077. * @returns The unioned CSG
  64078. */
  64079. union(csg: CSG): CSG;
  64080. /**
  64081. * Unions this CSG with another CSG in place
  64082. * @param csg The CSG to union against this CSG
  64083. */
  64084. unionInPlace(csg: CSG): void;
  64085. /**
  64086. * Subtracts this CSG with another CSG
  64087. * @param csg The CSG to subtract against this CSG
  64088. * @returns A new CSG
  64089. */
  64090. subtract(csg: CSG): CSG;
  64091. /**
  64092. * Subtracts this CSG with another CSG in place
  64093. * @param csg The CSG to subtact against this CSG
  64094. */
  64095. subtractInPlace(csg: CSG): void;
  64096. /**
  64097. * Intersect this CSG with another CSG
  64098. * @param csg The CSG to intersect against this CSG
  64099. * @returns A new CSG
  64100. */
  64101. intersect(csg: CSG): CSG;
  64102. /**
  64103. * Intersects this CSG with another CSG in place
  64104. * @param csg The CSG to intersect against this CSG
  64105. */
  64106. intersectInPlace(csg: CSG): void;
  64107. /**
  64108. * Return a new CSG solid with solid and empty space switched. This solid is
  64109. * not modified.
  64110. * @returns A new CSG solid with solid and empty space switched
  64111. */
  64112. inverse(): CSG;
  64113. /**
  64114. * Inverses the CSG in place
  64115. */
  64116. inverseInPlace(): void;
  64117. /**
  64118. * This is used to keep meshes transformations so they can be restored
  64119. * when we build back a Babylon Mesh
  64120. * NB : All CSG operations are performed in world coordinates
  64121. * @param csg The CSG to copy the transform attributes from
  64122. * @returns This CSG
  64123. */
  64124. copyTransformAttributes(csg: CSG): CSG;
  64125. /**
  64126. * Build Raw mesh from CSG
  64127. * Coordinates here are in world space
  64128. * @param name The name of the mesh geometry
  64129. * @param scene The Scene
  64130. * @param keepSubMeshes Specifies if the submeshes should be kept
  64131. * @returns A new Mesh
  64132. */
  64133. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64134. /**
  64135. * Build Mesh from CSG taking material and transforms into account
  64136. * @param name The name of the Mesh
  64137. * @param material The material of the Mesh
  64138. * @param scene The Scene
  64139. * @param keepSubMeshes Specifies if submeshes should be kept
  64140. * @returns The new Mesh
  64141. */
  64142. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64143. }
  64144. }
  64145. declare module "babylonjs/Meshes/trailMesh" {
  64146. import { Mesh } from "babylonjs/Meshes/mesh";
  64147. import { Scene } from "babylonjs/scene";
  64148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64149. /**
  64150. * Class used to create a trail following a mesh
  64151. */
  64152. export class TrailMesh extends Mesh {
  64153. private _generator;
  64154. private _autoStart;
  64155. private _running;
  64156. private _diameter;
  64157. private _length;
  64158. private _sectionPolygonPointsCount;
  64159. private _sectionVectors;
  64160. private _sectionNormalVectors;
  64161. private _beforeRenderObserver;
  64162. /**
  64163. * @constructor
  64164. * @param name The value used by scene.getMeshByName() to do a lookup.
  64165. * @param generator The mesh or transform node to generate a trail.
  64166. * @param scene The scene to add this mesh to.
  64167. * @param diameter Diameter of trailing mesh. Default is 1.
  64168. * @param length Length of trailing mesh. Default is 60.
  64169. * @param autoStart Automatically start trailing mesh. Default true.
  64170. */
  64171. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64172. /**
  64173. * "TrailMesh"
  64174. * @returns "TrailMesh"
  64175. */
  64176. getClassName(): string;
  64177. private _createMesh;
  64178. /**
  64179. * Start trailing mesh.
  64180. */
  64181. start(): void;
  64182. /**
  64183. * Stop trailing mesh.
  64184. */
  64185. stop(): void;
  64186. /**
  64187. * Update trailing mesh geometry.
  64188. */
  64189. update(): void;
  64190. /**
  64191. * Returns a new TrailMesh object.
  64192. * @param name is a string, the name given to the new mesh
  64193. * @param newGenerator use new generator object for cloned trail mesh
  64194. * @returns a new mesh
  64195. */
  64196. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64197. /**
  64198. * Serializes this trail mesh
  64199. * @param serializationObject object to write serialization to
  64200. */
  64201. serialize(serializationObject: any): void;
  64202. /**
  64203. * Parses a serialized trail mesh
  64204. * @param parsedMesh the serialized mesh
  64205. * @param scene the scene to create the trail mesh in
  64206. * @returns the created trail mesh
  64207. */
  64208. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64209. }
  64210. }
  64211. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  64212. import { Nullable } from "babylonjs/types";
  64213. import { Scene } from "babylonjs/scene";
  64214. import { Vector4 } from "babylonjs/Maths/math.vector";
  64215. import { Color4 } from "babylonjs/Maths/math.color";
  64216. import { Mesh } from "babylonjs/Meshes/mesh";
  64217. /**
  64218. * Class containing static functions to help procedurally build meshes
  64219. */
  64220. export class TiledBoxBuilder {
  64221. /**
  64222. * Creates a box mesh
  64223. * 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)
  64224. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64228. * @param name defines the name of the mesh
  64229. * @param options defines the options used to create the mesh
  64230. * @param scene defines the hosting scene
  64231. * @returns the box mesh
  64232. */
  64233. static CreateTiledBox(name: string, options: {
  64234. pattern?: number;
  64235. width?: number;
  64236. height?: number;
  64237. depth?: number;
  64238. tileSize?: number;
  64239. tileWidth?: number;
  64240. tileHeight?: number;
  64241. alignHorizontal?: number;
  64242. alignVertical?: number;
  64243. faceUV?: Vector4[];
  64244. faceColors?: Color4[];
  64245. sideOrientation?: number;
  64246. updatable?: boolean;
  64247. }, scene?: Nullable<Scene>): Mesh;
  64248. }
  64249. }
  64250. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  64251. import { Vector4 } from "babylonjs/Maths/math.vector";
  64252. import { Mesh } from "babylonjs/Meshes/mesh";
  64253. /**
  64254. * Class containing static functions to help procedurally build meshes
  64255. */
  64256. export class TorusKnotBuilder {
  64257. /**
  64258. * Creates a torus knot mesh
  64259. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64260. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64261. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64262. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64266. * @param name defines the name of the mesh
  64267. * @param options defines the options used to create the mesh
  64268. * @param scene defines the hosting scene
  64269. * @returns the torus knot mesh
  64270. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64271. */
  64272. static CreateTorusKnot(name: string, options: {
  64273. radius?: number;
  64274. tube?: number;
  64275. radialSegments?: number;
  64276. tubularSegments?: number;
  64277. p?: number;
  64278. q?: number;
  64279. updatable?: boolean;
  64280. sideOrientation?: number;
  64281. frontUVs?: Vector4;
  64282. backUVs?: Vector4;
  64283. }, scene: any): Mesh;
  64284. }
  64285. }
  64286. declare module "babylonjs/Meshes/polygonMesh" {
  64287. import { Scene } from "babylonjs/scene";
  64288. import { Vector2 } from "babylonjs/Maths/math.vector";
  64289. import { Mesh } from "babylonjs/Meshes/mesh";
  64290. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64291. import { Path2 } from "babylonjs/Maths/math.path";
  64292. /**
  64293. * Polygon
  64294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64295. */
  64296. export class Polygon {
  64297. /**
  64298. * Creates a rectangle
  64299. * @param xmin bottom X coord
  64300. * @param ymin bottom Y coord
  64301. * @param xmax top X coord
  64302. * @param ymax top Y coord
  64303. * @returns points that make the resulting rectation
  64304. */
  64305. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64306. /**
  64307. * Creates a circle
  64308. * @param radius radius of circle
  64309. * @param cx scale in x
  64310. * @param cy scale in y
  64311. * @param numberOfSides number of sides that make up the circle
  64312. * @returns points that make the resulting circle
  64313. */
  64314. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64315. /**
  64316. * Creates a polygon from input string
  64317. * @param input Input polygon data
  64318. * @returns the parsed points
  64319. */
  64320. static Parse(input: string): Vector2[];
  64321. /**
  64322. * Starts building a polygon from x and y coordinates
  64323. * @param x x coordinate
  64324. * @param y y coordinate
  64325. * @returns the started path2
  64326. */
  64327. static StartingAt(x: number, y: number): Path2;
  64328. }
  64329. /**
  64330. * Builds a polygon
  64331. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64332. */
  64333. export class PolygonMeshBuilder {
  64334. private _points;
  64335. private _outlinepoints;
  64336. private _holes;
  64337. private _name;
  64338. private _scene;
  64339. private _epoints;
  64340. private _eholes;
  64341. private _addToepoint;
  64342. /**
  64343. * Babylon reference to the earcut plugin.
  64344. */
  64345. bjsEarcut: any;
  64346. /**
  64347. * Creates a PolygonMeshBuilder
  64348. * @param name name of the builder
  64349. * @param contours Path of the polygon
  64350. * @param scene scene to add to when creating the mesh
  64351. * @param earcutInjection can be used to inject your own earcut reference
  64352. */
  64353. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64354. /**
  64355. * Adds a whole within the polygon
  64356. * @param hole Array of points defining the hole
  64357. * @returns this
  64358. */
  64359. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64360. /**
  64361. * Creates the polygon
  64362. * @param updatable If the mesh should be updatable
  64363. * @param depth The depth of the mesh created
  64364. * @returns the created mesh
  64365. */
  64366. build(updatable?: boolean, depth?: number): Mesh;
  64367. /**
  64368. * Creates the polygon
  64369. * @param depth The depth of the mesh created
  64370. * @returns the created VertexData
  64371. */
  64372. buildVertexData(depth?: number): VertexData;
  64373. /**
  64374. * Adds a side to the polygon
  64375. * @param positions points that make the polygon
  64376. * @param normals normals of the polygon
  64377. * @param uvs uvs of the polygon
  64378. * @param indices indices of the polygon
  64379. * @param bounds bounds of the polygon
  64380. * @param points points of the polygon
  64381. * @param depth depth of the polygon
  64382. * @param flip flip of the polygon
  64383. */
  64384. private addSide;
  64385. }
  64386. }
  64387. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  64388. import { Scene } from "babylonjs/scene";
  64389. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64390. import { Color4 } from "babylonjs/Maths/math.color";
  64391. import { Mesh } from "babylonjs/Meshes/mesh";
  64392. import { Nullable } from "babylonjs/types";
  64393. /**
  64394. * Class containing static functions to help procedurally build meshes
  64395. */
  64396. export class PolygonBuilder {
  64397. /**
  64398. * Creates a polygon mesh
  64399. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64400. * * 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
  64401. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64403. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64404. * * Remember you can only change the shape positions, not their number when updating a polygon
  64405. * @param name defines the name of the mesh
  64406. * @param options defines the options used to create the mesh
  64407. * @param scene defines the hosting scene
  64408. * @param earcutInjection can be used to inject your own earcut reference
  64409. * @returns the polygon mesh
  64410. */
  64411. static CreatePolygon(name: string, options: {
  64412. shape: Vector3[];
  64413. holes?: Vector3[][];
  64414. depth?: number;
  64415. faceUV?: Vector4[];
  64416. faceColors?: Color4[];
  64417. updatable?: boolean;
  64418. sideOrientation?: number;
  64419. frontUVs?: Vector4;
  64420. backUVs?: Vector4;
  64421. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64422. /**
  64423. * Creates an extruded polygon mesh, with depth in the Y direction.
  64424. * * 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)
  64425. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64426. * @param name defines the name of the mesh
  64427. * @param options defines the options used to create the mesh
  64428. * @param scene defines the hosting scene
  64429. * @param earcutInjection can be used to inject your own earcut reference
  64430. * @returns the polygon mesh
  64431. */
  64432. static ExtrudePolygon(name: string, options: {
  64433. shape: Vector3[];
  64434. holes?: Vector3[][];
  64435. depth?: number;
  64436. faceUV?: Vector4[];
  64437. faceColors?: Color4[];
  64438. updatable?: boolean;
  64439. sideOrientation?: number;
  64440. frontUVs?: Vector4;
  64441. backUVs?: Vector4;
  64442. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64443. }
  64444. }
  64445. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64446. import { Scene } from "babylonjs/scene";
  64447. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64448. import { Mesh } from "babylonjs/Meshes/mesh";
  64449. import { Nullable } from "babylonjs/types";
  64450. /**
  64451. * Class containing static functions to help procedurally build meshes
  64452. */
  64453. export class LatheBuilder {
  64454. /**
  64455. * Creates lathe mesh.
  64456. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64457. * * 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
  64458. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64459. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64460. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64461. * * 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
  64462. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64463. * * 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
  64464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64468. * @param name defines the name of the mesh
  64469. * @param options defines the options used to create the mesh
  64470. * @param scene defines the hosting scene
  64471. * @returns the lathe mesh
  64472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64473. */
  64474. static CreateLathe(name: string, options: {
  64475. shape: Vector3[];
  64476. radius?: number;
  64477. tessellation?: number;
  64478. clip?: number;
  64479. arc?: number;
  64480. closed?: boolean;
  64481. updatable?: boolean;
  64482. sideOrientation?: number;
  64483. frontUVs?: Vector4;
  64484. backUVs?: Vector4;
  64485. cap?: number;
  64486. invertUV?: boolean;
  64487. }, scene?: Nullable<Scene>): Mesh;
  64488. }
  64489. }
  64490. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64491. import { Nullable } from "babylonjs/types";
  64492. import { Scene } from "babylonjs/scene";
  64493. import { Vector4 } from "babylonjs/Maths/math.vector";
  64494. import { Mesh } from "babylonjs/Meshes/mesh";
  64495. /**
  64496. * Class containing static functions to help procedurally build meshes
  64497. */
  64498. export class TiledPlaneBuilder {
  64499. /**
  64500. * Creates a tiled plane mesh
  64501. * * The parameter `pattern` will, depending on value, do nothing or
  64502. * * * flip (reflect about central vertical) alternate tiles across and up
  64503. * * * flip every tile on alternate rows
  64504. * * * rotate (180 degs) alternate tiles across and up
  64505. * * * rotate every tile on alternate rows
  64506. * * * flip and rotate alternate tiles across and up
  64507. * * * flip and rotate every tile on alternate rows
  64508. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64509. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64511. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64512. * * 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)
  64513. * * 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)
  64514. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64515. * @param name defines the name of the mesh
  64516. * @param options defines the options used to create the mesh
  64517. * @param scene defines the hosting scene
  64518. * @returns the box mesh
  64519. */
  64520. static CreateTiledPlane(name: string, options: {
  64521. pattern?: number;
  64522. tileSize?: number;
  64523. tileWidth?: number;
  64524. tileHeight?: number;
  64525. size?: number;
  64526. width?: number;
  64527. height?: number;
  64528. alignHorizontal?: number;
  64529. alignVertical?: number;
  64530. sideOrientation?: number;
  64531. frontUVs?: Vector4;
  64532. backUVs?: Vector4;
  64533. updatable?: boolean;
  64534. }, scene?: Nullable<Scene>): Mesh;
  64535. }
  64536. }
  64537. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64538. import { Nullable } from "babylonjs/types";
  64539. import { Scene } from "babylonjs/scene";
  64540. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64541. import { Mesh } from "babylonjs/Meshes/mesh";
  64542. /**
  64543. * Class containing static functions to help procedurally build meshes
  64544. */
  64545. export class TubeBuilder {
  64546. /**
  64547. * Creates a tube mesh.
  64548. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64549. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64550. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64551. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64552. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64553. * * 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)
  64554. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64555. * * 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
  64556. * * 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
  64557. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64558. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64559. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64560. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64561. * @param name defines the name of the mesh
  64562. * @param options defines the options used to create the mesh
  64563. * @param scene defines the hosting scene
  64564. * @returns the tube mesh
  64565. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64566. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64567. */
  64568. static CreateTube(name: string, options: {
  64569. path: Vector3[];
  64570. radius?: number;
  64571. tessellation?: number;
  64572. radiusFunction?: {
  64573. (i: number, distance: number): number;
  64574. };
  64575. cap?: number;
  64576. arc?: number;
  64577. updatable?: boolean;
  64578. sideOrientation?: number;
  64579. frontUVs?: Vector4;
  64580. backUVs?: Vector4;
  64581. instance?: Mesh;
  64582. invertUV?: boolean;
  64583. }, scene?: Nullable<Scene>): Mesh;
  64584. }
  64585. }
  64586. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64587. import { Scene } from "babylonjs/scene";
  64588. import { Vector4 } from "babylonjs/Maths/math.vector";
  64589. import { Mesh } from "babylonjs/Meshes/mesh";
  64590. import { Nullable } from "babylonjs/types";
  64591. /**
  64592. * Class containing static functions to help procedurally build meshes
  64593. */
  64594. export class IcoSphereBuilder {
  64595. /**
  64596. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64597. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64598. * * 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`)
  64599. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64600. * * 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
  64601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64604. * @param name defines the name of the mesh
  64605. * @param options defines the options used to create the mesh
  64606. * @param scene defines the hosting scene
  64607. * @returns the icosahedron mesh
  64608. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64609. */
  64610. static CreateIcoSphere(name: string, options: {
  64611. radius?: number;
  64612. radiusX?: number;
  64613. radiusY?: number;
  64614. radiusZ?: number;
  64615. flat?: boolean;
  64616. subdivisions?: number;
  64617. sideOrientation?: number;
  64618. frontUVs?: Vector4;
  64619. backUVs?: Vector4;
  64620. updatable?: boolean;
  64621. }, scene?: Nullable<Scene>): Mesh;
  64622. }
  64623. }
  64624. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64625. import { Vector3 } from "babylonjs/Maths/math.vector";
  64626. import { Mesh } from "babylonjs/Meshes/mesh";
  64627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64628. /**
  64629. * Class containing static functions to help procedurally build meshes
  64630. */
  64631. export class DecalBuilder {
  64632. /**
  64633. * Creates a decal mesh.
  64634. * 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
  64635. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64636. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64637. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64638. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64639. * @param name defines the name of the mesh
  64640. * @param sourceMesh defines the mesh where the decal must be applied
  64641. * @param options defines the options used to create the mesh
  64642. * @param scene defines the hosting scene
  64643. * @returns the decal mesh
  64644. * @see https://doc.babylonjs.com/how_to/decals
  64645. */
  64646. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64647. position?: Vector3;
  64648. normal?: Vector3;
  64649. size?: Vector3;
  64650. angle?: number;
  64651. }): Mesh;
  64652. }
  64653. }
  64654. declare module "babylonjs/Meshes/meshBuilder" {
  64655. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64656. import { Nullable } from "babylonjs/types";
  64657. import { Scene } from "babylonjs/scene";
  64658. import { Mesh } from "babylonjs/Meshes/mesh";
  64659. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64660. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64662. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64663. import { Plane } from "babylonjs/Maths/math.plane";
  64664. /**
  64665. * Class containing static functions to help procedurally build meshes
  64666. */
  64667. export class MeshBuilder {
  64668. /**
  64669. * Creates a box mesh
  64670. * * The parameter `size` sets the size (float) of each box side (default 1)
  64671. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64672. * * 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)
  64673. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64677. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64678. * @param name defines the name of the mesh
  64679. * @param options defines the options used to create the mesh
  64680. * @param scene defines the hosting scene
  64681. * @returns the box mesh
  64682. */
  64683. static CreateBox(name: string, options: {
  64684. size?: number;
  64685. width?: number;
  64686. height?: number;
  64687. depth?: number;
  64688. faceUV?: Vector4[];
  64689. faceColors?: Color4[];
  64690. sideOrientation?: number;
  64691. frontUVs?: Vector4;
  64692. backUVs?: Vector4;
  64693. wrap?: boolean;
  64694. topBaseAt?: number;
  64695. bottomBaseAt?: number;
  64696. updatable?: boolean;
  64697. }, scene?: Nullable<Scene>): Mesh;
  64698. /**
  64699. * Creates a tiled box mesh
  64700. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64702. * @param name defines the name of the mesh
  64703. * @param options defines the options used to create the mesh
  64704. * @param scene defines the hosting scene
  64705. * @returns the tiled box mesh
  64706. */
  64707. static CreateTiledBox(name: string, options: {
  64708. pattern?: number;
  64709. size?: number;
  64710. width?: number;
  64711. height?: number;
  64712. depth: number;
  64713. tileSize?: number;
  64714. tileWidth?: number;
  64715. tileHeight?: number;
  64716. faceUV?: Vector4[];
  64717. faceColors?: Color4[];
  64718. alignHorizontal?: number;
  64719. alignVertical?: number;
  64720. sideOrientation?: number;
  64721. updatable?: boolean;
  64722. }, scene?: Nullable<Scene>): Mesh;
  64723. /**
  64724. * Creates a sphere mesh
  64725. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64726. * * 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`)
  64727. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64728. * * 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
  64729. * * 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)
  64730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64733. * @param name defines the name of the mesh
  64734. * @param options defines the options used to create the mesh
  64735. * @param scene defines the hosting scene
  64736. * @returns the sphere mesh
  64737. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64738. */
  64739. static CreateSphere(name: string, options: {
  64740. segments?: number;
  64741. diameter?: number;
  64742. diameterX?: number;
  64743. diameterY?: number;
  64744. diameterZ?: number;
  64745. arc?: number;
  64746. slice?: number;
  64747. sideOrientation?: number;
  64748. frontUVs?: Vector4;
  64749. backUVs?: Vector4;
  64750. updatable?: boolean;
  64751. }, scene?: Nullable<Scene>): Mesh;
  64752. /**
  64753. * Creates a plane polygonal mesh. By default, this is a disc
  64754. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64755. * * 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
  64756. * * 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
  64757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64760. * @param name defines the name of the mesh
  64761. * @param options defines the options used to create the mesh
  64762. * @param scene defines the hosting scene
  64763. * @returns the plane polygonal mesh
  64764. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64765. */
  64766. static CreateDisc(name: string, options: {
  64767. radius?: number;
  64768. tessellation?: number;
  64769. arc?: number;
  64770. updatable?: boolean;
  64771. sideOrientation?: number;
  64772. frontUVs?: Vector4;
  64773. backUVs?: Vector4;
  64774. }, scene?: Nullable<Scene>): Mesh;
  64775. /**
  64776. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64777. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64778. * * 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`)
  64779. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64780. * * 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
  64781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64784. * @param name defines the name of the mesh
  64785. * @param options defines the options used to create the mesh
  64786. * @param scene defines the hosting scene
  64787. * @returns the icosahedron mesh
  64788. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64789. */
  64790. static CreateIcoSphere(name: string, options: {
  64791. radius?: number;
  64792. radiusX?: number;
  64793. radiusY?: number;
  64794. radiusZ?: number;
  64795. flat?: boolean;
  64796. subdivisions?: number;
  64797. sideOrientation?: number;
  64798. frontUVs?: Vector4;
  64799. backUVs?: Vector4;
  64800. updatable?: boolean;
  64801. }, scene?: Nullable<Scene>): Mesh;
  64802. /**
  64803. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64804. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64805. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64806. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64807. * * 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
  64808. * * 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
  64809. * * 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
  64810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64812. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64813. * * 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
  64814. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64815. * * 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
  64816. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64818. * @param name defines the name of the mesh
  64819. * @param options defines the options used to create the mesh
  64820. * @param scene defines the hosting scene
  64821. * @returns the ribbon mesh
  64822. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64823. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64824. */
  64825. static CreateRibbon(name: string, options: {
  64826. pathArray: Vector3[][];
  64827. closeArray?: boolean;
  64828. closePath?: boolean;
  64829. offset?: number;
  64830. updatable?: boolean;
  64831. sideOrientation?: number;
  64832. frontUVs?: Vector4;
  64833. backUVs?: Vector4;
  64834. instance?: Mesh;
  64835. invertUV?: boolean;
  64836. uvs?: Vector2[];
  64837. colors?: Color4[];
  64838. }, scene?: Nullable<Scene>): Mesh;
  64839. /**
  64840. * Creates a cylinder or a cone mesh
  64841. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64842. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64843. * * 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.
  64844. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64845. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64846. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64847. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64848. * * 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).
  64849. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64850. * * 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).
  64851. * * 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
  64852. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64853. * * 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
  64854. * * 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.
  64855. * * If `enclose` is false, a ring surface is one element.
  64856. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64857. * * 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
  64858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64861. * @param name defines the name of the mesh
  64862. * @param options defines the options used to create the mesh
  64863. * @param scene defines the hosting scene
  64864. * @returns the cylinder mesh
  64865. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64866. */
  64867. static CreateCylinder(name: string, options: {
  64868. height?: number;
  64869. diameterTop?: number;
  64870. diameterBottom?: number;
  64871. diameter?: number;
  64872. tessellation?: number;
  64873. subdivisions?: number;
  64874. arc?: number;
  64875. faceColors?: Color4[];
  64876. faceUV?: Vector4[];
  64877. updatable?: boolean;
  64878. hasRings?: boolean;
  64879. enclose?: boolean;
  64880. cap?: number;
  64881. sideOrientation?: number;
  64882. frontUVs?: Vector4;
  64883. backUVs?: Vector4;
  64884. }, scene?: Nullable<Scene>): Mesh;
  64885. /**
  64886. * Creates a torus mesh
  64887. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64888. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64889. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64893. * @param name defines the name of the mesh
  64894. * @param options defines the options used to create the mesh
  64895. * @param scene defines the hosting scene
  64896. * @returns the torus mesh
  64897. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64898. */
  64899. static CreateTorus(name: string, options: {
  64900. diameter?: number;
  64901. thickness?: number;
  64902. tessellation?: number;
  64903. updatable?: boolean;
  64904. sideOrientation?: number;
  64905. frontUVs?: Vector4;
  64906. backUVs?: Vector4;
  64907. }, scene?: Nullable<Scene>): Mesh;
  64908. /**
  64909. * Creates a torus knot mesh
  64910. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64911. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64912. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64913. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64917. * @param name defines the name of the mesh
  64918. * @param options defines the options used to create the mesh
  64919. * @param scene defines the hosting scene
  64920. * @returns the torus knot mesh
  64921. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64922. */
  64923. static CreateTorusKnot(name: string, options: {
  64924. radius?: number;
  64925. tube?: number;
  64926. radialSegments?: number;
  64927. tubularSegments?: number;
  64928. p?: number;
  64929. q?: number;
  64930. updatable?: boolean;
  64931. sideOrientation?: number;
  64932. frontUVs?: Vector4;
  64933. backUVs?: Vector4;
  64934. }, scene?: Nullable<Scene>): Mesh;
  64935. /**
  64936. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64937. * * 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
  64938. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64939. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64940. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64941. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64942. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64943. * * 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
  64944. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64946. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64947. * @param name defines the name of the new line system
  64948. * @param options defines the options used to create the line system
  64949. * @param scene defines the hosting scene
  64950. * @returns a new line system mesh
  64951. */
  64952. static CreateLineSystem(name: string, options: {
  64953. lines: Vector3[][];
  64954. updatable?: boolean;
  64955. instance?: Nullable<LinesMesh>;
  64956. colors?: Nullable<Color4[][]>;
  64957. useVertexAlpha?: boolean;
  64958. }, scene: Nullable<Scene>): LinesMesh;
  64959. /**
  64960. * Creates a line mesh
  64961. * 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
  64962. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64963. * * The parameter `points` is an array successive Vector3
  64964. * * 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
  64965. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64966. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64967. * * When updating an instance, remember that only point positions can change, not the number of points
  64968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64970. * @param name defines the name of the new line system
  64971. * @param options defines the options used to create the line system
  64972. * @param scene defines the hosting scene
  64973. * @returns a new line mesh
  64974. */
  64975. static CreateLines(name: string, options: {
  64976. points: Vector3[];
  64977. updatable?: boolean;
  64978. instance?: Nullable<LinesMesh>;
  64979. colors?: Color4[];
  64980. useVertexAlpha?: boolean;
  64981. }, scene?: Nullable<Scene>): LinesMesh;
  64982. /**
  64983. * Creates a dashed line mesh
  64984. * * 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
  64985. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64986. * * The parameter `points` is an array successive Vector3
  64987. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64988. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64989. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64990. * * 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
  64991. * * When updating an instance, remember that only point positions can change, not the number of points
  64992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64993. * @param name defines the name of the mesh
  64994. * @param options defines the options used to create the mesh
  64995. * @param scene defines the hosting scene
  64996. * @returns the dashed line mesh
  64997. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64998. */
  64999. static CreateDashedLines(name: string, options: {
  65000. points: Vector3[];
  65001. dashSize?: number;
  65002. gapSize?: number;
  65003. dashNb?: number;
  65004. updatable?: boolean;
  65005. instance?: LinesMesh;
  65006. }, scene?: Nullable<Scene>): LinesMesh;
  65007. /**
  65008. * 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.
  65009. * * 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.
  65010. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65011. * * 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.
  65012. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65013. * * 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
  65014. * * 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
  65015. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65016. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65017. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65018. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65020. * @param name defines the name of the mesh
  65021. * @param options defines the options used to create the mesh
  65022. * @param scene defines the hosting scene
  65023. * @returns the extruded shape mesh
  65024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65025. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65026. */
  65027. static ExtrudeShape(name: string, options: {
  65028. shape: Vector3[];
  65029. path: Vector3[];
  65030. scale?: number;
  65031. rotation?: number;
  65032. cap?: number;
  65033. updatable?: boolean;
  65034. sideOrientation?: number;
  65035. frontUVs?: Vector4;
  65036. backUVs?: Vector4;
  65037. instance?: Mesh;
  65038. invertUV?: boolean;
  65039. }, scene?: Nullable<Scene>): Mesh;
  65040. /**
  65041. * Creates an custom extruded shape mesh.
  65042. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65043. * * 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.
  65044. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65045. * * 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
  65046. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65047. * * 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
  65048. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65049. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65050. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65051. * * 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
  65052. * * 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
  65053. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65056. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65058. * @param name defines the name of the mesh
  65059. * @param options defines the options used to create the mesh
  65060. * @param scene defines the hosting scene
  65061. * @returns the custom extruded shape mesh
  65062. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65063. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65064. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65065. */
  65066. static ExtrudeShapeCustom(name: string, options: {
  65067. shape: Vector3[];
  65068. path: Vector3[];
  65069. scaleFunction?: any;
  65070. rotationFunction?: any;
  65071. ribbonCloseArray?: boolean;
  65072. ribbonClosePath?: boolean;
  65073. cap?: number;
  65074. updatable?: boolean;
  65075. sideOrientation?: number;
  65076. frontUVs?: Vector4;
  65077. backUVs?: Vector4;
  65078. instance?: Mesh;
  65079. invertUV?: boolean;
  65080. }, scene?: Nullable<Scene>): Mesh;
  65081. /**
  65082. * Creates lathe mesh.
  65083. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65084. * * 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
  65085. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65086. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65087. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65088. * * 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
  65089. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65090. * * 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
  65091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65092. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65094. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65095. * @param name defines the name of the mesh
  65096. * @param options defines the options used to create the mesh
  65097. * @param scene defines the hosting scene
  65098. * @returns the lathe mesh
  65099. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65100. */
  65101. static CreateLathe(name: string, options: {
  65102. shape: Vector3[];
  65103. radius?: number;
  65104. tessellation?: number;
  65105. clip?: number;
  65106. arc?: number;
  65107. closed?: boolean;
  65108. updatable?: boolean;
  65109. sideOrientation?: number;
  65110. frontUVs?: Vector4;
  65111. backUVs?: Vector4;
  65112. cap?: number;
  65113. invertUV?: boolean;
  65114. }, scene?: Nullable<Scene>): Mesh;
  65115. /**
  65116. * Creates a tiled plane mesh
  65117. * * You can set a limited pattern arrangement with the tiles
  65118. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65119. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65121. * @param name defines the name of the mesh
  65122. * @param options defines the options used to create the mesh
  65123. * @param scene defines the hosting scene
  65124. * @returns the plane mesh
  65125. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65126. */
  65127. static CreateTiledPlane(name: string, options: {
  65128. pattern?: number;
  65129. tileSize?: number;
  65130. tileWidth?: number;
  65131. tileHeight?: number;
  65132. size?: number;
  65133. width?: number;
  65134. height?: number;
  65135. alignHorizontal?: number;
  65136. alignVertical?: number;
  65137. sideOrientation?: number;
  65138. frontUVs?: Vector4;
  65139. backUVs?: Vector4;
  65140. updatable?: boolean;
  65141. }, scene?: Nullable<Scene>): Mesh;
  65142. /**
  65143. * Creates a plane mesh
  65144. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65145. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65146. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65147. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65148. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65150. * @param name defines the name of the mesh
  65151. * @param options defines the options used to create the mesh
  65152. * @param scene defines the hosting scene
  65153. * @returns the plane mesh
  65154. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65155. */
  65156. static CreatePlane(name: string, options: {
  65157. size?: number;
  65158. width?: number;
  65159. height?: number;
  65160. sideOrientation?: number;
  65161. frontUVs?: Vector4;
  65162. backUVs?: Vector4;
  65163. updatable?: boolean;
  65164. sourcePlane?: Plane;
  65165. }, scene?: Nullable<Scene>): Mesh;
  65166. /**
  65167. * Creates a ground mesh
  65168. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65169. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65171. * @param name defines the name of the mesh
  65172. * @param options defines the options used to create the mesh
  65173. * @param scene defines the hosting scene
  65174. * @returns the ground mesh
  65175. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65176. */
  65177. static CreateGround(name: string, options: {
  65178. width?: number;
  65179. height?: number;
  65180. subdivisions?: number;
  65181. subdivisionsX?: number;
  65182. subdivisionsY?: number;
  65183. updatable?: boolean;
  65184. }, scene?: Nullable<Scene>): Mesh;
  65185. /**
  65186. * Creates a tiled ground mesh
  65187. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65188. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65189. * * 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
  65190. * * 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
  65191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65192. * @param name defines the name of the mesh
  65193. * @param options defines the options used to create the mesh
  65194. * @param scene defines the hosting scene
  65195. * @returns the tiled ground mesh
  65196. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65197. */
  65198. static CreateTiledGround(name: string, options: {
  65199. xmin: number;
  65200. zmin: number;
  65201. xmax: number;
  65202. zmax: number;
  65203. subdivisions?: {
  65204. w: number;
  65205. h: number;
  65206. };
  65207. precision?: {
  65208. w: number;
  65209. h: number;
  65210. };
  65211. updatable?: boolean;
  65212. }, scene?: Nullable<Scene>): Mesh;
  65213. /**
  65214. * Creates a ground mesh from a height map
  65215. * * The parameter `url` sets the URL of the height map image resource.
  65216. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65217. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65218. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65219. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65220. * * 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.
  65221. * * 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).
  65222. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65224. * @param name defines the name of the mesh
  65225. * @param url defines the url to the height map
  65226. * @param options defines the options used to create the mesh
  65227. * @param scene defines the hosting scene
  65228. * @returns the ground mesh
  65229. * @see https://doc.babylonjs.com/babylon101/height_map
  65230. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65231. */
  65232. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65233. width?: number;
  65234. height?: number;
  65235. subdivisions?: number;
  65236. minHeight?: number;
  65237. maxHeight?: number;
  65238. colorFilter?: Color3;
  65239. alphaFilter?: number;
  65240. updatable?: boolean;
  65241. onReady?: (mesh: GroundMesh) => void;
  65242. }, scene?: Nullable<Scene>): GroundMesh;
  65243. /**
  65244. * Creates a polygon mesh
  65245. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65246. * * 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
  65247. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65250. * * Remember you can only change the shape positions, not their number when updating a polygon
  65251. * @param name defines the name of the mesh
  65252. * @param options defines the options used to create the mesh
  65253. * @param scene defines the hosting scene
  65254. * @param earcutInjection can be used to inject your own earcut reference
  65255. * @returns the polygon mesh
  65256. */
  65257. static CreatePolygon(name: string, options: {
  65258. shape: Vector3[];
  65259. holes?: Vector3[][];
  65260. depth?: number;
  65261. faceUV?: Vector4[];
  65262. faceColors?: Color4[];
  65263. updatable?: boolean;
  65264. sideOrientation?: number;
  65265. frontUVs?: Vector4;
  65266. backUVs?: Vector4;
  65267. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65268. /**
  65269. * Creates an extruded polygon mesh, with depth in the Y direction.
  65270. * * 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)
  65271. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65272. * @param name defines the name of the mesh
  65273. * @param options defines the options used to create the mesh
  65274. * @param scene defines the hosting scene
  65275. * @param earcutInjection can be used to inject your own earcut reference
  65276. * @returns the polygon mesh
  65277. */
  65278. static ExtrudePolygon(name: string, options: {
  65279. shape: Vector3[];
  65280. holes?: Vector3[][];
  65281. depth?: number;
  65282. faceUV?: Vector4[];
  65283. faceColors?: Color4[];
  65284. updatable?: boolean;
  65285. sideOrientation?: number;
  65286. frontUVs?: Vector4;
  65287. backUVs?: Vector4;
  65288. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65289. /**
  65290. * Creates a tube mesh.
  65291. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65292. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65293. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65294. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65295. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65296. * * 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)
  65297. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65298. * * 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
  65299. * * 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
  65300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65302. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65304. * @param name defines the name of the mesh
  65305. * @param options defines the options used to create the mesh
  65306. * @param scene defines the hosting scene
  65307. * @returns the tube mesh
  65308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65309. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65310. */
  65311. static CreateTube(name: string, options: {
  65312. path: Vector3[];
  65313. radius?: number;
  65314. tessellation?: number;
  65315. radiusFunction?: {
  65316. (i: number, distance: number): number;
  65317. };
  65318. cap?: number;
  65319. arc?: number;
  65320. updatable?: boolean;
  65321. sideOrientation?: number;
  65322. frontUVs?: Vector4;
  65323. backUVs?: Vector4;
  65324. instance?: Mesh;
  65325. invertUV?: boolean;
  65326. }, scene?: Nullable<Scene>): Mesh;
  65327. /**
  65328. * Creates a polyhedron mesh
  65329. * * 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
  65330. * * The parameter `size` (positive float, default 1) sets the polygon size
  65331. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65332. * * 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`
  65333. * * 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
  65334. * * 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)`)
  65335. * * 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
  65336. * * 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
  65337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65340. * @param name defines the name of the mesh
  65341. * @param options defines the options used to create the mesh
  65342. * @param scene defines the hosting scene
  65343. * @returns the polyhedron mesh
  65344. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65345. */
  65346. static CreatePolyhedron(name: string, options: {
  65347. type?: number;
  65348. size?: number;
  65349. sizeX?: number;
  65350. sizeY?: number;
  65351. sizeZ?: number;
  65352. custom?: any;
  65353. faceUV?: Vector4[];
  65354. faceColors?: Color4[];
  65355. flat?: boolean;
  65356. updatable?: boolean;
  65357. sideOrientation?: number;
  65358. frontUVs?: Vector4;
  65359. backUVs?: Vector4;
  65360. }, scene?: Nullable<Scene>): Mesh;
  65361. /**
  65362. * Creates a decal mesh.
  65363. * 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
  65364. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65365. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65366. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65367. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65368. * @param name defines the name of the mesh
  65369. * @param sourceMesh defines the mesh where the decal must be applied
  65370. * @param options defines the options used to create the mesh
  65371. * @param scene defines the hosting scene
  65372. * @returns the decal mesh
  65373. * @see https://doc.babylonjs.com/how_to/decals
  65374. */
  65375. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65376. position?: Vector3;
  65377. normal?: Vector3;
  65378. size?: Vector3;
  65379. angle?: number;
  65380. }): Mesh;
  65381. }
  65382. }
  65383. declare module "babylonjs/Meshes/meshSimplification" {
  65384. import { Mesh } from "babylonjs/Meshes/mesh";
  65385. /**
  65386. * A simplifier interface for future simplification implementations
  65387. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65388. */
  65389. export interface ISimplifier {
  65390. /**
  65391. * Simplification of a given mesh according to the given settings.
  65392. * Since this requires computation, it is assumed that the function runs async.
  65393. * @param settings The settings of the simplification, including quality and distance
  65394. * @param successCallback A callback that will be called after the mesh was simplified.
  65395. * @param errorCallback in case of an error, this callback will be called. optional.
  65396. */
  65397. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65398. }
  65399. /**
  65400. * Expected simplification settings.
  65401. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65402. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65403. */
  65404. export interface ISimplificationSettings {
  65405. /**
  65406. * Gets or sets the expected quality
  65407. */
  65408. quality: number;
  65409. /**
  65410. * Gets or sets the distance when this optimized version should be used
  65411. */
  65412. distance: number;
  65413. /**
  65414. * Gets an already optimized mesh
  65415. */
  65416. optimizeMesh?: boolean;
  65417. }
  65418. /**
  65419. * Class used to specify simplification options
  65420. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65421. */
  65422. export class SimplificationSettings implements ISimplificationSettings {
  65423. /** expected quality */
  65424. quality: number;
  65425. /** distance when this optimized version should be used */
  65426. distance: number;
  65427. /** already optimized mesh */
  65428. optimizeMesh?: boolean | undefined;
  65429. /**
  65430. * Creates a SimplificationSettings
  65431. * @param quality expected quality
  65432. * @param distance distance when this optimized version should be used
  65433. * @param optimizeMesh already optimized mesh
  65434. */
  65435. constructor(
  65436. /** expected quality */
  65437. quality: number,
  65438. /** distance when this optimized version should be used */
  65439. distance: number,
  65440. /** already optimized mesh */
  65441. optimizeMesh?: boolean | undefined);
  65442. }
  65443. /**
  65444. * Interface used to define a simplification task
  65445. */
  65446. export interface ISimplificationTask {
  65447. /**
  65448. * Array of settings
  65449. */
  65450. settings: Array<ISimplificationSettings>;
  65451. /**
  65452. * Simplification type
  65453. */
  65454. simplificationType: SimplificationType;
  65455. /**
  65456. * Mesh to simplify
  65457. */
  65458. mesh: Mesh;
  65459. /**
  65460. * Callback called on success
  65461. */
  65462. successCallback?: () => void;
  65463. /**
  65464. * Defines if parallel processing can be used
  65465. */
  65466. parallelProcessing: boolean;
  65467. }
  65468. /**
  65469. * Queue used to order the simplification tasks
  65470. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65471. */
  65472. export class SimplificationQueue {
  65473. private _simplificationArray;
  65474. /**
  65475. * Gets a boolean indicating that the process is still running
  65476. */
  65477. running: boolean;
  65478. /**
  65479. * Creates a new queue
  65480. */
  65481. constructor();
  65482. /**
  65483. * Adds a new simplification task
  65484. * @param task defines a task to add
  65485. */
  65486. addTask(task: ISimplificationTask): void;
  65487. /**
  65488. * Execute next task
  65489. */
  65490. executeNext(): void;
  65491. /**
  65492. * Execute a simplification task
  65493. * @param task defines the task to run
  65494. */
  65495. runSimplification(task: ISimplificationTask): void;
  65496. private getSimplifier;
  65497. }
  65498. /**
  65499. * The implemented types of simplification
  65500. * At the moment only Quadratic Error Decimation is implemented
  65501. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65502. */
  65503. export enum SimplificationType {
  65504. /** Quadratic error decimation */
  65505. QUADRATIC = 0
  65506. }
  65507. /**
  65508. * An implementation of the Quadratic Error simplification algorithm.
  65509. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65510. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65511. * @author RaananW
  65512. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65513. */
  65514. export class QuadraticErrorSimplification implements ISimplifier {
  65515. private _mesh;
  65516. private triangles;
  65517. private vertices;
  65518. private references;
  65519. private _reconstructedMesh;
  65520. /** Gets or sets the number pf sync interations */
  65521. syncIterations: number;
  65522. /** Gets or sets the aggressiveness of the simplifier */
  65523. aggressiveness: number;
  65524. /** Gets or sets the number of allowed iterations for decimation */
  65525. decimationIterations: number;
  65526. /** Gets or sets the espilon to use for bounding box computation */
  65527. boundingBoxEpsilon: number;
  65528. /**
  65529. * Creates a new QuadraticErrorSimplification
  65530. * @param _mesh defines the target mesh
  65531. */
  65532. constructor(_mesh: Mesh);
  65533. /**
  65534. * Simplification of a given mesh according to the given settings.
  65535. * Since this requires computation, it is assumed that the function runs async.
  65536. * @param settings The settings of the simplification, including quality and distance
  65537. * @param successCallback A callback that will be called after the mesh was simplified.
  65538. */
  65539. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65540. private runDecimation;
  65541. private initWithMesh;
  65542. private init;
  65543. private reconstructMesh;
  65544. private initDecimatedMesh;
  65545. private isFlipped;
  65546. private updateTriangles;
  65547. private identifyBorder;
  65548. private updateMesh;
  65549. private vertexError;
  65550. private calculateError;
  65551. }
  65552. }
  65553. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65554. import { Scene } from "babylonjs/scene";
  65555. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65556. import { ISceneComponent } from "babylonjs/sceneComponent";
  65557. module "babylonjs/scene" {
  65558. interface Scene {
  65559. /** @hidden (Backing field) */
  65560. _simplificationQueue: SimplificationQueue;
  65561. /**
  65562. * Gets or sets the simplification queue attached to the scene
  65563. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65564. */
  65565. simplificationQueue: SimplificationQueue;
  65566. }
  65567. }
  65568. module "babylonjs/Meshes/mesh" {
  65569. interface Mesh {
  65570. /**
  65571. * Simplify the mesh according to the given array of settings.
  65572. * Function will return immediately and will simplify async
  65573. * @param settings a collection of simplification settings
  65574. * @param parallelProcessing should all levels calculate parallel or one after the other
  65575. * @param simplificationType the type of simplification to run
  65576. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65577. * @returns the current mesh
  65578. */
  65579. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65580. }
  65581. }
  65582. /**
  65583. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65584. * created in a scene
  65585. */
  65586. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65587. /**
  65588. * The component name helpfull to identify the component in the list of scene components.
  65589. */
  65590. readonly name: string;
  65591. /**
  65592. * The scene the component belongs to.
  65593. */
  65594. scene: Scene;
  65595. /**
  65596. * Creates a new instance of the component for the given scene
  65597. * @param scene Defines the scene to register the component in
  65598. */
  65599. constructor(scene: Scene);
  65600. /**
  65601. * Registers the component in a given scene
  65602. */
  65603. register(): void;
  65604. /**
  65605. * Rebuilds the elements related to this component in case of
  65606. * context lost for instance.
  65607. */
  65608. rebuild(): void;
  65609. /**
  65610. * Disposes the component and the associated ressources
  65611. */
  65612. dispose(): void;
  65613. private _beforeCameraUpdate;
  65614. }
  65615. }
  65616. declare module "babylonjs/Meshes/Builders/index" {
  65617. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65618. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65619. export * from "babylonjs/Meshes/Builders/discBuilder";
  65620. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65621. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65622. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65623. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65624. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65625. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65626. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65627. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65628. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65629. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65630. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65631. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65632. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65633. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65634. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65635. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65636. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65637. }
  65638. declare module "babylonjs/Meshes/index" {
  65639. export * from "babylonjs/Meshes/abstractMesh";
  65640. export * from "babylonjs/Meshes/buffer";
  65641. export * from "babylonjs/Meshes/Compression/index";
  65642. export * from "babylonjs/Meshes/csg";
  65643. export * from "babylonjs/Meshes/geometry";
  65644. export * from "babylonjs/Meshes/groundMesh";
  65645. export * from "babylonjs/Meshes/trailMesh";
  65646. export * from "babylonjs/Meshes/instancedMesh";
  65647. export * from "babylonjs/Meshes/linesMesh";
  65648. export * from "babylonjs/Meshes/mesh";
  65649. export * from "babylonjs/Meshes/mesh.vertexData";
  65650. export * from "babylonjs/Meshes/meshBuilder";
  65651. export * from "babylonjs/Meshes/meshSimplification";
  65652. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65653. export * from "babylonjs/Meshes/polygonMesh";
  65654. export * from "babylonjs/Meshes/subMesh";
  65655. export * from "babylonjs/Meshes/meshLODLevel";
  65656. export * from "babylonjs/Meshes/transformNode";
  65657. export * from "babylonjs/Meshes/Builders/index";
  65658. export * from "babylonjs/Meshes/dataBuffer";
  65659. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65660. }
  65661. declare module "babylonjs/Morph/index" {
  65662. export * from "babylonjs/Morph/morphTarget";
  65663. export * from "babylonjs/Morph/morphTargetManager";
  65664. }
  65665. declare module "babylonjs/Navigation/INavigationEngine" {
  65666. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65667. import { Vector3 } from "babylonjs/Maths/math";
  65668. import { Mesh } from "babylonjs/Meshes/mesh";
  65669. import { Scene } from "babylonjs/scene";
  65670. /**
  65671. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65672. */
  65673. export interface INavigationEnginePlugin {
  65674. /**
  65675. * plugin name
  65676. */
  65677. name: string;
  65678. /**
  65679. * Creates a navigation mesh
  65680. * @param meshes array of all the geometry used to compute the navigatio mesh
  65681. * @param parameters bunch of parameters used to filter geometry
  65682. */
  65683. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65684. /**
  65685. * Create a navigation mesh debug mesh
  65686. * @param scene is where the mesh will be added
  65687. * @returns debug display mesh
  65688. */
  65689. createDebugNavMesh(scene: Scene): Mesh;
  65690. /**
  65691. * Get a navigation mesh constrained position, closest to the parameter position
  65692. * @param position world position
  65693. * @returns the closest point to position constrained by the navigation mesh
  65694. */
  65695. getClosestPoint(position: Vector3): Vector3;
  65696. /**
  65697. * Get a navigation mesh constrained position, closest to the parameter position
  65698. * @param position world position
  65699. * @param result output the closest point to position constrained by the navigation mesh
  65700. */
  65701. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65702. /**
  65703. * Get a navigation mesh constrained position, within a particular radius
  65704. * @param position world position
  65705. * @param maxRadius the maximum distance to the constrained world position
  65706. * @returns the closest point to position constrained by the navigation mesh
  65707. */
  65708. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65709. /**
  65710. * Get a navigation mesh constrained position, within a particular radius
  65711. * @param position world position
  65712. * @param maxRadius the maximum distance to the constrained world position
  65713. * @param result output the closest point to position constrained by the navigation mesh
  65714. */
  65715. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65716. /**
  65717. * Compute the final position from a segment made of destination-position
  65718. * @param position world position
  65719. * @param destination world position
  65720. * @returns the resulting point along the navmesh
  65721. */
  65722. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65723. /**
  65724. * Compute the final position from a segment made of destination-position
  65725. * @param position world position
  65726. * @param destination world position
  65727. * @param result output the resulting point along the navmesh
  65728. */
  65729. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65730. /**
  65731. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65732. * @param start world position
  65733. * @param end world position
  65734. * @returns array containing world position composing the path
  65735. */
  65736. computePath(start: Vector3, end: Vector3): Vector3[];
  65737. /**
  65738. * If this plugin is supported
  65739. * @returns true if plugin is supported
  65740. */
  65741. isSupported(): boolean;
  65742. /**
  65743. * Create a new Crowd so you can add agents
  65744. * @param maxAgents the maximum agent count in the crowd
  65745. * @param maxAgentRadius the maximum radius an agent can have
  65746. * @param scene to attach the crowd to
  65747. * @returns the crowd you can add agents to
  65748. */
  65749. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65750. /**
  65751. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65752. * The queries will try to find a solution within those bounds
  65753. * default is (1,1,1)
  65754. * @param extent x,y,z value that define the extent around the queries point of reference
  65755. */
  65756. setDefaultQueryExtent(extent: Vector3): void;
  65757. /**
  65758. * Get the Bounding box extent specified by setDefaultQueryExtent
  65759. * @returns the box extent values
  65760. */
  65761. getDefaultQueryExtent(): Vector3;
  65762. /**
  65763. * build the navmesh from a previously saved state using getNavmeshData
  65764. * @param data the Uint8Array returned by getNavmeshData
  65765. */
  65766. buildFromNavmeshData(data: Uint8Array): void;
  65767. /**
  65768. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65769. * @returns data the Uint8Array that can be saved and reused
  65770. */
  65771. getNavmeshData(): Uint8Array;
  65772. /**
  65773. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65774. * @param result output the box extent values
  65775. */
  65776. getDefaultQueryExtentToRef(result: Vector3): void;
  65777. /**
  65778. * Release all resources
  65779. */
  65780. dispose(): void;
  65781. }
  65782. /**
  65783. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65784. */
  65785. export interface ICrowd {
  65786. /**
  65787. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65788. * You can attach anything to that node. The node position is updated in the scene update tick.
  65789. * @param pos world position that will be constrained by the navigation mesh
  65790. * @param parameters agent parameters
  65791. * @param transform hooked to the agent that will be update by the scene
  65792. * @returns agent index
  65793. */
  65794. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65795. /**
  65796. * Returns the agent position in world space
  65797. * @param index agent index returned by addAgent
  65798. * @returns world space position
  65799. */
  65800. getAgentPosition(index: number): Vector3;
  65801. /**
  65802. * Gets the agent position result in world space
  65803. * @param index agent index returned by addAgent
  65804. * @param result output world space position
  65805. */
  65806. getAgentPositionToRef(index: number, result: Vector3): void;
  65807. /**
  65808. * Gets the agent velocity in world space
  65809. * @param index agent index returned by addAgent
  65810. * @returns world space velocity
  65811. */
  65812. getAgentVelocity(index: number): Vector3;
  65813. /**
  65814. * Gets the agent velocity result in world space
  65815. * @param index agent index returned by addAgent
  65816. * @param result output world space velocity
  65817. */
  65818. getAgentVelocityToRef(index: number, result: Vector3): void;
  65819. /**
  65820. * remove a particular agent previously created
  65821. * @param index agent index returned by addAgent
  65822. */
  65823. removeAgent(index: number): void;
  65824. /**
  65825. * get the list of all agents attached to this crowd
  65826. * @returns list of agent indices
  65827. */
  65828. getAgents(): number[];
  65829. /**
  65830. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65831. * @param deltaTime in seconds
  65832. */
  65833. update(deltaTime: number): void;
  65834. /**
  65835. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65836. * @param index agent index returned by addAgent
  65837. * @param destination targeted world position
  65838. */
  65839. agentGoto(index: number, destination: Vector3): void;
  65840. /**
  65841. * Teleport the agent to a new position
  65842. * @param index agent index returned by addAgent
  65843. * @param destination targeted world position
  65844. */
  65845. agentTeleport(index: number, destination: Vector3): void;
  65846. /**
  65847. * Update agent parameters
  65848. * @param index agent index returned by addAgent
  65849. * @param parameters agent parameters
  65850. */
  65851. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65852. /**
  65853. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65854. * The queries will try to find a solution within those bounds
  65855. * default is (1,1,1)
  65856. * @param extent x,y,z value that define the extent around the queries point of reference
  65857. */
  65858. setDefaultQueryExtent(extent: Vector3): void;
  65859. /**
  65860. * Get the Bounding box extent specified by setDefaultQueryExtent
  65861. * @returns the box extent values
  65862. */
  65863. getDefaultQueryExtent(): Vector3;
  65864. /**
  65865. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65866. * @param result output the box extent values
  65867. */
  65868. getDefaultQueryExtentToRef(result: Vector3): void;
  65869. /**
  65870. * Release all resources
  65871. */
  65872. dispose(): void;
  65873. }
  65874. /**
  65875. * Configures an agent
  65876. */
  65877. export interface IAgentParameters {
  65878. /**
  65879. * Agent radius. [Limit: >= 0]
  65880. */
  65881. radius: number;
  65882. /**
  65883. * Agent height. [Limit: > 0]
  65884. */
  65885. height: number;
  65886. /**
  65887. * Maximum allowed acceleration. [Limit: >= 0]
  65888. */
  65889. maxAcceleration: number;
  65890. /**
  65891. * Maximum allowed speed. [Limit: >= 0]
  65892. */
  65893. maxSpeed: number;
  65894. /**
  65895. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65896. */
  65897. collisionQueryRange: number;
  65898. /**
  65899. * The path visibility optimization range. [Limit: > 0]
  65900. */
  65901. pathOptimizationRange: number;
  65902. /**
  65903. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65904. */
  65905. separationWeight: number;
  65906. }
  65907. /**
  65908. * Configures the navigation mesh creation
  65909. */
  65910. export interface INavMeshParameters {
  65911. /**
  65912. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65913. */
  65914. cs: number;
  65915. /**
  65916. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65917. */
  65918. ch: number;
  65919. /**
  65920. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65921. */
  65922. walkableSlopeAngle: number;
  65923. /**
  65924. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65925. * be considered walkable. [Limit: >= 3] [Units: vx]
  65926. */
  65927. walkableHeight: number;
  65928. /**
  65929. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65930. */
  65931. walkableClimb: number;
  65932. /**
  65933. * The distance to erode/shrink the walkable area of the heightfield away from
  65934. * obstructions. [Limit: >=0] [Units: vx]
  65935. */
  65936. walkableRadius: number;
  65937. /**
  65938. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65939. */
  65940. maxEdgeLen: number;
  65941. /**
  65942. * The maximum distance a simplfied contour's border edges should deviate
  65943. * the original raw contour. [Limit: >=0] [Units: vx]
  65944. */
  65945. maxSimplificationError: number;
  65946. /**
  65947. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65948. */
  65949. minRegionArea: number;
  65950. /**
  65951. * Any regions with a span count smaller than this value will, if possible,
  65952. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65953. */
  65954. mergeRegionArea: number;
  65955. /**
  65956. * The maximum number of vertices allowed for polygons generated during the
  65957. * contour to polygon conversion process. [Limit: >= 3]
  65958. */
  65959. maxVertsPerPoly: number;
  65960. /**
  65961. * Sets the sampling distance to use when generating the detail mesh.
  65962. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65963. */
  65964. detailSampleDist: number;
  65965. /**
  65966. * The maximum distance the detail mesh surface should deviate from heightfield
  65967. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65968. */
  65969. detailSampleMaxError: number;
  65970. }
  65971. }
  65972. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65973. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65974. import { Mesh } from "babylonjs/Meshes/mesh";
  65975. import { Scene } from "babylonjs/scene";
  65976. import { Vector3 } from "babylonjs/Maths/math";
  65977. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65978. /**
  65979. * RecastJS navigation plugin
  65980. */
  65981. export class RecastJSPlugin implements INavigationEnginePlugin {
  65982. /**
  65983. * Reference to the Recast library
  65984. */
  65985. bjsRECAST: any;
  65986. /**
  65987. * plugin name
  65988. */
  65989. name: string;
  65990. /**
  65991. * the first navmesh created. We might extend this to support multiple navmeshes
  65992. */
  65993. navMesh: any;
  65994. /**
  65995. * Initializes the recastJS plugin
  65996. * @param recastInjection can be used to inject your own recast reference
  65997. */
  65998. constructor(recastInjection?: any);
  65999. /**
  66000. * Creates a navigation mesh
  66001. * @param meshes array of all the geometry used to compute the navigatio mesh
  66002. * @param parameters bunch of parameters used to filter geometry
  66003. */
  66004. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66005. /**
  66006. * Create a navigation mesh debug mesh
  66007. * @param scene is where the mesh will be added
  66008. * @returns debug display mesh
  66009. */
  66010. createDebugNavMesh(scene: Scene): Mesh;
  66011. /**
  66012. * Get a navigation mesh constrained position, closest to the parameter position
  66013. * @param position world position
  66014. * @returns the closest point to position constrained by the navigation mesh
  66015. */
  66016. getClosestPoint(position: Vector3): Vector3;
  66017. /**
  66018. * Get a navigation mesh constrained position, closest to the parameter position
  66019. * @param position world position
  66020. * @param result output the closest point to position constrained by the navigation mesh
  66021. */
  66022. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66023. /**
  66024. * Get a navigation mesh constrained position, within a particular radius
  66025. * @param position world position
  66026. * @param maxRadius the maximum distance to the constrained world position
  66027. * @returns the closest point to position constrained by the navigation mesh
  66028. */
  66029. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66030. /**
  66031. * Get a navigation mesh constrained position, within a particular radius
  66032. * @param position world position
  66033. * @param maxRadius the maximum distance to the constrained world position
  66034. * @param result output the closest point to position constrained by the navigation mesh
  66035. */
  66036. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66037. /**
  66038. * Compute the final position from a segment made of destination-position
  66039. * @param position world position
  66040. * @param destination world position
  66041. * @returns the resulting point along the navmesh
  66042. */
  66043. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66044. /**
  66045. * Compute the final position from a segment made of destination-position
  66046. * @param position world position
  66047. * @param destination world position
  66048. * @param result output the resulting point along the navmesh
  66049. */
  66050. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66051. /**
  66052. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66053. * @param start world position
  66054. * @param end world position
  66055. * @returns array containing world position composing the path
  66056. */
  66057. computePath(start: Vector3, end: Vector3): Vector3[];
  66058. /**
  66059. * Create a new Crowd so you can add agents
  66060. * @param maxAgents the maximum agent count in the crowd
  66061. * @param maxAgentRadius the maximum radius an agent can have
  66062. * @param scene to attach the crowd to
  66063. * @returns the crowd you can add agents to
  66064. */
  66065. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66066. /**
  66067. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66068. * The queries will try to find a solution within those bounds
  66069. * default is (1,1,1)
  66070. * @param extent x,y,z value that define the extent around the queries point of reference
  66071. */
  66072. setDefaultQueryExtent(extent: Vector3): void;
  66073. /**
  66074. * Get the Bounding box extent specified by setDefaultQueryExtent
  66075. * @returns the box extent values
  66076. */
  66077. getDefaultQueryExtent(): Vector3;
  66078. /**
  66079. * build the navmesh from a previously saved state using getNavmeshData
  66080. * @param data the Uint8Array returned by getNavmeshData
  66081. */
  66082. buildFromNavmeshData(data: Uint8Array): void;
  66083. /**
  66084. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66085. * @returns data the Uint8Array that can be saved and reused
  66086. */
  66087. getNavmeshData(): Uint8Array;
  66088. /**
  66089. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66090. * @param result output the box extent values
  66091. */
  66092. getDefaultQueryExtentToRef(result: Vector3): void;
  66093. /**
  66094. * Disposes
  66095. */
  66096. dispose(): void;
  66097. /**
  66098. * If this plugin is supported
  66099. * @returns true if plugin is supported
  66100. */
  66101. isSupported(): boolean;
  66102. }
  66103. /**
  66104. * Recast detour crowd implementation
  66105. */
  66106. export class RecastJSCrowd implements ICrowd {
  66107. /**
  66108. * Recast/detour plugin
  66109. */
  66110. bjsRECASTPlugin: RecastJSPlugin;
  66111. /**
  66112. * Link to the detour crowd
  66113. */
  66114. recastCrowd: any;
  66115. /**
  66116. * One transform per agent
  66117. */
  66118. transforms: TransformNode[];
  66119. /**
  66120. * All agents created
  66121. */
  66122. agents: number[];
  66123. /**
  66124. * Link to the scene is kept to unregister the crowd from the scene
  66125. */
  66126. private _scene;
  66127. /**
  66128. * Observer for crowd updates
  66129. */
  66130. private _onBeforeAnimationsObserver;
  66131. /**
  66132. * Constructor
  66133. * @param plugin recastJS plugin
  66134. * @param maxAgents the maximum agent count in the crowd
  66135. * @param maxAgentRadius the maximum radius an agent can have
  66136. * @param scene to attach the crowd to
  66137. * @returns the crowd you can add agents to
  66138. */
  66139. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66140. /**
  66141. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66142. * You can attach anything to that node. The node position is updated in the scene update tick.
  66143. * @param pos world position that will be constrained by the navigation mesh
  66144. * @param parameters agent parameters
  66145. * @param transform hooked to the agent that will be update by the scene
  66146. * @returns agent index
  66147. */
  66148. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66149. /**
  66150. * Returns the agent position in world space
  66151. * @param index agent index returned by addAgent
  66152. * @returns world space position
  66153. */
  66154. getAgentPosition(index: number): Vector3;
  66155. /**
  66156. * Returns the agent position result in world space
  66157. * @param index agent index returned by addAgent
  66158. * @param result output world space position
  66159. */
  66160. getAgentPositionToRef(index: number, result: Vector3): void;
  66161. /**
  66162. * Returns the agent velocity in world space
  66163. * @param index agent index returned by addAgent
  66164. * @returns world space velocity
  66165. */
  66166. getAgentVelocity(index: number): Vector3;
  66167. /**
  66168. * Returns the agent velocity result in world space
  66169. * @param index agent index returned by addAgent
  66170. * @param result output world space velocity
  66171. */
  66172. getAgentVelocityToRef(index: number, result: Vector3): void;
  66173. /**
  66174. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66175. * @param index agent index returned by addAgent
  66176. * @param destination targeted world position
  66177. */
  66178. agentGoto(index: number, destination: Vector3): void;
  66179. /**
  66180. * Teleport the agent to a new position
  66181. * @param index agent index returned by addAgent
  66182. * @param destination targeted world position
  66183. */
  66184. agentTeleport(index: number, destination: Vector3): void;
  66185. /**
  66186. * Update agent parameters
  66187. * @param index agent index returned by addAgent
  66188. * @param parameters agent parameters
  66189. */
  66190. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66191. /**
  66192. * remove a particular agent previously created
  66193. * @param index agent index returned by addAgent
  66194. */
  66195. removeAgent(index: number): void;
  66196. /**
  66197. * get the list of all agents attached to this crowd
  66198. * @returns list of agent indices
  66199. */
  66200. getAgents(): number[];
  66201. /**
  66202. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66203. * @param deltaTime in seconds
  66204. */
  66205. update(deltaTime: number): void;
  66206. /**
  66207. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66208. * The queries will try to find a solution within those bounds
  66209. * default is (1,1,1)
  66210. * @param extent x,y,z value that define the extent around the queries point of reference
  66211. */
  66212. setDefaultQueryExtent(extent: Vector3): void;
  66213. /**
  66214. * Get the Bounding box extent specified by setDefaultQueryExtent
  66215. * @returns the box extent values
  66216. */
  66217. getDefaultQueryExtent(): Vector3;
  66218. /**
  66219. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66220. * @param result output the box extent values
  66221. */
  66222. getDefaultQueryExtentToRef(result: Vector3): void;
  66223. /**
  66224. * Release all resources
  66225. */
  66226. dispose(): void;
  66227. }
  66228. }
  66229. declare module "babylonjs/Navigation/Plugins/index" {
  66230. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  66231. }
  66232. declare module "babylonjs/Navigation/index" {
  66233. export * from "babylonjs/Navigation/INavigationEngine";
  66234. export * from "babylonjs/Navigation/Plugins/index";
  66235. }
  66236. declare module "babylonjs/Offline/database" {
  66237. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  66238. /**
  66239. * Class used to enable access to IndexedDB
  66240. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66241. */
  66242. export class Database implements IOfflineProvider {
  66243. private _callbackManifestChecked;
  66244. private _currentSceneUrl;
  66245. private _db;
  66246. private _enableSceneOffline;
  66247. private _enableTexturesOffline;
  66248. private _manifestVersionFound;
  66249. private _mustUpdateRessources;
  66250. private _hasReachedQuota;
  66251. private _isSupported;
  66252. private _idbFactory;
  66253. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66254. private static IsUASupportingBlobStorage;
  66255. /**
  66256. * Gets a boolean indicating if Database storate is enabled (off by default)
  66257. */
  66258. static IDBStorageEnabled: boolean;
  66259. /**
  66260. * Gets a boolean indicating if scene must be saved in the database
  66261. */
  66262. get enableSceneOffline(): boolean;
  66263. /**
  66264. * Gets a boolean indicating if textures must be saved in the database
  66265. */
  66266. get enableTexturesOffline(): boolean;
  66267. /**
  66268. * Creates a new Database
  66269. * @param urlToScene defines the url to load the scene
  66270. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66271. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66272. */
  66273. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66274. private static _ParseURL;
  66275. private static _ReturnFullUrlLocation;
  66276. private _checkManifestFile;
  66277. /**
  66278. * Open the database and make it available
  66279. * @param successCallback defines the callback to call on success
  66280. * @param errorCallback defines the callback to call on error
  66281. */
  66282. open(successCallback: () => void, errorCallback: () => void): void;
  66283. /**
  66284. * Loads an image from the database
  66285. * @param url defines the url to load from
  66286. * @param image defines the target DOM image
  66287. */
  66288. loadImage(url: string, image: HTMLImageElement): void;
  66289. private _loadImageFromDBAsync;
  66290. private _saveImageIntoDBAsync;
  66291. private _checkVersionFromDB;
  66292. private _loadVersionFromDBAsync;
  66293. private _saveVersionIntoDBAsync;
  66294. /**
  66295. * Loads a file from database
  66296. * @param url defines the URL to load from
  66297. * @param sceneLoaded defines a callback to call on success
  66298. * @param progressCallBack defines a callback to call when progress changed
  66299. * @param errorCallback defines a callback to call on error
  66300. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66301. */
  66302. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66303. private _loadFileAsync;
  66304. private _saveFileAsync;
  66305. /**
  66306. * Validates if xhr data is correct
  66307. * @param xhr defines the request to validate
  66308. * @param dataType defines the expected data type
  66309. * @returns true if data is correct
  66310. */
  66311. private static _ValidateXHRData;
  66312. }
  66313. }
  66314. declare module "babylonjs/Offline/index" {
  66315. export * from "babylonjs/Offline/database";
  66316. export * from "babylonjs/Offline/IOfflineProvider";
  66317. }
  66318. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  66319. /** @hidden */
  66320. export var gpuUpdateParticlesPixelShader: {
  66321. name: string;
  66322. shader: string;
  66323. };
  66324. }
  66325. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  66326. /** @hidden */
  66327. export var gpuUpdateParticlesVertexShader: {
  66328. name: string;
  66329. shader: string;
  66330. };
  66331. }
  66332. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  66333. /** @hidden */
  66334. export var clipPlaneFragmentDeclaration2: {
  66335. name: string;
  66336. shader: string;
  66337. };
  66338. }
  66339. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  66340. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  66341. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66342. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66343. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66344. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  66345. /** @hidden */
  66346. export var gpuRenderParticlesPixelShader: {
  66347. name: string;
  66348. shader: string;
  66349. };
  66350. }
  66351. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  66352. /** @hidden */
  66353. export var clipPlaneVertexDeclaration2: {
  66354. name: string;
  66355. shader: string;
  66356. };
  66357. }
  66358. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  66359. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  66360. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  66361. /** @hidden */
  66362. export var gpuRenderParticlesVertexShader: {
  66363. name: string;
  66364. shader: string;
  66365. };
  66366. }
  66367. declare module "babylonjs/Particles/gpuParticleSystem" {
  66368. import { Nullable } from "babylonjs/types";
  66369. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  66370. import { Observable } from "babylonjs/Misc/observable";
  66371. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66372. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66373. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  66374. import { Scene, IDisposable } from "babylonjs/scene";
  66375. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  66376. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66377. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  66378. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  66379. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  66380. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  66381. /**
  66382. * This represents a GPU particle system in Babylon
  66383. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66384. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66385. */
  66386. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66387. /**
  66388. * The layer mask we are rendering the particles through.
  66389. */
  66390. layerMask: number;
  66391. private _capacity;
  66392. private _activeCount;
  66393. private _currentActiveCount;
  66394. private _accumulatedCount;
  66395. private _renderEffect;
  66396. private _updateEffect;
  66397. private _buffer0;
  66398. private _buffer1;
  66399. private _spriteBuffer;
  66400. private _updateVAO;
  66401. private _renderVAO;
  66402. private _targetIndex;
  66403. private _sourceBuffer;
  66404. private _targetBuffer;
  66405. private _engine;
  66406. private _currentRenderId;
  66407. private _started;
  66408. private _stopped;
  66409. private _timeDelta;
  66410. private _randomTexture;
  66411. private _randomTexture2;
  66412. private _attributesStrideSize;
  66413. private _updateEffectOptions;
  66414. private _randomTextureSize;
  66415. private _actualFrame;
  66416. private readonly _rawTextureWidth;
  66417. /**
  66418. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66419. */
  66420. static get IsSupported(): boolean;
  66421. /**
  66422. * An event triggered when the system is disposed.
  66423. */
  66424. onDisposeObservable: Observable<GPUParticleSystem>;
  66425. /**
  66426. * Gets the maximum number of particles active at the same time.
  66427. * @returns The max number of active particles.
  66428. */
  66429. getCapacity(): number;
  66430. /**
  66431. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66432. * to override the particles.
  66433. */
  66434. forceDepthWrite: boolean;
  66435. /**
  66436. * Gets or set the number of active particles
  66437. */
  66438. get activeParticleCount(): number;
  66439. set activeParticleCount(value: number);
  66440. private _preWarmDone;
  66441. /**
  66442. * Specifies if the particles are updated in emitter local space or world space.
  66443. * This is always false for GPU particles
  66444. */
  66445. get isLocal(): boolean;
  66446. set isLocal(value: boolean);
  66447. /**
  66448. * Is this system ready to be used/rendered
  66449. * @return true if the system is ready
  66450. */
  66451. isReady(): boolean;
  66452. /**
  66453. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66454. * @returns True if it has been started, otherwise false.
  66455. */
  66456. isStarted(): boolean;
  66457. /**
  66458. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66459. * @returns True if it has been stopped, otherwise false.
  66460. */
  66461. isStopped(): boolean;
  66462. /**
  66463. * Gets a boolean indicating that the system is stopping
  66464. * @returns true if the system is currently stopping
  66465. */
  66466. isStopping(): boolean;
  66467. /**
  66468. * Gets the number of particles active at the same time.
  66469. * @returns The number of active particles.
  66470. */
  66471. getActiveCount(): number;
  66472. /**
  66473. * Starts the particle system and begins to emit
  66474. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66475. */
  66476. start(delay?: number): void;
  66477. /**
  66478. * Stops the particle system.
  66479. */
  66480. stop(): void;
  66481. /**
  66482. * Remove all active particles
  66483. */
  66484. reset(): void;
  66485. /**
  66486. * Returns the string "GPUParticleSystem"
  66487. * @returns a string containing the class name
  66488. */
  66489. getClassName(): string;
  66490. private _colorGradientsTexture;
  66491. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66492. /**
  66493. * Adds a new color gradient
  66494. * @param gradient defines the gradient to use (between 0 and 1)
  66495. * @param color1 defines the color to affect to the specified gradient
  66496. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66497. * @returns the current particle system
  66498. */
  66499. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66500. private _refreshColorGradient;
  66501. /** Force the system to rebuild all gradients that need to be resync */
  66502. forceRefreshGradients(): void;
  66503. /**
  66504. * Remove a specific color gradient
  66505. * @param gradient defines the gradient to remove
  66506. * @returns the current particle system
  66507. */
  66508. removeColorGradient(gradient: number): GPUParticleSystem;
  66509. private _angularSpeedGradientsTexture;
  66510. private _sizeGradientsTexture;
  66511. private _velocityGradientsTexture;
  66512. private _limitVelocityGradientsTexture;
  66513. private _dragGradientsTexture;
  66514. private _addFactorGradient;
  66515. /**
  66516. * Adds a new size gradient
  66517. * @param gradient defines the gradient to use (between 0 and 1)
  66518. * @param factor defines the size factor to affect to the specified gradient
  66519. * @returns the current particle system
  66520. */
  66521. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66522. /**
  66523. * Remove a specific size gradient
  66524. * @param gradient defines the gradient to remove
  66525. * @returns the current particle system
  66526. */
  66527. removeSizeGradient(gradient: number): GPUParticleSystem;
  66528. private _refreshFactorGradient;
  66529. /**
  66530. * Adds a new angular speed gradient
  66531. * @param gradient defines the gradient to use (between 0 and 1)
  66532. * @param factor defines the angular speed to affect to the specified gradient
  66533. * @returns the current particle system
  66534. */
  66535. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66536. /**
  66537. * Remove a specific angular speed gradient
  66538. * @param gradient defines the gradient to remove
  66539. * @returns the current particle system
  66540. */
  66541. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66542. /**
  66543. * Adds a new velocity gradient
  66544. * @param gradient defines the gradient to use (between 0 and 1)
  66545. * @param factor defines the velocity to affect to the specified gradient
  66546. * @returns the current particle system
  66547. */
  66548. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66549. /**
  66550. * Remove a specific velocity gradient
  66551. * @param gradient defines the gradient to remove
  66552. * @returns the current particle system
  66553. */
  66554. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66555. /**
  66556. * Adds a new limit velocity gradient
  66557. * @param gradient defines the gradient to use (between 0 and 1)
  66558. * @param factor defines the limit velocity value to affect to the specified gradient
  66559. * @returns the current particle system
  66560. */
  66561. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66562. /**
  66563. * Remove a specific limit velocity gradient
  66564. * @param gradient defines the gradient to remove
  66565. * @returns the current particle system
  66566. */
  66567. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66568. /**
  66569. * Adds a new drag gradient
  66570. * @param gradient defines the gradient to use (between 0 and 1)
  66571. * @param factor defines the drag value to affect to the specified gradient
  66572. * @returns the current particle system
  66573. */
  66574. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66575. /**
  66576. * Remove a specific drag gradient
  66577. * @param gradient defines the gradient to remove
  66578. * @returns the current particle system
  66579. */
  66580. removeDragGradient(gradient: number): GPUParticleSystem;
  66581. /**
  66582. * Not supported by GPUParticleSystem
  66583. * @param gradient defines the gradient to use (between 0 and 1)
  66584. * @param factor defines the emit rate value to affect to the specified gradient
  66585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66586. * @returns the current particle system
  66587. */
  66588. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66589. /**
  66590. * Not supported by GPUParticleSystem
  66591. * @param gradient defines the gradient to remove
  66592. * @returns the current particle system
  66593. */
  66594. removeEmitRateGradient(gradient: number): IParticleSystem;
  66595. /**
  66596. * Not supported by GPUParticleSystem
  66597. * @param gradient defines the gradient to use (between 0 and 1)
  66598. * @param factor defines the start size value to affect to the specified gradient
  66599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66600. * @returns the current particle system
  66601. */
  66602. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66603. /**
  66604. * Not supported by GPUParticleSystem
  66605. * @param gradient defines the gradient to remove
  66606. * @returns the current particle system
  66607. */
  66608. removeStartSizeGradient(gradient: number): IParticleSystem;
  66609. /**
  66610. * Not supported by GPUParticleSystem
  66611. * @param gradient defines the gradient to use (between 0 and 1)
  66612. * @param min defines the color remap minimal range
  66613. * @param max defines the color remap maximal range
  66614. * @returns the current particle system
  66615. */
  66616. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66617. /**
  66618. * Not supported by GPUParticleSystem
  66619. * @param gradient defines the gradient to remove
  66620. * @returns the current particle system
  66621. */
  66622. removeColorRemapGradient(): IParticleSystem;
  66623. /**
  66624. * Not supported by GPUParticleSystem
  66625. * @param gradient defines the gradient to use (between 0 and 1)
  66626. * @param min defines the alpha remap minimal range
  66627. * @param max defines the alpha remap maximal range
  66628. * @returns the current particle system
  66629. */
  66630. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66631. /**
  66632. * Not supported by GPUParticleSystem
  66633. * @param gradient defines the gradient to remove
  66634. * @returns the current particle system
  66635. */
  66636. removeAlphaRemapGradient(): IParticleSystem;
  66637. /**
  66638. * Not supported by GPUParticleSystem
  66639. * @param gradient defines the gradient to use (between 0 and 1)
  66640. * @param color defines the color to affect to the specified gradient
  66641. * @returns the current particle system
  66642. */
  66643. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66644. /**
  66645. * Not supported by GPUParticleSystem
  66646. * @param gradient defines the gradient to remove
  66647. * @returns the current particle system
  66648. */
  66649. removeRampGradient(): IParticleSystem;
  66650. /**
  66651. * Not supported by GPUParticleSystem
  66652. * @returns the list of ramp gradients
  66653. */
  66654. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66655. /**
  66656. * Not supported by GPUParticleSystem
  66657. * Gets or sets a boolean indicating that ramp gradients must be used
  66658. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66659. */
  66660. get useRampGradients(): boolean;
  66661. set useRampGradients(value: boolean);
  66662. /**
  66663. * Not supported by GPUParticleSystem
  66664. * @param gradient defines the gradient to use (between 0 and 1)
  66665. * @param factor defines the life time factor to affect to the specified gradient
  66666. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66667. * @returns the current particle system
  66668. */
  66669. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66670. /**
  66671. * Not supported by GPUParticleSystem
  66672. * @param gradient defines the gradient to remove
  66673. * @returns the current particle system
  66674. */
  66675. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66676. /**
  66677. * Instantiates a GPU particle system.
  66678. * 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.
  66679. * @param name The name of the particle system
  66680. * @param options The options used to create the system
  66681. * @param scene The scene the particle system belongs to
  66682. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66683. */
  66684. constructor(name: string, options: Partial<{
  66685. capacity: number;
  66686. randomTextureSize: number;
  66687. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66688. protected _reset(): void;
  66689. private _createUpdateVAO;
  66690. private _createRenderVAO;
  66691. private _initialize;
  66692. /** @hidden */
  66693. _recreateUpdateEffect(): void;
  66694. /** @hidden */
  66695. _recreateRenderEffect(): void;
  66696. /**
  66697. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66698. * @param preWarm defines if we are in the pre-warmimg phase
  66699. */
  66700. animate(preWarm?: boolean): void;
  66701. private _createFactorGradientTexture;
  66702. private _createSizeGradientTexture;
  66703. private _createAngularSpeedGradientTexture;
  66704. private _createVelocityGradientTexture;
  66705. private _createLimitVelocityGradientTexture;
  66706. private _createDragGradientTexture;
  66707. private _createColorGradientTexture;
  66708. /**
  66709. * Renders the particle system in its current state
  66710. * @param preWarm defines if the system should only update the particles but not render them
  66711. * @returns the current number of particles
  66712. */
  66713. render(preWarm?: boolean): number;
  66714. /**
  66715. * Rebuilds the particle system
  66716. */
  66717. rebuild(): void;
  66718. private _releaseBuffers;
  66719. private _releaseVAOs;
  66720. /**
  66721. * Disposes the particle system and free the associated resources
  66722. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66723. */
  66724. dispose(disposeTexture?: boolean): void;
  66725. /**
  66726. * Clones the particle system.
  66727. * @param name The name of the cloned object
  66728. * @param newEmitter The new emitter to use
  66729. * @returns the cloned particle system
  66730. */
  66731. clone(name: string, newEmitter: any): GPUParticleSystem;
  66732. /**
  66733. * Serializes the particle system to a JSON object
  66734. * @param serializeTexture defines if the texture must be serialized as well
  66735. * @returns the JSON object
  66736. */
  66737. serialize(serializeTexture?: boolean): any;
  66738. /**
  66739. * Parses a JSON object to create a GPU particle system.
  66740. * @param parsedParticleSystem The JSON object to parse
  66741. * @param scene The scene to create the particle system in
  66742. * @param rootUrl The root url to use to load external dependencies like texture
  66743. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66744. * @returns the parsed GPU particle system
  66745. */
  66746. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66747. }
  66748. }
  66749. declare module "babylonjs/Particles/particleSystemSet" {
  66750. import { Nullable } from "babylonjs/types";
  66751. import { Color3 } from "babylonjs/Maths/math.color";
  66752. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66754. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66755. import { Scene, IDisposable } from "babylonjs/scene";
  66756. /**
  66757. * Represents a set of particle systems working together to create a specific effect
  66758. */
  66759. export class ParticleSystemSet implements IDisposable {
  66760. /**
  66761. * Gets or sets base Assets URL
  66762. */
  66763. static BaseAssetsUrl: string;
  66764. private _emitterCreationOptions;
  66765. private _emitterNode;
  66766. /**
  66767. * Gets the particle system list
  66768. */
  66769. systems: IParticleSystem[];
  66770. /**
  66771. * Gets the emitter node used with this set
  66772. */
  66773. get emitterNode(): Nullable<TransformNode>;
  66774. /**
  66775. * Creates a new emitter mesh as a sphere
  66776. * @param options defines the options used to create the sphere
  66777. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66778. * @param scene defines the hosting scene
  66779. */
  66780. setEmitterAsSphere(options: {
  66781. diameter: number;
  66782. segments: number;
  66783. color: Color3;
  66784. }, renderingGroupId: number, scene: Scene): void;
  66785. /**
  66786. * Starts all particle systems of the set
  66787. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66788. */
  66789. start(emitter?: AbstractMesh): void;
  66790. /**
  66791. * Release all associated resources
  66792. */
  66793. dispose(): void;
  66794. /**
  66795. * Serialize the set into a JSON compatible object
  66796. * @param serializeTexture defines if the texture must be serialized as well
  66797. * @returns a JSON compatible representation of the set
  66798. */
  66799. serialize(serializeTexture?: boolean): any;
  66800. /**
  66801. * Parse a new ParticleSystemSet from a serialized source
  66802. * @param data defines a JSON compatible representation of the set
  66803. * @param scene defines the hosting scene
  66804. * @param gpu defines if we want GPU particles or CPU particles
  66805. * @returns a new ParticleSystemSet
  66806. */
  66807. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66808. }
  66809. }
  66810. declare module "babylonjs/Particles/particleHelper" {
  66811. import { Nullable } from "babylonjs/types";
  66812. import { Scene } from "babylonjs/scene";
  66813. import { Vector3 } from "babylonjs/Maths/math.vector";
  66814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66815. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66816. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66817. /**
  66818. * This class is made for on one-liner static method to help creating particle system set.
  66819. */
  66820. export class ParticleHelper {
  66821. /**
  66822. * Gets or sets base Assets URL
  66823. */
  66824. static BaseAssetsUrl: string;
  66825. /** Define the Url to load snippets */
  66826. static SnippetUrl: string;
  66827. /**
  66828. * Create a default particle system that you can tweak
  66829. * @param emitter defines the emitter to use
  66830. * @param capacity defines the system capacity (default is 500 particles)
  66831. * @param scene defines the hosting scene
  66832. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66833. * @returns the new Particle system
  66834. */
  66835. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66836. /**
  66837. * This is the main static method (one-liner) of this helper to create different particle systems
  66838. * @param type This string represents the type to the particle system to create
  66839. * @param scene The scene where the particle system should live
  66840. * @param gpu If the system will use gpu
  66841. * @returns the ParticleSystemSet created
  66842. */
  66843. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66844. /**
  66845. * Static function used to export a particle system to a ParticleSystemSet variable.
  66846. * Please note that the emitter shape is not exported
  66847. * @param systems defines the particle systems to export
  66848. * @returns the created particle system set
  66849. */
  66850. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66851. /**
  66852. * Creates a particle system from a snippet saved in a remote file
  66853. * @param name defines the name of the particle system to create
  66854. * @param url defines the url to load from
  66855. * @param scene defines the hosting scene
  66856. * @param gpu If the system will use gpu
  66857. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66858. * @returns a promise that will resolve to the new particle system
  66859. */
  66860. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66861. /**
  66862. * Creates a particle system from a snippet saved by the particle system editor
  66863. * @param snippetId defines the snippet to load
  66864. * @param scene defines the hosting scene
  66865. * @param gpu If the system will use gpu
  66866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66867. * @returns a promise that will resolve to the new particle system
  66868. */
  66869. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66870. }
  66871. }
  66872. declare module "babylonjs/Particles/particleSystemComponent" {
  66873. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66874. import { Effect } from "babylonjs/Materials/effect";
  66875. import "babylonjs/Shaders/particles.vertex";
  66876. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66877. module "babylonjs/Engines/engine" {
  66878. interface Engine {
  66879. /**
  66880. * Create an effect to use with particle systems.
  66881. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66882. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66883. * @param uniformsNames defines a list of attribute names
  66884. * @param samplers defines an array of string used to represent textures
  66885. * @param defines defines the string containing the defines to use to compile the shaders
  66886. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66887. * @param onCompiled defines a function to call when the effect creation is successful
  66888. * @param onError defines a function to call when the effect creation has failed
  66889. * @returns the new Effect
  66890. */
  66891. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66892. }
  66893. }
  66894. module "babylonjs/Meshes/mesh" {
  66895. interface Mesh {
  66896. /**
  66897. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66898. * @returns an array of IParticleSystem
  66899. */
  66900. getEmittedParticleSystems(): IParticleSystem[];
  66901. /**
  66902. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66903. * @returns an array of IParticleSystem
  66904. */
  66905. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66906. }
  66907. }
  66908. /**
  66909. * @hidden
  66910. */
  66911. export var _IDoNeedToBeInTheBuild: number;
  66912. }
  66913. declare module "babylonjs/Particles/pointsCloudSystem" {
  66914. import { Color4 } from "babylonjs/Maths/math";
  66915. import { Mesh } from "babylonjs/Meshes/mesh";
  66916. import { Scene, IDisposable } from "babylonjs/scene";
  66917. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66918. /** Defines the 4 color options */
  66919. export enum PointColor {
  66920. /** color value */
  66921. Color = 2,
  66922. /** uv value */
  66923. UV = 1,
  66924. /** random value */
  66925. Random = 0,
  66926. /** stated value */
  66927. Stated = 3
  66928. }
  66929. /**
  66930. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66931. * 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.
  66932. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66933. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66934. *
  66935. * Full documentation here : TO BE ENTERED
  66936. */
  66937. export class PointsCloudSystem implements IDisposable {
  66938. /**
  66939. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66940. * Example : var p = SPS.particles[i];
  66941. */
  66942. particles: CloudPoint[];
  66943. /**
  66944. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66945. */
  66946. nbParticles: number;
  66947. /**
  66948. * This a counter for your own usage. It's not set by any SPS functions.
  66949. */
  66950. counter: number;
  66951. /**
  66952. * The PCS name. This name is also given to the underlying mesh.
  66953. */
  66954. name: string;
  66955. /**
  66956. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66957. */
  66958. mesh: Mesh;
  66959. /**
  66960. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66961. * Please read :
  66962. */
  66963. vars: any;
  66964. /**
  66965. * @hidden
  66966. */
  66967. _size: number;
  66968. private _scene;
  66969. private _promises;
  66970. private _positions;
  66971. private _indices;
  66972. private _normals;
  66973. private _colors;
  66974. private _uvs;
  66975. private _indices32;
  66976. private _positions32;
  66977. private _colors32;
  66978. private _uvs32;
  66979. private _updatable;
  66980. private _isVisibilityBoxLocked;
  66981. private _alwaysVisible;
  66982. private _groups;
  66983. private _groupCounter;
  66984. private _computeParticleColor;
  66985. private _computeParticleTexture;
  66986. private _computeParticleRotation;
  66987. private _computeBoundingBox;
  66988. private _isReady;
  66989. /**
  66990. * Creates a PCS (Points Cloud System) object
  66991. * @param name (String) is the PCS name, this will be the underlying mesh name
  66992. * @param pointSize (number) is the size for each point
  66993. * @param scene (Scene) is the scene in which the PCS is added
  66994. * @param options defines the options of the PCS e.g.
  66995. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66996. */
  66997. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66998. updatable?: boolean;
  66999. });
  67000. /**
  67001. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67002. * If no points were added to the PCS, the returned mesh is just a single point.
  67003. * @returns a promise for the created mesh
  67004. */
  67005. buildMeshAsync(): Promise<Mesh>;
  67006. /**
  67007. * @hidden
  67008. */
  67009. private _buildMesh;
  67010. private _addParticle;
  67011. private _randomUnitVector;
  67012. private _getColorIndicesForCoord;
  67013. private _setPointsColorOrUV;
  67014. private _colorFromTexture;
  67015. private _calculateDensity;
  67016. /**
  67017. * Adds points to the PCS in random positions within a unit sphere
  67018. * @param nb (positive integer) the number of particles to be created from this model
  67019. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67020. * @returns the number of groups in the system
  67021. */
  67022. addPoints(nb: number, pointFunction?: any): number;
  67023. /**
  67024. * Adds points to the PCS from the surface of the model shape
  67025. * @param mesh is any Mesh object that will be used as a surface model for the points
  67026. * @param nb (positive integer) the number of particles to be created from this model
  67027. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67028. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67029. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67030. * @returns the number of groups in the system
  67031. */
  67032. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67033. /**
  67034. * Adds points to the PCS inside the model shape
  67035. * @param mesh is any Mesh object that will be used as a surface model for the points
  67036. * @param nb (positive integer) the number of particles to be created from this model
  67037. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67038. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67039. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67040. * @returns the number of groups in the system
  67041. */
  67042. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67043. /**
  67044. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67045. * This method calls `updateParticle()` for each particle of the SPS.
  67046. * For an animated SPS, it is usually called within the render loop.
  67047. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67048. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67049. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67050. * @returns the PCS.
  67051. */
  67052. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67053. /**
  67054. * Disposes the PCS.
  67055. */
  67056. dispose(): void;
  67057. /**
  67058. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67059. * doc :
  67060. * @returns the PCS.
  67061. */
  67062. refreshVisibleSize(): PointsCloudSystem;
  67063. /**
  67064. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67065. * @param size the size (float) of the visibility box
  67066. * note : this doesn't lock the PCS mesh bounding box.
  67067. * doc :
  67068. */
  67069. setVisibilityBox(size: number): void;
  67070. /**
  67071. * Gets whether the PCS is always visible or not
  67072. * doc :
  67073. */
  67074. get isAlwaysVisible(): boolean;
  67075. /**
  67076. * Sets the PCS as always visible or not
  67077. * doc :
  67078. */
  67079. set isAlwaysVisible(val: boolean);
  67080. /**
  67081. * Tells to `setParticles()` to compute the particle rotations or not
  67082. * Default value : false. The PCS is faster when it's set to false
  67083. * Note : particle rotations are only applied to parent particles
  67084. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67085. */
  67086. set computeParticleRotation(val: boolean);
  67087. /**
  67088. * Tells to `setParticles()` to compute the particle colors or not.
  67089. * Default value : true. The PCS is faster when it's set to false.
  67090. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67091. */
  67092. set computeParticleColor(val: boolean);
  67093. set computeParticleTexture(val: boolean);
  67094. /**
  67095. * Gets if `setParticles()` computes the particle colors or not.
  67096. * Default value : false. The PCS is faster when it's set to false.
  67097. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67098. */
  67099. get computeParticleColor(): boolean;
  67100. /**
  67101. * Gets if `setParticles()` computes the particle textures or not.
  67102. * Default value : false. The PCS is faster when it's set to false.
  67103. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67104. */
  67105. get computeParticleTexture(): boolean;
  67106. /**
  67107. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67108. */
  67109. set computeBoundingBox(val: boolean);
  67110. /**
  67111. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67112. */
  67113. get computeBoundingBox(): boolean;
  67114. /**
  67115. * This function does nothing. It may be overwritten to set all the particle first values.
  67116. * The PCS doesn't call this function, you may have to call it by your own.
  67117. * doc :
  67118. */
  67119. initParticles(): void;
  67120. /**
  67121. * This function does nothing. It may be overwritten to recycle a particle
  67122. * The PCS doesn't call this function, you can to call it
  67123. * doc :
  67124. * @param particle The particle to recycle
  67125. * @returns the recycled particle
  67126. */
  67127. recycleParticle(particle: CloudPoint): CloudPoint;
  67128. /**
  67129. * Updates a particle : this function should be overwritten by the user.
  67130. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67131. * doc :
  67132. * @example : just set a particle position or velocity and recycle conditions
  67133. * @param particle The particle to update
  67134. * @returns the updated particle
  67135. */
  67136. updateParticle(particle: CloudPoint): CloudPoint;
  67137. /**
  67138. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67139. * This does nothing and may be overwritten by the user.
  67140. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67141. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67142. * @param update the boolean update value actually passed to setParticles()
  67143. */
  67144. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67145. /**
  67146. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67147. * This will be passed three parameters.
  67148. * This does nothing and may be overwritten by the user.
  67149. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67150. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67151. * @param update the boolean update value actually passed to setParticles()
  67152. */
  67153. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67154. }
  67155. }
  67156. declare module "babylonjs/Particles/cloudPoint" {
  67157. import { Nullable } from "babylonjs/types";
  67158. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  67159. import { Mesh } from "babylonjs/Meshes/mesh";
  67160. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67161. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  67162. /**
  67163. * Represents one particle of a points cloud system.
  67164. */
  67165. export class CloudPoint {
  67166. /**
  67167. * particle global index
  67168. */
  67169. idx: number;
  67170. /**
  67171. * The color of the particle
  67172. */
  67173. color: Nullable<Color4>;
  67174. /**
  67175. * The world space position of the particle.
  67176. */
  67177. position: Vector3;
  67178. /**
  67179. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67180. */
  67181. rotation: Vector3;
  67182. /**
  67183. * The world space rotation quaternion of the particle.
  67184. */
  67185. rotationQuaternion: Nullable<Quaternion>;
  67186. /**
  67187. * The uv of the particle.
  67188. */
  67189. uv: Nullable<Vector2>;
  67190. /**
  67191. * The current speed of the particle.
  67192. */
  67193. velocity: Vector3;
  67194. /**
  67195. * The pivot point in the particle local space.
  67196. */
  67197. pivot: Vector3;
  67198. /**
  67199. * Must the particle be translated from its pivot point in its local space ?
  67200. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67201. * Default : false
  67202. */
  67203. translateFromPivot: boolean;
  67204. /**
  67205. * Index of this particle in the global "positions" array (Internal use)
  67206. * @hidden
  67207. */
  67208. _pos: number;
  67209. /**
  67210. * @hidden Index of this particle in the global "indices" array (Internal use)
  67211. */
  67212. _ind: number;
  67213. /**
  67214. * Group this particle belongs to
  67215. */
  67216. _group: PointsGroup;
  67217. /**
  67218. * Group id of this particle
  67219. */
  67220. groupId: number;
  67221. /**
  67222. * Index of the particle in its group id (Internal use)
  67223. */
  67224. idxInGroup: number;
  67225. /**
  67226. * @hidden Particle BoundingInfo object (Internal use)
  67227. */
  67228. _boundingInfo: BoundingInfo;
  67229. /**
  67230. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67231. */
  67232. _pcs: PointsCloudSystem;
  67233. /**
  67234. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67235. */
  67236. _stillInvisible: boolean;
  67237. /**
  67238. * @hidden Last computed particle rotation matrix
  67239. */
  67240. _rotationMatrix: number[];
  67241. /**
  67242. * Parent particle Id, if any.
  67243. * Default null.
  67244. */
  67245. parentId: Nullable<number>;
  67246. /**
  67247. * @hidden Internal global position in the PCS.
  67248. */
  67249. _globalPosition: Vector3;
  67250. /**
  67251. * Creates a Point Cloud object.
  67252. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67253. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67254. * @param group (PointsGroup) is the group the particle belongs to
  67255. * @param groupId (integer) is the group identifier in the PCS.
  67256. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67257. * @param pcs defines the PCS it is associated to
  67258. */
  67259. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67260. /**
  67261. * get point size
  67262. */
  67263. get size(): Vector3;
  67264. /**
  67265. * Set point size
  67266. */
  67267. set size(scale: Vector3);
  67268. /**
  67269. * Legacy support, changed quaternion to rotationQuaternion
  67270. */
  67271. get quaternion(): Nullable<Quaternion>;
  67272. /**
  67273. * Legacy support, changed quaternion to rotationQuaternion
  67274. */
  67275. set quaternion(q: Nullable<Quaternion>);
  67276. /**
  67277. * Returns a boolean. True if the particle intersects a mesh, else false
  67278. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67279. * @param target is the object (point or mesh) what the intersection is computed against
  67280. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67281. * @returns true if it intersects
  67282. */
  67283. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67284. /**
  67285. * get the rotation matrix of the particle
  67286. * @hidden
  67287. */
  67288. getRotationMatrix(m: Matrix): void;
  67289. }
  67290. /**
  67291. * Represents a group of points in a points cloud system
  67292. * * PCS internal tool, don't use it manually.
  67293. */
  67294. export class PointsGroup {
  67295. /**
  67296. * The group id
  67297. * @hidden
  67298. */
  67299. groupID: number;
  67300. /**
  67301. * image data for group (internal use)
  67302. * @hidden
  67303. */
  67304. _groupImageData: Nullable<ArrayBufferView>;
  67305. /**
  67306. * Image Width (internal use)
  67307. * @hidden
  67308. */
  67309. _groupImgWidth: number;
  67310. /**
  67311. * Image Height (internal use)
  67312. * @hidden
  67313. */
  67314. _groupImgHeight: number;
  67315. /**
  67316. * Custom position function (internal use)
  67317. * @hidden
  67318. */
  67319. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67320. /**
  67321. * density per facet for surface points
  67322. * @hidden
  67323. */
  67324. _groupDensity: number[];
  67325. /**
  67326. * Only when points are colored by texture carries pointer to texture list array
  67327. * @hidden
  67328. */
  67329. _textureNb: number;
  67330. /**
  67331. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67332. * PCS internal tool, don't use it manually.
  67333. * @hidden
  67334. */
  67335. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67336. }
  67337. }
  67338. declare module "babylonjs/Particles/index" {
  67339. export * from "babylonjs/Particles/baseParticleSystem";
  67340. export * from "babylonjs/Particles/EmitterTypes/index";
  67341. export * from "babylonjs/Particles/gpuParticleSystem";
  67342. export * from "babylonjs/Particles/IParticleSystem";
  67343. export * from "babylonjs/Particles/particle";
  67344. export * from "babylonjs/Particles/particleHelper";
  67345. export * from "babylonjs/Particles/particleSystem";
  67346. export * from "babylonjs/Particles/particleSystemComponent";
  67347. export * from "babylonjs/Particles/particleSystemSet";
  67348. export * from "babylonjs/Particles/solidParticle";
  67349. export * from "babylonjs/Particles/solidParticleSystem";
  67350. export * from "babylonjs/Particles/cloudPoint";
  67351. export * from "babylonjs/Particles/pointsCloudSystem";
  67352. export * from "babylonjs/Particles/subEmitter";
  67353. }
  67354. declare module "babylonjs/Physics/physicsEngineComponent" {
  67355. import { Nullable } from "babylonjs/types";
  67356. import { Observable, Observer } from "babylonjs/Misc/observable";
  67357. import { Vector3 } from "babylonjs/Maths/math.vector";
  67358. import { Mesh } from "babylonjs/Meshes/mesh";
  67359. import { ISceneComponent } from "babylonjs/sceneComponent";
  67360. import { Scene } from "babylonjs/scene";
  67361. import { Node } from "babylonjs/node";
  67362. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67363. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67364. module "babylonjs/scene" {
  67365. interface Scene {
  67366. /** @hidden (Backing field) */
  67367. _physicsEngine: Nullable<IPhysicsEngine>;
  67368. /** @hidden */
  67369. _physicsTimeAccumulator: number;
  67370. /**
  67371. * Gets the current physics engine
  67372. * @returns a IPhysicsEngine or null if none attached
  67373. */
  67374. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67375. /**
  67376. * Enables physics to the current scene
  67377. * @param gravity defines the scene's gravity for the physics engine
  67378. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67379. * @return a boolean indicating if the physics engine was initialized
  67380. */
  67381. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67382. /**
  67383. * Disables and disposes the physics engine associated with the scene
  67384. */
  67385. disablePhysicsEngine(): void;
  67386. /**
  67387. * Gets a boolean indicating if there is an active physics engine
  67388. * @returns a boolean indicating if there is an active physics engine
  67389. */
  67390. isPhysicsEnabled(): boolean;
  67391. /**
  67392. * Deletes a physics compound impostor
  67393. * @param compound defines the compound to delete
  67394. */
  67395. deleteCompoundImpostor(compound: any): void;
  67396. /**
  67397. * An event triggered when physic simulation is about to be run
  67398. */
  67399. onBeforePhysicsObservable: Observable<Scene>;
  67400. /**
  67401. * An event triggered when physic simulation has been done
  67402. */
  67403. onAfterPhysicsObservable: Observable<Scene>;
  67404. }
  67405. }
  67406. module "babylonjs/Meshes/abstractMesh" {
  67407. interface AbstractMesh {
  67408. /** @hidden */
  67409. _physicsImpostor: Nullable<PhysicsImpostor>;
  67410. /**
  67411. * Gets or sets impostor used for physic simulation
  67412. * @see http://doc.babylonjs.com/features/physics_engine
  67413. */
  67414. physicsImpostor: Nullable<PhysicsImpostor>;
  67415. /**
  67416. * Gets the current physics impostor
  67417. * @see http://doc.babylonjs.com/features/physics_engine
  67418. * @returns a physics impostor or null
  67419. */
  67420. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67421. /** Apply a physic impulse to the mesh
  67422. * @param force defines the force to apply
  67423. * @param contactPoint defines where to apply the force
  67424. * @returns the current mesh
  67425. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67426. */
  67427. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67428. /**
  67429. * Creates a physic joint between two meshes
  67430. * @param otherMesh defines the other mesh to use
  67431. * @param pivot1 defines the pivot to use on this mesh
  67432. * @param pivot2 defines the pivot to use on the other mesh
  67433. * @param options defines additional options (can be plugin dependent)
  67434. * @returns the current mesh
  67435. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67436. */
  67437. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67438. /** @hidden */
  67439. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67440. }
  67441. }
  67442. /**
  67443. * Defines the physics engine scene component responsible to manage a physics engine
  67444. */
  67445. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67446. /**
  67447. * The component name helpful to identify the component in the list of scene components.
  67448. */
  67449. readonly name: string;
  67450. /**
  67451. * The scene the component belongs to.
  67452. */
  67453. scene: Scene;
  67454. /**
  67455. * Creates a new instance of the component for the given scene
  67456. * @param scene Defines the scene to register the component in
  67457. */
  67458. constructor(scene: Scene);
  67459. /**
  67460. * Registers the component in a given scene
  67461. */
  67462. register(): void;
  67463. /**
  67464. * Rebuilds the elements related to this component in case of
  67465. * context lost for instance.
  67466. */
  67467. rebuild(): void;
  67468. /**
  67469. * Disposes the component and the associated ressources
  67470. */
  67471. dispose(): void;
  67472. }
  67473. }
  67474. declare module "babylonjs/Physics/physicsHelper" {
  67475. import { Nullable } from "babylonjs/types";
  67476. import { Vector3 } from "babylonjs/Maths/math.vector";
  67477. import { Mesh } from "babylonjs/Meshes/mesh";
  67478. import { Scene } from "babylonjs/scene";
  67479. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67480. /**
  67481. * A helper for physics simulations
  67482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67483. */
  67484. export class PhysicsHelper {
  67485. private _scene;
  67486. private _physicsEngine;
  67487. /**
  67488. * Initializes the Physics helper
  67489. * @param scene Babylon.js scene
  67490. */
  67491. constructor(scene: Scene);
  67492. /**
  67493. * Applies a radial explosion impulse
  67494. * @param origin the origin of the explosion
  67495. * @param radiusOrEventOptions the radius or the options of radial explosion
  67496. * @param strength the explosion strength
  67497. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67498. * @returns A physics radial explosion event, or null
  67499. */
  67500. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67501. /**
  67502. * Applies a radial explosion force
  67503. * @param origin the origin of the explosion
  67504. * @param radiusOrEventOptions the radius or the options of radial explosion
  67505. * @param strength the explosion strength
  67506. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67507. * @returns A physics radial explosion event, or null
  67508. */
  67509. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67510. /**
  67511. * Creates a gravitational field
  67512. * @param origin the origin of the explosion
  67513. * @param radiusOrEventOptions the radius or the options of radial explosion
  67514. * @param strength the explosion strength
  67515. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67516. * @returns A physics gravitational field event, or null
  67517. */
  67518. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67519. /**
  67520. * Creates a physics updraft event
  67521. * @param origin the origin of the updraft
  67522. * @param radiusOrEventOptions the radius or the options of the updraft
  67523. * @param strength the strength of the updraft
  67524. * @param height the height of the updraft
  67525. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67526. * @returns A physics updraft event, or null
  67527. */
  67528. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67529. /**
  67530. * Creates a physics vortex event
  67531. * @param origin the of the vortex
  67532. * @param radiusOrEventOptions the radius or the options of the vortex
  67533. * @param strength the strength of the vortex
  67534. * @param height the height of the vortex
  67535. * @returns a Physics vortex event, or null
  67536. * A physics vortex event or null
  67537. */
  67538. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67539. }
  67540. /**
  67541. * Represents a physics radial explosion event
  67542. */
  67543. class PhysicsRadialExplosionEvent {
  67544. private _scene;
  67545. private _options;
  67546. private _sphere;
  67547. private _dataFetched;
  67548. /**
  67549. * Initializes a radial explosioin event
  67550. * @param _scene BabylonJS scene
  67551. * @param _options The options for the vortex event
  67552. */
  67553. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67554. /**
  67555. * Returns the data related to the radial explosion event (sphere).
  67556. * @returns The radial explosion event data
  67557. */
  67558. getData(): PhysicsRadialExplosionEventData;
  67559. /**
  67560. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67561. * @param impostor A physics imposter
  67562. * @param origin the origin of the explosion
  67563. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67564. */
  67565. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67566. /**
  67567. * Triggers affecterd impostors callbacks
  67568. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67569. */
  67570. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67571. /**
  67572. * Disposes the sphere.
  67573. * @param force Specifies if the sphere should be disposed by force
  67574. */
  67575. dispose(force?: boolean): void;
  67576. /*** Helpers ***/
  67577. private _prepareSphere;
  67578. private _intersectsWithSphere;
  67579. }
  67580. /**
  67581. * Represents a gravitational field event
  67582. */
  67583. class PhysicsGravitationalFieldEvent {
  67584. private _physicsHelper;
  67585. private _scene;
  67586. private _origin;
  67587. private _options;
  67588. private _tickCallback;
  67589. private _sphere;
  67590. private _dataFetched;
  67591. /**
  67592. * Initializes the physics gravitational field event
  67593. * @param _physicsHelper A physics helper
  67594. * @param _scene BabylonJS scene
  67595. * @param _origin The origin position of the gravitational field event
  67596. * @param _options The options for the vortex event
  67597. */
  67598. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67599. /**
  67600. * Returns the data related to the gravitational field event (sphere).
  67601. * @returns A gravitational field event
  67602. */
  67603. getData(): PhysicsGravitationalFieldEventData;
  67604. /**
  67605. * Enables the gravitational field.
  67606. */
  67607. enable(): void;
  67608. /**
  67609. * Disables the gravitational field.
  67610. */
  67611. disable(): void;
  67612. /**
  67613. * Disposes the sphere.
  67614. * @param force The force to dispose from the gravitational field event
  67615. */
  67616. dispose(force?: boolean): void;
  67617. private _tick;
  67618. }
  67619. /**
  67620. * Represents a physics updraft event
  67621. */
  67622. class PhysicsUpdraftEvent {
  67623. private _scene;
  67624. private _origin;
  67625. private _options;
  67626. private _physicsEngine;
  67627. private _originTop;
  67628. private _originDirection;
  67629. private _tickCallback;
  67630. private _cylinder;
  67631. private _cylinderPosition;
  67632. private _dataFetched;
  67633. /**
  67634. * Initializes the physics updraft event
  67635. * @param _scene BabylonJS scene
  67636. * @param _origin The origin position of the updraft
  67637. * @param _options The options for the updraft event
  67638. */
  67639. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67640. /**
  67641. * Returns the data related to the updraft event (cylinder).
  67642. * @returns A physics updraft event
  67643. */
  67644. getData(): PhysicsUpdraftEventData;
  67645. /**
  67646. * Enables the updraft.
  67647. */
  67648. enable(): void;
  67649. /**
  67650. * Disables the updraft.
  67651. */
  67652. disable(): void;
  67653. /**
  67654. * Disposes the cylinder.
  67655. * @param force Specifies if the updraft should be disposed by force
  67656. */
  67657. dispose(force?: boolean): void;
  67658. private getImpostorHitData;
  67659. private _tick;
  67660. /*** Helpers ***/
  67661. private _prepareCylinder;
  67662. private _intersectsWithCylinder;
  67663. }
  67664. /**
  67665. * Represents a physics vortex event
  67666. */
  67667. class PhysicsVortexEvent {
  67668. private _scene;
  67669. private _origin;
  67670. private _options;
  67671. private _physicsEngine;
  67672. private _originTop;
  67673. private _tickCallback;
  67674. private _cylinder;
  67675. private _cylinderPosition;
  67676. private _dataFetched;
  67677. /**
  67678. * Initializes the physics vortex event
  67679. * @param _scene The BabylonJS scene
  67680. * @param _origin The origin position of the vortex
  67681. * @param _options The options for the vortex event
  67682. */
  67683. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67684. /**
  67685. * Returns the data related to the vortex event (cylinder).
  67686. * @returns The physics vortex event data
  67687. */
  67688. getData(): PhysicsVortexEventData;
  67689. /**
  67690. * Enables the vortex.
  67691. */
  67692. enable(): void;
  67693. /**
  67694. * Disables the cortex.
  67695. */
  67696. disable(): void;
  67697. /**
  67698. * Disposes the sphere.
  67699. * @param force
  67700. */
  67701. dispose(force?: boolean): void;
  67702. private getImpostorHitData;
  67703. private _tick;
  67704. /*** Helpers ***/
  67705. private _prepareCylinder;
  67706. private _intersectsWithCylinder;
  67707. }
  67708. /**
  67709. * Options fot the radial explosion event
  67710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67711. */
  67712. export class PhysicsRadialExplosionEventOptions {
  67713. /**
  67714. * The radius of the sphere for the radial explosion.
  67715. */
  67716. radius: number;
  67717. /**
  67718. * The strenth of the explosion.
  67719. */
  67720. strength: number;
  67721. /**
  67722. * The strenght of the force in correspondence to the distance of the affected object
  67723. */
  67724. falloff: PhysicsRadialImpulseFalloff;
  67725. /**
  67726. * Sphere options for the radial explosion.
  67727. */
  67728. sphere: {
  67729. segments: number;
  67730. diameter: number;
  67731. };
  67732. /**
  67733. * Sphere options for the radial explosion.
  67734. */
  67735. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67736. }
  67737. /**
  67738. * Options fot the updraft event
  67739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67740. */
  67741. export class PhysicsUpdraftEventOptions {
  67742. /**
  67743. * The radius of the cylinder for the vortex
  67744. */
  67745. radius: number;
  67746. /**
  67747. * The strenth of the updraft.
  67748. */
  67749. strength: number;
  67750. /**
  67751. * The height of the cylinder for the updraft.
  67752. */
  67753. height: number;
  67754. /**
  67755. * The mode for the the updraft.
  67756. */
  67757. updraftMode: PhysicsUpdraftMode;
  67758. }
  67759. /**
  67760. * Options fot the vortex event
  67761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67762. */
  67763. export class PhysicsVortexEventOptions {
  67764. /**
  67765. * The radius of the cylinder for the vortex
  67766. */
  67767. radius: number;
  67768. /**
  67769. * The strenth of the vortex.
  67770. */
  67771. strength: number;
  67772. /**
  67773. * The height of the cylinder for the vortex.
  67774. */
  67775. height: number;
  67776. /**
  67777. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67778. */
  67779. centripetalForceThreshold: number;
  67780. /**
  67781. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67782. */
  67783. centripetalForceMultiplier: number;
  67784. /**
  67785. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67786. */
  67787. centrifugalForceMultiplier: number;
  67788. /**
  67789. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67790. */
  67791. updraftForceMultiplier: number;
  67792. }
  67793. /**
  67794. * The strenght of the force in correspondence to the distance of the affected object
  67795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67796. */
  67797. export enum PhysicsRadialImpulseFalloff {
  67798. /** Defines that impulse is constant in strength across it's whole radius */
  67799. Constant = 0,
  67800. /** Defines that impulse gets weaker if it's further from the origin */
  67801. Linear = 1
  67802. }
  67803. /**
  67804. * The strength of the force in correspondence to the distance of the affected object
  67805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67806. */
  67807. export enum PhysicsUpdraftMode {
  67808. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67809. Center = 0,
  67810. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67811. Perpendicular = 1
  67812. }
  67813. /**
  67814. * Interface for a physics hit data
  67815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67816. */
  67817. export interface PhysicsHitData {
  67818. /**
  67819. * The force applied at the contact point
  67820. */
  67821. force: Vector3;
  67822. /**
  67823. * The contact point
  67824. */
  67825. contactPoint: Vector3;
  67826. /**
  67827. * The distance from the origin to the contact point
  67828. */
  67829. distanceFromOrigin: number;
  67830. }
  67831. /**
  67832. * Interface for radial explosion event data
  67833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67834. */
  67835. export interface PhysicsRadialExplosionEventData {
  67836. /**
  67837. * A sphere used for the radial explosion event
  67838. */
  67839. sphere: Mesh;
  67840. }
  67841. /**
  67842. * Interface for gravitational field event data
  67843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67844. */
  67845. export interface PhysicsGravitationalFieldEventData {
  67846. /**
  67847. * A sphere mesh used for the gravitational field event
  67848. */
  67849. sphere: Mesh;
  67850. }
  67851. /**
  67852. * Interface for updraft event data
  67853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67854. */
  67855. export interface PhysicsUpdraftEventData {
  67856. /**
  67857. * A cylinder used for the updraft event
  67858. */
  67859. cylinder: Mesh;
  67860. }
  67861. /**
  67862. * Interface for vortex event data
  67863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67864. */
  67865. export interface PhysicsVortexEventData {
  67866. /**
  67867. * A cylinder used for the vortex event
  67868. */
  67869. cylinder: Mesh;
  67870. }
  67871. /**
  67872. * Interface for an affected physics impostor
  67873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67874. */
  67875. export interface PhysicsAffectedImpostorWithData {
  67876. /**
  67877. * The impostor affected by the effect
  67878. */
  67879. impostor: PhysicsImpostor;
  67880. /**
  67881. * The data about the hit/horce from the explosion
  67882. */
  67883. hitData: PhysicsHitData;
  67884. }
  67885. }
  67886. declare module "babylonjs/Physics/Plugins/index" {
  67887. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67888. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67889. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67890. }
  67891. declare module "babylonjs/Physics/index" {
  67892. export * from "babylonjs/Physics/IPhysicsEngine";
  67893. export * from "babylonjs/Physics/physicsEngine";
  67894. export * from "babylonjs/Physics/physicsEngineComponent";
  67895. export * from "babylonjs/Physics/physicsHelper";
  67896. export * from "babylonjs/Physics/physicsImpostor";
  67897. export * from "babylonjs/Physics/physicsJoint";
  67898. export * from "babylonjs/Physics/Plugins/index";
  67899. }
  67900. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67901. /** @hidden */
  67902. export var blackAndWhitePixelShader: {
  67903. name: string;
  67904. shader: string;
  67905. };
  67906. }
  67907. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67908. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67909. import { Camera } from "babylonjs/Cameras/camera";
  67910. import { Engine } from "babylonjs/Engines/engine";
  67911. import "babylonjs/Shaders/blackAndWhite.fragment";
  67912. /**
  67913. * Post process used to render in black and white
  67914. */
  67915. export class BlackAndWhitePostProcess extends PostProcess {
  67916. /**
  67917. * Linear about to convert he result to black and white (default: 1)
  67918. */
  67919. degree: number;
  67920. /**
  67921. * Creates a black and white post process
  67922. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67923. * @param name The name of the effect.
  67924. * @param options The required width/height ratio to downsize to before computing the render pass.
  67925. * @param camera The camera to apply the render pass to.
  67926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67927. * @param engine The engine which the post process will be applied. (default: current engine)
  67928. * @param reusable If the post process can be reused on the same frame. (default: false)
  67929. */
  67930. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67931. }
  67932. }
  67933. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67934. import { Nullable } from "babylonjs/types";
  67935. import { Camera } from "babylonjs/Cameras/camera";
  67936. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67937. import { Engine } from "babylonjs/Engines/engine";
  67938. /**
  67939. * This represents a set of one or more post processes in Babylon.
  67940. * A post process can be used to apply a shader to a texture after it is rendered.
  67941. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67942. */
  67943. export class PostProcessRenderEffect {
  67944. private _postProcesses;
  67945. private _getPostProcesses;
  67946. private _singleInstance;
  67947. private _cameras;
  67948. private _indicesForCamera;
  67949. /**
  67950. * Name of the effect
  67951. * @hidden
  67952. */
  67953. _name: string;
  67954. /**
  67955. * Instantiates a post process render effect.
  67956. * A post process can be used to apply a shader to a texture after it is rendered.
  67957. * @param engine The engine the effect is tied to
  67958. * @param name The name of the effect
  67959. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67960. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67961. */
  67962. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67963. /**
  67964. * Checks if all the post processes in the effect are supported.
  67965. */
  67966. get isSupported(): boolean;
  67967. /**
  67968. * Updates the current state of the effect
  67969. * @hidden
  67970. */
  67971. _update(): void;
  67972. /**
  67973. * Attaches the effect on cameras
  67974. * @param cameras The camera to attach to.
  67975. * @hidden
  67976. */
  67977. _attachCameras(cameras: Camera): void;
  67978. /**
  67979. * Attaches the effect on cameras
  67980. * @param cameras The camera to attach to.
  67981. * @hidden
  67982. */
  67983. _attachCameras(cameras: Camera[]): void;
  67984. /**
  67985. * Detaches the effect on cameras
  67986. * @param cameras The camera to detatch from.
  67987. * @hidden
  67988. */
  67989. _detachCameras(cameras: Camera): void;
  67990. /**
  67991. * Detatches the effect on cameras
  67992. * @param cameras The camera to detatch from.
  67993. * @hidden
  67994. */
  67995. _detachCameras(cameras: Camera[]): void;
  67996. /**
  67997. * Enables the effect on given cameras
  67998. * @param cameras The camera to enable.
  67999. * @hidden
  68000. */
  68001. _enable(cameras: Camera): void;
  68002. /**
  68003. * Enables the effect on given cameras
  68004. * @param cameras The camera to enable.
  68005. * @hidden
  68006. */
  68007. _enable(cameras: Nullable<Camera[]>): void;
  68008. /**
  68009. * Disables the effect on the given cameras
  68010. * @param cameras The camera to disable.
  68011. * @hidden
  68012. */
  68013. _disable(cameras: Camera): void;
  68014. /**
  68015. * Disables the effect on the given cameras
  68016. * @param cameras The camera to disable.
  68017. * @hidden
  68018. */
  68019. _disable(cameras: Nullable<Camera[]>): void;
  68020. /**
  68021. * Gets a list of the post processes contained in the effect.
  68022. * @param camera The camera to get the post processes on.
  68023. * @returns The list of the post processes in the effect.
  68024. */
  68025. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68026. }
  68027. }
  68028. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  68029. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68030. /** @hidden */
  68031. export var extractHighlightsPixelShader: {
  68032. name: string;
  68033. shader: string;
  68034. };
  68035. }
  68036. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  68037. import { Nullable } from "babylonjs/types";
  68038. import { Camera } from "babylonjs/Cameras/camera";
  68039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68040. import { Engine } from "babylonjs/Engines/engine";
  68041. import "babylonjs/Shaders/extractHighlights.fragment";
  68042. /**
  68043. * 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.
  68044. */
  68045. export class ExtractHighlightsPostProcess extends PostProcess {
  68046. /**
  68047. * The luminance threshold, pixels below this value will be set to black.
  68048. */
  68049. threshold: number;
  68050. /** @hidden */
  68051. _exposure: number;
  68052. /**
  68053. * Post process which has the input texture to be used when performing highlight extraction
  68054. * @hidden
  68055. */
  68056. _inputPostProcess: Nullable<PostProcess>;
  68057. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68058. }
  68059. }
  68060. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  68061. /** @hidden */
  68062. export var bloomMergePixelShader: {
  68063. name: string;
  68064. shader: string;
  68065. };
  68066. }
  68067. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  68068. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68069. import { Nullable } from "babylonjs/types";
  68070. import { Engine } from "babylonjs/Engines/engine";
  68071. import { Camera } from "babylonjs/Cameras/camera";
  68072. import "babylonjs/Shaders/bloomMerge.fragment";
  68073. /**
  68074. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68075. */
  68076. export class BloomMergePostProcess extends PostProcess {
  68077. /** Weight of the bloom to be added to the original input. */
  68078. weight: number;
  68079. /**
  68080. * Creates a new instance of @see BloomMergePostProcess
  68081. * @param name The name of the effect.
  68082. * @param originalFromInput Post process which's input will be used for the merge.
  68083. * @param blurred Blurred highlights post process which's output will be used.
  68084. * @param weight Weight of the bloom to be added to the original input.
  68085. * @param options The required width/height ratio to downsize to before computing the render pass.
  68086. * @param camera The camera to apply the render pass to.
  68087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68088. * @param engine The engine which the post process will be applied. (default: current engine)
  68089. * @param reusable If the post process can be reused on the same frame. (default: false)
  68090. * @param textureType Type of textures used when performing the post process. (default: 0)
  68091. * @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)
  68092. */
  68093. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68094. /** Weight of the bloom to be added to the original input. */
  68095. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68096. }
  68097. }
  68098. declare module "babylonjs/PostProcesses/bloomEffect" {
  68099. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68100. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68101. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68102. import { Camera } from "babylonjs/Cameras/camera";
  68103. import { Scene } from "babylonjs/scene";
  68104. /**
  68105. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68106. */
  68107. export class BloomEffect extends PostProcessRenderEffect {
  68108. private bloomScale;
  68109. /**
  68110. * @hidden Internal
  68111. */
  68112. _effects: Array<PostProcess>;
  68113. /**
  68114. * @hidden Internal
  68115. */
  68116. _downscale: ExtractHighlightsPostProcess;
  68117. private _blurX;
  68118. private _blurY;
  68119. private _merge;
  68120. /**
  68121. * The luminance threshold to find bright areas of the image to bloom.
  68122. */
  68123. get threshold(): number;
  68124. set threshold(value: number);
  68125. /**
  68126. * The strength of the bloom.
  68127. */
  68128. get weight(): number;
  68129. set weight(value: number);
  68130. /**
  68131. * Specifies the size of the bloom blur kernel, relative to the final output size
  68132. */
  68133. get kernel(): number;
  68134. set kernel(value: number);
  68135. /**
  68136. * Creates a new instance of @see BloomEffect
  68137. * @param scene The scene the effect belongs to.
  68138. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68139. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68140. * @param bloomWeight The the strength of bloom.
  68141. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68142. * @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)
  68143. */
  68144. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68145. /**
  68146. * Disposes each of the internal effects for a given camera.
  68147. * @param camera The camera to dispose the effect on.
  68148. */
  68149. disposeEffects(camera: Camera): void;
  68150. /**
  68151. * @hidden Internal
  68152. */
  68153. _updateEffects(): void;
  68154. /**
  68155. * Internal
  68156. * @returns if all the contained post processes are ready.
  68157. * @hidden
  68158. */
  68159. _isReady(): boolean;
  68160. }
  68161. }
  68162. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  68163. /** @hidden */
  68164. export var chromaticAberrationPixelShader: {
  68165. name: string;
  68166. shader: string;
  68167. };
  68168. }
  68169. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  68170. import { Vector2 } from "babylonjs/Maths/math.vector";
  68171. import { Nullable } from "babylonjs/types";
  68172. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68173. import { Camera } from "babylonjs/Cameras/camera";
  68174. import { Engine } from "babylonjs/Engines/engine";
  68175. import "babylonjs/Shaders/chromaticAberration.fragment";
  68176. /**
  68177. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68178. */
  68179. export class ChromaticAberrationPostProcess extends PostProcess {
  68180. /**
  68181. * The amount of seperation of rgb channels (default: 30)
  68182. */
  68183. aberrationAmount: number;
  68184. /**
  68185. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68186. */
  68187. radialIntensity: number;
  68188. /**
  68189. * 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))
  68190. */
  68191. direction: Vector2;
  68192. /**
  68193. * 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))
  68194. */
  68195. centerPosition: Vector2;
  68196. /**
  68197. * Creates a new instance ChromaticAberrationPostProcess
  68198. * @param name The name of the effect.
  68199. * @param screenWidth The width of the screen to apply the effect on.
  68200. * @param screenHeight The height of the screen to apply the effect on.
  68201. * @param options The required width/height ratio to downsize to before computing the render pass.
  68202. * @param camera The camera to apply the render pass to.
  68203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68204. * @param engine The engine which the post process will be applied. (default: current engine)
  68205. * @param reusable If the post process can be reused on the same frame. (default: false)
  68206. * @param textureType Type of textures used when performing the post process. (default: 0)
  68207. * @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)
  68208. */
  68209. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68210. }
  68211. }
  68212. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  68213. /** @hidden */
  68214. export var circleOfConfusionPixelShader: {
  68215. name: string;
  68216. shader: string;
  68217. };
  68218. }
  68219. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  68220. import { Nullable } from "babylonjs/types";
  68221. import { Engine } from "babylonjs/Engines/engine";
  68222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68223. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68224. import { Camera } from "babylonjs/Cameras/camera";
  68225. import "babylonjs/Shaders/circleOfConfusion.fragment";
  68226. /**
  68227. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68228. */
  68229. export class CircleOfConfusionPostProcess extends PostProcess {
  68230. /**
  68231. * 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.
  68232. */
  68233. lensSize: number;
  68234. /**
  68235. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68236. */
  68237. fStop: number;
  68238. /**
  68239. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68240. */
  68241. focusDistance: number;
  68242. /**
  68243. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68244. */
  68245. focalLength: number;
  68246. private _depthTexture;
  68247. /**
  68248. * Creates a new instance CircleOfConfusionPostProcess
  68249. * @param name The name of the effect.
  68250. * @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.
  68251. * @param options The required width/height ratio to downsize to before computing the render pass.
  68252. * @param camera The camera to apply the render pass to.
  68253. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68254. * @param engine The engine which the post process will be applied. (default: current engine)
  68255. * @param reusable If the post process can be reused on the same frame. (default: false)
  68256. * @param textureType Type of textures used when performing the post process. (default: 0)
  68257. * @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)
  68258. */
  68259. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68260. /**
  68261. * 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.
  68262. */
  68263. set depthTexture(value: RenderTargetTexture);
  68264. }
  68265. }
  68266. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  68267. /** @hidden */
  68268. export var colorCorrectionPixelShader: {
  68269. name: string;
  68270. shader: string;
  68271. };
  68272. }
  68273. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  68274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68275. import { Engine } from "babylonjs/Engines/engine";
  68276. import { Camera } from "babylonjs/Cameras/camera";
  68277. import "babylonjs/Shaders/colorCorrection.fragment";
  68278. /**
  68279. *
  68280. * This post-process allows the modification of rendered colors by using
  68281. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68282. *
  68283. * The object needs to be provided an url to a texture containing the color
  68284. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68285. * Use an image editing software to tweak the LUT to match your needs.
  68286. *
  68287. * For an example of a color LUT, see here:
  68288. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68289. * For explanations on color grading, see here:
  68290. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68291. *
  68292. */
  68293. export class ColorCorrectionPostProcess extends PostProcess {
  68294. private _colorTableTexture;
  68295. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68296. }
  68297. }
  68298. declare module "babylonjs/Shaders/convolution.fragment" {
  68299. /** @hidden */
  68300. export var convolutionPixelShader: {
  68301. name: string;
  68302. shader: string;
  68303. };
  68304. }
  68305. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  68306. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68307. import { Nullable } from "babylonjs/types";
  68308. import { Camera } from "babylonjs/Cameras/camera";
  68309. import { Engine } from "babylonjs/Engines/engine";
  68310. import "babylonjs/Shaders/convolution.fragment";
  68311. /**
  68312. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68313. * input texture to perform effects such as edge detection or sharpening
  68314. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68315. */
  68316. export class ConvolutionPostProcess extends PostProcess {
  68317. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68318. kernel: number[];
  68319. /**
  68320. * Creates a new instance ConvolutionPostProcess
  68321. * @param name The name of the effect.
  68322. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68323. * @param options The required width/height ratio to downsize to before computing the render pass.
  68324. * @param camera The camera to apply the render pass to.
  68325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68326. * @param engine The engine which the post process will be applied. (default: current engine)
  68327. * @param reusable If the post process can be reused on the same frame. (default: false)
  68328. * @param textureType Type of textures used when performing the post process. (default: 0)
  68329. */
  68330. constructor(name: string,
  68331. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68332. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68333. /**
  68334. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68335. */
  68336. static EdgeDetect0Kernel: number[];
  68337. /**
  68338. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68339. */
  68340. static EdgeDetect1Kernel: number[];
  68341. /**
  68342. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68343. */
  68344. static EdgeDetect2Kernel: number[];
  68345. /**
  68346. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68347. */
  68348. static SharpenKernel: number[];
  68349. /**
  68350. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68351. */
  68352. static EmbossKernel: number[];
  68353. /**
  68354. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68355. */
  68356. static GaussianKernel: number[];
  68357. }
  68358. }
  68359. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  68360. import { Nullable } from "babylonjs/types";
  68361. import { Vector2 } from "babylonjs/Maths/math.vector";
  68362. import { Camera } from "babylonjs/Cameras/camera";
  68363. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68364. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68365. import { Engine } from "babylonjs/Engines/engine";
  68366. import { Scene } from "babylonjs/scene";
  68367. /**
  68368. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68369. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68370. * based on samples that have a large difference in distance than the center pixel.
  68371. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68372. */
  68373. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68374. direction: Vector2;
  68375. /**
  68376. * Creates a new instance CircleOfConfusionPostProcess
  68377. * @param name The name of the effect.
  68378. * @param scene The scene the effect belongs to.
  68379. * @param direction The direction the blur should be applied.
  68380. * @param kernel The size of the kernel used to blur.
  68381. * @param options The required width/height ratio to downsize to before computing the render pass.
  68382. * @param camera The camera to apply the render pass to.
  68383. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68384. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68385. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68386. * @param engine The engine which the post process will be applied. (default: current engine)
  68387. * @param reusable If the post process can be reused on the same frame. (default: false)
  68388. * @param textureType Type of textures used when performing the post process. (default: 0)
  68389. * @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)
  68390. */
  68391. 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);
  68392. }
  68393. }
  68394. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  68395. /** @hidden */
  68396. export var depthOfFieldMergePixelShader: {
  68397. name: string;
  68398. shader: string;
  68399. };
  68400. }
  68401. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  68402. import { Nullable } from "babylonjs/types";
  68403. import { Camera } from "babylonjs/Cameras/camera";
  68404. import { Effect } from "babylonjs/Materials/effect";
  68405. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68406. import { Engine } from "babylonjs/Engines/engine";
  68407. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  68408. /**
  68409. * Options to be set when merging outputs from the default pipeline.
  68410. */
  68411. export class DepthOfFieldMergePostProcessOptions {
  68412. /**
  68413. * The original image to merge on top of
  68414. */
  68415. originalFromInput: PostProcess;
  68416. /**
  68417. * Parameters to perform the merge of the depth of field effect
  68418. */
  68419. depthOfField?: {
  68420. circleOfConfusion: PostProcess;
  68421. blurSteps: Array<PostProcess>;
  68422. };
  68423. /**
  68424. * Parameters to perform the merge of bloom effect
  68425. */
  68426. bloom?: {
  68427. blurred: PostProcess;
  68428. weight: number;
  68429. };
  68430. }
  68431. /**
  68432. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68433. */
  68434. export class DepthOfFieldMergePostProcess extends PostProcess {
  68435. private blurSteps;
  68436. /**
  68437. * Creates a new instance of DepthOfFieldMergePostProcess
  68438. * @param name The name of the effect.
  68439. * @param originalFromInput Post process which's input will be used for the merge.
  68440. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68441. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68442. * @param options The required width/height ratio to downsize to before computing the render pass.
  68443. * @param camera The camera to apply the render pass to.
  68444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68445. * @param engine The engine which the post process will be applied. (default: current engine)
  68446. * @param reusable If the post process can be reused on the same frame. (default: false)
  68447. * @param textureType Type of textures used when performing the post process. (default: 0)
  68448. * @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)
  68449. */
  68450. 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);
  68451. /**
  68452. * Updates the effect with the current post process compile time values and recompiles the shader.
  68453. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68454. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68455. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68456. * @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
  68457. * @param onCompiled Called when the shader has been compiled.
  68458. * @param onError Called if there is an error when compiling a shader.
  68459. */
  68460. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68461. }
  68462. }
  68463. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68464. import { Nullable } from "babylonjs/types";
  68465. import { Camera } from "babylonjs/Cameras/camera";
  68466. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68467. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68468. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68469. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68470. import { Scene } from "babylonjs/scene";
  68471. /**
  68472. * Specifies the level of max blur that should be applied when using the depth of field effect
  68473. */
  68474. export enum DepthOfFieldEffectBlurLevel {
  68475. /**
  68476. * Subtle blur
  68477. */
  68478. Low = 0,
  68479. /**
  68480. * Medium blur
  68481. */
  68482. Medium = 1,
  68483. /**
  68484. * Large blur
  68485. */
  68486. High = 2
  68487. }
  68488. /**
  68489. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68490. */
  68491. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68492. private _circleOfConfusion;
  68493. /**
  68494. * @hidden Internal, blurs from high to low
  68495. */
  68496. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68497. private _depthOfFieldBlurY;
  68498. private _dofMerge;
  68499. /**
  68500. * @hidden Internal post processes in depth of field effect
  68501. */
  68502. _effects: Array<PostProcess>;
  68503. /**
  68504. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68505. */
  68506. set focalLength(value: number);
  68507. get focalLength(): number;
  68508. /**
  68509. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68510. */
  68511. set fStop(value: number);
  68512. get fStop(): number;
  68513. /**
  68514. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68515. */
  68516. set focusDistance(value: number);
  68517. get focusDistance(): number;
  68518. /**
  68519. * 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.
  68520. */
  68521. set lensSize(value: number);
  68522. get lensSize(): number;
  68523. /**
  68524. * Creates a new instance DepthOfFieldEffect
  68525. * @param scene The scene the effect belongs to.
  68526. * @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.
  68527. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68528. * @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)
  68529. */
  68530. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68531. /**
  68532. * Get the current class name of the current effet
  68533. * @returns "DepthOfFieldEffect"
  68534. */
  68535. getClassName(): string;
  68536. /**
  68537. * 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.
  68538. */
  68539. set depthTexture(value: RenderTargetTexture);
  68540. /**
  68541. * Disposes each of the internal effects for a given camera.
  68542. * @param camera The camera to dispose the effect on.
  68543. */
  68544. disposeEffects(camera: Camera): void;
  68545. /**
  68546. * @hidden Internal
  68547. */
  68548. _updateEffects(): void;
  68549. /**
  68550. * Internal
  68551. * @returns if all the contained post processes are ready.
  68552. * @hidden
  68553. */
  68554. _isReady(): boolean;
  68555. }
  68556. }
  68557. declare module "babylonjs/Shaders/displayPass.fragment" {
  68558. /** @hidden */
  68559. export var displayPassPixelShader: {
  68560. name: string;
  68561. shader: string;
  68562. };
  68563. }
  68564. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68565. import { Nullable } from "babylonjs/types";
  68566. import { Camera } from "babylonjs/Cameras/camera";
  68567. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68568. import { Engine } from "babylonjs/Engines/engine";
  68569. import "babylonjs/Shaders/displayPass.fragment";
  68570. /**
  68571. * DisplayPassPostProcess which produces an output the same as it's input
  68572. */
  68573. export class DisplayPassPostProcess extends PostProcess {
  68574. /**
  68575. * Creates the DisplayPassPostProcess
  68576. * @param name The name of the effect.
  68577. * @param options The required width/height ratio to downsize to before computing the render pass.
  68578. * @param camera The camera to apply the render pass to.
  68579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68580. * @param engine The engine which the post process will be applied. (default: current engine)
  68581. * @param reusable If the post process can be reused on the same frame. (default: false)
  68582. */
  68583. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68584. }
  68585. }
  68586. declare module "babylonjs/Shaders/filter.fragment" {
  68587. /** @hidden */
  68588. export var filterPixelShader: {
  68589. name: string;
  68590. shader: string;
  68591. };
  68592. }
  68593. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68594. import { Nullable } from "babylonjs/types";
  68595. import { Matrix } from "babylonjs/Maths/math.vector";
  68596. import { Camera } from "babylonjs/Cameras/camera";
  68597. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68598. import { Engine } from "babylonjs/Engines/engine";
  68599. import "babylonjs/Shaders/filter.fragment";
  68600. /**
  68601. * Applies a kernel filter to the image
  68602. */
  68603. export class FilterPostProcess extends PostProcess {
  68604. /** The matrix to be applied to the image */
  68605. kernelMatrix: Matrix;
  68606. /**
  68607. *
  68608. * @param name The name of the effect.
  68609. * @param kernelMatrix The matrix to be applied to the image
  68610. * @param options The required width/height ratio to downsize to before computing the render pass.
  68611. * @param camera The camera to apply the render pass to.
  68612. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68613. * @param engine The engine which the post process will be applied. (default: current engine)
  68614. * @param reusable If the post process can be reused on the same frame. (default: false)
  68615. */
  68616. constructor(name: string,
  68617. /** The matrix to be applied to the image */
  68618. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68619. }
  68620. }
  68621. declare module "babylonjs/Shaders/fxaa.fragment" {
  68622. /** @hidden */
  68623. export var fxaaPixelShader: {
  68624. name: string;
  68625. shader: string;
  68626. };
  68627. }
  68628. declare module "babylonjs/Shaders/fxaa.vertex" {
  68629. /** @hidden */
  68630. export var fxaaVertexShader: {
  68631. name: string;
  68632. shader: string;
  68633. };
  68634. }
  68635. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68636. import { Nullable } from "babylonjs/types";
  68637. import { Camera } from "babylonjs/Cameras/camera";
  68638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68639. import { Engine } from "babylonjs/Engines/engine";
  68640. import "babylonjs/Shaders/fxaa.fragment";
  68641. import "babylonjs/Shaders/fxaa.vertex";
  68642. /**
  68643. * Fxaa post process
  68644. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68645. */
  68646. export class FxaaPostProcess extends PostProcess {
  68647. /** @hidden */
  68648. texelWidth: number;
  68649. /** @hidden */
  68650. texelHeight: number;
  68651. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68652. private _getDefines;
  68653. }
  68654. }
  68655. declare module "babylonjs/Shaders/grain.fragment" {
  68656. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68657. /** @hidden */
  68658. export var grainPixelShader: {
  68659. name: string;
  68660. shader: string;
  68661. };
  68662. }
  68663. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68664. import { Nullable } from "babylonjs/types";
  68665. import { Camera } from "babylonjs/Cameras/camera";
  68666. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68667. import { Engine } from "babylonjs/Engines/engine";
  68668. import "babylonjs/Shaders/grain.fragment";
  68669. /**
  68670. * The GrainPostProcess adds noise to the image at mid luminance levels
  68671. */
  68672. export class GrainPostProcess extends PostProcess {
  68673. /**
  68674. * The intensity of the grain added (default: 30)
  68675. */
  68676. intensity: number;
  68677. /**
  68678. * If the grain should be randomized on every frame
  68679. */
  68680. animated: boolean;
  68681. /**
  68682. * Creates a new instance of @see GrainPostProcess
  68683. * @param name The name of the effect.
  68684. * @param options The required width/height ratio to downsize to before computing the render pass.
  68685. * @param camera The camera to apply the render pass to.
  68686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68687. * @param engine The engine which the post process will be applied. (default: current engine)
  68688. * @param reusable If the post process can be reused on the same frame. (default: false)
  68689. * @param textureType Type of textures used when performing the post process. (default: 0)
  68690. * @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)
  68691. */
  68692. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68693. }
  68694. }
  68695. declare module "babylonjs/Shaders/highlights.fragment" {
  68696. /** @hidden */
  68697. export var highlightsPixelShader: {
  68698. name: string;
  68699. shader: string;
  68700. };
  68701. }
  68702. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68703. import { Nullable } from "babylonjs/types";
  68704. import { Camera } from "babylonjs/Cameras/camera";
  68705. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68706. import { Engine } from "babylonjs/Engines/engine";
  68707. import "babylonjs/Shaders/highlights.fragment";
  68708. /**
  68709. * Extracts highlights from the image
  68710. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68711. */
  68712. export class HighlightsPostProcess extends PostProcess {
  68713. /**
  68714. * Extracts highlights from the image
  68715. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68716. * @param name The name of the effect.
  68717. * @param options The required width/height ratio to downsize to before computing the render pass.
  68718. * @param camera The camera to apply the render pass to.
  68719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68720. * @param engine The engine which the post process will be applied. (default: current engine)
  68721. * @param reusable If the post process can be reused on the same frame. (default: false)
  68722. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68723. */
  68724. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68725. }
  68726. }
  68727. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68728. /** @hidden */
  68729. export var mrtFragmentDeclaration: {
  68730. name: string;
  68731. shader: string;
  68732. };
  68733. }
  68734. declare module "babylonjs/Shaders/geometry.fragment" {
  68735. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68736. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68737. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68738. /** @hidden */
  68739. export var geometryPixelShader: {
  68740. name: string;
  68741. shader: string;
  68742. };
  68743. }
  68744. declare module "babylonjs/Shaders/geometry.vertex" {
  68745. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68747. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68748. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68749. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68750. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68751. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68752. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68753. /** @hidden */
  68754. export var geometryVertexShader: {
  68755. name: string;
  68756. shader: string;
  68757. };
  68758. }
  68759. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68760. import { Matrix } from "babylonjs/Maths/math.vector";
  68761. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68762. import { Mesh } from "babylonjs/Meshes/mesh";
  68763. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68764. import { Effect } from "babylonjs/Materials/effect";
  68765. import { Scene } from "babylonjs/scene";
  68766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68767. import "babylonjs/Shaders/geometry.fragment";
  68768. import "babylonjs/Shaders/geometry.vertex";
  68769. /** @hidden */
  68770. interface ISavedTransformationMatrix {
  68771. world: Matrix;
  68772. viewProjection: Matrix;
  68773. }
  68774. /**
  68775. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68776. */
  68777. export class GeometryBufferRenderer {
  68778. /**
  68779. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68780. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68781. */
  68782. static readonly POSITION_TEXTURE_TYPE: number;
  68783. /**
  68784. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68785. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68786. */
  68787. static readonly VELOCITY_TEXTURE_TYPE: number;
  68788. /**
  68789. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68790. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68791. */
  68792. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68793. /**
  68794. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68795. * in order to compute objects velocities when enableVelocity is set to "true"
  68796. * @hidden
  68797. */
  68798. _previousTransformationMatrices: {
  68799. [index: number]: ISavedTransformationMatrix;
  68800. };
  68801. /**
  68802. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68803. * in order to compute objects velocities when enableVelocity is set to "true"
  68804. * @hidden
  68805. */
  68806. _previousBonesTransformationMatrices: {
  68807. [index: number]: Float32Array;
  68808. };
  68809. /**
  68810. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68811. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68812. */
  68813. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68814. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68815. renderTransparentMeshes: boolean;
  68816. private _scene;
  68817. private _multiRenderTarget;
  68818. private _ratio;
  68819. private _enablePosition;
  68820. private _enableVelocity;
  68821. private _enableReflectivity;
  68822. private _positionIndex;
  68823. private _velocityIndex;
  68824. private _reflectivityIndex;
  68825. protected _effect: Effect;
  68826. protected _cachedDefines: string;
  68827. /**
  68828. * Set the render list (meshes to be rendered) used in the G buffer.
  68829. */
  68830. set renderList(meshes: Mesh[]);
  68831. /**
  68832. * Gets wether or not G buffer are supported by the running hardware.
  68833. * This requires draw buffer supports
  68834. */
  68835. get isSupported(): boolean;
  68836. /**
  68837. * Returns the index of the given texture type in the G-Buffer textures array
  68838. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68839. * @returns the index of the given texture type in the G-Buffer textures array
  68840. */
  68841. getTextureIndex(textureType: number): number;
  68842. /**
  68843. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68844. */
  68845. get enablePosition(): boolean;
  68846. /**
  68847. * Sets whether or not objects positions are enabled for the G buffer.
  68848. */
  68849. set enablePosition(enable: boolean);
  68850. /**
  68851. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68852. */
  68853. get enableVelocity(): boolean;
  68854. /**
  68855. * Sets wether or not objects velocities are enabled for the G buffer.
  68856. */
  68857. set enableVelocity(enable: boolean);
  68858. /**
  68859. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68860. */
  68861. get enableReflectivity(): boolean;
  68862. /**
  68863. * Sets wether or not objects roughness are enabled for the G buffer.
  68864. */
  68865. set enableReflectivity(enable: boolean);
  68866. /**
  68867. * Gets the scene associated with the buffer.
  68868. */
  68869. get scene(): Scene;
  68870. /**
  68871. * Gets the ratio used by the buffer during its creation.
  68872. * How big is the buffer related to the main canvas.
  68873. */
  68874. get ratio(): number;
  68875. /** @hidden */
  68876. static _SceneComponentInitialization: (scene: Scene) => void;
  68877. /**
  68878. * Creates a new G Buffer for the scene
  68879. * @param scene The scene the buffer belongs to
  68880. * @param ratio How big is the buffer related to the main canvas.
  68881. */
  68882. constructor(scene: Scene, ratio?: number);
  68883. /**
  68884. * Checks wether everything is ready to render a submesh to the G buffer.
  68885. * @param subMesh the submesh to check readiness for
  68886. * @param useInstances is the mesh drawn using instance or not
  68887. * @returns true if ready otherwise false
  68888. */
  68889. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68890. /**
  68891. * Gets the current underlying G Buffer.
  68892. * @returns the buffer
  68893. */
  68894. getGBuffer(): MultiRenderTarget;
  68895. /**
  68896. * Gets the number of samples used to render the buffer (anti aliasing).
  68897. */
  68898. get samples(): number;
  68899. /**
  68900. * Sets the number of samples used to render the buffer (anti aliasing).
  68901. */
  68902. set samples(value: number);
  68903. /**
  68904. * Disposes the renderer and frees up associated resources.
  68905. */
  68906. dispose(): void;
  68907. protected _createRenderTargets(): void;
  68908. private _copyBonesTransformationMatrices;
  68909. }
  68910. }
  68911. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68912. import { Nullable } from "babylonjs/types";
  68913. import { Scene } from "babylonjs/scene";
  68914. import { ISceneComponent } from "babylonjs/sceneComponent";
  68915. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68916. module "babylonjs/scene" {
  68917. interface Scene {
  68918. /** @hidden (Backing field) */
  68919. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68920. /**
  68921. * Gets or Sets the current geometry buffer associated to the scene.
  68922. */
  68923. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68924. /**
  68925. * Enables a GeometryBufferRender and associates it with the scene
  68926. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68927. * @returns the GeometryBufferRenderer
  68928. */
  68929. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68930. /**
  68931. * Disables the GeometryBufferRender associated with the scene
  68932. */
  68933. disableGeometryBufferRenderer(): void;
  68934. }
  68935. }
  68936. /**
  68937. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68938. * in several rendering techniques.
  68939. */
  68940. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68941. /**
  68942. * The component name helpful to identify the component in the list of scene components.
  68943. */
  68944. readonly name: string;
  68945. /**
  68946. * The scene the component belongs to.
  68947. */
  68948. scene: Scene;
  68949. /**
  68950. * Creates a new instance of the component for the given scene
  68951. * @param scene Defines the scene to register the component in
  68952. */
  68953. constructor(scene: Scene);
  68954. /**
  68955. * Registers the component in a given scene
  68956. */
  68957. register(): void;
  68958. /**
  68959. * Rebuilds the elements related to this component in case of
  68960. * context lost for instance.
  68961. */
  68962. rebuild(): void;
  68963. /**
  68964. * Disposes the component and the associated ressources
  68965. */
  68966. dispose(): void;
  68967. private _gatherRenderTargets;
  68968. }
  68969. }
  68970. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68971. /** @hidden */
  68972. export var motionBlurPixelShader: {
  68973. name: string;
  68974. shader: string;
  68975. };
  68976. }
  68977. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68978. import { Nullable } from "babylonjs/types";
  68979. import { Camera } from "babylonjs/Cameras/camera";
  68980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68981. import { Scene } from "babylonjs/scene";
  68982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68983. import "babylonjs/Animations/animatable";
  68984. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68985. import "babylonjs/Shaders/motionBlur.fragment";
  68986. import { Engine } from "babylonjs/Engines/engine";
  68987. /**
  68988. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68989. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68990. * As an example, all you have to do is to create the post-process:
  68991. * var mb = new BABYLON.MotionBlurPostProcess(
  68992. * 'mb', // The name of the effect.
  68993. * scene, // The scene containing the objects to blur according to their velocity.
  68994. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68995. * camera // The camera to apply the render pass to.
  68996. * );
  68997. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68998. */
  68999. export class MotionBlurPostProcess extends PostProcess {
  69000. /**
  69001. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69002. */
  69003. motionStrength: number;
  69004. /**
  69005. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69006. */
  69007. get motionBlurSamples(): number;
  69008. /**
  69009. * Sets the number of iterations to be used for motion blur quality
  69010. */
  69011. set motionBlurSamples(samples: number);
  69012. private _motionBlurSamples;
  69013. private _geometryBufferRenderer;
  69014. /**
  69015. * Creates a new instance MotionBlurPostProcess
  69016. * @param name The name of the effect.
  69017. * @param scene The scene containing the objects to blur according to their velocity.
  69018. * @param options The required width/height ratio to downsize to before computing the render pass.
  69019. * @param camera The camera to apply the render pass to.
  69020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69021. * @param engine The engine which the post process will be applied. (default: current engine)
  69022. * @param reusable If the post process can be reused on the same frame. (default: false)
  69023. * @param textureType Type of textures used when performing the post process. (default: 0)
  69024. * @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)
  69025. */
  69026. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69027. /**
  69028. * Excludes the given skinned mesh from computing bones velocities.
  69029. * 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.
  69030. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69031. */
  69032. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69033. /**
  69034. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69035. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69036. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69037. */
  69038. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69039. /**
  69040. * Disposes the post process.
  69041. * @param camera The camera to dispose the post process on.
  69042. */
  69043. dispose(camera?: Camera): void;
  69044. }
  69045. }
  69046. declare module "babylonjs/Shaders/refraction.fragment" {
  69047. /** @hidden */
  69048. export var refractionPixelShader: {
  69049. name: string;
  69050. shader: string;
  69051. };
  69052. }
  69053. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  69054. import { Color3 } from "babylonjs/Maths/math.color";
  69055. import { Camera } from "babylonjs/Cameras/camera";
  69056. import { Texture } from "babylonjs/Materials/Textures/texture";
  69057. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69058. import { Engine } from "babylonjs/Engines/engine";
  69059. import "babylonjs/Shaders/refraction.fragment";
  69060. /**
  69061. * Post process which applies a refractin texture
  69062. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69063. */
  69064. export class RefractionPostProcess extends PostProcess {
  69065. /** the base color of the refraction (used to taint the rendering) */
  69066. color: Color3;
  69067. /** simulated refraction depth */
  69068. depth: number;
  69069. /** the coefficient of the base color (0 to remove base color tainting) */
  69070. colorLevel: number;
  69071. private _refTexture;
  69072. private _ownRefractionTexture;
  69073. /**
  69074. * Gets or sets the refraction texture
  69075. * Please note that you are responsible for disposing the texture if you set it manually
  69076. */
  69077. get refractionTexture(): Texture;
  69078. set refractionTexture(value: Texture);
  69079. /**
  69080. * Initializes the RefractionPostProcess
  69081. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69082. * @param name The name of the effect.
  69083. * @param refractionTextureUrl Url of the refraction texture to use
  69084. * @param color the base color of the refraction (used to taint the rendering)
  69085. * @param depth simulated refraction depth
  69086. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69087. * @param camera The camera to apply the render pass to.
  69088. * @param options The required width/height ratio to downsize to before computing the render pass.
  69089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69090. * @param engine The engine which the post process will be applied. (default: current engine)
  69091. * @param reusable If the post process can be reused on the same frame. (default: false)
  69092. */
  69093. constructor(name: string, refractionTextureUrl: string,
  69094. /** the base color of the refraction (used to taint the rendering) */
  69095. color: Color3,
  69096. /** simulated refraction depth */
  69097. depth: number,
  69098. /** the coefficient of the base color (0 to remove base color tainting) */
  69099. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69100. /**
  69101. * Disposes of the post process
  69102. * @param camera Camera to dispose post process on
  69103. */
  69104. dispose(camera: Camera): void;
  69105. }
  69106. }
  69107. declare module "babylonjs/Shaders/sharpen.fragment" {
  69108. /** @hidden */
  69109. export var sharpenPixelShader: {
  69110. name: string;
  69111. shader: string;
  69112. };
  69113. }
  69114. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  69115. import { Nullable } from "babylonjs/types";
  69116. import { Camera } from "babylonjs/Cameras/camera";
  69117. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69118. import "babylonjs/Shaders/sharpen.fragment";
  69119. import { Engine } from "babylonjs/Engines/engine";
  69120. /**
  69121. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69122. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69123. */
  69124. export class SharpenPostProcess extends PostProcess {
  69125. /**
  69126. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69127. */
  69128. colorAmount: number;
  69129. /**
  69130. * How much sharpness should be applied (default: 0.3)
  69131. */
  69132. edgeAmount: number;
  69133. /**
  69134. * Creates a new instance ConvolutionPostProcess
  69135. * @param name The name of the effect.
  69136. * @param options The required width/height ratio to downsize to before computing the render pass.
  69137. * @param camera The camera to apply the render pass to.
  69138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69139. * @param engine The engine which the post process will be applied. (default: current engine)
  69140. * @param reusable If the post process can be reused on the same frame. (default: false)
  69141. * @param textureType Type of textures used when performing the post process. (default: 0)
  69142. * @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)
  69143. */
  69144. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69145. }
  69146. }
  69147. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  69148. import { Nullable } from "babylonjs/types";
  69149. import { Camera } from "babylonjs/Cameras/camera";
  69150. import { Engine } from "babylonjs/Engines/engine";
  69151. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69152. import { IInspectable } from "babylonjs/Misc/iInspectable";
  69153. /**
  69154. * PostProcessRenderPipeline
  69155. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69156. */
  69157. export class PostProcessRenderPipeline {
  69158. private engine;
  69159. private _renderEffects;
  69160. private _renderEffectsForIsolatedPass;
  69161. /**
  69162. * List of inspectable custom properties (used by the Inspector)
  69163. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69164. */
  69165. inspectableCustomProperties: IInspectable[];
  69166. /**
  69167. * @hidden
  69168. */
  69169. protected _cameras: Camera[];
  69170. /** @hidden */
  69171. _name: string;
  69172. /**
  69173. * Gets pipeline name
  69174. */
  69175. get name(): string;
  69176. /** Gets the list of attached cameras */
  69177. get cameras(): Camera[];
  69178. /**
  69179. * Initializes a PostProcessRenderPipeline
  69180. * @param engine engine to add the pipeline to
  69181. * @param name name of the pipeline
  69182. */
  69183. constructor(engine: Engine, name: string);
  69184. /**
  69185. * Gets the class name
  69186. * @returns "PostProcessRenderPipeline"
  69187. */
  69188. getClassName(): string;
  69189. /**
  69190. * If all the render effects in the pipeline are supported
  69191. */
  69192. get isSupported(): boolean;
  69193. /**
  69194. * Adds an effect to the pipeline
  69195. * @param renderEffect the effect to add
  69196. */
  69197. addEffect(renderEffect: PostProcessRenderEffect): void;
  69198. /** @hidden */
  69199. _rebuild(): void;
  69200. /** @hidden */
  69201. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69202. /** @hidden */
  69203. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69204. /** @hidden */
  69205. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69206. /** @hidden */
  69207. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69208. /** @hidden */
  69209. _attachCameras(cameras: Camera, unique: boolean): void;
  69210. /** @hidden */
  69211. _attachCameras(cameras: Camera[], unique: boolean): void;
  69212. /** @hidden */
  69213. _detachCameras(cameras: Camera): void;
  69214. /** @hidden */
  69215. _detachCameras(cameras: Nullable<Camera[]>): void;
  69216. /** @hidden */
  69217. _update(): void;
  69218. /** @hidden */
  69219. _reset(): void;
  69220. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69221. /**
  69222. * Disposes of the pipeline
  69223. */
  69224. dispose(): void;
  69225. }
  69226. }
  69227. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  69228. import { Camera } from "babylonjs/Cameras/camera";
  69229. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69230. /**
  69231. * PostProcessRenderPipelineManager class
  69232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69233. */
  69234. export class PostProcessRenderPipelineManager {
  69235. private _renderPipelines;
  69236. /**
  69237. * Initializes a PostProcessRenderPipelineManager
  69238. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69239. */
  69240. constructor();
  69241. /**
  69242. * Gets the list of supported render pipelines
  69243. */
  69244. get supportedPipelines(): PostProcessRenderPipeline[];
  69245. /**
  69246. * Adds a pipeline to the manager
  69247. * @param renderPipeline The pipeline to add
  69248. */
  69249. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69250. /**
  69251. * Attaches a camera to the pipeline
  69252. * @param renderPipelineName The name of the pipeline to attach to
  69253. * @param cameras the camera to attach
  69254. * @param unique if the camera can be attached multiple times to the pipeline
  69255. */
  69256. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69257. /**
  69258. * Detaches a camera from the pipeline
  69259. * @param renderPipelineName The name of the pipeline to detach from
  69260. * @param cameras the camera to detach
  69261. */
  69262. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69263. /**
  69264. * Enables an effect by name on a pipeline
  69265. * @param renderPipelineName the name of the pipeline to enable the effect in
  69266. * @param renderEffectName the name of the effect to enable
  69267. * @param cameras the cameras that the effect should be enabled on
  69268. */
  69269. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69270. /**
  69271. * Disables an effect by name on a pipeline
  69272. * @param renderPipelineName the name of the pipeline to disable the effect in
  69273. * @param renderEffectName the name of the effect to disable
  69274. * @param cameras the cameras that the effect should be disabled on
  69275. */
  69276. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69277. /**
  69278. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69279. */
  69280. update(): void;
  69281. /** @hidden */
  69282. _rebuild(): void;
  69283. /**
  69284. * Disposes of the manager and pipelines
  69285. */
  69286. dispose(): void;
  69287. }
  69288. }
  69289. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  69290. import { ISceneComponent } from "babylonjs/sceneComponent";
  69291. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69292. import { Scene } from "babylonjs/scene";
  69293. module "babylonjs/scene" {
  69294. interface Scene {
  69295. /** @hidden (Backing field) */
  69296. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69297. /**
  69298. * Gets the postprocess render pipeline manager
  69299. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69300. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69301. */
  69302. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69303. }
  69304. }
  69305. /**
  69306. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69307. */
  69308. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69309. /**
  69310. * The component name helpfull to identify the component in the list of scene components.
  69311. */
  69312. readonly name: string;
  69313. /**
  69314. * The scene the component belongs to.
  69315. */
  69316. scene: Scene;
  69317. /**
  69318. * Creates a new instance of the component for the given scene
  69319. * @param scene Defines the scene to register the component in
  69320. */
  69321. constructor(scene: Scene);
  69322. /**
  69323. * Registers the component in a given scene
  69324. */
  69325. register(): void;
  69326. /**
  69327. * Rebuilds the elements related to this component in case of
  69328. * context lost for instance.
  69329. */
  69330. rebuild(): void;
  69331. /**
  69332. * Disposes the component and the associated ressources
  69333. */
  69334. dispose(): void;
  69335. private _gatherRenderTargets;
  69336. }
  69337. }
  69338. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  69339. import { Nullable } from "babylonjs/types";
  69340. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69341. import { Camera } from "babylonjs/Cameras/camera";
  69342. import { IDisposable } from "babylonjs/scene";
  69343. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  69344. import { Scene } from "babylonjs/scene";
  69345. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  69346. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69347. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69348. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  69349. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69350. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69351. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  69352. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69353. import { Animation } from "babylonjs/Animations/animation";
  69354. /**
  69355. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69356. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69357. */
  69358. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69359. private _scene;
  69360. private _camerasToBeAttached;
  69361. /**
  69362. * ID of the sharpen post process,
  69363. */
  69364. private readonly SharpenPostProcessId;
  69365. /**
  69366. * @ignore
  69367. * ID of the image processing post process;
  69368. */
  69369. readonly ImageProcessingPostProcessId: string;
  69370. /**
  69371. * @ignore
  69372. * ID of the Fast Approximate Anti-Aliasing post process;
  69373. */
  69374. readonly FxaaPostProcessId: string;
  69375. /**
  69376. * ID of the chromatic aberration post process,
  69377. */
  69378. private readonly ChromaticAberrationPostProcessId;
  69379. /**
  69380. * ID of the grain post process
  69381. */
  69382. private readonly GrainPostProcessId;
  69383. /**
  69384. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69385. */
  69386. sharpen: SharpenPostProcess;
  69387. private _sharpenEffect;
  69388. private bloom;
  69389. /**
  69390. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69391. */
  69392. depthOfField: DepthOfFieldEffect;
  69393. /**
  69394. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69395. */
  69396. fxaa: FxaaPostProcess;
  69397. /**
  69398. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69399. */
  69400. imageProcessing: ImageProcessingPostProcess;
  69401. /**
  69402. * Chromatic aberration post process which will shift rgb colors in the image
  69403. */
  69404. chromaticAberration: ChromaticAberrationPostProcess;
  69405. private _chromaticAberrationEffect;
  69406. /**
  69407. * Grain post process which add noise to the image
  69408. */
  69409. grain: GrainPostProcess;
  69410. private _grainEffect;
  69411. /**
  69412. * Glow post process which adds a glow to emissive areas of the image
  69413. */
  69414. private _glowLayer;
  69415. /**
  69416. * Animations which can be used to tweak settings over a period of time
  69417. */
  69418. animations: Animation[];
  69419. private _imageProcessingConfigurationObserver;
  69420. private _sharpenEnabled;
  69421. private _bloomEnabled;
  69422. private _depthOfFieldEnabled;
  69423. private _depthOfFieldBlurLevel;
  69424. private _fxaaEnabled;
  69425. private _imageProcessingEnabled;
  69426. private _defaultPipelineTextureType;
  69427. private _bloomScale;
  69428. private _chromaticAberrationEnabled;
  69429. private _grainEnabled;
  69430. private _buildAllowed;
  69431. /**
  69432. * Gets active scene
  69433. */
  69434. get scene(): Scene;
  69435. /**
  69436. * Enable or disable the sharpen process from the pipeline
  69437. */
  69438. set sharpenEnabled(enabled: boolean);
  69439. get sharpenEnabled(): boolean;
  69440. private _resizeObserver;
  69441. private _hardwareScaleLevel;
  69442. private _bloomKernel;
  69443. /**
  69444. * Specifies the size of the bloom blur kernel, relative to the final output size
  69445. */
  69446. get bloomKernel(): number;
  69447. set bloomKernel(value: number);
  69448. /**
  69449. * Specifies the weight of the bloom in the final rendering
  69450. */
  69451. private _bloomWeight;
  69452. /**
  69453. * Specifies the luma threshold for the area that will be blurred by the bloom
  69454. */
  69455. private _bloomThreshold;
  69456. private _hdr;
  69457. /**
  69458. * The strength of the bloom.
  69459. */
  69460. set bloomWeight(value: number);
  69461. get bloomWeight(): number;
  69462. /**
  69463. * The strength of the bloom.
  69464. */
  69465. set bloomThreshold(value: number);
  69466. get bloomThreshold(): number;
  69467. /**
  69468. * The scale of the bloom, lower value will provide better performance.
  69469. */
  69470. set bloomScale(value: number);
  69471. get bloomScale(): number;
  69472. /**
  69473. * Enable or disable the bloom from the pipeline
  69474. */
  69475. set bloomEnabled(enabled: boolean);
  69476. get bloomEnabled(): boolean;
  69477. private _rebuildBloom;
  69478. /**
  69479. * If the depth of field is enabled.
  69480. */
  69481. get depthOfFieldEnabled(): boolean;
  69482. set depthOfFieldEnabled(enabled: boolean);
  69483. /**
  69484. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69485. */
  69486. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69487. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69488. /**
  69489. * If the anti aliasing is enabled.
  69490. */
  69491. set fxaaEnabled(enabled: boolean);
  69492. get fxaaEnabled(): boolean;
  69493. private _samples;
  69494. /**
  69495. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69496. */
  69497. set samples(sampleCount: number);
  69498. get samples(): number;
  69499. /**
  69500. * If image processing is enabled.
  69501. */
  69502. set imageProcessingEnabled(enabled: boolean);
  69503. get imageProcessingEnabled(): boolean;
  69504. /**
  69505. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69506. */
  69507. set glowLayerEnabled(enabled: boolean);
  69508. get glowLayerEnabled(): boolean;
  69509. /**
  69510. * Gets the glow layer (or null if not defined)
  69511. */
  69512. get glowLayer(): Nullable<GlowLayer>;
  69513. /**
  69514. * Enable or disable the chromaticAberration process from the pipeline
  69515. */
  69516. set chromaticAberrationEnabled(enabled: boolean);
  69517. get chromaticAberrationEnabled(): boolean;
  69518. /**
  69519. * Enable or disable the grain process from the pipeline
  69520. */
  69521. set grainEnabled(enabled: boolean);
  69522. get grainEnabled(): boolean;
  69523. /**
  69524. * @constructor
  69525. * @param name - The rendering pipeline name (default: "")
  69526. * @param hdr - If high dynamic range textures should be used (default: true)
  69527. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69528. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69529. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69530. */
  69531. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69532. /**
  69533. * Get the class name
  69534. * @returns "DefaultRenderingPipeline"
  69535. */
  69536. getClassName(): string;
  69537. /**
  69538. * Force the compilation of the entire pipeline.
  69539. */
  69540. prepare(): void;
  69541. private _hasCleared;
  69542. private _prevPostProcess;
  69543. private _prevPrevPostProcess;
  69544. private _setAutoClearAndTextureSharing;
  69545. private _depthOfFieldSceneObserver;
  69546. private _buildPipeline;
  69547. private _disposePostProcesses;
  69548. /**
  69549. * Adds a camera to the pipeline
  69550. * @param camera the camera to be added
  69551. */
  69552. addCamera(camera: Camera): void;
  69553. /**
  69554. * Removes a camera from the pipeline
  69555. * @param camera the camera to remove
  69556. */
  69557. removeCamera(camera: Camera): void;
  69558. /**
  69559. * Dispose of the pipeline and stop all post processes
  69560. */
  69561. dispose(): void;
  69562. /**
  69563. * Serialize the rendering pipeline (Used when exporting)
  69564. * @returns the serialized object
  69565. */
  69566. serialize(): any;
  69567. /**
  69568. * Parse the serialized pipeline
  69569. * @param source Source pipeline.
  69570. * @param scene The scene to load the pipeline to.
  69571. * @param rootUrl The URL of the serialized pipeline.
  69572. * @returns An instantiated pipeline from the serialized object.
  69573. */
  69574. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69575. }
  69576. }
  69577. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69578. /** @hidden */
  69579. export var lensHighlightsPixelShader: {
  69580. name: string;
  69581. shader: string;
  69582. };
  69583. }
  69584. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69585. /** @hidden */
  69586. export var depthOfFieldPixelShader: {
  69587. name: string;
  69588. shader: string;
  69589. };
  69590. }
  69591. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69592. import { Camera } from "babylonjs/Cameras/camera";
  69593. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69594. import { Scene } from "babylonjs/scene";
  69595. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69596. import "babylonjs/Shaders/chromaticAberration.fragment";
  69597. import "babylonjs/Shaders/lensHighlights.fragment";
  69598. import "babylonjs/Shaders/depthOfField.fragment";
  69599. /**
  69600. * BABYLON.JS Chromatic Aberration GLSL Shader
  69601. * Author: Olivier Guyot
  69602. * Separates very slightly R, G and B colors on the edges of the screen
  69603. * Inspired by Francois Tarlier & Martins Upitis
  69604. */
  69605. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69606. /**
  69607. * @ignore
  69608. * The chromatic aberration PostProcess id in the pipeline
  69609. */
  69610. LensChromaticAberrationEffect: string;
  69611. /**
  69612. * @ignore
  69613. * The highlights enhancing PostProcess id in the pipeline
  69614. */
  69615. HighlightsEnhancingEffect: string;
  69616. /**
  69617. * @ignore
  69618. * The depth-of-field PostProcess id in the pipeline
  69619. */
  69620. LensDepthOfFieldEffect: string;
  69621. private _scene;
  69622. private _depthTexture;
  69623. private _grainTexture;
  69624. private _chromaticAberrationPostProcess;
  69625. private _highlightsPostProcess;
  69626. private _depthOfFieldPostProcess;
  69627. private _edgeBlur;
  69628. private _grainAmount;
  69629. private _chromaticAberration;
  69630. private _distortion;
  69631. private _highlightsGain;
  69632. private _highlightsThreshold;
  69633. private _dofDistance;
  69634. private _dofAperture;
  69635. private _dofDarken;
  69636. private _dofPentagon;
  69637. private _blurNoise;
  69638. /**
  69639. * @constructor
  69640. *
  69641. * Effect parameters are as follow:
  69642. * {
  69643. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69644. * edge_blur: number; // from 0 to x (1 for realism)
  69645. * distortion: number; // from 0 to x (1 for realism)
  69646. * grain_amount: number; // from 0 to 1
  69647. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69648. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69649. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69650. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69651. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69652. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69653. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69654. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69655. * }
  69656. * Note: if an effect parameter is unset, effect is disabled
  69657. *
  69658. * @param name The rendering pipeline name
  69659. * @param parameters - An object containing all parameters (see above)
  69660. * @param scene The scene linked to this pipeline
  69661. * @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)
  69662. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69663. */
  69664. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69665. /**
  69666. * Get the class name
  69667. * @returns "LensRenderingPipeline"
  69668. */
  69669. getClassName(): string;
  69670. /**
  69671. * Gets associated scene
  69672. */
  69673. get scene(): Scene;
  69674. /**
  69675. * Gets or sets the edge blur
  69676. */
  69677. get edgeBlur(): number;
  69678. set edgeBlur(value: number);
  69679. /**
  69680. * Gets or sets the grain amount
  69681. */
  69682. get grainAmount(): number;
  69683. set grainAmount(value: number);
  69684. /**
  69685. * Gets or sets the chromatic aberration amount
  69686. */
  69687. get chromaticAberration(): number;
  69688. set chromaticAberration(value: number);
  69689. /**
  69690. * Gets or sets the depth of field aperture
  69691. */
  69692. get dofAperture(): number;
  69693. set dofAperture(value: number);
  69694. /**
  69695. * Gets or sets the edge distortion
  69696. */
  69697. get edgeDistortion(): number;
  69698. set edgeDistortion(value: number);
  69699. /**
  69700. * Gets or sets the depth of field distortion
  69701. */
  69702. get dofDistortion(): number;
  69703. set dofDistortion(value: number);
  69704. /**
  69705. * Gets or sets the darken out of focus amount
  69706. */
  69707. get darkenOutOfFocus(): number;
  69708. set darkenOutOfFocus(value: number);
  69709. /**
  69710. * Gets or sets a boolean indicating if blur noise is enabled
  69711. */
  69712. get blurNoise(): boolean;
  69713. set blurNoise(value: boolean);
  69714. /**
  69715. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69716. */
  69717. get pentagonBokeh(): boolean;
  69718. set pentagonBokeh(value: boolean);
  69719. /**
  69720. * Gets or sets the highlight grain amount
  69721. */
  69722. get highlightsGain(): number;
  69723. set highlightsGain(value: number);
  69724. /**
  69725. * Gets or sets the highlight threshold
  69726. */
  69727. get highlightsThreshold(): number;
  69728. set highlightsThreshold(value: number);
  69729. /**
  69730. * Sets the amount of blur at the edges
  69731. * @param amount blur amount
  69732. */
  69733. setEdgeBlur(amount: number): void;
  69734. /**
  69735. * Sets edge blur to 0
  69736. */
  69737. disableEdgeBlur(): void;
  69738. /**
  69739. * Sets the amout of grain
  69740. * @param amount Amount of grain
  69741. */
  69742. setGrainAmount(amount: number): void;
  69743. /**
  69744. * Set grain amount to 0
  69745. */
  69746. disableGrain(): void;
  69747. /**
  69748. * Sets the chromatic aberration amount
  69749. * @param amount amount of chromatic aberration
  69750. */
  69751. setChromaticAberration(amount: number): void;
  69752. /**
  69753. * Sets chromatic aberration amount to 0
  69754. */
  69755. disableChromaticAberration(): void;
  69756. /**
  69757. * Sets the EdgeDistortion amount
  69758. * @param amount amount of EdgeDistortion
  69759. */
  69760. setEdgeDistortion(amount: number): void;
  69761. /**
  69762. * Sets edge distortion to 0
  69763. */
  69764. disableEdgeDistortion(): void;
  69765. /**
  69766. * Sets the FocusDistance amount
  69767. * @param amount amount of FocusDistance
  69768. */
  69769. setFocusDistance(amount: number): void;
  69770. /**
  69771. * Disables depth of field
  69772. */
  69773. disableDepthOfField(): void;
  69774. /**
  69775. * Sets the Aperture amount
  69776. * @param amount amount of Aperture
  69777. */
  69778. setAperture(amount: number): void;
  69779. /**
  69780. * Sets the DarkenOutOfFocus amount
  69781. * @param amount amount of DarkenOutOfFocus
  69782. */
  69783. setDarkenOutOfFocus(amount: number): void;
  69784. private _pentagonBokehIsEnabled;
  69785. /**
  69786. * Creates a pentagon bokeh effect
  69787. */
  69788. enablePentagonBokeh(): void;
  69789. /**
  69790. * Disables the pentagon bokeh effect
  69791. */
  69792. disablePentagonBokeh(): void;
  69793. /**
  69794. * Enables noise blur
  69795. */
  69796. enableNoiseBlur(): void;
  69797. /**
  69798. * Disables noise blur
  69799. */
  69800. disableNoiseBlur(): void;
  69801. /**
  69802. * Sets the HighlightsGain amount
  69803. * @param amount amount of HighlightsGain
  69804. */
  69805. setHighlightsGain(amount: number): void;
  69806. /**
  69807. * Sets the HighlightsThreshold amount
  69808. * @param amount amount of HighlightsThreshold
  69809. */
  69810. setHighlightsThreshold(amount: number): void;
  69811. /**
  69812. * Disables highlights
  69813. */
  69814. disableHighlights(): void;
  69815. /**
  69816. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69817. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69818. */
  69819. dispose(disableDepthRender?: boolean): void;
  69820. private _createChromaticAberrationPostProcess;
  69821. private _createHighlightsPostProcess;
  69822. private _createDepthOfFieldPostProcess;
  69823. private _createGrainTexture;
  69824. }
  69825. }
  69826. declare module "babylonjs/Shaders/ssao2.fragment" {
  69827. /** @hidden */
  69828. export var ssao2PixelShader: {
  69829. name: string;
  69830. shader: string;
  69831. };
  69832. }
  69833. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69834. /** @hidden */
  69835. export var ssaoCombinePixelShader: {
  69836. name: string;
  69837. shader: string;
  69838. };
  69839. }
  69840. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69841. import { Camera } from "babylonjs/Cameras/camera";
  69842. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69843. import { Scene } from "babylonjs/scene";
  69844. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69845. import "babylonjs/Shaders/ssao2.fragment";
  69846. import "babylonjs/Shaders/ssaoCombine.fragment";
  69847. /**
  69848. * Render pipeline to produce ssao effect
  69849. */
  69850. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69851. /**
  69852. * @ignore
  69853. * The PassPostProcess id in the pipeline that contains the original scene color
  69854. */
  69855. SSAOOriginalSceneColorEffect: string;
  69856. /**
  69857. * @ignore
  69858. * The SSAO PostProcess id in the pipeline
  69859. */
  69860. SSAORenderEffect: string;
  69861. /**
  69862. * @ignore
  69863. * The horizontal blur PostProcess id in the pipeline
  69864. */
  69865. SSAOBlurHRenderEffect: string;
  69866. /**
  69867. * @ignore
  69868. * The vertical blur PostProcess id in the pipeline
  69869. */
  69870. SSAOBlurVRenderEffect: string;
  69871. /**
  69872. * @ignore
  69873. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69874. */
  69875. SSAOCombineRenderEffect: string;
  69876. /**
  69877. * The output strength of the SSAO post-process. Default value is 1.0.
  69878. */
  69879. totalStrength: number;
  69880. /**
  69881. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69882. */
  69883. maxZ: number;
  69884. /**
  69885. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69886. */
  69887. minZAspect: number;
  69888. private _samples;
  69889. /**
  69890. * Number of samples used for the SSAO calculations. Default value is 8
  69891. */
  69892. set samples(n: number);
  69893. get samples(): number;
  69894. private _textureSamples;
  69895. /**
  69896. * Number of samples to use for antialiasing
  69897. */
  69898. set textureSamples(n: number);
  69899. get textureSamples(): number;
  69900. /**
  69901. * Ratio object used for SSAO ratio and blur ratio
  69902. */
  69903. private _ratio;
  69904. /**
  69905. * Dynamically generated sphere sampler.
  69906. */
  69907. private _sampleSphere;
  69908. /**
  69909. * Blur filter offsets
  69910. */
  69911. private _samplerOffsets;
  69912. private _expensiveBlur;
  69913. /**
  69914. * If bilateral blur should be used
  69915. */
  69916. set expensiveBlur(b: boolean);
  69917. get expensiveBlur(): boolean;
  69918. /**
  69919. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69920. */
  69921. radius: number;
  69922. /**
  69923. * The base color of the SSAO post-process
  69924. * The final result is "base + ssao" between [0, 1]
  69925. */
  69926. base: number;
  69927. /**
  69928. * Support test.
  69929. */
  69930. static get IsSupported(): boolean;
  69931. private _scene;
  69932. private _depthTexture;
  69933. private _normalTexture;
  69934. private _randomTexture;
  69935. private _originalColorPostProcess;
  69936. private _ssaoPostProcess;
  69937. private _blurHPostProcess;
  69938. private _blurVPostProcess;
  69939. private _ssaoCombinePostProcess;
  69940. /**
  69941. * Gets active scene
  69942. */
  69943. get scene(): Scene;
  69944. /**
  69945. * @constructor
  69946. * @param name The rendering pipeline name
  69947. * @param scene The scene linked to this pipeline
  69948. * @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 }
  69949. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69950. */
  69951. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69952. /**
  69953. * Get the class name
  69954. * @returns "SSAO2RenderingPipeline"
  69955. */
  69956. getClassName(): string;
  69957. /**
  69958. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69959. */
  69960. dispose(disableGeometryBufferRenderer?: boolean): void;
  69961. private _createBlurPostProcess;
  69962. /** @hidden */
  69963. _rebuild(): void;
  69964. private _bits;
  69965. private _radicalInverse_VdC;
  69966. private _hammersley;
  69967. private _hemisphereSample_uniform;
  69968. private _generateHemisphere;
  69969. private _createSSAOPostProcess;
  69970. private _createSSAOCombinePostProcess;
  69971. private _createRandomTexture;
  69972. /**
  69973. * Serialize the rendering pipeline (Used when exporting)
  69974. * @returns the serialized object
  69975. */
  69976. serialize(): any;
  69977. /**
  69978. * Parse the serialized pipeline
  69979. * @param source Source pipeline.
  69980. * @param scene The scene to load the pipeline to.
  69981. * @param rootUrl The URL of the serialized pipeline.
  69982. * @returns An instantiated pipeline from the serialized object.
  69983. */
  69984. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69985. }
  69986. }
  69987. declare module "babylonjs/Shaders/ssao.fragment" {
  69988. /** @hidden */
  69989. export var ssaoPixelShader: {
  69990. name: string;
  69991. shader: string;
  69992. };
  69993. }
  69994. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69995. import { Camera } from "babylonjs/Cameras/camera";
  69996. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69997. import { Scene } from "babylonjs/scene";
  69998. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69999. import "babylonjs/Shaders/ssao.fragment";
  70000. import "babylonjs/Shaders/ssaoCombine.fragment";
  70001. /**
  70002. * Render pipeline to produce ssao effect
  70003. */
  70004. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70005. /**
  70006. * @ignore
  70007. * The PassPostProcess id in the pipeline that contains the original scene color
  70008. */
  70009. SSAOOriginalSceneColorEffect: string;
  70010. /**
  70011. * @ignore
  70012. * The SSAO PostProcess id in the pipeline
  70013. */
  70014. SSAORenderEffect: string;
  70015. /**
  70016. * @ignore
  70017. * The horizontal blur PostProcess id in the pipeline
  70018. */
  70019. SSAOBlurHRenderEffect: string;
  70020. /**
  70021. * @ignore
  70022. * The vertical blur PostProcess id in the pipeline
  70023. */
  70024. SSAOBlurVRenderEffect: string;
  70025. /**
  70026. * @ignore
  70027. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70028. */
  70029. SSAOCombineRenderEffect: string;
  70030. /**
  70031. * The output strength of the SSAO post-process. Default value is 1.0.
  70032. */
  70033. totalStrength: number;
  70034. /**
  70035. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70036. */
  70037. radius: number;
  70038. /**
  70039. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70040. * Must not be equal to fallOff and superior to fallOff.
  70041. * Default value is 0.0075
  70042. */
  70043. area: number;
  70044. /**
  70045. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70046. * Must not be equal to area and inferior to area.
  70047. * Default value is 0.000001
  70048. */
  70049. fallOff: number;
  70050. /**
  70051. * The base color of the SSAO post-process
  70052. * The final result is "base + ssao" between [0, 1]
  70053. */
  70054. base: number;
  70055. private _scene;
  70056. private _depthTexture;
  70057. private _randomTexture;
  70058. private _originalColorPostProcess;
  70059. private _ssaoPostProcess;
  70060. private _blurHPostProcess;
  70061. private _blurVPostProcess;
  70062. private _ssaoCombinePostProcess;
  70063. private _firstUpdate;
  70064. /**
  70065. * Gets active scene
  70066. */
  70067. get scene(): Scene;
  70068. /**
  70069. * @constructor
  70070. * @param name - The rendering pipeline name
  70071. * @param scene - The scene linked to this pipeline
  70072. * @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 }
  70073. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70074. */
  70075. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70076. /**
  70077. * Get the class name
  70078. * @returns "SSAORenderingPipeline"
  70079. */
  70080. getClassName(): string;
  70081. /**
  70082. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70083. */
  70084. dispose(disableDepthRender?: boolean): void;
  70085. private _createBlurPostProcess;
  70086. /** @hidden */
  70087. _rebuild(): void;
  70088. private _createSSAOPostProcess;
  70089. private _createSSAOCombinePostProcess;
  70090. private _createRandomTexture;
  70091. }
  70092. }
  70093. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  70094. /** @hidden */
  70095. export var screenSpaceReflectionPixelShader: {
  70096. name: string;
  70097. shader: string;
  70098. };
  70099. }
  70100. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  70101. import { Nullable } from "babylonjs/types";
  70102. import { Camera } from "babylonjs/Cameras/camera";
  70103. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70104. import { Scene } from "babylonjs/scene";
  70105. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  70106. import { Engine } from "babylonjs/Engines/engine";
  70107. /**
  70108. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70109. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70110. */
  70111. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70112. /**
  70113. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70114. */
  70115. threshold: number;
  70116. /**
  70117. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70118. */
  70119. strength: number;
  70120. /**
  70121. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70122. */
  70123. reflectionSpecularFalloffExponent: number;
  70124. /**
  70125. * 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]
  70126. */
  70127. step: number;
  70128. /**
  70129. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70130. */
  70131. roughnessFactor: number;
  70132. private _geometryBufferRenderer;
  70133. private _enableSmoothReflections;
  70134. private _reflectionSamples;
  70135. private _smoothSteps;
  70136. /**
  70137. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70138. * @param name The name of the effect.
  70139. * @param scene The scene containing the objects to calculate reflections.
  70140. * @param options The required width/height ratio to downsize to before computing the render pass.
  70141. * @param camera The camera to apply the render pass to.
  70142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70143. * @param engine The engine which the post process will be applied. (default: current engine)
  70144. * @param reusable If the post process can be reused on the same frame. (default: false)
  70145. * @param textureType Type of textures used when performing the post process. (default: 0)
  70146. * @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)
  70147. */
  70148. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70149. /**
  70150. * Gets wether or not smoothing reflections is enabled.
  70151. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70152. */
  70153. get enableSmoothReflections(): boolean;
  70154. /**
  70155. * Sets wether or not smoothing reflections is enabled.
  70156. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70157. */
  70158. set enableSmoothReflections(enabled: boolean);
  70159. /**
  70160. * Gets the number of samples taken while computing reflections. More samples count is high,
  70161. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70162. */
  70163. get reflectionSamples(): number;
  70164. /**
  70165. * Sets the number of samples taken while computing reflections. More samples count is high,
  70166. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70167. */
  70168. set reflectionSamples(samples: number);
  70169. /**
  70170. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70171. * more the post-process will require GPU power and can generate a drop in FPS.
  70172. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70173. */
  70174. get smoothSteps(): number;
  70175. set smoothSteps(steps: number);
  70176. private _updateEffectDefines;
  70177. }
  70178. }
  70179. declare module "babylonjs/Shaders/standard.fragment" {
  70180. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  70181. /** @hidden */
  70182. export var standardPixelShader: {
  70183. name: string;
  70184. shader: string;
  70185. };
  70186. }
  70187. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  70188. import { Nullable } from "babylonjs/types";
  70189. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70190. import { Camera } from "babylonjs/Cameras/camera";
  70191. import { Texture } from "babylonjs/Materials/Textures/texture";
  70192. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70193. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70194. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70195. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70196. import { IDisposable } from "babylonjs/scene";
  70197. import { SpotLight } from "babylonjs/Lights/spotLight";
  70198. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  70199. import { Scene } from "babylonjs/scene";
  70200. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70201. import { Animation } from "babylonjs/Animations/animation";
  70202. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70203. import "babylonjs/Shaders/standard.fragment";
  70204. /**
  70205. * Standard rendering pipeline
  70206. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70207. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70208. */
  70209. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70210. /**
  70211. * Public members
  70212. */
  70213. /**
  70214. * Post-process which contains the original scene color before the pipeline applies all the effects
  70215. */
  70216. originalPostProcess: Nullable<PostProcess>;
  70217. /**
  70218. * Post-process used to down scale an image x4
  70219. */
  70220. downSampleX4PostProcess: Nullable<PostProcess>;
  70221. /**
  70222. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70223. */
  70224. brightPassPostProcess: Nullable<PostProcess>;
  70225. /**
  70226. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70227. */
  70228. blurHPostProcesses: PostProcess[];
  70229. /**
  70230. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70231. */
  70232. blurVPostProcesses: PostProcess[];
  70233. /**
  70234. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70235. */
  70236. textureAdderPostProcess: Nullable<PostProcess>;
  70237. /**
  70238. * Post-process used to create volumetric lighting effect
  70239. */
  70240. volumetricLightPostProcess: Nullable<PostProcess>;
  70241. /**
  70242. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70243. */
  70244. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70245. /**
  70246. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70247. */
  70248. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70249. /**
  70250. * Post-process used to merge the volumetric light effect and the real scene color
  70251. */
  70252. volumetricLightMergePostProces: Nullable<PostProcess>;
  70253. /**
  70254. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70255. */
  70256. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70257. /**
  70258. * Base post-process used to calculate the average luminance of the final image for HDR
  70259. */
  70260. luminancePostProcess: Nullable<PostProcess>;
  70261. /**
  70262. * Post-processes used to create down sample post-processes in order to get
  70263. * the average luminance of the final image for HDR
  70264. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70265. */
  70266. luminanceDownSamplePostProcesses: PostProcess[];
  70267. /**
  70268. * Post-process used to create a HDR effect (light adaptation)
  70269. */
  70270. hdrPostProcess: Nullable<PostProcess>;
  70271. /**
  70272. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70273. */
  70274. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70275. /**
  70276. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70277. */
  70278. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70279. /**
  70280. * Post-process used to merge the final HDR post-process and the real scene color
  70281. */
  70282. hdrFinalPostProcess: Nullable<PostProcess>;
  70283. /**
  70284. * Post-process used to create a lens flare effect
  70285. */
  70286. lensFlarePostProcess: Nullable<PostProcess>;
  70287. /**
  70288. * Post-process that merges the result of the lens flare post-process and the real scene color
  70289. */
  70290. lensFlareComposePostProcess: Nullable<PostProcess>;
  70291. /**
  70292. * Post-process used to create a motion blur effect
  70293. */
  70294. motionBlurPostProcess: Nullable<PostProcess>;
  70295. /**
  70296. * Post-process used to create a depth of field effect
  70297. */
  70298. depthOfFieldPostProcess: Nullable<PostProcess>;
  70299. /**
  70300. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70301. */
  70302. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70303. /**
  70304. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70305. */
  70306. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70307. /**
  70308. * Represents the brightness threshold in order to configure the illuminated surfaces
  70309. */
  70310. brightThreshold: number;
  70311. /**
  70312. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70313. */
  70314. blurWidth: number;
  70315. /**
  70316. * Sets if the blur for highlighted surfaces must be only horizontal
  70317. */
  70318. horizontalBlur: boolean;
  70319. /**
  70320. * Gets the overall exposure used by the pipeline
  70321. */
  70322. get exposure(): number;
  70323. /**
  70324. * Sets the overall exposure used by the pipeline
  70325. */
  70326. set exposure(value: number);
  70327. /**
  70328. * Texture used typically to simulate "dirty" on camera lens
  70329. */
  70330. lensTexture: Nullable<Texture>;
  70331. /**
  70332. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70333. */
  70334. volumetricLightCoefficient: number;
  70335. /**
  70336. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70337. */
  70338. volumetricLightPower: number;
  70339. /**
  70340. * Used the set the blur intensity to smooth the volumetric lights
  70341. */
  70342. volumetricLightBlurScale: number;
  70343. /**
  70344. * Light (spot or directional) used to generate the volumetric lights rays
  70345. * The source light must have a shadow generate so the pipeline can get its
  70346. * depth map
  70347. */
  70348. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70349. /**
  70350. * For eye adaptation, represents the minimum luminance the eye can see
  70351. */
  70352. hdrMinimumLuminance: number;
  70353. /**
  70354. * For eye adaptation, represents the decrease luminance speed
  70355. */
  70356. hdrDecreaseRate: number;
  70357. /**
  70358. * For eye adaptation, represents the increase luminance speed
  70359. */
  70360. hdrIncreaseRate: number;
  70361. /**
  70362. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70363. */
  70364. get hdrAutoExposure(): boolean;
  70365. /**
  70366. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70367. */
  70368. set hdrAutoExposure(value: boolean);
  70369. /**
  70370. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70371. */
  70372. lensColorTexture: Nullable<Texture>;
  70373. /**
  70374. * The overall strengh for the lens flare effect
  70375. */
  70376. lensFlareStrength: number;
  70377. /**
  70378. * Dispersion coefficient for lens flare ghosts
  70379. */
  70380. lensFlareGhostDispersal: number;
  70381. /**
  70382. * Main lens flare halo width
  70383. */
  70384. lensFlareHaloWidth: number;
  70385. /**
  70386. * Based on the lens distortion effect, defines how much the lens flare result
  70387. * is distorted
  70388. */
  70389. lensFlareDistortionStrength: number;
  70390. /**
  70391. * Configures the blur intensity used for for lens flare (halo)
  70392. */
  70393. lensFlareBlurWidth: number;
  70394. /**
  70395. * Lens star texture must be used to simulate rays on the flares and is available
  70396. * in the documentation
  70397. */
  70398. lensStarTexture: Nullable<Texture>;
  70399. /**
  70400. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70401. * flare effect by taking account of the dirt texture
  70402. */
  70403. lensFlareDirtTexture: Nullable<Texture>;
  70404. /**
  70405. * Represents the focal length for the depth of field effect
  70406. */
  70407. depthOfFieldDistance: number;
  70408. /**
  70409. * Represents the blur intensity for the blurred part of the depth of field effect
  70410. */
  70411. depthOfFieldBlurWidth: number;
  70412. /**
  70413. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70414. */
  70415. get motionStrength(): number;
  70416. /**
  70417. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70418. */
  70419. set motionStrength(strength: number);
  70420. /**
  70421. * Gets wether or not the motion blur post-process is object based or screen based.
  70422. */
  70423. get objectBasedMotionBlur(): boolean;
  70424. /**
  70425. * Sets wether or not the motion blur post-process should be object based or screen based
  70426. */
  70427. set objectBasedMotionBlur(value: boolean);
  70428. /**
  70429. * List of animations for the pipeline (IAnimatable implementation)
  70430. */
  70431. animations: Animation[];
  70432. /**
  70433. * Private members
  70434. */
  70435. private _scene;
  70436. private _currentDepthOfFieldSource;
  70437. private _basePostProcess;
  70438. private _fixedExposure;
  70439. private _currentExposure;
  70440. private _hdrAutoExposure;
  70441. private _hdrCurrentLuminance;
  70442. private _motionStrength;
  70443. private _isObjectBasedMotionBlur;
  70444. private _floatTextureType;
  70445. private _camerasToBeAttached;
  70446. private _ratio;
  70447. private _bloomEnabled;
  70448. private _depthOfFieldEnabled;
  70449. private _vlsEnabled;
  70450. private _lensFlareEnabled;
  70451. private _hdrEnabled;
  70452. private _motionBlurEnabled;
  70453. private _fxaaEnabled;
  70454. private _screenSpaceReflectionsEnabled;
  70455. private _motionBlurSamples;
  70456. private _volumetricLightStepsCount;
  70457. private _samples;
  70458. /**
  70459. * @ignore
  70460. * Specifies if the bloom pipeline is enabled
  70461. */
  70462. get BloomEnabled(): boolean;
  70463. set BloomEnabled(enabled: boolean);
  70464. /**
  70465. * @ignore
  70466. * Specifies if the depth of field pipeline is enabed
  70467. */
  70468. get DepthOfFieldEnabled(): boolean;
  70469. set DepthOfFieldEnabled(enabled: boolean);
  70470. /**
  70471. * @ignore
  70472. * Specifies if the lens flare pipeline is enabed
  70473. */
  70474. get LensFlareEnabled(): boolean;
  70475. set LensFlareEnabled(enabled: boolean);
  70476. /**
  70477. * @ignore
  70478. * Specifies if the HDR pipeline is enabled
  70479. */
  70480. get HDREnabled(): boolean;
  70481. set HDREnabled(enabled: boolean);
  70482. /**
  70483. * @ignore
  70484. * Specifies if the volumetric lights scattering effect is enabled
  70485. */
  70486. get VLSEnabled(): boolean;
  70487. set VLSEnabled(enabled: boolean);
  70488. /**
  70489. * @ignore
  70490. * Specifies if the motion blur effect is enabled
  70491. */
  70492. get MotionBlurEnabled(): boolean;
  70493. set MotionBlurEnabled(enabled: boolean);
  70494. /**
  70495. * Specifies if anti-aliasing is enabled
  70496. */
  70497. get fxaaEnabled(): boolean;
  70498. set fxaaEnabled(enabled: boolean);
  70499. /**
  70500. * Specifies if screen space reflections are enabled.
  70501. */
  70502. get screenSpaceReflectionsEnabled(): boolean;
  70503. set screenSpaceReflectionsEnabled(enabled: boolean);
  70504. /**
  70505. * Specifies the number of steps used to calculate the volumetric lights
  70506. * Typically in interval [50, 200]
  70507. */
  70508. get volumetricLightStepsCount(): number;
  70509. set volumetricLightStepsCount(count: number);
  70510. /**
  70511. * Specifies the number of samples used for the motion blur effect
  70512. * Typically in interval [16, 64]
  70513. */
  70514. get motionBlurSamples(): number;
  70515. set motionBlurSamples(samples: number);
  70516. /**
  70517. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70518. */
  70519. get samples(): number;
  70520. set samples(sampleCount: number);
  70521. /**
  70522. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70523. * @constructor
  70524. * @param name The rendering pipeline name
  70525. * @param scene The scene linked to this pipeline
  70526. * @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)
  70527. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70528. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70529. */
  70530. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70531. private _buildPipeline;
  70532. private _createDownSampleX4PostProcess;
  70533. private _createBrightPassPostProcess;
  70534. private _createBlurPostProcesses;
  70535. private _createTextureAdderPostProcess;
  70536. private _createVolumetricLightPostProcess;
  70537. private _createLuminancePostProcesses;
  70538. private _createHdrPostProcess;
  70539. private _createLensFlarePostProcess;
  70540. private _createDepthOfFieldPostProcess;
  70541. private _createMotionBlurPostProcess;
  70542. private _getDepthTexture;
  70543. private _disposePostProcesses;
  70544. /**
  70545. * Dispose of the pipeline and stop all post processes
  70546. */
  70547. dispose(): void;
  70548. /**
  70549. * Serialize the rendering pipeline (Used when exporting)
  70550. * @returns the serialized object
  70551. */
  70552. serialize(): any;
  70553. /**
  70554. * Parse the serialized pipeline
  70555. * @param source Source pipeline.
  70556. * @param scene The scene to load the pipeline to.
  70557. * @param rootUrl The URL of the serialized pipeline.
  70558. * @returns An instantiated pipeline from the serialized object.
  70559. */
  70560. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70561. /**
  70562. * Luminance steps
  70563. */
  70564. static LuminanceSteps: number;
  70565. }
  70566. }
  70567. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70568. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70569. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70570. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70571. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70572. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70573. }
  70574. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70575. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70576. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70577. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70578. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70579. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70580. }
  70581. declare module "babylonjs/Shaders/tonemap.fragment" {
  70582. /** @hidden */
  70583. export var tonemapPixelShader: {
  70584. name: string;
  70585. shader: string;
  70586. };
  70587. }
  70588. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70589. import { Camera } from "babylonjs/Cameras/camera";
  70590. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70591. import "babylonjs/Shaders/tonemap.fragment";
  70592. import { Engine } from "babylonjs/Engines/engine";
  70593. /** Defines operator used for tonemapping */
  70594. export enum TonemappingOperator {
  70595. /** Hable */
  70596. Hable = 0,
  70597. /** Reinhard */
  70598. Reinhard = 1,
  70599. /** HejiDawson */
  70600. HejiDawson = 2,
  70601. /** Photographic */
  70602. Photographic = 3
  70603. }
  70604. /**
  70605. * Defines a post process to apply tone mapping
  70606. */
  70607. export class TonemapPostProcess extends PostProcess {
  70608. private _operator;
  70609. /** Defines the required exposure adjustement */
  70610. exposureAdjustment: number;
  70611. /**
  70612. * Creates a new TonemapPostProcess
  70613. * @param name defines the name of the postprocess
  70614. * @param _operator defines the operator to use
  70615. * @param exposureAdjustment defines the required exposure adjustement
  70616. * @param camera defines the camera to use (can be null)
  70617. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70618. * @param engine defines the hosting engine (can be ignore if camera is set)
  70619. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70620. */
  70621. constructor(name: string, _operator: TonemappingOperator,
  70622. /** Defines the required exposure adjustement */
  70623. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70624. }
  70625. }
  70626. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70627. /** @hidden */
  70628. export var volumetricLightScatteringPixelShader: {
  70629. name: string;
  70630. shader: string;
  70631. };
  70632. }
  70633. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70634. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70635. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70636. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70637. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70639. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70640. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70641. /** @hidden */
  70642. export var volumetricLightScatteringPassVertexShader: {
  70643. name: string;
  70644. shader: string;
  70645. };
  70646. }
  70647. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70648. /** @hidden */
  70649. export var volumetricLightScatteringPassPixelShader: {
  70650. name: string;
  70651. shader: string;
  70652. };
  70653. }
  70654. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70655. import { Vector3 } from "babylonjs/Maths/math.vector";
  70656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70657. import { Mesh } from "babylonjs/Meshes/mesh";
  70658. import { Camera } from "babylonjs/Cameras/camera";
  70659. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70660. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70661. import { Scene } from "babylonjs/scene";
  70662. import "babylonjs/Meshes/Builders/planeBuilder";
  70663. import "babylonjs/Shaders/depth.vertex";
  70664. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70665. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70666. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70667. import { Engine } from "babylonjs/Engines/engine";
  70668. /**
  70669. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70670. */
  70671. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70672. private _volumetricLightScatteringPass;
  70673. private _volumetricLightScatteringRTT;
  70674. private _viewPort;
  70675. private _screenCoordinates;
  70676. private _cachedDefines;
  70677. /**
  70678. * If not undefined, the mesh position is computed from the attached node position
  70679. */
  70680. attachedNode: {
  70681. position: Vector3;
  70682. };
  70683. /**
  70684. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70685. */
  70686. customMeshPosition: Vector3;
  70687. /**
  70688. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70689. */
  70690. useCustomMeshPosition: boolean;
  70691. /**
  70692. * If the post-process should inverse the light scattering direction
  70693. */
  70694. invert: boolean;
  70695. /**
  70696. * The internal mesh used by the post-process
  70697. */
  70698. mesh: Mesh;
  70699. /**
  70700. * @hidden
  70701. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70702. */
  70703. get useDiffuseColor(): boolean;
  70704. set useDiffuseColor(useDiffuseColor: boolean);
  70705. /**
  70706. * Array containing the excluded meshes not rendered in the internal pass
  70707. */
  70708. excludedMeshes: AbstractMesh[];
  70709. /**
  70710. * Controls the overall intensity of the post-process
  70711. */
  70712. exposure: number;
  70713. /**
  70714. * Dissipates each sample's contribution in range [0, 1]
  70715. */
  70716. decay: number;
  70717. /**
  70718. * Controls the overall intensity of each sample
  70719. */
  70720. weight: number;
  70721. /**
  70722. * Controls the density of each sample
  70723. */
  70724. density: number;
  70725. /**
  70726. * @constructor
  70727. * @param name The post-process name
  70728. * @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)
  70729. * @param camera The camera that the post-process will be attached to
  70730. * @param mesh The mesh used to create the light scattering
  70731. * @param samples The post-process quality, default 100
  70732. * @param samplingModeThe post-process filtering mode
  70733. * @param engine The babylon engine
  70734. * @param reusable If the post-process is reusable
  70735. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70736. */
  70737. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70738. /**
  70739. * Returns the string "VolumetricLightScatteringPostProcess"
  70740. * @returns "VolumetricLightScatteringPostProcess"
  70741. */
  70742. getClassName(): string;
  70743. private _isReady;
  70744. /**
  70745. * Sets the new light position for light scattering effect
  70746. * @param position The new custom light position
  70747. */
  70748. setCustomMeshPosition(position: Vector3): void;
  70749. /**
  70750. * Returns the light position for light scattering effect
  70751. * @return Vector3 The custom light position
  70752. */
  70753. getCustomMeshPosition(): Vector3;
  70754. /**
  70755. * Disposes the internal assets and detaches the post-process from the camera
  70756. */
  70757. dispose(camera: Camera): void;
  70758. /**
  70759. * Returns the render target texture used by the post-process
  70760. * @return the render target texture used by the post-process
  70761. */
  70762. getPass(): RenderTargetTexture;
  70763. private _meshExcluded;
  70764. private _createPass;
  70765. private _updateMeshScreenCoordinates;
  70766. /**
  70767. * Creates a default mesh for the Volumeric Light Scattering post-process
  70768. * @param name The mesh name
  70769. * @param scene The scene where to create the mesh
  70770. * @return the default mesh
  70771. */
  70772. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70773. }
  70774. }
  70775. declare module "babylonjs/PostProcesses/index" {
  70776. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70777. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70778. export * from "babylonjs/PostProcesses/bloomEffect";
  70779. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70780. export * from "babylonjs/PostProcesses/blurPostProcess";
  70781. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70782. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70783. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70784. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70785. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70786. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70787. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70788. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70789. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70790. export * from "babylonjs/PostProcesses/filterPostProcess";
  70791. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70792. export * from "babylonjs/PostProcesses/grainPostProcess";
  70793. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70794. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70795. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70796. export * from "babylonjs/PostProcesses/passPostProcess";
  70797. export * from "babylonjs/PostProcesses/postProcess";
  70798. export * from "babylonjs/PostProcesses/postProcessManager";
  70799. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70800. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70801. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70802. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70803. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70804. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70805. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70806. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70807. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70808. }
  70809. declare module "babylonjs/Probes/index" {
  70810. export * from "babylonjs/Probes/reflectionProbe";
  70811. }
  70812. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70813. import { Scene } from "babylonjs/scene";
  70814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70815. import { SmartArray } from "babylonjs/Misc/smartArray";
  70816. import { ISceneComponent } from "babylonjs/sceneComponent";
  70817. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70818. import "babylonjs/Meshes/Builders/boxBuilder";
  70819. import "babylonjs/Shaders/color.fragment";
  70820. import "babylonjs/Shaders/color.vertex";
  70821. import { Color3 } from "babylonjs/Maths/math.color";
  70822. module "babylonjs/scene" {
  70823. interface Scene {
  70824. /** @hidden (Backing field) */
  70825. _boundingBoxRenderer: BoundingBoxRenderer;
  70826. /** @hidden (Backing field) */
  70827. _forceShowBoundingBoxes: boolean;
  70828. /**
  70829. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70830. */
  70831. forceShowBoundingBoxes: boolean;
  70832. /**
  70833. * Gets the bounding box renderer associated with the scene
  70834. * @returns a BoundingBoxRenderer
  70835. */
  70836. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70837. }
  70838. }
  70839. module "babylonjs/Meshes/abstractMesh" {
  70840. interface AbstractMesh {
  70841. /** @hidden (Backing field) */
  70842. _showBoundingBox: boolean;
  70843. /**
  70844. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70845. */
  70846. showBoundingBox: boolean;
  70847. }
  70848. }
  70849. /**
  70850. * Component responsible of rendering the bounding box of the meshes in a scene.
  70851. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70852. */
  70853. export class BoundingBoxRenderer implements ISceneComponent {
  70854. /**
  70855. * The component name helpfull to identify the component in the list of scene components.
  70856. */
  70857. readonly name: string;
  70858. /**
  70859. * The scene the component belongs to.
  70860. */
  70861. scene: Scene;
  70862. /**
  70863. * Color of the bounding box lines placed in front of an object
  70864. */
  70865. frontColor: Color3;
  70866. /**
  70867. * Color of the bounding box lines placed behind an object
  70868. */
  70869. backColor: Color3;
  70870. /**
  70871. * Defines if the renderer should show the back lines or not
  70872. */
  70873. showBackLines: boolean;
  70874. /**
  70875. * @hidden
  70876. */
  70877. renderList: SmartArray<BoundingBox>;
  70878. private _colorShader;
  70879. private _vertexBuffers;
  70880. private _indexBuffer;
  70881. private _fillIndexBuffer;
  70882. private _fillIndexData;
  70883. /**
  70884. * Instantiates a new bounding box renderer in a scene.
  70885. * @param scene the scene the renderer renders in
  70886. */
  70887. constructor(scene: Scene);
  70888. /**
  70889. * Registers the component in a given scene
  70890. */
  70891. register(): void;
  70892. private _evaluateSubMesh;
  70893. private _activeMesh;
  70894. private _prepareRessources;
  70895. private _createIndexBuffer;
  70896. /**
  70897. * Rebuilds the elements related to this component in case of
  70898. * context lost for instance.
  70899. */
  70900. rebuild(): void;
  70901. /**
  70902. * @hidden
  70903. */
  70904. reset(): void;
  70905. /**
  70906. * Render the bounding boxes of a specific rendering group
  70907. * @param renderingGroupId defines the rendering group to render
  70908. */
  70909. render(renderingGroupId: number): void;
  70910. /**
  70911. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70912. * @param mesh Define the mesh to render the occlusion bounding box for
  70913. */
  70914. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70915. /**
  70916. * Dispose and release the resources attached to this renderer.
  70917. */
  70918. dispose(): void;
  70919. }
  70920. }
  70921. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70922. import { Nullable } from "babylonjs/types";
  70923. import { Scene } from "babylonjs/scene";
  70924. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70925. import { Camera } from "babylonjs/Cameras/camera";
  70926. import { ISceneComponent } from "babylonjs/sceneComponent";
  70927. module "babylonjs/scene" {
  70928. interface Scene {
  70929. /** @hidden (Backing field) */
  70930. _depthRenderer: {
  70931. [id: string]: DepthRenderer;
  70932. };
  70933. /**
  70934. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70935. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70936. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70937. * @returns the created depth renderer
  70938. */
  70939. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70940. /**
  70941. * Disables a depth renderer for a given camera
  70942. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70943. */
  70944. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70945. }
  70946. }
  70947. /**
  70948. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70949. * in several rendering techniques.
  70950. */
  70951. export class DepthRendererSceneComponent implements ISceneComponent {
  70952. /**
  70953. * The component name helpfull to identify the component in the list of scene components.
  70954. */
  70955. readonly name: string;
  70956. /**
  70957. * The scene the component belongs to.
  70958. */
  70959. scene: Scene;
  70960. /**
  70961. * Creates a new instance of the component for the given scene
  70962. * @param scene Defines the scene to register the component in
  70963. */
  70964. constructor(scene: Scene);
  70965. /**
  70966. * Registers the component in a given scene
  70967. */
  70968. register(): void;
  70969. /**
  70970. * Rebuilds the elements related to this component in case of
  70971. * context lost for instance.
  70972. */
  70973. rebuild(): void;
  70974. /**
  70975. * Disposes the component and the associated ressources
  70976. */
  70977. dispose(): void;
  70978. private _gatherRenderTargets;
  70979. private _gatherActiveCameraRenderTargets;
  70980. }
  70981. }
  70982. declare module "babylonjs/Shaders/outline.fragment" {
  70983. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70984. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70985. /** @hidden */
  70986. export var outlinePixelShader: {
  70987. name: string;
  70988. shader: string;
  70989. };
  70990. }
  70991. declare module "babylonjs/Shaders/outline.vertex" {
  70992. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70993. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70994. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70995. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70996. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70997. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70998. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70999. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71000. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  71001. /** @hidden */
  71002. export var outlineVertexShader: {
  71003. name: string;
  71004. shader: string;
  71005. };
  71006. }
  71007. declare module "babylonjs/Rendering/outlineRenderer" {
  71008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71009. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  71010. import { Scene } from "babylonjs/scene";
  71011. import { ISceneComponent } from "babylonjs/sceneComponent";
  71012. import "babylonjs/Shaders/outline.fragment";
  71013. import "babylonjs/Shaders/outline.vertex";
  71014. module "babylonjs/scene" {
  71015. interface Scene {
  71016. /** @hidden */
  71017. _outlineRenderer: OutlineRenderer;
  71018. /**
  71019. * Gets the outline renderer associated with the scene
  71020. * @returns a OutlineRenderer
  71021. */
  71022. getOutlineRenderer(): OutlineRenderer;
  71023. }
  71024. }
  71025. module "babylonjs/Meshes/abstractMesh" {
  71026. interface AbstractMesh {
  71027. /** @hidden (Backing field) */
  71028. _renderOutline: boolean;
  71029. /**
  71030. * Gets or sets a boolean indicating if the outline must be rendered as well
  71031. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71032. */
  71033. renderOutline: boolean;
  71034. /** @hidden (Backing field) */
  71035. _renderOverlay: boolean;
  71036. /**
  71037. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71038. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71039. */
  71040. renderOverlay: boolean;
  71041. }
  71042. }
  71043. /**
  71044. * This class is responsible to draw bothe outline/overlay of meshes.
  71045. * It should not be used directly but through the available method on mesh.
  71046. */
  71047. export class OutlineRenderer implements ISceneComponent {
  71048. /**
  71049. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71050. */
  71051. private static _StencilReference;
  71052. /**
  71053. * The name of the component. Each component must have a unique name.
  71054. */
  71055. name: string;
  71056. /**
  71057. * The scene the component belongs to.
  71058. */
  71059. scene: Scene;
  71060. /**
  71061. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71062. */
  71063. zOffset: number;
  71064. private _engine;
  71065. private _effect;
  71066. private _cachedDefines;
  71067. private _savedDepthWrite;
  71068. /**
  71069. * Instantiates a new outline renderer. (There could be only one per scene).
  71070. * @param scene Defines the scene it belongs to
  71071. */
  71072. constructor(scene: Scene);
  71073. /**
  71074. * Register the component to one instance of a scene.
  71075. */
  71076. register(): void;
  71077. /**
  71078. * Rebuilds the elements related to this component in case of
  71079. * context lost for instance.
  71080. */
  71081. rebuild(): void;
  71082. /**
  71083. * Disposes the component and the associated ressources.
  71084. */
  71085. dispose(): void;
  71086. /**
  71087. * Renders the outline in the canvas.
  71088. * @param subMesh Defines the sumesh to render
  71089. * @param batch Defines the batch of meshes in case of instances
  71090. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71091. */
  71092. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71093. /**
  71094. * Returns whether or not the outline renderer is ready for a given submesh.
  71095. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71096. * @param subMesh Defines the submesh to check readyness for
  71097. * @param useInstances Defines wheter wee are trying to render instances or not
  71098. * @returns true if ready otherwise false
  71099. */
  71100. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71101. private _beforeRenderingMesh;
  71102. private _afterRenderingMesh;
  71103. }
  71104. }
  71105. declare module "babylonjs/Rendering/index" {
  71106. export * from "babylonjs/Rendering/boundingBoxRenderer";
  71107. export * from "babylonjs/Rendering/depthRenderer";
  71108. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  71109. export * from "babylonjs/Rendering/edgesRenderer";
  71110. export * from "babylonjs/Rendering/geometryBufferRenderer";
  71111. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71112. export * from "babylonjs/Rendering/outlineRenderer";
  71113. export * from "babylonjs/Rendering/renderingGroup";
  71114. export * from "babylonjs/Rendering/renderingManager";
  71115. export * from "babylonjs/Rendering/utilityLayerRenderer";
  71116. }
  71117. declare module "babylonjs/Sprites/ISprites" {
  71118. /**
  71119. * Defines the basic options interface of a Sprite Frame Source Size.
  71120. */
  71121. export interface ISpriteJSONSpriteSourceSize {
  71122. /**
  71123. * number of the original width of the Frame
  71124. */
  71125. w: number;
  71126. /**
  71127. * number of the original height of the Frame
  71128. */
  71129. h: number;
  71130. }
  71131. /**
  71132. * Defines the basic options interface of a Sprite Frame Data.
  71133. */
  71134. export interface ISpriteJSONSpriteFrameData {
  71135. /**
  71136. * number of the x offset of the Frame
  71137. */
  71138. x: number;
  71139. /**
  71140. * number of the y offset of the Frame
  71141. */
  71142. y: number;
  71143. /**
  71144. * number of the width of the Frame
  71145. */
  71146. w: number;
  71147. /**
  71148. * number of the height of the Frame
  71149. */
  71150. h: number;
  71151. }
  71152. /**
  71153. * Defines the basic options interface of a JSON Sprite.
  71154. */
  71155. export interface ISpriteJSONSprite {
  71156. /**
  71157. * string name of the Frame
  71158. */
  71159. filename: string;
  71160. /**
  71161. * ISpriteJSONSpriteFrame basic object of the frame data
  71162. */
  71163. frame: ISpriteJSONSpriteFrameData;
  71164. /**
  71165. * boolean to flag is the frame was rotated.
  71166. */
  71167. rotated: boolean;
  71168. /**
  71169. * boolean to flag is the frame was trimmed.
  71170. */
  71171. trimmed: boolean;
  71172. /**
  71173. * ISpriteJSONSpriteFrame basic object of the source data
  71174. */
  71175. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71176. /**
  71177. * ISpriteJSONSpriteFrame basic object of the source data
  71178. */
  71179. sourceSize: ISpriteJSONSpriteSourceSize;
  71180. }
  71181. /**
  71182. * Defines the basic options interface of a JSON atlas.
  71183. */
  71184. export interface ISpriteJSONAtlas {
  71185. /**
  71186. * Array of objects that contain the frame data.
  71187. */
  71188. frames: Array<ISpriteJSONSprite>;
  71189. /**
  71190. * object basic object containing the sprite meta data.
  71191. */
  71192. meta?: object;
  71193. }
  71194. }
  71195. declare module "babylonjs/Shaders/spriteMap.fragment" {
  71196. /** @hidden */
  71197. export var spriteMapPixelShader: {
  71198. name: string;
  71199. shader: string;
  71200. };
  71201. }
  71202. declare module "babylonjs/Shaders/spriteMap.vertex" {
  71203. /** @hidden */
  71204. export var spriteMapVertexShader: {
  71205. name: string;
  71206. shader: string;
  71207. };
  71208. }
  71209. declare module "babylonjs/Sprites/spriteMap" {
  71210. import { IDisposable, Scene } from "babylonjs/scene";
  71211. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  71212. import { Texture } from "babylonjs/Materials/Textures/texture";
  71213. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71214. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  71215. import "babylonjs/Meshes/Builders/planeBuilder";
  71216. import "babylonjs/Shaders/spriteMap.fragment";
  71217. import "babylonjs/Shaders/spriteMap.vertex";
  71218. /**
  71219. * Defines the basic options interface of a SpriteMap
  71220. */
  71221. export interface ISpriteMapOptions {
  71222. /**
  71223. * Vector2 of the number of cells in the grid.
  71224. */
  71225. stageSize?: Vector2;
  71226. /**
  71227. * Vector2 of the size of the output plane in World Units.
  71228. */
  71229. outputSize?: Vector2;
  71230. /**
  71231. * Vector3 of the position of the output plane in World Units.
  71232. */
  71233. outputPosition?: Vector3;
  71234. /**
  71235. * Vector3 of the rotation of the output plane.
  71236. */
  71237. outputRotation?: Vector3;
  71238. /**
  71239. * number of layers that the system will reserve in resources.
  71240. */
  71241. layerCount?: number;
  71242. /**
  71243. * number of max animation frames a single cell will reserve in resources.
  71244. */
  71245. maxAnimationFrames?: number;
  71246. /**
  71247. * number cell index of the base tile when the system compiles.
  71248. */
  71249. baseTile?: number;
  71250. /**
  71251. * boolean flip the sprite after its been repositioned by the framing data.
  71252. */
  71253. flipU?: boolean;
  71254. /**
  71255. * Vector3 scalar of the global RGB values of the SpriteMap.
  71256. */
  71257. colorMultiply?: Vector3;
  71258. }
  71259. /**
  71260. * Defines the IDisposable interface in order to be cleanable from resources.
  71261. */
  71262. export interface ISpriteMap extends IDisposable {
  71263. /**
  71264. * String name of the SpriteMap.
  71265. */
  71266. name: string;
  71267. /**
  71268. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71269. */
  71270. atlasJSON: ISpriteJSONAtlas;
  71271. /**
  71272. * Texture of the SpriteMap.
  71273. */
  71274. spriteSheet: Texture;
  71275. /**
  71276. * The parameters to initialize the SpriteMap with.
  71277. */
  71278. options: ISpriteMapOptions;
  71279. }
  71280. /**
  71281. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71282. */
  71283. export class SpriteMap implements ISpriteMap {
  71284. /** The Name of the spriteMap */
  71285. name: string;
  71286. /** The JSON file with the frame and meta data */
  71287. atlasJSON: ISpriteJSONAtlas;
  71288. /** The systems Sprite Sheet Texture */
  71289. spriteSheet: Texture;
  71290. /** Arguments passed with the Constructor */
  71291. options: ISpriteMapOptions;
  71292. /** Public Sprite Storage array, parsed from atlasJSON */
  71293. sprites: Array<ISpriteJSONSprite>;
  71294. /** Returns the Number of Sprites in the System */
  71295. get spriteCount(): number;
  71296. /** Returns the Position of Output Plane*/
  71297. get position(): Vector3;
  71298. /** Returns the Position of Output Plane*/
  71299. set position(v: Vector3);
  71300. /** Returns the Rotation of Output Plane*/
  71301. get rotation(): Vector3;
  71302. /** Returns the Rotation of Output Plane*/
  71303. set rotation(v: Vector3);
  71304. /** Sets the AnimationMap*/
  71305. get animationMap(): RawTexture;
  71306. /** Sets the AnimationMap*/
  71307. set animationMap(v: RawTexture);
  71308. /** Scene that the SpriteMap was created in */
  71309. private _scene;
  71310. /** Texture Buffer of Float32 that holds tile frame data*/
  71311. private _frameMap;
  71312. /** Texture Buffers of Float32 that holds tileMap data*/
  71313. private _tileMaps;
  71314. /** Texture Buffer of Float32 that holds Animation Data*/
  71315. private _animationMap;
  71316. /** Custom ShaderMaterial Central to the System*/
  71317. private _material;
  71318. /** Custom ShaderMaterial Central to the System*/
  71319. private _output;
  71320. /** Systems Time Ticker*/
  71321. private _time;
  71322. /**
  71323. * Creates a new SpriteMap
  71324. * @param name defines the SpriteMaps Name
  71325. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71326. * @param spriteSheet is the Texture that the Sprites are on.
  71327. * @param options a basic deployment configuration
  71328. * @param scene The Scene that the map is deployed on
  71329. */
  71330. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71331. /**
  71332. * Returns tileID location
  71333. * @returns Vector2 the cell position ID
  71334. */
  71335. getTileID(): Vector2;
  71336. /**
  71337. * Gets the UV location of the mouse over the SpriteMap.
  71338. * @returns Vector2 the UV position of the mouse interaction
  71339. */
  71340. getMousePosition(): Vector2;
  71341. /**
  71342. * Creates the "frame" texture Buffer
  71343. * -------------------------------------
  71344. * Structure of frames
  71345. * "filename": "Falling-Water-2.png",
  71346. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71347. * "rotated": true,
  71348. * "trimmed": true,
  71349. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71350. * "sourceSize": {"w":32,"h":32}
  71351. * @returns RawTexture of the frameMap
  71352. */
  71353. private _createFrameBuffer;
  71354. /**
  71355. * Creates the tileMap texture Buffer
  71356. * @param buffer normally and array of numbers, or a false to generate from scratch
  71357. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71358. * @returns RawTexture of the tileMap
  71359. */
  71360. private _createTileBuffer;
  71361. /**
  71362. * Modifies the data of the tileMaps
  71363. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71364. * @param pos is the iVector2 Coordinates of the Tile
  71365. * @param tile The SpriteIndex of the new Tile
  71366. */
  71367. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71368. /**
  71369. * Creates the animationMap texture Buffer
  71370. * @param buffer normally and array of numbers, or a false to generate from scratch
  71371. * @returns RawTexture of the animationMap
  71372. */
  71373. private _createTileAnimationBuffer;
  71374. /**
  71375. * Modifies the data of the animationMap
  71376. * @param cellID is the Index of the Sprite
  71377. * @param _frame is the target Animation frame
  71378. * @param toCell is the Target Index of the next frame of the animation
  71379. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71380. * @param speed is a global scalar of the time variable on the map.
  71381. */
  71382. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71383. /**
  71384. * Exports the .tilemaps file
  71385. */
  71386. saveTileMaps(): void;
  71387. /**
  71388. * Imports the .tilemaps file
  71389. * @param url of the .tilemaps file
  71390. */
  71391. loadTileMaps(url: string): void;
  71392. /**
  71393. * Release associated resources
  71394. */
  71395. dispose(): void;
  71396. }
  71397. }
  71398. declare module "babylonjs/Sprites/spritePackedManager" {
  71399. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  71400. import { Scene } from "babylonjs/scene";
  71401. /**
  71402. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71403. * @see http://doc.babylonjs.com/babylon101/sprites
  71404. */
  71405. export class SpritePackedManager extends SpriteManager {
  71406. /** defines the packed manager's name */
  71407. name: string;
  71408. /**
  71409. * Creates a new sprite manager from a packed sprite sheet
  71410. * @param name defines the manager's name
  71411. * @param imgUrl defines the sprite sheet url
  71412. * @param capacity defines the maximum allowed number of sprites
  71413. * @param scene defines the hosting scene
  71414. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71415. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71416. * @param samplingMode defines the smapling mode to use with spritesheet
  71417. * @param fromPacked set to true; do not alter
  71418. */
  71419. constructor(
  71420. /** defines the packed manager's name */
  71421. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71422. }
  71423. }
  71424. declare module "babylonjs/Sprites/index" {
  71425. export * from "babylonjs/Sprites/sprite";
  71426. export * from "babylonjs/Sprites/ISprites";
  71427. export * from "babylonjs/Sprites/spriteManager";
  71428. export * from "babylonjs/Sprites/spriteMap";
  71429. export * from "babylonjs/Sprites/spritePackedManager";
  71430. export * from "babylonjs/Sprites/spriteSceneComponent";
  71431. }
  71432. declare module "babylonjs/States/index" {
  71433. export * from "babylonjs/States/alphaCullingState";
  71434. export * from "babylonjs/States/depthCullingState";
  71435. export * from "babylonjs/States/stencilState";
  71436. }
  71437. declare module "babylonjs/Misc/assetsManager" {
  71438. import { Scene } from "babylonjs/scene";
  71439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71440. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71441. import { Skeleton } from "babylonjs/Bones/skeleton";
  71442. import { Observable } from "babylonjs/Misc/observable";
  71443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71444. import { Texture } from "babylonjs/Materials/Textures/texture";
  71445. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  71446. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  71447. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  71448. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  71449. /**
  71450. * Defines the list of states available for a task inside a AssetsManager
  71451. */
  71452. export enum AssetTaskState {
  71453. /**
  71454. * Initialization
  71455. */
  71456. INIT = 0,
  71457. /**
  71458. * Running
  71459. */
  71460. RUNNING = 1,
  71461. /**
  71462. * Done
  71463. */
  71464. DONE = 2,
  71465. /**
  71466. * Error
  71467. */
  71468. ERROR = 3
  71469. }
  71470. /**
  71471. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71472. */
  71473. export abstract class AbstractAssetTask {
  71474. /**
  71475. * Task name
  71476. */ name: string;
  71477. /**
  71478. * Callback called when the task is successful
  71479. */
  71480. onSuccess: (task: any) => void;
  71481. /**
  71482. * Callback called when the task is not successful
  71483. */
  71484. onError: (task: any, message?: string, exception?: any) => void;
  71485. /**
  71486. * Creates a new AssetsManager
  71487. * @param name defines the name of the task
  71488. */
  71489. constructor(
  71490. /**
  71491. * Task name
  71492. */ name: string);
  71493. private _isCompleted;
  71494. private _taskState;
  71495. private _errorObject;
  71496. /**
  71497. * Get if the task is completed
  71498. */
  71499. get isCompleted(): boolean;
  71500. /**
  71501. * Gets the current state of the task
  71502. */
  71503. get taskState(): AssetTaskState;
  71504. /**
  71505. * Gets the current error object (if task is in error)
  71506. */
  71507. get errorObject(): {
  71508. message?: string;
  71509. exception?: any;
  71510. };
  71511. /**
  71512. * Internal only
  71513. * @hidden
  71514. */
  71515. _setErrorObject(message?: string, exception?: any): void;
  71516. /**
  71517. * Execute the current task
  71518. * @param scene defines the scene where you want your assets to be loaded
  71519. * @param onSuccess is a callback called when the task is successfully executed
  71520. * @param onError is a callback called if an error occurs
  71521. */
  71522. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71523. /**
  71524. * Execute the current task
  71525. * @param scene defines the scene where you want your assets to be loaded
  71526. * @param onSuccess is a callback called when the task is successfully executed
  71527. * @param onError is a callback called if an error occurs
  71528. */
  71529. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71530. /**
  71531. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71532. * This can be used with failed tasks that have the reason for failure fixed.
  71533. */
  71534. reset(): void;
  71535. private onErrorCallback;
  71536. private onDoneCallback;
  71537. }
  71538. /**
  71539. * Define the interface used by progress events raised during assets loading
  71540. */
  71541. export interface IAssetsProgressEvent {
  71542. /**
  71543. * Defines the number of remaining tasks to process
  71544. */
  71545. remainingCount: number;
  71546. /**
  71547. * Defines the total number of tasks
  71548. */
  71549. totalCount: number;
  71550. /**
  71551. * Defines the task that was just processed
  71552. */
  71553. task: AbstractAssetTask;
  71554. }
  71555. /**
  71556. * Class used to share progress information about assets loading
  71557. */
  71558. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71559. /**
  71560. * Defines the number of remaining tasks to process
  71561. */
  71562. remainingCount: number;
  71563. /**
  71564. * Defines the total number of tasks
  71565. */
  71566. totalCount: number;
  71567. /**
  71568. * Defines the task that was just processed
  71569. */
  71570. task: AbstractAssetTask;
  71571. /**
  71572. * Creates a AssetsProgressEvent
  71573. * @param remainingCount defines the number of remaining tasks to process
  71574. * @param totalCount defines the total number of tasks
  71575. * @param task defines the task that was just processed
  71576. */
  71577. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71578. }
  71579. /**
  71580. * Define a task used by AssetsManager to load meshes
  71581. */
  71582. export class MeshAssetTask extends AbstractAssetTask {
  71583. /**
  71584. * Defines the name of the task
  71585. */
  71586. name: string;
  71587. /**
  71588. * Defines the list of mesh's names you want to load
  71589. */
  71590. meshesNames: any;
  71591. /**
  71592. * Defines the root url to use as a base to load your meshes and associated resources
  71593. */
  71594. rootUrl: string;
  71595. /**
  71596. * Defines the filename of the scene to load from
  71597. */
  71598. sceneFilename: string;
  71599. /**
  71600. * Gets the list of loaded meshes
  71601. */
  71602. loadedMeshes: Array<AbstractMesh>;
  71603. /**
  71604. * Gets the list of loaded particle systems
  71605. */
  71606. loadedParticleSystems: Array<IParticleSystem>;
  71607. /**
  71608. * Gets the list of loaded skeletons
  71609. */
  71610. loadedSkeletons: Array<Skeleton>;
  71611. /**
  71612. * Gets the list of loaded animation groups
  71613. */
  71614. loadedAnimationGroups: Array<AnimationGroup>;
  71615. /**
  71616. * Callback called when the task is successful
  71617. */
  71618. onSuccess: (task: MeshAssetTask) => void;
  71619. /**
  71620. * Callback called when the task is successful
  71621. */
  71622. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71623. /**
  71624. * Creates a new MeshAssetTask
  71625. * @param name defines the name of the task
  71626. * @param meshesNames defines the list of mesh's names you want to load
  71627. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71628. * @param sceneFilename defines the filename of the scene to load from
  71629. */
  71630. constructor(
  71631. /**
  71632. * Defines the name of the task
  71633. */
  71634. name: string,
  71635. /**
  71636. * Defines the list of mesh's names you want to load
  71637. */
  71638. meshesNames: any,
  71639. /**
  71640. * Defines the root url to use as a base to load your meshes and associated resources
  71641. */
  71642. rootUrl: string,
  71643. /**
  71644. * Defines the filename of the scene to load from
  71645. */
  71646. sceneFilename: string);
  71647. /**
  71648. * Execute the current task
  71649. * @param scene defines the scene where you want your assets to be loaded
  71650. * @param onSuccess is a callback called when the task is successfully executed
  71651. * @param onError is a callback called if an error occurs
  71652. */
  71653. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71654. }
  71655. /**
  71656. * Define a task used by AssetsManager to load text content
  71657. */
  71658. export class TextFileAssetTask extends AbstractAssetTask {
  71659. /**
  71660. * Defines the name of the task
  71661. */
  71662. name: string;
  71663. /**
  71664. * Defines the location of the file to load
  71665. */
  71666. url: string;
  71667. /**
  71668. * Gets the loaded text string
  71669. */
  71670. text: string;
  71671. /**
  71672. * Callback called when the task is successful
  71673. */
  71674. onSuccess: (task: TextFileAssetTask) => void;
  71675. /**
  71676. * Callback called when the task is successful
  71677. */
  71678. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71679. /**
  71680. * Creates a new TextFileAssetTask object
  71681. * @param name defines the name of the task
  71682. * @param url defines the location of the file to load
  71683. */
  71684. constructor(
  71685. /**
  71686. * Defines the name of the task
  71687. */
  71688. name: string,
  71689. /**
  71690. * Defines the location of the file to load
  71691. */
  71692. url: string);
  71693. /**
  71694. * Execute the current task
  71695. * @param scene defines the scene where you want your assets to be loaded
  71696. * @param onSuccess is a callback called when the task is successfully executed
  71697. * @param onError is a callback called if an error occurs
  71698. */
  71699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71700. }
  71701. /**
  71702. * Define a task used by AssetsManager to load binary data
  71703. */
  71704. export class BinaryFileAssetTask extends AbstractAssetTask {
  71705. /**
  71706. * Defines the name of the task
  71707. */
  71708. name: string;
  71709. /**
  71710. * Defines the location of the file to load
  71711. */
  71712. url: string;
  71713. /**
  71714. * Gets the lodaded data (as an array buffer)
  71715. */
  71716. data: ArrayBuffer;
  71717. /**
  71718. * Callback called when the task is successful
  71719. */
  71720. onSuccess: (task: BinaryFileAssetTask) => void;
  71721. /**
  71722. * Callback called when the task is successful
  71723. */
  71724. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71725. /**
  71726. * Creates a new BinaryFileAssetTask object
  71727. * @param name defines the name of the new task
  71728. * @param url defines the location of the file to load
  71729. */
  71730. constructor(
  71731. /**
  71732. * Defines the name of the task
  71733. */
  71734. name: string,
  71735. /**
  71736. * Defines the location of the file to load
  71737. */
  71738. url: string);
  71739. /**
  71740. * Execute the current task
  71741. * @param scene defines the scene where you want your assets to be loaded
  71742. * @param onSuccess is a callback called when the task is successfully executed
  71743. * @param onError is a callback called if an error occurs
  71744. */
  71745. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71746. }
  71747. /**
  71748. * Define a task used by AssetsManager to load images
  71749. */
  71750. export class ImageAssetTask extends AbstractAssetTask {
  71751. /**
  71752. * Defines the name of the task
  71753. */
  71754. name: string;
  71755. /**
  71756. * Defines the location of the image to load
  71757. */
  71758. url: string;
  71759. /**
  71760. * Gets the loaded images
  71761. */
  71762. image: HTMLImageElement;
  71763. /**
  71764. * Callback called when the task is successful
  71765. */
  71766. onSuccess: (task: ImageAssetTask) => void;
  71767. /**
  71768. * Callback called when the task is successful
  71769. */
  71770. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71771. /**
  71772. * Creates a new ImageAssetTask
  71773. * @param name defines the name of the task
  71774. * @param url defines the location of the image to load
  71775. */
  71776. constructor(
  71777. /**
  71778. * Defines the name of the task
  71779. */
  71780. name: string,
  71781. /**
  71782. * Defines the location of the image to load
  71783. */
  71784. url: string);
  71785. /**
  71786. * Execute the current task
  71787. * @param scene defines the scene where you want your assets to be loaded
  71788. * @param onSuccess is a callback called when the task is successfully executed
  71789. * @param onError is a callback called if an error occurs
  71790. */
  71791. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71792. }
  71793. /**
  71794. * Defines the interface used by texture loading tasks
  71795. */
  71796. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71797. /**
  71798. * Gets the loaded texture
  71799. */
  71800. texture: TEX;
  71801. }
  71802. /**
  71803. * Define a task used by AssetsManager to load 2D textures
  71804. */
  71805. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71806. /**
  71807. * Defines the name of the task
  71808. */
  71809. name: string;
  71810. /**
  71811. * Defines the location of the file to load
  71812. */
  71813. url: string;
  71814. /**
  71815. * Defines if mipmap should not be generated (default is false)
  71816. */
  71817. noMipmap?: boolean | undefined;
  71818. /**
  71819. * Defines if texture must be inverted on Y axis (default is true)
  71820. */
  71821. invertY: boolean;
  71822. /**
  71823. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71824. */
  71825. samplingMode: number;
  71826. /**
  71827. * Gets the loaded texture
  71828. */
  71829. texture: Texture;
  71830. /**
  71831. * Callback called when the task is successful
  71832. */
  71833. onSuccess: (task: TextureAssetTask) => void;
  71834. /**
  71835. * Callback called when the task is successful
  71836. */
  71837. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71838. /**
  71839. * Creates a new TextureAssetTask object
  71840. * @param name defines the name of the task
  71841. * @param url defines the location of the file to load
  71842. * @param noMipmap defines if mipmap should not be generated (default is false)
  71843. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71844. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71845. */
  71846. constructor(
  71847. /**
  71848. * Defines the name of the task
  71849. */
  71850. name: string,
  71851. /**
  71852. * Defines the location of the file to load
  71853. */
  71854. url: string,
  71855. /**
  71856. * Defines if mipmap should not be generated (default is false)
  71857. */
  71858. noMipmap?: boolean | undefined,
  71859. /**
  71860. * Defines if texture must be inverted on Y axis (default is true)
  71861. */
  71862. invertY?: boolean,
  71863. /**
  71864. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71865. */
  71866. samplingMode?: number);
  71867. /**
  71868. * Execute the current task
  71869. * @param scene defines the scene where you want your assets to be loaded
  71870. * @param onSuccess is a callback called when the task is successfully executed
  71871. * @param onError is a callback called if an error occurs
  71872. */
  71873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71874. }
  71875. /**
  71876. * Define a task used by AssetsManager to load cube textures
  71877. */
  71878. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71879. /**
  71880. * Defines the name of the task
  71881. */
  71882. name: string;
  71883. /**
  71884. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71885. */
  71886. url: string;
  71887. /**
  71888. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71889. */
  71890. extensions?: string[] | undefined;
  71891. /**
  71892. * Defines if mipmaps should not be generated (default is false)
  71893. */
  71894. noMipmap?: boolean | undefined;
  71895. /**
  71896. * Defines the explicit list of files (undefined by default)
  71897. */
  71898. files?: string[] | undefined;
  71899. /**
  71900. * Gets the loaded texture
  71901. */
  71902. texture: CubeTexture;
  71903. /**
  71904. * Callback called when the task is successful
  71905. */
  71906. onSuccess: (task: CubeTextureAssetTask) => void;
  71907. /**
  71908. * Callback called when the task is successful
  71909. */
  71910. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71911. /**
  71912. * Creates a new CubeTextureAssetTask
  71913. * @param name defines the name of the task
  71914. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71915. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71916. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71917. * @param files defines the explicit list of files (undefined by default)
  71918. */
  71919. constructor(
  71920. /**
  71921. * Defines the name of the task
  71922. */
  71923. name: string,
  71924. /**
  71925. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71926. */
  71927. url: string,
  71928. /**
  71929. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71930. */
  71931. extensions?: string[] | undefined,
  71932. /**
  71933. * Defines if mipmaps should not be generated (default is false)
  71934. */
  71935. noMipmap?: boolean | undefined,
  71936. /**
  71937. * Defines the explicit list of files (undefined by default)
  71938. */
  71939. files?: string[] | undefined);
  71940. /**
  71941. * Execute the current task
  71942. * @param scene defines the scene where you want your assets to be loaded
  71943. * @param onSuccess is a callback called when the task is successfully executed
  71944. * @param onError is a callback called if an error occurs
  71945. */
  71946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71947. }
  71948. /**
  71949. * Define a task used by AssetsManager to load HDR cube textures
  71950. */
  71951. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71952. /**
  71953. * Defines the name of the task
  71954. */
  71955. name: string;
  71956. /**
  71957. * Defines the location of the file to load
  71958. */
  71959. url: string;
  71960. /**
  71961. * Defines the desired size (the more it increases the longer the generation will be)
  71962. */
  71963. size: number;
  71964. /**
  71965. * Defines if mipmaps should not be generated (default is false)
  71966. */
  71967. noMipmap: boolean;
  71968. /**
  71969. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71970. */
  71971. generateHarmonics: boolean;
  71972. /**
  71973. * 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)
  71974. */
  71975. gammaSpace: boolean;
  71976. /**
  71977. * Internal Use Only
  71978. */
  71979. reserved: boolean;
  71980. /**
  71981. * Gets the loaded texture
  71982. */
  71983. texture: HDRCubeTexture;
  71984. /**
  71985. * Callback called when the task is successful
  71986. */
  71987. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71988. /**
  71989. * Callback called when the task is successful
  71990. */
  71991. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71992. /**
  71993. * Creates a new HDRCubeTextureAssetTask object
  71994. * @param name defines the name of the task
  71995. * @param url defines the location of the file to load
  71996. * @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.
  71997. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71998. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71999. * @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)
  72000. * @param reserved Internal use only
  72001. */
  72002. constructor(
  72003. /**
  72004. * Defines the name of the task
  72005. */
  72006. name: string,
  72007. /**
  72008. * Defines the location of the file to load
  72009. */
  72010. url: string,
  72011. /**
  72012. * Defines the desired size (the more it increases the longer the generation will be)
  72013. */
  72014. size: number,
  72015. /**
  72016. * Defines if mipmaps should not be generated (default is false)
  72017. */
  72018. noMipmap?: boolean,
  72019. /**
  72020. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72021. */
  72022. generateHarmonics?: boolean,
  72023. /**
  72024. * 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)
  72025. */
  72026. gammaSpace?: boolean,
  72027. /**
  72028. * Internal Use Only
  72029. */
  72030. reserved?: boolean);
  72031. /**
  72032. * Execute the current task
  72033. * @param scene defines the scene where you want your assets to be loaded
  72034. * @param onSuccess is a callback called when the task is successfully executed
  72035. * @param onError is a callback called if an error occurs
  72036. */
  72037. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72038. }
  72039. /**
  72040. * Define a task used by AssetsManager to load Equirectangular cube textures
  72041. */
  72042. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72043. /**
  72044. * Defines the name of the task
  72045. */
  72046. name: string;
  72047. /**
  72048. * Defines the location of the file to load
  72049. */
  72050. url: string;
  72051. /**
  72052. * Defines the desired size (the more it increases the longer the generation will be)
  72053. */
  72054. size: number;
  72055. /**
  72056. * Defines if mipmaps should not be generated (default is false)
  72057. */
  72058. noMipmap: boolean;
  72059. /**
  72060. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72061. * but the standard material would require them in Gamma space) (default is true)
  72062. */
  72063. gammaSpace: boolean;
  72064. /**
  72065. * Gets the loaded texture
  72066. */
  72067. texture: EquiRectangularCubeTexture;
  72068. /**
  72069. * Callback called when the task is successful
  72070. */
  72071. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72072. /**
  72073. * Callback called when the task is successful
  72074. */
  72075. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72076. /**
  72077. * Creates a new EquiRectangularCubeTextureAssetTask object
  72078. * @param name defines the name of the task
  72079. * @param url defines the location of the file to load
  72080. * @param size defines the desired size (the more it increases the longer the generation will be)
  72081. * If the size is omitted this implies you are using a preprocessed cubemap.
  72082. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72083. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72084. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72085. * (default is true)
  72086. */
  72087. constructor(
  72088. /**
  72089. * Defines the name of the task
  72090. */
  72091. name: string,
  72092. /**
  72093. * Defines the location of the file to load
  72094. */
  72095. url: string,
  72096. /**
  72097. * Defines the desired size (the more it increases the longer the generation will be)
  72098. */
  72099. size: number,
  72100. /**
  72101. * Defines if mipmaps should not be generated (default is false)
  72102. */
  72103. noMipmap?: boolean,
  72104. /**
  72105. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72106. * but the standard material would require them in Gamma space) (default is true)
  72107. */
  72108. gammaSpace?: boolean);
  72109. /**
  72110. * Execute the current task
  72111. * @param scene defines the scene where you want your assets to be loaded
  72112. * @param onSuccess is a callback called when the task is successfully executed
  72113. * @param onError is a callback called if an error occurs
  72114. */
  72115. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72116. }
  72117. /**
  72118. * This class can be used to easily import assets into a scene
  72119. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72120. */
  72121. export class AssetsManager {
  72122. private _scene;
  72123. private _isLoading;
  72124. protected _tasks: AbstractAssetTask[];
  72125. protected _waitingTasksCount: number;
  72126. protected _totalTasksCount: number;
  72127. /**
  72128. * Callback called when all tasks are processed
  72129. */
  72130. onFinish: (tasks: AbstractAssetTask[]) => void;
  72131. /**
  72132. * Callback called when a task is successful
  72133. */
  72134. onTaskSuccess: (task: AbstractAssetTask) => void;
  72135. /**
  72136. * Callback called when a task had an error
  72137. */
  72138. onTaskError: (task: AbstractAssetTask) => void;
  72139. /**
  72140. * Callback called when a task is done (whatever the result is)
  72141. */
  72142. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72143. /**
  72144. * Observable called when all tasks are processed
  72145. */
  72146. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72147. /**
  72148. * Observable called when a task had an error
  72149. */
  72150. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72151. /**
  72152. * Observable called when all tasks were executed
  72153. */
  72154. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72155. /**
  72156. * Observable called when a task is done (whatever the result is)
  72157. */
  72158. onProgressObservable: Observable<IAssetsProgressEvent>;
  72159. /**
  72160. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72161. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72162. */
  72163. useDefaultLoadingScreen: boolean;
  72164. /**
  72165. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72166. * when all assets have been downloaded.
  72167. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72168. */
  72169. autoHideLoadingUI: boolean;
  72170. /**
  72171. * Creates a new AssetsManager
  72172. * @param scene defines the scene to work on
  72173. */
  72174. constructor(scene: Scene);
  72175. /**
  72176. * Add a MeshAssetTask to the list of active tasks
  72177. * @param taskName defines the name of the new task
  72178. * @param meshesNames defines the name of meshes to load
  72179. * @param rootUrl defines the root url to use to locate files
  72180. * @param sceneFilename defines the filename of the scene file
  72181. * @returns a new MeshAssetTask object
  72182. */
  72183. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72184. /**
  72185. * Add a TextFileAssetTask to the list of active tasks
  72186. * @param taskName defines the name of the new task
  72187. * @param url defines the url of the file to load
  72188. * @returns a new TextFileAssetTask object
  72189. */
  72190. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72191. /**
  72192. * Add a BinaryFileAssetTask to the list of active tasks
  72193. * @param taskName defines the name of the new task
  72194. * @param url defines the url of the file to load
  72195. * @returns a new BinaryFileAssetTask object
  72196. */
  72197. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72198. /**
  72199. * Add a ImageAssetTask to the list of active tasks
  72200. * @param taskName defines the name of the new task
  72201. * @param url defines the url of the file to load
  72202. * @returns a new ImageAssetTask object
  72203. */
  72204. addImageTask(taskName: string, url: string): ImageAssetTask;
  72205. /**
  72206. * Add a TextureAssetTask to the list of active tasks
  72207. * @param taskName defines the name of the new task
  72208. * @param url defines the url of the file to load
  72209. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72210. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72211. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72212. * @returns a new TextureAssetTask object
  72213. */
  72214. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72215. /**
  72216. * Add a CubeTextureAssetTask to the list of active tasks
  72217. * @param taskName defines the name of the new task
  72218. * @param url defines the url of the file to load
  72219. * @param extensions defines the extension to use to load the cube map (can be null)
  72220. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72221. * @param files defines the list of files to load (can be null)
  72222. * @returns a new CubeTextureAssetTask object
  72223. */
  72224. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72225. /**
  72226. *
  72227. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72228. * @param taskName defines the name of the new task
  72229. * @param url defines the url of the file to load
  72230. * @param size defines the size you want for the cubemap (can be null)
  72231. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72232. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72233. * @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)
  72234. * @param reserved Internal use only
  72235. * @returns a new HDRCubeTextureAssetTask object
  72236. */
  72237. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72238. /**
  72239. *
  72240. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72241. * @param taskName defines the name of the new task
  72242. * @param url defines the url of the file to load
  72243. * @param size defines the size you want for the cubemap (can be null)
  72244. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72245. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72246. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72247. * @returns a new EquiRectangularCubeTextureAssetTask object
  72248. */
  72249. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72250. /**
  72251. * Remove a task from the assets manager.
  72252. * @param task the task to remove
  72253. */
  72254. removeTask(task: AbstractAssetTask): void;
  72255. private _decreaseWaitingTasksCount;
  72256. private _runTask;
  72257. /**
  72258. * Reset the AssetsManager and remove all tasks
  72259. * @return the current instance of the AssetsManager
  72260. */
  72261. reset(): AssetsManager;
  72262. /**
  72263. * Start the loading process
  72264. * @return the current instance of the AssetsManager
  72265. */
  72266. load(): AssetsManager;
  72267. /**
  72268. * Start the loading process as an async operation
  72269. * @return a promise returning the list of failed tasks
  72270. */
  72271. loadAsync(): Promise<void>;
  72272. }
  72273. }
  72274. declare module "babylonjs/Misc/deferred" {
  72275. /**
  72276. * Wrapper class for promise with external resolve and reject.
  72277. */
  72278. export class Deferred<T> {
  72279. /**
  72280. * The promise associated with this deferred object.
  72281. */
  72282. readonly promise: Promise<T>;
  72283. private _resolve;
  72284. private _reject;
  72285. /**
  72286. * The resolve method of the promise associated with this deferred object.
  72287. */
  72288. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72289. /**
  72290. * The reject method of the promise associated with this deferred object.
  72291. */
  72292. get reject(): (reason?: any) => void;
  72293. /**
  72294. * Constructor for this deferred object.
  72295. */
  72296. constructor();
  72297. }
  72298. }
  72299. declare module "babylonjs/Misc/meshExploder" {
  72300. import { Mesh } from "babylonjs/Meshes/mesh";
  72301. /**
  72302. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72303. */
  72304. export class MeshExploder {
  72305. private _centerMesh;
  72306. private _meshes;
  72307. private _meshesOrigins;
  72308. private _toCenterVectors;
  72309. private _scaledDirection;
  72310. private _newPosition;
  72311. private _centerPosition;
  72312. /**
  72313. * Explodes meshes from a center mesh.
  72314. * @param meshes The meshes to explode.
  72315. * @param centerMesh The mesh to be center of explosion.
  72316. */
  72317. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72318. private _setCenterMesh;
  72319. /**
  72320. * Get class name
  72321. * @returns "MeshExploder"
  72322. */
  72323. getClassName(): string;
  72324. /**
  72325. * "Exploded meshes"
  72326. * @returns Array of meshes with the centerMesh at index 0.
  72327. */
  72328. getMeshes(): Array<Mesh>;
  72329. /**
  72330. * Explodes meshes giving a specific direction
  72331. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72332. */
  72333. explode(direction?: number): void;
  72334. }
  72335. }
  72336. declare module "babylonjs/Misc/filesInput" {
  72337. import { Engine } from "babylonjs/Engines/engine";
  72338. import { Scene } from "babylonjs/scene";
  72339. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  72340. /**
  72341. * Class used to help managing file picking and drag'n'drop
  72342. */
  72343. export class FilesInput {
  72344. /**
  72345. * List of files ready to be loaded
  72346. */
  72347. static get FilesToLoad(): {
  72348. [key: string]: File;
  72349. };
  72350. /**
  72351. * Callback called when a file is processed
  72352. */
  72353. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  72354. private _engine;
  72355. private _currentScene;
  72356. private _sceneLoadedCallback;
  72357. private _progressCallback;
  72358. private _additionalRenderLoopLogicCallback;
  72359. private _textureLoadingCallback;
  72360. private _startingProcessingFilesCallback;
  72361. private _onReloadCallback;
  72362. private _errorCallback;
  72363. private _elementToMonitor;
  72364. private _sceneFileToLoad;
  72365. private _filesToLoad;
  72366. /**
  72367. * Creates a new FilesInput
  72368. * @param engine defines the rendering engine
  72369. * @param scene defines the hosting scene
  72370. * @param sceneLoadedCallback callback called when scene is loaded
  72371. * @param progressCallback callback called to track progress
  72372. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72373. * @param textureLoadingCallback callback called when a texture is loading
  72374. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72375. * @param onReloadCallback callback called when a reload is requested
  72376. * @param errorCallback callback call if an error occurs
  72377. */
  72378. 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);
  72379. private _dragEnterHandler;
  72380. private _dragOverHandler;
  72381. private _dropHandler;
  72382. /**
  72383. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72384. * @param elementToMonitor defines the DOM element to track
  72385. */
  72386. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72387. /**
  72388. * Release all associated resources
  72389. */
  72390. dispose(): void;
  72391. private renderFunction;
  72392. private drag;
  72393. private drop;
  72394. private _traverseFolder;
  72395. private _processFiles;
  72396. /**
  72397. * Load files from a drop event
  72398. * @param event defines the drop event to use as source
  72399. */
  72400. loadFiles(event: any): void;
  72401. private _processReload;
  72402. /**
  72403. * Reload the current scene from the loaded files
  72404. */
  72405. reload(): void;
  72406. }
  72407. }
  72408. declare module "babylonjs/Misc/HighDynamicRange/index" {
  72409. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  72410. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  72411. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  72412. }
  72413. declare module "babylonjs/Misc/sceneOptimizer" {
  72414. import { Scene, IDisposable } from "babylonjs/scene";
  72415. import { Observable } from "babylonjs/Misc/observable";
  72416. /**
  72417. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72419. */
  72420. export class SceneOptimization {
  72421. /**
  72422. * Defines the priority of this optimization (0 by default which means first in the list)
  72423. */
  72424. priority: number;
  72425. /**
  72426. * Gets a string describing the action executed by the current optimization
  72427. * @returns description string
  72428. */
  72429. getDescription(): string;
  72430. /**
  72431. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72432. * @param scene defines the current scene where to apply this optimization
  72433. * @param optimizer defines the current optimizer
  72434. * @returns true if everything that can be done was applied
  72435. */
  72436. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72437. /**
  72438. * Creates the SceneOptimization object
  72439. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72440. * @param desc defines the description associated with the optimization
  72441. */
  72442. constructor(
  72443. /**
  72444. * Defines the priority of this optimization (0 by default which means first in the list)
  72445. */
  72446. priority?: number);
  72447. }
  72448. /**
  72449. * Defines an optimization used to reduce the size of render target textures
  72450. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72451. */
  72452. export class TextureOptimization extends SceneOptimization {
  72453. /**
  72454. * Defines the priority of this optimization (0 by default which means first in the list)
  72455. */
  72456. priority: number;
  72457. /**
  72458. * 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
  72459. */
  72460. maximumSize: number;
  72461. /**
  72462. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72463. */
  72464. step: number;
  72465. /**
  72466. * Gets a string describing the action executed by the current optimization
  72467. * @returns description string
  72468. */
  72469. getDescription(): string;
  72470. /**
  72471. * Creates the TextureOptimization object
  72472. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72473. * @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
  72474. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72475. */
  72476. constructor(
  72477. /**
  72478. * Defines the priority of this optimization (0 by default which means first in the list)
  72479. */
  72480. priority?: number,
  72481. /**
  72482. * 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
  72483. */
  72484. maximumSize?: number,
  72485. /**
  72486. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72487. */
  72488. step?: number);
  72489. /**
  72490. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72491. * @param scene defines the current scene where to apply this optimization
  72492. * @param optimizer defines the current optimizer
  72493. * @returns true if everything that can be done was applied
  72494. */
  72495. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72496. }
  72497. /**
  72498. * Defines an optimization used to increase or decrease the rendering resolution
  72499. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72500. */
  72501. export class HardwareScalingOptimization extends SceneOptimization {
  72502. /**
  72503. * Defines the priority of this optimization (0 by default which means first in the list)
  72504. */
  72505. priority: number;
  72506. /**
  72507. * Defines the maximum scale to use (2 by default)
  72508. */
  72509. maximumScale: number;
  72510. /**
  72511. * Defines the step to use between two passes (0.5 by default)
  72512. */
  72513. step: number;
  72514. private _currentScale;
  72515. private _directionOffset;
  72516. /**
  72517. * Gets a string describing the action executed by the current optimization
  72518. * @return description string
  72519. */
  72520. getDescription(): string;
  72521. /**
  72522. * Creates the HardwareScalingOptimization object
  72523. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72524. * @param maximumScale defines the maximum scale to use (2 by default)
  72525. * @param step defines the step to use between two passes (0.5 by default)
  72526. */
  72527. constructor(
  72528. /**
  72529. * Defines the priority of this optimization (0 by default which means first in the list)
  72530. */
  72531. priority?: number,
  72532. /**
  72533. * Defines the maximum scale to use (2 by default)
  72534. */
  72535. maximumScale?: number,
  72536. /**
  72537. * Defines the step to use between two passes (0.5 by default)
  72538. */
  72539. step?: number);
  72540. /**
  72541. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72542. * @param scene defines the current scene where to apply this optimization
  72543. * @param optimizer defines the current optimizer
  72544. * @returns true if everything that can be done was applied
  72545. */
  72546. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72547. }
  72548. /**
  72549. * Defines an optimization used to remove shadows
  72550. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72551. */
  72552. export class ShadowsOptimization extends SceneOptimization {
  72553. /**
  72554. * Gets a string describing the action executed by the current optimization
  72555. * @return description string
  72556. */
  72557. getDescription(): string;
  72558. /**
  72559. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72560. * @param scene defines the current scene where to apply this optimization
  72561. * @param optimizer defines the current optimizer
  72562. * @returns true if everything that can be done was applied
  72563. */
  72564. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72565. }
  72566. /**
  72567. * Defines an optimization used to turn post-processes off
  72568. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72569. */
  72570. export class PostProcessesOptimization extends SceneOptimization {
  72571. /**
  72572. * Gets a string describing the action executed by the current optimization
  72573. * @return description string
  72574. */
  72575. getDescription(): string;
  72576. /**
  72577. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72578. * @param scene defines the current scene where to apply this optimization
  72579. * @param optimizer defines the current optimizer
  72580. * @returns true if everything that can be done was applied
  72581. */
  72582. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72583. }
  72584. /**
  72585. * Defines an optimization used to turn lens flares off
  72586. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72587. */
  72588. export class LensFlaresOptimization extends SceneOptimization {
  72589. /**
  72590. * Gets a string describing the action executed by the current optimization
  72591. * @return description string
  72592. */
  72593. getDescription(): string;
  72594. /**
  72595. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72596. * @param scene defines the current scene where to apply this optimization
  72597. * @param optimizer defines the current optimizer
  72598. * @returns true if everything that can be done was applied
  72599. */
  72600. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72601. }
  72602. /**
  72603. * Defines an optimization based on user defined callback.
  72604. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72605. */
  72606. export class CustomOptimization extends SceneOptimization {
  72607. /**
  72608. * Callback called to apply the custom optimization.
  72609. */
  72610. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72611. /**
  72612. * Callback called to get custom description
  72613. */
  72614. onGetDescription: () => string;
  72615. /**
  72616. * Gets a string describing the action executed by the current optimization
  72617. * @returns description string
  72618. */
  72619. getDescription(): string;
  72620. /**
  72621. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72622. * @param scene defines the current scene where to apply this optimization
  72623. * @param optimizer defines the current optimizer
  72624. * @returns true if everything that can be done was applied
  72625. */
  72626. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72627. }
  72628. /**
  72629. * Defines an optimization used to turn particles off
  72630. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72631. */
  72632. export class ParticlesOptimization extends SceneOptimization {
  72633. /**
  72634. * Gets a string describing the action executed by the current optimization
  72635. * @return description string
  72636. */
  72637. getDescription(): string;
  72638. /**
  72639. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72640. * @param scene defines the current scene where to apply this optimization
  72641. * @param optimizer defines the current optimizer
  72642. * @returns true if everything that can be done was applied
  72643. */
  72644. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72645. }
  72646. /**
  72647. * Defines an optimization used to turn render targets off
  72648. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72649. */
  72650. export class RenderTargetsOptimization extends SceneOptimization {
  72651. /**
  72652. * Gets a string describing the action executed by the current optimization
  72653. * @return description string
  72654. */
  72655. getDescription(): string;
  72656. /**
  72657. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72658. * @param scene defines the current scene where to apply this optimization
  72659. * @param optimizer defines the current optimizer
  72660. * @returns true if everything that can be done was applied
  72661. */
  72662. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72663. }
  72664. /**
  72665. * Defines an optimization used to merge meshes with compatible materials
  72666. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72667. */
  72668. export class MergeMeshesOptimization extends SceneOptimization {
  72669. private static _UpdateSelectionTree;
  72670. /**
  72671. * Gets or sets a boolean which defines if optimization octree has to be updated
  72672. */
  72673. static get UpdateSelectionTree(): boolean;
  72674. /**
  72675. * Gets or sets a boolean which defines if optimization octree has to be updated
  72676. */
  72677. static set UpdateSelectionTree(value: boolean);
  72678. /**
  72679. * Gets a string describing the action executed by the current optimization
  72680. * @return description string
  72681. */
  72682. getDescription(): string;
  72683. private _canBeMerged;
  72684. /**
  72685. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72686. * @param scene defines the current scene where to apply this optimization
  72687. * @param optimizer defines the current optimizer
  72688. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72689. * @returns true if everything that can be done was applied
  72690. */
  72691. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72692. }
  72693. /**
  72694. * Defines a list of options used by SceneOptimizer
  72695. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72696. */
  72697. export class SceneOptimizerOptions {
  72698. /**
  72699. * Defines the target frame rate to reach (60 by default)
  72700. */
  72701. targetFrameRate: number;
  72702. /**
  72703. * Defines the interval between two checkes (2000ms by default)
  72704. */
  72705. trackerDuration: number;
  72706. /**
  72707. * Gets the list of optimizations to apply
  72708. */
  72709. optimizations: SceneOptimization[];
  72710. /**
  72711. * Creates a new list of options used by SceneOptimizer
  72712. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72713. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72714. */
  72715. constructor(
  72716. /**
  72717. * Defines the target frame rate to reach (60 by default)
  72718. */
  72719. targetFrameRate?: number,
  72720. /**
  72721. * Defines the interval between two checkes (2000ms by default)
  72722. */
  72723. trackerDuration?: number);
  72724. /**
  72725. * Add a new optimization
  72726. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72727. * @returns the current SceneOptimizerOptions
  72728. */
  72729. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72730. /**
  72731. * Add a new custom optimization
  72732. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72733. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72734. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72735. * @returns the current SceneOptimizerOptions
  72736. */
  72737. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72738. /**
  72739. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72740. * @param targetFrameRate defines the target frame rate (60 by default)
  72741. * @returns a SceneOptimizerOptions object
  72742. */
  72743. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72744. /**
  72745. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72746. * @param targetFrameRate defines the target frame rate (60 by default)
  72747. * @returns a SceneOptimizerOptions object
  72748. */
  72749. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72750. /**
  72751. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72752. * @param targetFrameRate defines the target frame rate (60 by default)
  72753. * @returns a SceneOptimizerOptions object
  72754. */
  72755. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72756. }
  72757. /**
  72758. * Class used to run optimizations in order to reach a target frame rate
  72759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72760. */
  72761. export class SceneOptimizer implements IDisposable {
  72762. private _isRunning;
  72763. private _options;
  72764. private _scene;
  72765. private _currentPriorityLevel;
  72766. private _targetFrameRate;
  72767. private _trackerDuration;
  72768. private _currentFrameRate;
  72769. private _sceneDisposeObserver;
  72770. private _improvementMode;
  72771. /**
  72772. * Defines an observable called when the optimizer reaches the target frame rate
  72773. */
  72774. onSuccessObservable: Observable<SceneOptimizer>;
  72775. /**
  72776. * Defines an observable called when the optimizer enables an optimization
  72777. */
  72778. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72779. /**
  72780. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72781. */
  72782. onFailureObservable: Observable<SceneOptimizer>;
  72783. /**
  72784. * Gets a boolean indicating if the optimizer is in improvement mode
  72785. */
  72786. get isInImprovementMode(): boolean;
  72787. /**
  72788. * Gets the current priority level (0 at start)
  72789. */
  72790. get currentPriorityLevel(): number;
  72791. /**
  72792. * Gets the current frame rate checked by the SceneOptimizer
  72793. */
  72794. get currentFrameRate(): number;
  72795. /**
  72796. * Gets or sets the current target frame rate (60 by default)
  72797. */
  72798. get targetFrameRate(): number;
  72799. /**
  72800. * Gets or sets the current target frame rate (60 by default)
  72801. */
  72802. set targetFrameRate(value: number);
  72803. /**
  72804. * Gets or sets the current interval between two checks (every 2000ms by default)
  72805. */
  72806. get trackerDuration(): number;
  72807. /**
  72808. * Gets or sets the current interval between two checks (every 2000ms by default)
  72809. */
  72810. set trackerDuration(value: number);
  72811. /**
  72812. * Gets the list of active optimizations
  72813. */
  72814. get optimizations(): SceneOptimization[];
  72815. /**
  72816. * Creates a new SceneOptimizer
  72817. * @param scene defines the scene to work on
  72818. * @param options defines the options to use with the SceneOptimizer
  72819. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72820. * @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)
  72821. */
  72822. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72823. /**
  72824. * Stops the current optimizer
  72825. */
  72826. stop(): void;
  72827. /**
  72828. * Reset the optimizer to initial step (current priority level = 0)
  72829. */
  72830. reset(): void;
  72831. /**
  72832. * Start the optimizer. By default it will try to reach a specific framerate
  72833. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72834. */
  72835. start(): void;
  72836. private _checkCurrentState;
  72837. /**
  72838. * Release all resources
  72839. */
  72840. dispose(): void;
  72841. /**
  72842. * Helper function to create a SceneOptimizer with one single line of code
  72843. * @param scene defines the scene to work on
  72844. * @param options defines the options to use with the SceneOptimizer
  72845. * @param onSuccess defines a callback to call on success
  72846. * @param onFailure defines a callback to call on failure
  72847. * @returns the new SceneOptimizer object
  72848. */
  72849. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72850. }
  72851. }
  72852. declare module "babylonjs/Misc/sceneSerializer" {
  72853. import { Scene } from "babylonjs/scene";
  72854. /**
  72855. * Class used to serialize a scene into a string
  72856. */
  72857. export class SceneSerializer {
  72858. /**
  72859. * Clear cache used by a previous serialization
  72860. */
  72861. static ClearCache(): void;
  72862. /**
  72863. * Serialize a scene into a JSON compatible object
  72864. * @param scene defines the scene to serialize
  72865. * @returns a JSON compatible object
  72866. */
  72867. static Serialize(scene: Scene): any;
  72868. /**
  72869. * Serialize a mesh into a JSON compatible object
  72870. * @param toSerialize defines the mesh to serialize
  72871. * @param withParents defines if parents must be serialized as well
  72872. * @param withChildren defines if children must be serialized as well
  72873. * @returns a JSON compatible object
  72874. */
  72875. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72876. }
  72877. }
  72878. declare module "babylonjs/Misc/textureTools" {
  72879. import { Texture } from "babylonjs/Materials/Textures/texture";
  72880. /**
  72881. * Class used to host texture specific utilities
  72882. */
  72883. export class TextureTools {
  72884. /**
  72885. * Uses the GPU to create a copy texture rescaled at a given size
  72886. * @param texture Texture to copy from
  72887. * @param width defines the desired width
  72888. * @param height defines the desired height
  72889. * @param useBilinearMode defines if bilinear mode has to be used
  72890. * @return the generated texture
  72891. */
  72892. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72893. }
  72894. }
  72895. declare module "babylonjs/Misc/videoRecorder" {
  72896. import { Nullable } from "babylonjs/types";
  72897. import { Engine } from "babylonjs/Engines/engine";
  72898. /**
  72899. * This represents the different options available for the video capture.
  72900. */
  72901. export interface VideoRecorderOptions {
  72902. /** Defines the mime type of the video. */
  72903. mimeType: string;
  72904. /** Defines the FPS the video should be recorded at. */
  72905. fps: number;
  72906. /** Defines the chunk size for the recording data. */
  72907. recordChunckSize: number;
  72908. /** The audio tracks to attach to the recording. */
  72909. audioTracks?: MediaStreamTrack[];
  72910. }
  72911. /**
  72912. * This can help with recording videos from BabylonJS.
  72913. * This is based on the available WebRTC functionalities of the browser.
  72914. *
  72915. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72916. */
  72917. export class VideoRecorder {
  72918. private static readonly _defaultOptions;
  72919. /**
  72920. * Returns whether or not the VideoRecorder is available in your browser.
  72921. * @param engine Defines the Babylon Engine.
  72922. * @returns true if supported otherwise false.
  72923. */
  72924. static IsSupported(engine: Engine): boolean;
  72925. private readonly _options;
  72926. private _canvas;
  72927. private _mediaRecorder;
  72928. private _recordedChunks;
  72929. private _fileName;
  72930. private _resolve;
  72931. private _reject;
  72932. /**
  72933. * True when a recording is already in progress.
  72934. */
  72935. get isRecording(): boolean;
  72936. /**
  72937. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72938. * @param engine Defines the BabylonJS Engine you wish to record.
  72939. * @param options Defines options that can be used to customize the capture.
  72940. */
  72941. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72942. /**
  72943. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72944. */
  72945. stopRecording(): void;
  72946. /**
  72947. * Starts recording the canvas for a max duration specified in parameters.
  72948. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72949. * If null no automatic download will start and you can rely on the promise to get the data back.
  72950. * @param maxDuration Defines the maximum recording time in seconds.
  72951. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72952. * @return A promise callback at the end of the recording with the video data in Blob.
  72953. */
  72954. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72955. /**
  72956. * Releases internal resources used during the recording.
  72957. */
  72958. dispose(): void;
  72959. private _handleDataAvailable;
  72960. private _handleError;
  72961. private _handleStop;
  72962. }
  72963. }
  72964. declare module "babylonjs/Misc/screenshotTools" {
  72965. import { Camera } from "babylonjs/Cameras/camera";
  72966. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72967. import { Engine } from "babylonjs/Engines/engine";
  72968. /**
  72969. * Class containing a set of static utilities functions for screenshots
  72970. */
  72971. export class ScreenshotTools {
  72972. /**
  72973. * Captures a screenshot of the current rendering
  72974. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72975. * @param engine defines the rendering engine
  72976. * @param camera defines the source camera
  72977. * @param size This parameter can be set to a single number or to an object with the
  72978. * following (optional) properties: precision, width, height. If a single number is passed,
  72979. * it will be used for both width and height. If an object is passed, the screenshot size
  72980. * will be derived from the parameters. The precision property is a multiplier allowing
  72981. * rendering at a higher or lower resolution
  72982. * @param successCallback defines the callback receives a single parameter which contains the
  72983. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72984. * src parameter of an <img> to display it
  72985. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72986. * Check your browser for supported MIME types
  72987. */
  72988. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72989. /**
  72990. * Captures a screenshot of the current rendering
  72991. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72992. * @param engine defines the rendering engine
  72993. * @param camera defines the source camera
  72994. * @param size This parameter can be set to a single number or to an object with the
  72995. * following (optional) properties: precision, width, height. If a single number is passed,
  72996. * it will be used for both width and height. If an object is passed, the screenshot size
  72997. * will be derived from the parameters. The precision property is a multiplier allowing
  72998. * rendering at a higher or lower resolution
  72999. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73000. * Check your browser for supported MIME types
  73001. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73002. * to the src parameter of an <img> to display it
  73003. */
  73004. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73005. /**
  73006. * Generates an image screenshot from the specified camera.
  73007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73008. * @param engine The engine to use for rendering
  73009. * @param camera The camera to use for rendering
  73010. * @param size This parameter can be set to a single number or to an object with the
  73011. * following (optional) properties: precision, width, height. If a single number is passed,
  73012. * it will be used for both width and height. If an object is passed, the screenshot size
  73013. * will be derived from the parameters. The precision property is a multiplier allowing
  73014. * rendering at a higher or lower resolution
  73015. * @param successCallback The callback receives a single parameter which contains the
  73016. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73017. * src parameter of an <img> to display it
  73018. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73019. * Check your browser for supported MIME types
  73020. * @param samples Texture samples (default: 1)
  73021. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73022. * @param fileName A name for for the downloaded file.
  73023. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73024. */
  73025. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73026. /**
  73027. * Generates an image screenshot from the specified camera.
  73028. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73029. * @param engine The engine to use for rendering
  73030. * @param camera The camera to use for rendering
  73031. * @param size This parameter can be set to a single number or to an object with the
  73032. * following (optional) properties: precision, width, height. If a single number is passed,
  73033. * it will be used for both width and height. If an object is passed, the screenshot size
  73034. * will be derived from the parameters. The precision property is a multiplier allowing
  73035. * rendering at a higher or lower resolution
  73036. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73037. * Check your browser for supported MIME types
  73038. * @param samples Texture samples (default: 1)
  73039. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73040. * @param fileName A name for for the downloaded file.
  73041. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73042. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73043. * to the src parameter of an <img> to display it
  73044. */
  73045. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73046. /**
  73047. * Gets height and width for screenshot size
  73048. * @private
  73049. */
  73050. private static _getScreenshotSize;
  73051. }
  73052. }
  73053. declare module "babylonjs/Misc/dataReader" {
  73054. /**
  73055. * Interface for a data buffer
  73056. */
  73057. export interface IDataBuffer {
  73058. /**
  73059. * Reads bytes from the data buffer.
  73060. * @param byteOffset The byte offset to read
  73061. * @param byteLength The byte length to read
  73062. * @returns A promise that resolves when the bytes are read
  73063. */
  73064. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73065. /**
  73066. * The byte length of the buffer.
  73067. */
  73068. readonly byteLength: number;
  73069. }
  73070. /**
  73071. * Utility class for reading from a data buffer
  73072. */
  73073. export class DataReader {
  73074. /**
  73075. * The data buffer associated with this data reader.
  73076. */
  73077. readonly buffer: IDataBuffer;
  73078. /**
  73079. * The current byte offset from the beginning of the data buffer.
  73080. */
  73081. byteOffset: number;
  73082. private _dataView;
  73083. private _dataByteOffset;
  73084. /**
  73085. * Constructor
  73086. * @param buffer The buffer to read
  73087. */
  73088. constructor(buffer: IDataBuffer);
  73089. /**
  73090. * Loads the given byte length.
  73091. * @param byteLength The byte length to load
  73092. * @returns A promise that resolves when the load is complete
  73093. */
  73094. loadAsync(byteLength: number): Promise<void>;
  73095. /**
  73096. * Read a unsigned 32-bit integer from the currently loaded data range.
  73097. * @returns The 32-bit integer read
  73098. */
  73099. readUint32(): number;
  73100. /**
  73101. * Read a byte array from the currently loaded data range.
  73102. * @param byteLength The byte length to read
  73103. * @returns The byte array read
  73104. */
  73105. readUint8Array(byteLength: number): Uint8Array;
  73106. /**
  73107. * Read a string from the currently loaded data range.
  73108. * @param byteLength The byte length to read
  73109. * @returns The string read
  73110. */
  73111. readString(byteLength: number): string;
  73112. /**
  73113. * Skips the given byte length the currently loaded data range.
  73114. * @param byteLength The byte length to skip
  73115. */
  73116. skipBytes(byteLength: number): void;
  73117. }
  73118. }
  73119. declare module "babylonjs/Misc/dataStorage" {
  73120. /**
  73121. * Class for storing data to local storage if available or in-memory storage otherwise
  73122. */
  73123. export class DataStorage {
  73124. private static _Storage;
  73125. private static _GetStorage;
  73126. /**
  73127. * Reads a string from the data storage
  73128. * @param key The key to read
  73129. * @param defaultValue The value if the key doesn't exist
  73130. * @returns The string value
  73131. */
  73132. static ReadString(key: string, defaultValue: string): string;
  73133. /**
  73134. * Writes a string to the data storage
  73135. * @param key The key to write
  73136. * @param value The value to write
  73137. */
  73138. static WriteString(key: string, value: string): void;
  73139. /**
  73140. * Reads a boolean from the data storage
  73141. * @param key The key to read
  73142. * @param defaultValue The value if the key doesn't exist
  73143. * @returns The boolean value
  73144. */
  73145. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73146. /**
  73147. * Writes a boolean to the data storage
  73148. * @param key The key to write
  73149. * @param value The value to write
  73150. */
  73151. static WriteBoolean(key: string, value: boolean): void;
  73152. /**
  73153. * Reads a number from the data storage
  73154. * @param key The key to read
  73155. * @param defaultValue The value if the key doesn't exist
  73156. * @returns The number value
  73157. */
  73158. static ReadNumber(key: string, defaultValue: number): number;
  73159. /**
  73160. * Writes a number to the data storage
  73161. * @param key The key to write
  73162. * @param value The value to write
  73163. */
  73164. static WriteNumber(key: string, value: number): void;
  73165. }
  73166. }
  73167. declare module "babylonjs/Misc/index" {
  73168. export * from "babylonjs/Misc/andOrNotEvaluator";
  73169. export * from "babylonjs/Misc/assetsManager";
  73170. export * from "babylonjs/Misc/basis";
  73171. export * from "babylonjs/Misc/dds";
  73172. export * from "babylonjs/Misc/decorators";
  73173. export * from "babylonjs/Misc/deferred";
  73174. export * from "babylonjs/Misc/environmentTextureTools";
  73175. export * from "babylonjs/Misc/meshExploder";
  73176. export * from "babylonjs/Misc/filesInput";
  73177. export * from "babylonjs/Misc/HighDynamicRange/index";
  73178. export * from "babylonjs/Misc/khronosTextureContainer";
  73179. export * from "babylonjs/Misc/observable";
  73180. export * from "babylonjs/Misc/performanceMonitor";
  73181. export * from "babylonjs/Misc/promise";
  73182. export * from "babylonjs/Misc/sceneOptimizer";
  73183. export * from "babylonjs/Misc/sceneSerializer";
  73184. export * from "babylonjs/Misc/smartArray";
  73185. export * from "babylonjs/Misc/stringDictionary";
  73186. export * from "babylonjs/Misc/tags";
  73187. export * from "babylonjs/Misc/textureTools";
  73188. export * from "babylonjs/Misc/tga";
  73189. export * from "babylonjs/Misc/tools";
  73190. export * from "babylonjs/Misc/videoRecorder";
  73191. export * from "babylonjs/Misc/virtualJoystick";
  73192. export * from "babylonjs/Misc/workerPool";
  73193. export * from "babylonjs/Misc/logger";
  73194. export * from "babylonjs/Misc/typeStore";
  73195. export * from "babylonjs/Misc/filesInputStore";
  73196. export * from "babylonjs/Misc/deepCopier";
  73197. export * from "babylonjs/Misc/pivotTools";
  73198. export * from "babylonjs/Misc/precisionDate";
  73199. export * from "babylonjs/Misc/screenshotTools";
  73200. export * from "babylonjs/Misc/typeStore";
  73201. export * from "babylonjs/Misc/webRequest";
  73202. export * from "babylonjs/Misc/iInspectable";
  73203. export * from "babylonjs/Misc/brdfTextureTools";
  73204. export * from "babylonjs/Misc/rgbdTextureTools";
  73205. export * from "babylonjs/Misc/gradients";
  73206. export * from "babylonjs/Misc/perfCounter";
  73207. export * from "babylonjs/Misc/fileRequest";
  73208. export * from "babylonjs/Misc/customAnimationFrameRequester";
  73209. export * from "babylonjs/Misc/retryStrategy";
  73210. export * from "babylonjs/Misc/interfaces/screenshotSize";
  73211. export * from "babylonjs/Misc/canvasGenerator";
  73212. export * from "babylonjs/Misc/fileTools";
  73213. export * from "babylonjs/Misc/stringTools";
  73214. export * from "babylonjs/Misc/dataReader";
  73215. export * from "babylonjs/Misc/minMaxReducer";
  73216. export * from "babylonjs/Misc/depthReducer";
  73217. export * from "babylonjs/Misc/dataStorage";
  73218. }
  73219. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  73220. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73221. import { Observable } from "babylonjs/Misc/observable";
  73222. import { Matrix } from "babylonjs/Maths/math.vector";
  73223. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73224. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73225. /**
  73226. * Options used for hit testing
  73227. */
  73228. export interface IWebXRLegacyHitTestOptions {
  73229. /**
  73230. * Only test when user interacted with the scene. Default - hit test every frame
  73231. */
  73232. testOnPointerDownOnly?: boolean;
  73233. /**
  73234. * The node to use to transform the local results to world coordinates
  73235. */
  73236. worldParentNode?: TransformNode;
  73237. }
  73238. /**
  73239. * Interface defining the babylon result of raycasting/hit-test
  73240. */
  73241. export interface IWebXRLegacyHitResult {
  73242. /**
  73243. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73244. */
  73245. transformationMatrix: Matrix;
  73246. /**
  73247. * The native hit test result
  73248. */
  73249. xrHitResult: XRHitResult | XRHitTestResult;
  73250. }
  73251. /**
  73252. * The currently-working hit-test module.
  73253. * Hit test (or Ray-casting) is used to interact with the real world.
  73254. * For further information read here - https://github.com/immersive-web/hit-test
  73255. */
  73256. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  73257. /**
  73258. * options to use when constructing this feature
  73259. */
  73260. readonly options: IWebXRLegacyHitTestOptions;
  73261. private _direction;
  73262. private _mat;
  73263. private _onSelectEnabled;
  73264. private _origin;
  73265. /**
  73266. * The module's name
  73267. */
  73268. static readonly Name: string;
  73269. /**
  73270. * The (Babylon) version of this module.
  73271. * This is an integer representing the implementation version.
  73272. * This number does not correspond to the WebXR specs version
  73273. */
  73274. static readonly Version: number;
  73275. /**
  73276. * Populated with the last native XR Hit Results
  73277. */
  73278. lastNativeXRHitResults: XRHitResult[];
  73279. /**
  73280. * Triggered when new babylon (transformed) hit test results are available
  73281. */
  73282. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73283. /**
  73284. * Creates a new instance of the (legacy version) hit test feature
  73285. * @param _xrSessionManager an instance of WebXRSessionManager
  73286. * @param options options to use when constructing this feature
  73287. */
  73288. constructor(_xrSessionManager: WebXRSessionManager,
  73289. /**
  73290. * options to use when constructing this feature
  73291. */
  73292. options?: IWebXRLegacyHitTestOptions);
  73293. /**
  73294. * execute a hit test with an XR Ray
  73295. *
  73296. * @param xrSession a native xrSession that will execute this hit test
  73297. * @param xrRay the ray (position and direction) to use for ray-casting
  73298. * @param referenceSpace native XR reference space to use for the hit-test
  73299. * @param filter filter function that will filter the results
  73300. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73301. */
  73302. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73303. /**
  73304. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73305. * @param event the (select) event to use to select with
  73306. * @param referenceSpace the reference space to use for this hit test
  73307. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73308. */
  73309. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73310. /**
  73311. * attach this feature
  73312. * Will usually be called by the features manager
  73313. *
  73314. * @returns true if successful.
  73315. */
  73316. attach(): boolean;
  73317. /**
  73318. * detach this feature.
  73319. * Will usually be called by the features manager
  73320. *
  73321. * @returns true if successful.
  73322. */
  73323. detach(): boolean;
  73324. /**
  73325. * Dispose this feature and all of the resources attached
  73326. */
  73327. dispose(): void;
  73328. protected _onXRFrame(frame: XRFrame): void;
  73329. private _onHitTestResults;
  73330. private _onSelect;
  73331. }
  73332. }
  73333. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  73334. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73335. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73336. import { Observable } from "babylonjs/Misc/observable";
  73337. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  73338. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73339. /**
  73340. * Options used in the plane detector module
  73341. */
  73342. export interface IWebXRPlaneDetectorOptions {
  73343. /**
  73344. * The node to use to transform the local results to world coordinates
  73345. */
  73346. worldParentNode?: TransformNode;
  73347. }
  73348. /**
  73349. * A babylon interface for a WebXR plane.
  73350. * A Plane is actually a polygon, built from N points in space
  73351. *
  73352. * Supported in chrome 79, not supported in canary 81 ATM
  73353. */
  73354. export interface IWebXRPlane {
  73355. /**
  73356. * a babylon-assigned ID for this polygon
  73357. */
  73358. id: number;
  73359. /**
  73360. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73361. */
  73362. polygonDefinition: Array<Vector3>;
  73363. /**
  73364. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73365. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73366. */
  73367. transformationMatrix: Matrix;
  73368. /**
  73369. * the native xr-plane object
  73370. */
  73371. xrPlane: XRPlane;
  73372. }
  73373. /**
  73374. * The plane detector is used to detect planes in the real world when in AR
  73375. * For more information see https://github.com/immersive-web/real-world-geometry/
  73376. */
  73377. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73378. private _options;
  73379. private _detectedPlanes;
  73380. private _enabled;
  73381. private _lastFrameDetected;
  73382. /**
  73383. * The module's name
  73384. */
  73385. static readonly Name: string;
  73386. /**
  73387. * The (Babylon) version of this module.
  73388. * This is an integer representing the implementation version.
  73389. * This number does not correspond to the WebXR specs version
  73390. */
  73391. static readonly Version: number;
  73392. /**
  73393. * Observers registered here will be executed when a new plane was added to the session
  73394. */
  73395. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73396. /**
  73397. * Observers registered here will be executed when a plane is no longer detected in the session
  73398. */
  73399. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73400. /**
  73401. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73402. * This can execute N times every frame
  73403. */
  73404. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73405. /**
  73406. * construct a new Plane Detector
  73407. * @param _xrSessionManager an instance of xr Session manager
  73408. * @param _options configuration to use when constructing this feature
  73409. */
  73410. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73411. /**
  73412. * Dispose this feature and all of the resources attached
  73413. */
  73414. dispose(): void;
  73415. protected _onXRFrame(frame: XRFrame): void;
  73416. private _init;
  73417. private _updatePlaneWithXRPlane;
  73418. /**
  73419. * avoiding using Array.find for global support.
  73420. * @param xrPlane the plane to find in the array
  73421. */
  73422. private findIndexInPlaneArray;
  73423. }
  73424. }
  73425. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  73426. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73427. import { Observable } from "babylonjs/Misc/observable";
  73428. import { Matrix } from "babylonjs/Maths/math.vector";
  73429. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73430. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  73431. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73432. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73433. /**
  73434. * Configuration options of the anchor system
  73435. */
  73436. export interface IWebXRAnchorSystemOptions {
  73437. /**
  73438. * Should a new anchor be added every time a select event is triggered
  73439. */
  73440. addAnchorOnSelect?: boolean;
  73441. /**
  73442. * should the anchor system use plane detection.
  73443. * If set to true, the plane-detection feature should be set using setPlaneDetector
  73444. */
  73445. usePlaneDetection?: boolean;
  73446. /**
  73447. * a node that will be used to convert local to world coordinates
  73448. */
  73449. worldParentNode?: TransformNode;
  73450. }
  73451. /**
  73452. * A babylon container for an XR Anchor
  73453. */
  73454. export interface IWebXRAnchor {
  73455. /**
  73456. * A babylon-assigned ID for this anchor
  73457. */
  73458. id: number;
  73459. /**
  73460. * Transformation matrix to apply to an object attached to this anchor
  73461. */
  73462. transformationMatrix: Matrix;
  73463. /**
  73464. * The native anchor object
  73465. */
  73466. xrAnchor: XRAnchor;
  73467. }
  73468. /**
  73469. * An implementation of the anchor system of WebXR.
  73470. * Note that the current documented implementation is not available in any browser. Future implementations
  73471. * will use the frame to create an anchor and not the session or a detected plane
  73472. * For further information see https://github.com/immersive-web/anchors/
  73473. */
  73474. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73475. private _options;
  73476. private _enabled;
  73477. private _hitTestModule;
  73478. private _lastFrameDetected;
  73479. private _onSelect;
  73480. private _planeDetector;
  73481. private _trackedAnchors;
  73482. /**
  73483. * The module's name
  73484. */
  73485. static readonly Name: string;
  73486. /**
  73487. * The (Babylon) version of this module.
  73488. * This is an integer representing the implementation version.
  73489. * This number does not correspond to the WebXR specs version
  73490. */
  73491. static readonly Version: number;
  73492. /**
  73493. * Observers registered here will be executed when a new anchor was added to the session
  73494. */
  73495. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73496. /**
  73497. * Observers registered here will be executed when an anchor was removed from the session
  73498. */
  73499. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73500. /**
  73501. * Observers registered here will be executed when an existing anchor updates
  73502. * This can execute N times every frame
  73503. */
  73504. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73505. /**
  73506. * constructs a new anchor system
  73507. * @param _xrSessionManager an instance of WebXRSessionManager
  73508. * @param _options configuration object for this feature
  73509. */
  73510. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73511. /**
  73512. * Add anchor at a specific XR point.
  73513. *
  73514. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73515. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73516. * @returns a promise the fulfills when the anchor was created
  73517. */
  73518. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73519. /**
  73520. * attach this feature
  73521. * Will usually be called by the features manager
  73522. *
  73523. * @returns true if successful.
  73524. */
  73525. attach(): boolean;
  73526. /**
  73527. * detach this feature.
  73528. * Will usually be called by the features manager
  73529. *
  73530. * @returns true if successful.
  73531. */
  73532. detach(): boolean;
  73533. /**
  73534. * Dispose this feature and all of the resources attached
  73535. */
  73536. dispose(): void;
  73537. /**
  73538. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73539. * @param hitTestModule the hit-test module to use.
  73540. */
  73541. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73542. /**
  73543. * set the plane detector to use in order to create anchors from frames
  73544. * @param planeDetector the plane-detector module to use
  73545. * @param enable enable plane-anchors. default is true
  73546. */
  73547. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73548. protected _onXRFrame(frame: XRFrame): void;
  73549. /**
  73550. * avoiding using Array.find for global support.
  73551. * @param xrAnchor the plane to find in the array
  73552. */
  73553. private _findIndexInAnchorArray;
  73554. private _updateAnchorWithXRFrame;
  73555. }
  73556. }
  73557. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73558. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73560. import { Observable } from "babylonjs/Misc/observable";
  73561. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73562. /**
  73563. * Options interface for the background remover plugin
  73564. */
  73565. export interface IWebXRBackgroundRemoverOptions {
  73566. /**
  73567. * Further background meshes to disable when entering AR
  73568. */
  73569. backgroundMeshes?: AbstractMesh[];
  73570. /**
  73571. * flags to configure the removal of the environment helper.
  73572. * If not set, the entire background will be removed. If set, flags should be set as well.
  73573. */
  73574. environmentHelperRemovalFlags?: {
  73575. /**
  73576. * Should the skybox be removed (default false)
  73577. */
  73578. skyBox?: boolean;
  73579. /**
  73580. * Should the ground be removed (default false)
  73581. */
  73582. ground?: boolean;
  73583. };
  73584. /**
  73585. * don't disable the environment helper
  73586. */
  73587. ignoreEnvironmentHelper?: boolean;
  73588. }
  73589. /**
  73590. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73591. */
  73592. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73593. /**
  73594. * read-only options to be used in this module
  73595. */
  73596. readonly options: IWebXRBackgroundRemoverOptions;
  73597. /**
  73598. * The module's name
  73599. */
  73600. static readonly Name: string;
  73601. /**
  73602. * The (Babylon) version of this module.
  73603. * This is an integer representing the implementation version.
  73604. * This number does not correspond to the WebXR specs version
  73605. */
  73606. static readonly Version: number;
  73607. /**
  73608. * registered observers will be triggered when the background state changes
  73609. */
  73610. onBackgroundStateChangedObservable: Observable<boolean>;
  73611. /**
  73612. * constructs a new background remover module
  73613. * @param _xrSessionManager the session manager for this module
  73614. * @param options read-only options to be used in this module
  73615. */
  73616. constructor(_xrSessionManager: WebXRSessionManager,
  73617. /**
  73618. * read-only options to be used in this module
  73619. */
  73620. options?: IWebXRBackgroundRemoverOptions);
  73621. /**
  73622. * attach this feature
  73623. * Will usually be called by the features manager
  73624. *
  73625. * @returns true if successful.
  73626. */
  73627. attach(): boolean;
  73628. /**
  73629. * detach this feature.
  73630. * Will usually be called by the features manager
  73631. *
  73632. * @returns true if successful.
  73633. */
  73634. detach(): boolean;
  73635. /**
  73636. * Dispose this feature and all of the resources attached
  73637. */
  73638. dispose(): void;
  73639. protected _onXRFrame(_xrFrame: XRFrame): void;
  73640. private _setBackgroundState;
  73641. }
  73642. }
  73643. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73644. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73645. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73646. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73647. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73648. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73649. import { Nullable } from "babylonjs/types";
  73650. /**
  73651. * Options for the controller physics feature
  73652. */
  73653. export class IWebXRControllerPhysicsOptions {
  73654. /**
  73655. * Should the headset get its own impostor
  73656. */
  73657. enableHeadsetImpostor?: boolean;
  73658. /**
  73659. * Optional parameters for the headset impostor
  73660. */
  73661. headsetImpostorParams?: {
  73662. /**
  73663. * The type of impostor to create. Default is sphere
  73664. */
  73665. impostorType: number;
  73666. /**
  73667. * the size of the impostor. Defaults to 10cm
  73668. */
  73669. impostorSize?: number | {
  73670. width: number;
  73671. height: number;
  73672. depth: number;
  73673. };
  73674. /**
  73675. * Friction definitions
  73676. */
  73677. friction?: number;
  73678. /**
  73679. * Restitution
  73680. */
  73681. restitution?: number;
  73682. };
  73683. /**
  73684. * The physics properties of the future impostors
  73685. */
  73686. physicsProperties?: {
  73687. /**
  73688. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73689. * Note that this requires a physics engine that supports mesh impostors!
  73690. */
  73691. useControllerMesh?: boolean;
  73692. /**
  73693. * The type of impostor to create. Default is sphere
  73694. */
  73695. impostorType?: number;
  73696. /**
  73697. * the size of the impostor. Defaults to 10cm
  73698. */
  73699. impostorSize?: number | {
  73700. width: number;
  73701. height: number;
  73702. depth: number;
  73703. };
  73704. /**
  73705. * Friction definitions
  73706. */
  73707. friction?: number;
  73708. /**
  73709. * Restitution
  73710. */
  73711. restitution?: number;
  73712. };
  73713. /**
  73714. * the xr input to use with this pointer selection
  73715. */
  73716. xrInput: WebXRInput;
  73717. }
  73718. /**
  73719. * Add physics impostor to your webxr controllers,
  73720. * including naive calculation of their linear and angular velocity
  73721. */
  73722. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73723. private readonly _options;
  73724. private _attachController;
  73725. private _controllers;
  73726. private _debugMode;
  73727. private _delta;
  73728. private _headsetImpostor?;
  73729. private _headsetMesh?;
  73730. private _lastTimestamp;
  73731. private _tmpQuaternion;
  73732. private _tmpVector;
  73733. /**
  73734. * The module's name
  73735. */
  73736. static readonly Name: string;
  73737. /**
  73738. * The (Babylon) version of this module.
  73739. * This is an integer representing the implementation version.
  73740. * This number does not correspond to the webxr specs version
  73741. */
  73742. static readonly Version: number;
  73743. /**
  73744. * Construct a new Controller Physics Feature
  73745. * @param _xrSessionManager the corresponding xr session manager
  73746. * @param _options options to create this feature with
  73747. */
  73748. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73749. /**
  73750. * @hidden
  73751. * enable debugging - will show console outputs and the impostor mesh
  73752. */
  73753. _enablePhysicsDebug(): void;
  73754. /**
  73755. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73756. * @param xrController the controller to add
  73757. */
  73758. addController(xrController: WebXRInputSource): void;
  73759. /**
  73760. * attach this feature
  73761. * Will usually be called by the features manager
  73762. *
  73763. * @returns true if successful.
  73764. */
  73765. attach(): boolean;
  73766. /**
  73767. * detach this feature.
  73768. * Will usually be called by the features manager
  73769. *
  73770. * @returns true if successful.
  73771. */
  73772. detach(): boolean;
  73773. /**
  73774. * Get the headset impostor, if enabled
  73775. * @returns the impostor
  73776. */
  73777. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73778. /**
  73779. * Get the physics impostor of a specific controller.
  73780. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73781. * @param controller the controller or the controller id of which to get the impostor
  73782. * @returns the impostor or null
  73783. */
  73784. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73785. /**
  73786. * Update the physics properties provided in the constructor
  73787. * @param newProperties the new properties object
  73788. */
  73789. setPhysicsProperties(newProperties: {
  73790. impostorType?: number;
  73791. impostorSize?: number | {
  73792. width: number;
  73793. height: number;
  73794. depth: number;
  73795. };
  73796. friction?: number;
  73797. restitution?: number;
  73798. }): void;
  73799. protected _onXRFrame(_xrFrame: any): void;
  73800. private _detachController;
  73801. }
  73802. }
  73803. declare module "babylonjs/XR/features/WebXRHitTest" {
  73804. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73805. import { Observable } from "babylonjs/Misc/observable";
  73806. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  73807. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73808. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73809. /**
  73810. * Options used for hit testing (version 2)
  73811. */
  73812. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73813. /**
  73814. * Do not create a permanent hit test. Will usually be used when only
  73815. * transient inputs are needed.
  73816. */
  73817. disablePermanentHitTest?: boolean;
  73818. /**
  73819. * Enable transient (for example touch-based) hit test inspections
  73820. */
  73821. enableTransientHitTest?: boolean;
  73822. /**
  73823. * Offset ray for the permanent hit test
  73824. */
  73825. offsetRay?: Vector3;
  73826. /**
  73827. * Offset ray for the transient hit test
  73828. */
  73829. transientOffsetRay?: Vector3;
  73830. /**
  73831. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73832. */
  73833. useReferenceSpace?: boolean;
  73834. }
  73835. /**
  73836. * Interface defining the babylon result of hit-test
  73837. */
  73838. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73839. /**
  73840. * The input source that generated this hit test (if transient)
  73841. */
  73842. inputSource?: XRInputSource;
  73843. /**
  73844. * Is this a transient hit test
  73845. */
  73846. isTransient?: boolean;
  73847. /**
  73848. * Position of the hit test result
  73849. */
  73850. position: Vector3;
  73851. /**
  73852. * Rotation of the hit test result
  73853. */
  73854. rotationQuaternion: Quaternion;
  73855. }
  73856. /**
  73857. * The currently-working hit-test module.
  73858. * Hit test (or Ray-casting) is used to interact with the real world.
  73859. * For further information read here - https://github.com/immersive-web/hit-test
  73860. *
  73861. * Tested on chrome (mobile) 80.
  73862. */
  73863. export class WebXRHitTest extends WebXRAbstractFeature {
  73864. /**
  73865. * options to use when constructing this feature
  73866. */
  73867. readonly options: IWebXRHitTestOptions;
  73868. private _tmpMat;
  73869. private _tmpPos;
  73870. private _tmpQuat;
  73871. private _transientXrHitTestSource;
  73872. private _xrHitTestSource;
  73873. private initHitTestSource;
  73874. /**
  73875. * The module's name
  73876. */
  73877. static readonly Name: string;
  73878. /**
  73879. * The (Babylon) version of this module.
  73880. * This is an integer representing the implementation version.
  73881. * This number does not correspond to the WebXR specs version
  73882. */
  73883. static readonly Version: number;
  73884. /**
  73885. * When set to true, each hit test will have its own position/rotation objects
  73886. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73887. * the developers will clone them or copy them as they see fit.
  73888. */
  73889. autoCloneTransformation: boolean;
  73890. /**
  73891. * Populated with the last native XR Hit Results
  73892. */
  73893. lastNativeXRHitResults: XRHitResult[];
  73894. /**
  73895. * Triggered when new babylon (transformed) hit test results are available
  73896. */
  73897. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73898. /**
  73899. * Use this to temporarily pause hit test checks.
  73900. */
  73901. paused: boolean;
  73902. /**
  73903. * Creates a new instance of the hit test feature
  73904. * @param _xrSessionManager an instance of WebXRSessionManager
  73905. * @param options options to use when constructing this feature
  73906. */
  73907. constructor(_xrSessionManager: WebXRSessionManager,
  73908. /**
  73909. * options to use when constructing this feature
  73910. */
  73911. options?: IWebXRHitTestOptions);
  73912. /**
  73913. * attach this feature
  73914. * Will usually be called by the features manager
  73915. *
  73916. * @returns true if successful.
  73917. */
  73918. attach(): boolean;
  73919. /**
  73920. * detach this feature.
  73921. * Will usually be called by the features manager
  73922. *
  73923. * @returns true if successful.
  73924. */
  73925. detach(): boolean;
  73926. /**
  73927. * Dispose this feature and all of the resources attached
  73928. */
  73929. dispose(): void;
  73930. protected _onXRFrame(frame: XRFrame): void;
  73931. private _processWebXRHitTestResult;
  73932. }
  73933. }
  73934. declare module "babylonjs/XR/features/index" {
  73935. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73936. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73937. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73938. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73939. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73940. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73941. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73942. export * from "babylonjs/XR/features/WebXRHitTest";
  73943. }
  73944. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73945. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73947. import { Scene } from "babylonjs/scene";
  73948. /**
  73949. * The motion controller class for all microsoft mixed reality controllers
  73950. */
  73951. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73952. protected readonly _mapping: {
  73953. defaultButton: {
  73954. valueNodeName: string;
  73955. unpressedNodeName: string;
  73956. pressedNodeName: string;
  73957. };
  73958. defaultAxis: {
  73959. valueNodeName: string;
  73960. minNodeName: string;
  73961. maxNodeName: string;
  73962. };
  73963. buttons: {
  73964. "xr-standard-trigger": {
  73965. rootNodeName: string;
  73966. componentProperty: string;
  73967. states: string[];
  73968. };
  73969. "xr-standard-squeeze": {
  73970. rootNodeName: string;
  73971. componentProperty: string;
  73972. states: string[];
  73973. };
  73974. "xr-standard-touchpad": {
  73975. rootNodeName: string;
  73976. labelAnchorNodeName: string;
  73977. touchPointNodeName: string;
  73978. };
  73979. "xr-standard-thumbstick": {
  73980. rootNodeName: string;
  73981. componentProperty: string;
  73982. states: string[];
  73983. };
  73984. };
  73985. axes: {
  73986. "xr-standard-touchpad": {
  73987. "x-axis": {
  73988. rootNodeName: string;
  73989. };
  73990. "y-axis": {
  73991. rootNodeName: string;
  73992. };
  73993. };
  73994. "xr-standard-thumbstick": {
  73995. "x-axis": {
  73996. rootNodeName: string;
  73997. };
  73998. "y-axis": {
  73999. rootNodeName: string;
  74000. };
  74001. };
  74002. };
  74003. };
  74004. /**
  74005. * The base url used to load the left and right controller models
  74006. */
  74007. static MODEL_BASE_URL: string;
  74008. /**
  74009. * The name of the left controller model file
  74010. */
  74011. static MODEL_LEFT_FILENAME: string;
  74012. /**
  74013. * The name of the right controller model file
  74014. */
  74015. static MODEL_RIGHT_FILENAME: string;
  74016. profileId: string;
  74017. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74018. protected _getFilenameAndPath(): {
  74019. filename: string;
  74020. path: string;
  74021. };
  74022. protected _getModelLoadingConstraints(): boolean;
  74023. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74024. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74025. protected _updateModel(): void;
  74026. }
  74027. }
  74028. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  74029. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74031. import { Scene } from "babylonjs/scene";
  74032. /**
  74033. * The motion controller class for oculus touch (quest, rift).
  74034. * This class supports legacy mapping as well the standard xr mapping
  74035. */
  74036. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74037. private _forceLegacyControllers;
  74038. private _modelRootNode;
  74039. /**
  74040. * The base url used to load the left and right controller models
  74041. */
  74042. static MODEL_BASE_URL: string;
  74043. /**
  74044. * The name of the left controller model file
  74045. */
  74046. static MODEL_LEFT_FILENAME: string;
  74047. /**
  74048. * The name of the right controller model file
  74049. */
  74050. static MODEL_RIGHT_FILENAME: string;
  74051. /**
  74052. * Base Url for the Quest controller model.
  74053. */
  74054. static QUEST_MODEL_BASE_URL: string;
  74055. profileId: string;
  74056. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74057. protected _getFilenameAndPath(): {
  74058. filename: string;
  74059. path: string;
  74060. };
  74061. protected _getModelLoadingConstraints(): boolean;
  74062. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74063. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74064. protected _updateModel(): void;
  74065. /**
  74066. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74067. * between the touch and touch 2.
  74068. */
  74069. private _isQuest;
  74070. }
  74071. }
  74072. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  74073. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74074. import { Scene } from "babylonjs/scene";
  74075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74076. /**
  74077. * The motion controller class for the standard HTC-Vive controllers
  74078. */
  74079. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74080. private _modelRootNode;
  74081. /**
  74082. * The base url used to load the left and right controller models
  74083. */
  74084. static MODEL_BASE_URL: string;
  74085. /**
  74086. * File name for the controller model.
  74087. */
  74088. static MODEL_FILENAME: string;
  74089. profileId: string;
  74090. /**
  74091. * Create a new Vive motion controller object
  74092. * @param scene the scene to use to create this controller
  74093. * @param gamepadObject the corresponding gamepad object
  74094. * @param handness the handness of the controller
  74095. */
  74096. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74097. protected _getFilenameAndPath(): {
  74098. filename: string;
  74099. path: string;
  74100. };
  74101. protected _getModelLoadingConstraints(): boolean;
  74102. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74103. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74104. protected _updateModel(): void;
  74105. }
  74106. }
  74107. declare module "babylonjs/XR/motionController/index" {
  74108. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74109. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  74110. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  74111. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  74112. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  74113. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  74114. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  74115. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  74116. }
  74117. declare module "babylonjs/XR/index" {
  74118. export * from "babylonjs/XR/webXRCamera";
  74119. export * from "babylonjs/XR/webXREnterExitUI";
  74120. export * from "babylonjs/XR/webXRExperienceHelper";
  74121. export * from "babylonjs/XR/webXRInput";
  74122. export * from "babylonjs/XR/webXRInputSource";
  74123. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  74124. export * from "babylonjs/XR/webXRTypes";
  74125. export * from "babylonjs/XR/webXRSessionManager";
  74126. export * from "babylonjs/XR/webXRDefaultExperience";
  74127. export * from "babylonjs/XR/webXRFeaturesManager";
  74128. export * from "babylonjs/XR/features/index";
  74129. export * from "babylonjs/XR/motionController/index";
  74130. }
  74131. declare module "babylonjs/index" {
  74132. export * from "babylonjs/abstractScene";
  74133. export * from "babylonjs/Actions/index";
  74134. export * from "babylonjs/Animations/index";
  74135. export * from "babylonjs/assetContainer";
  74136. export * from "babylonjs/Audio/index";
  74137. export * from "babylonjs/Behaviors/index";
  74138. export * from "babylonjs/Bones/index";
  74139. export * from "babylonjs/Cameras/index";
  74140. export * from "babylonjs/Collisions/index";
  74141. export * from "babylonjs/Culling/index";
  74142. export * from "babylonjs/Debug/index";
  74143. export * from "babylonjs/Engines/index";
  74144. export * from "babylonjs/Events/index";
  74145. export * from "babylonjs/Gamepads/index";
  74146. export * from "babylonjs/Gizmos/index";
  74147. export * from "babylonjs/Helpers/index";
  74148. export * from "babylonjs/Instrumentation/index";
  74149. export * from "babylonjs/Layers/index";
  74150. export * from "babylonjs/LensFlares/index";
  74151. export * from "babylonjs/Lights/index";
  74152. export * from "babylonjs/Loading/index";
  74153. export * from "babylonjs/Materials/index";
  74154. export * from "babylonjs/Maths/index";
  74155. export * from "babylonjs/Meshes/index";
  74156. export * from "babylonjs/Morph/index";
  74157. export * from "babylonjs/Navigation/index";
  74158. export * from "babylonjs/node";
  74159. export * from "babylonjs/Offline/index";
  74160. export * from "babylonjs/Particles/index";
  74161. export * from "babylonjs/Physics/index";
  74162. export * from "babylonjs/PostProcesses/index";
  74163. export * from "babylonjs/Probes/index";
  74164. export * from "babylonjs/Rendering/index";
  74165. export * from "babylonjs/scene";
  74166. export * from "babylonjs/sceneComponent";
  74167. export * from "babylonjs/Sprites/index";
  74168. export * from "babylonjs/States/index";
  74169. export * from "babylonjs/Misc/index";
  74170. export * from "babylonjs/XR/index";
  74171. export * from "babylonjs/types";
  74172. }
  74173. declare module "babylonjs/Animations/pathCursor" {
  74174. import { Vector3 } from "babylonjs/Maths/math.vector";
  74175. import { Path2 } from "babylonjs/Maths/math.path";
  74176. /**
  74177. * A cursor which tracks a point on a path
  74178. */
  74179. export class PathCursor {
  74180. private path;
  74181. /**
  74182. * Stores path cursor callbacks for when an onchange event is triggered
  74183. */
  74184. private _onchange;
  74185. /**
  74186. * The value of the path cursor
  74187. */
  74188. value: number;
  74189. /**
  74190. * The animation array of the path cursor
  74191. */
  74192. animations: Animation[];
  74193. /**
  74194. * Initializes the path cursor
  74195. * @param path The path to track
  74196. */
  74197. constructor(path: Path2);
  74198. /**
  74199. * Gets the cursor point on the path
  74200. * @returns A point on the path cursor at the cursor location
  74201. */
  74202. getPoint(): Vector3;
  74203. /**
  74204. * Moves the cursor ahead by the step amount
  74205. * @param step The amount to move the cursor forward
  74206. * @returns This path cursor
  74207. */
  74208. moveAhead(step?: number): PathCursor;
  74209. /**
  74210. * Moves the cursor behind by the step amount
  74211. * @param step The amount to move the cursor back
  74212. * @returns This path cursor
  74213. */
  74214. moveBack(step?: number): PathCursor;
  74215. /**
  74216. * Moves the cursor by the step amount
  74217. * If the step amount is greater than one, an exception is thrown
  74218. * @param step The amount to move the cursor
  74219. * @returns This path cursor
  74220. */
  74221. move(step: number): PathCursor;
  74222. /**
  74223. * Ensures that the value is limited between zero and one
  74224. * @returns This path cursor
  74225. */
  74226. private ensureLimits;
  74227. /**
  74228. * Runs onchange callbacks on change (used by the animation engine)
  74229. * @returns This path cursor
  74230. */
  74231. private raiseOnChange;
  74232. /**
  74233. * Executes a function on change
  74234. * @param f A path cursor onchange callback
  74235. * @returns This path cursor
  74236. */
  74237. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74238. }
  74239. }
  74240. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  74241. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  74242. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  74243. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  74244. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  74245. }
  74246. declare module "babylonjs/Engines/Processors/Expressions/index" {
  74247. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  74248. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  74249. }
  74250. declare module "babylonjs/Engines/Processors/index" {
  74251. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  74252. export * from "babylonjs/Engines/Processors/Expressions/index";
  74253. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  74254. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  74255. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  74256. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  74257. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  74258. export * from "babylonjs/Engines/Processors/shaderProcessor";
  74259. }
  74260. declare module "babylonjs/Legacy/legacy" {
  74261. import * as Babylon from "babylonjs/index";
  74262. export * from "babylonjs/index";
  74263. }
  74264. declare module "babylonjs/Shaders/blur.fragment" {
  74265. /** @hidden */
  74266. export var blurPixelShader: {
  74267. name: string;
  74268. shader: string;
  74269. };
  74270. }
  74271. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  74272. /** @hidden */
  74273. export var pointCloudVertexDeclaration: {
  74274. name: string;
  74275. shader: string;
  74276. };
  74277. }
  74278. declare module "babylonjs" {
  74279. export * from "babylonjs/Legacy/legacy";
  74280. }
  74281. declare module BABYLON {
  74282. /** Alias type for value that can be null */
  74283. export type Nullable<T> = T | null;
  74284. /**
  74285. * Alias type for number that are floats
  74286. * @ignorenaming
  74287. */
  74288. export type float = number;
  74289. /**
  74290. * Alias type for number that are doubles.
  74291. * @ignorenaming
  74292. */
  74293. export type double = number;
  74294. /**
  74295. * Alias type for number that are integer
  74296. * @ignorenaming
  74297. */
  74298. export type int = number;
  74299. /** Alias type for number array or Float32Array */
  74300. export type FloatArray = number[] | Float32Array;
  74301. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  74302. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  74303. /**
  74304. * Alias for types that can be used by a Buffer or VertexBuffer.
  74305. */
  74306. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  74307. /**
  74308. * Alias type for primitive types
  74309. * @ignorenaming
  74310. */
  74311. type Primitive = undefined | null | boolean | string | number | Function;
  74312. /**
  74313. * Type modifier to make all the properties of an object Readonly
  74314. */
  74315. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  74316. /**
  74317. * Type modifier to make all the properties of an object Readonly recursively
  74318. */
  74319. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  74320. /**
  74321. * Type modifier to make object properties readonly.
  74322. */
  74323. export type DeepImmutableObject<T> = {
  74324. readonly [K in keyof T]: DeepImmutable<T[K]>;
  74325. };
  74326. /** @hidden */
  74327. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  74328. }
  74329. }
  74330. declare module BABYLON {
  74331. /**
  74332. * A class serves as a medium between the observable and its observers
  74333. */
  74334. export class EventState {
  74335. /**
  74336. * Create a new EventState
  74337. * @param mask defines the mask associated with this state
  74338. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74339. * @param target defines the original target of the state
  74340. * @param currentTarget defines the current target of the state
  74341. */
  74342. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  74343. /**
  74344. * Initialize the current event state
  74345. * @param mask defines the mask associated with this state
  74346. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74347. * @param target defines the original target of the state
  74348. * @param currentTarget defines the current target of the state
  74349. * @returns the current event state
  74350. */
  74351. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  74352. /**
  74353. * An Observer can set this property to true to prevent subsequent observers of being notified
  74354. */
  74355. skipNextObservers: boolean;
  74356. /**
  74357. * Get the mask value that were used to trigger the event corresponding to this EventState object
  74358. */
  74359. mask: number;
  74360. /**
  74361. * The object that originally notified the event
  74362. */
  74363. target?: any;
  74364. /**
  74365. * The current object in the bubbling phase
  74366. */
  74367. currentTarget?: any;
  74368. /**
  74369. * This will be populated with the return value of the last function that was executed.
  74370. * If it is the first function in the callback chain it will be the event data.
  74371. */
  74372. lastReturnValue?: any;
  74373. }
  74374. /**
  74375. * Represent an Observer registered to a given Observable object.
  74376. */
  74377. export class Observer<T> {
  74378. /**
  74379. * Defines the callback to call when the observer is notified
  74380. */
  74381. callback: (eventData: T, eventState: EventState) => void;
  74382. /**
  74383. * Defines the mask of the observer (used to filter notifications)
  74384. */
  74385. mask: number;
  74386. /**
  74387. * Defines the current scope used to restore the JS context
  74388. */
  74389. scope: any;
  74390. /** @hidden */
  74391. _willBeUnregistered: boolean;
  74392. /**
  74393. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  74394. */
  74395. unregisterOnNextCall: boolean;
  74396. /**
  74397. * Creates a new observer
  74398. * @param callback defines the callback to call when the observer is notified
  74399. * @param mask defines the mask of the observer (used to filter notifications)
  74400. * @param scope defines the current scope used to restore the JS context
  74401. */
  74402. constructor(
  74403. /**
  74404. * Defines the callback to call when the observer is notified
  74405. */
  74406. callback: (eventData: T, eventState: EventState) => void,
  74407. /**
  74408. * Defines the mask of the observer (used to filter notifications)
  74409. */
  74410. mask: number,
  74411. /**
  74412. * Defines the current scope used to restore the JS context
  74413. */
  74414. scope?: any);
  74415. }
  74416. /**
  74417. * Represent a list of observers registered to multiple Observables object.
  74418. */
  74419. export class MultiObserver<T> {
  74420. private _observers;
  74421. private _observables;
  74422. /**
  74423. * Release associated resources
  74424. */
  74425. dispose(): void;
  74426. /**
  74427. * Raise a callback when one of the observable will notify
  74428. * @param observables defines a list of observables to watch
  74429. * @param callback defines the callback to call on notification
  74430. * @param mask defines the mask used to filter notifications
  74431. * @param scope defines the current scope used to restore the JS context
  74432. * @returns the new MultiObserver
  74433. */
  74434. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  74435. }
  74436. /**
  74437. * The Observable class is a simple implementation of the Observable pattern.
  74438. *
  74439. * 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.
  74440. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  74441. * 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).
  74442. * 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.
  74443. */
  74444. export class Observable<T> {
  74445. private _observers;
  74446. private _eventState;
  74447. private _onObserverAdded;
  74448. /**
  74449. * Gets the list of observers
  74450. */
  74451. get observers(): Array<Observer<T>>;
  74452. /**
  74453. * Creates a new observable
  74454. * @param onObserverAdded defines a callback to call when a new observer is added
  74455. */
  74456. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  74457. /**
  74458. * Create a new Observer with the specified callback
  74459. * @param callback the callback that will be executed for that Observer
  74460. * @param mask the mask used to filter observers
  74461. * @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.
  74462. * @param scope optional scope for the callback to be called from
  74463. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  74464. * @returns the new observer created for the callback
  74465. */
  74466. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  74467. /**
  74468. * Create a new Observer with the specified callback and unregisters after the next notification
  74469. * @param callback the callback that will be executed for that Observer
  74470. * @returns the new observer created for the callback
  74471. */
  74472. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  74473. /**
  74474. * Remove an Observer from the Observable object
  74475. * @param observer the instance of the Observer to remove
  74476. * @returns false if it doesn't belong to this Observable
  74477. */
  74478. remove(observer: Nullable<Observer<T>>): boolean;
  74479. /**
  74480. * Remove a callback from the Observable object
  74481. * @param callback the callback to remove
  74482. * @param scope optional scope. If used only the callbacks with this scope will be removed
  74483. * @returns false if it doesn't belong to this Observable
  74484. */
  74485. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  74486. private _deferUnregister;
  74487. private _remove;
  74488. /**
  74489. * Moves the observable to the top of the observer list making it get called first when notified
  74490. * @param observer the observer to move
  74491. */
  74492. makeObserverTopPriority(observer: Observer<T>): void;
  74493. /**
  74494. * Moves the observable to the bottom of the observer list making it get called last when notified
  74495. * @param observer the observer to move
  74496. */
  74497. makeObserverBottomPriority(observer: Observer<T>): void;
  74498. /**
  74499. * Notify all Observers by calling their respective callback with the given data
  74500. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  74501. * @param eventData defines the data to send to all observers
  74502. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  74503. * @param target defines the original target of the state
  74504. * @param currentTarget defines the current target of the state
  74505. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  74506. */
  74507. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  74508. /**
  74509. * Calling this will execute each callback, expecting it to be a promise or return a value.
  74510. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  74511. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  74512. * and it is crucial that all callbacks will be executed.
  74513. * The order of the callbacks is kept, callbacks are not executed parallel.
  74514. *
  74515. * @param eventData The data to be sent to each callback
  74516. * @param mask is used to filter observers defaults to -1
  74517. * @param target defines the callback target (see EventState)
  74518. * @param currentTarget defines he current object in the bubbling phase
  74519. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  74520. */
  74521. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  74522. /**
  74523. * Notify a specific observer
  74524. * @param observer defines the observer to notify
  74525. * @param eventData defines the data to be sent to each callback
  74526. * @param mask is used to filter observers defaults to -1
  74527. */
  74528. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  74529. /**
  74530. * Gets a boolean indicating if the observable has at least one observer
  74531. * @returns true is the Observable has at least one Observer registered
  74532. */
  74533. hasObservers(): boolean;
  74534. /**
  74535. * Clear the list of observers
  74536. */
  74537. clear(): void;
  74538. /**
  74539. * Clone the current observable
  74540. * @returns a new observable
  74541. */
  74542. clone(): Observable<T>;
  74543. /**
  74544. * Does this observable handles observer registered with a given mask
  74545. * @param mask defines the mask to be tested
  74546. * @return whether or not one observer registered with the given mask is handeled
  74547. **/
  74548. hasSpecificMask(mask?: number): boolean;
  74549. }
  74550. }
  74551. declare module BABYLON {
  74552. /**
  74553. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  74554. * Babylon.js
  74555. */
  74556. export class DomManagement {
  74557. /**
  74558. * Checks if the window object exists
  74559. * @returns true if the window object exists
  74560. */
  74561. static IsWindowObjectExist(): boolean;
  74562. /**
  74563. * Checks if the navigator object exists
  74564. * @returns true if the navigator object exists
  74565. */
  74566. static IsNavigatorAvailable(): boolean;
  74567. /**
  74568. * Check if the document object exists
  74569. * @returns true if the document object exists
  74570. */
  74571. static IsDocumentAvailable(): boolean;
  74572. /**
  74573. * Extracts text content from a DOM element hierarchy
  74574. * @param element defines the root element
  74575. * @returns a string
  74576. */
  74577. static GetDOMTextContent(element: HTMLElement): string;
  74578. }
  74579. }
  74580. declare module BABYLON {
  74581. /**
  74582. * Logger used througouht the application to allow configuration of
  74583. * the log level required for the messages.
  74584. */
  74585. export class Logger {
  74586. /**
  74587. * No log
  74588. */
  74589. static readonly NoneLogLevel: number;
  74590. /**
  74591. * Only message logs
  74592. */
  74593. static readonly MessageLogLevel: number;
  74594. /**
  74595. * Only warning logs
  74596. */
  74597. static readonly WarningLogLevel: number;
  74598. /**
  74599. * Only error logs
  74600. */
  74601. static readonly ErrorLogLevel: number;
  74602. /**
  74603. * All logs
  74604. */
  74605. static readonly AllLogLevel: number;
  74606. private static _LogCache;
  74607. /**
  74608. * Gets a value indicating the number of loading errors
  74609. * @ignorenaming
  74610. */
  74611. static errorsCount: number;
  74612. /**
  74613. * Callback called when a new log is added
  74614. */
  74615. static OnNewCacheEntry: (entry: string) => void;
  74616. private static _AddLogEntry;
  74617. private static _FormatMessage;
  74618. private static _LogDisabled;
  74619. private static _LogEnabled;
  74620. private static _WarnDisabled;
  74621. private static _WarnEnabled;
  74622. private static _ErrorDisabled;
  74623. private static _ErrorEnabled;
  74624. /**
  74625. * Log a message to the console
  74626. */
  74627. static Log: (message: string) => void;
  74628. /**
  74629. * Write a warning message to the console
  74630. */
  74631. static Warn: (message: string) => void;
  74632. /**
  74633. * Write an error message to the console
  74634. */
  74635. static Error: (message: string) => void;
  74636. /**
  74637. * Gets current log cache (list of logs)
  74638. */
  74639. static get LogCache(): string;
  74640. /**
  74641. * Clears the log cache
  74642. */
  74643. static ClearLogCache(): void;
  74644. /**
  74645. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74646. */
  74647. static set LogLevels(level: number);
  74648. }
  74649. }
  74650. declare module BABYLON {
  74651. /** @hidden */
  74652. export class _TypeStore {
  74653. /** @hidden */
  74654. static RegisteredTypes: {
  74655. [key: string]: Object;
  74656. };
  74657. /** @hidden */
  74658. static GetClass(fqdn: string): any;
  74659. }
  74660. }
  74661. declare module BABYLON {
  74662. /**
  74663. * Helper to manipulate strings
  74664. */
  74665. export class StringTools {
  74666. /**
  74667. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74668. * @param str Source string
  74669. * @param suffix Suffix to search for in the source string
  74670. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74671. */
  74672. static EndsWith(str: string, suffix: string): boolean;
  74673. /**
  74674. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74675. * @param str Source string
  74676. * @param suffix Suffix to search for in the source string
  74677. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74678. */
  74679. static StartsWith(str: string, suffix: string): boolean;
  74680. /**
  74681. * Decodes a buffer into a string
  74682. * @param buffer The buffer to decode
  74683. * @returns The decoded string
  74684. */
  74685. static Decode(buffer: Uint8Array | Uint16Array): string;
  74686. /**
  74687. * Encode a buffer to a base64 string
  74688. * @param buffer defines the buffer to encode
  74689. * @returns the encoded string
  74690. */
  74691. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74692. /**
  74693. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74694. * @param num the number to convert and pad
  74695. * @param length the expected length of the string
  74696. * @returns the padded string
  74697. */
  74698. static PadNumber(num: number, length: number): string;
  74699. }
  74700. }
  74701. declare module BABYLON {
  74702. /**
  74703. * Class containing a set of static utilities functions for deep copy.
  74704. */
  74705. export class DeepCopier {
  74706. /**
  74707. * Tries to copy an object by duplicating every property
  74708. * @param source defines the source object
  74709. * @param destination defines the target object
  74710. * @param doNotCopyList defines a list of properties to avoid
  74711. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74712. */
  74713. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74714. }
  74715. }
  74716. declare module BABYLON {
  74717. /**
  74718. * Class containing a set of static utilities functions for precision date
  74719. */
  74720. export class PrecisionDate {
  74721. /**
  74722. * Gets either window.performance.now() if supported or Date.now() else
  74723. */
  74724. static get Now(): number;
  74725. }
  74726. }
  74727. declare module BABYLON {
  74728. /** @hidden */
  74729. export class _DevTools {
  74730. static WarnImport(name: string): string;
  74731. }
  74732. }
  74733. declare module BABYLON {
  74734. /**
  74735. * Interface used to define the mechanism to get data from the network
  74736. */
  74737. export interface IWebRequest {
  74738. /**
  74739. * Returns client's response url
  74740. */
  74741. responseURL: string;
  74742. /**
  74743. * Returns client's status
  74744. */
  74745. status: number;
  74746. /**
  74747. * Returns client's status as a text
  74748. */
  74749. statusText: string;
  74750. }
  74751. }
  74752. declare module BABYLON {
  74753. /**
  74754. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74755. */
  74756. export class WebRequest implements IWebRequest {
  74757. private _xhr;
  74758. /**
  74759. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74760. * i.e. when loading files, where the server/service expects an Authorization header
  74761. */
  74762. static CustomRequestHeaders: {
  74763. [key: string]: string;
  74764. };
  74765. /**
  74766. * Add callback functions in this array to update all the requests before they get sent to the network
  74767. */
  74768. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74769. private _injectCustomRequestHeaders;
  74770. /**
  74771. * Gets or sets a function to be called when loading progress changes
  74772. */
  74773. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74774. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74775. /**
  74776. * Returns client's state
  74777. */
  74778. get readyState(): number;
  74779. /**
  74780. * Returns client's status
  74781. */
  74782. get status(): number;
  74783. /**
  74784. * Returns client's status as a text
  74785. */
  74786. get statusText(): string;
  74787. /**
  74788. * Returns client's response
  74789. */
  74790. get response(): any;
  74791. /**
  74792. * Returns client's response url
  74793. */
  74794. get responseURL(): string;
  74795. /**
  74796. * Returns client's response as text
  74797. */
  74798. get responseText(): string;
  74799. /**
  74800. * Gets or sets the expected response type
  74801. */
  74802. get responseType(): XMLHttpRequestResponseType;
  74803. set responseType(value: XMLHttpRequestResponseType);
  74804. /** @hidden */
  74805. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74806. /** @hidden */
  74807. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74808. /**
  74809. * Cancels any network activity
  74810. */
  74811. abort(): void;
  74812. /**
  74813. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74814. * @param body defines an optional request body
  74815. */
  74816. send(body?: Document | BodyInit | null): void;
  74817. /**
  74818. * Sets the request method, request URL
  74819. * @param method defines the method to use (GET, POST, etc..)
  74820. * @param url defines the url to connect with
  74821. */
  74822. open(method: string, url: string): void;
  74823. /**
  74824. * Sets the value of a request header.
  74825. * @param name The name of the header whose value is to be set
  74826. * @param value The value to set as the body of the header
  74827. */
  74828. setRequestHeader(name: string, value: string): void;
  74829. /**
  74830. * Get the string containing the text of a particular header's value.
  74831. * @param name The name of the header
  74832. * @returns The string containing the text of the given header name
  74833. */
  74834. getResponseHeader(name: string): Nullable<string>;
  74835. }
  74836. }
  74837. declare module BABYLON {
  74838. /**
  74839. * File request interface
  74840. */
  74841. export interface IFileRequest {
  74842. /**
  74843. * Raised when the request is complete (success or error).
  74844. */
  74845. onCompleteObservable: Observable<IFileRequest>;
  74846. /**
  74847. * Aborts the request for a file.
  74848. */
  74849. abort: () => void;
  74850. }
  74851. }
  74852. declare module BABYLON {
  74853. /**
  74854. * Define options used to create a render target texture
  74855. */
  74856. export class RenderTargetCreationOptions {
  74857. /**
  74858. * Specifies is mipmaps must be generated
  74859. */
  74860. generateMipMaps?: boolean;
  74861. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74862. generateDepthBuffer?: boolean;
  74863. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74864. generateStencilBuffer?: boolean;
  74865. /** Defines texture type (int by default) */
  74866. type?: number;
  74867. /** Defines sampling mode (trilinear by default) */
  74868. samplingMode?: number;
  74869. /** Defines format (RGBA by default) */
  74870. format?: number;
  74871. }
  74872. }
  74873. declare module BABYLON {
  74874. /** Defines the cross module used constants to avoid circular dependncies */
  74875. export class Constants {
  74876. /** Defines that alpha blending is disabled */
  74877. static readonly ALPHA_DISABLE: number;
  74878. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74879. static readonly ALPHA_ADD: number;
  74880. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74881. static readonly ALPHA_COMBINE: number;
  74882. /** Defines that alpha blending is DEST - SRC * DEST */
  74883. static readonly ALPHA_SUBTRACT: number;
  74884. /** Defines that alpha blending is SRC * DEST */
  74885. static readonly ALPHA_MULTIPLY: number;
  74886. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74887. static readonly ALPHA_MAXIMIZED: number;
  74888. /** Defines that alpha blending is SRC + DEST */
  74889. static readonly ALPHA_ONEONE: number;
  74890. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74891. static readonly ALPHA_PREMULTIPLIED: number;
  74892. /**
  74893. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74894. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74895. */
  74896. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74897. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74898. static readonly ALPHA_INTERPOLATE: number;
  74899. /**
  74900. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74901. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74902. */
  74903. static readonly ALPHA_SCREENMODE: number;
  74904. /**
  74905. * Defines that alpha blending is SRC + DST
  74906. * Alpha will be set to SRC ALPHA + DST ALPHA
  74907. */
  74908. static readonly ALPHA_ONEONE_ONEONE: number;
  74909. /**
  74910. * Defines that alpha blending is SRC * DST ALPHA + DST
  74911. * Alpha will be set to 0
  74912. */
  74913. static readonly ALPHA_ALPHATOCOLOR: number;
  74914. /**
  74915. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74916. */
  74917. static readonly ALPHA_REVERSEONEMINUS: number;
  74918. /**
  74919. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74920. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74921. */
  74922. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74923. /**
  74924. * Defines that alpha blending is SRC + DST
  74925. * Alpha will be set to SRC ALPHA
  74926. */
  74927. static readonly ALPHA_ONEONE_ONEZERO: number;
  74928. /**
  74929. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74930. * Alpha will be set to DST ALPHA
  74931. */
  74932. static readonly ALPHA_EXCLUSION: number;
  74933. /** Defines that alpha blending equation a SUM */
  74934. static readonly ALPHA_EQUATION_ADD: number;
  74935. /** Defines that alpha blending equation a SUBSTRACTION */
  74936. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74937. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74938. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74939. /** Defines that alpha blending equation a MAX operation */
  74940. static readonly ALPHA_EQUATION_MAX: number;
  74941. /** Defines that alpha blending equation a MIN operation */
  74942. static readonly ALPHA_EQUATION_MIN: number;
  74943. /**
  74944. * Defines that alpha blending equation a DARKEN operation:
  74945. * It takes the min of the src and sums the alpha channels.
  74946. */
  74947. static readonly ALPHA_EQUATION_DARKEN: number;
  74948. /** Defines that the ressource is not delayed*/
  74949. static readonly DELAYLOADSTATE_NONE: number;
  74950. /** Defines that the ressource was successfully delay loaded */
  74951. static readonly DELAYLOADSTATE_LOADED: number;
  74952. /** Defines that the ressource is currently delay loading */
  74953. static readonly DELAYLOADSTATE_LOADING: number;
  74954. /** Defines that the ressource is delayed and has not started loading */
  74955. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74956. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74957. static readonly NEVER: number;
  74958. /** 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 */
  74959. static readonly ALWAYS: number;
  74960. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74961. static readonly LESS: number;
  74962. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74963. static readonly EQUAL: number;
  74964. /** 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 */
  74965. static readonly LEQUAL: number;
  74966. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74967. static readonly GREATER: number;
  74968. /** 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 */
  74969. static readonly GEQUAL: number;
  74970. /** 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 */
  74971. static readonly NOTEQUAL: number;
  74972. /** Passed to stencilOperation to specify that stencil value must be kept */
  74973. static readonly KEEP: number;
  74974. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74975. static readonly REPLACE: number;
  74976. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74977. static readonly INCR: number;
  74978. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74979. static readonly DECR: number;
  74980. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74981. static readonly INVERT: number;
  74982. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74983. static readonly INCR_WRAP: number;
  74984. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74985. static readonly DECR_WRAP: number;
  74986. /** Texture is not repeating outside of 0..1 UVs */
  74987. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74988. /** Texture is repeating outside of 0..1 UVs */
  74989. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74990. /** Texture is repeating and mirrored */
  74991. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74992. /** ALPHA */
  74993. static readonly TEXTUREFORMAT_ALPHA: number;
  74994. /** LUMINANCE */
  74995. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74996. /** LUMINANCE_ALPHA */
  74997. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74998. /** RGB */
  74999. static readonly TEXTUREFORMAT_RGB: number;
  75000. /** RGBA */
  75001. static readonly TEXTUREFORMAT_RGBA: number;
  75002. /** RED */
  75003. static readonly TEXTUREFORMAT_RED: number;
  75004. /** RED (2nd reference) */
  75005. static readonly TEXTUREFORMAT_R: number;
  75006. /** RG */
  75007. static readonly TEXTUREFORMAT_RG: number;
  75008. /** RED_INTEGER */
  75009. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  75010. /** RED_INTEGER (2nd reference) */
  75011. static readonly TEXTUREFORMAT_R_INTEGER: number;
  75012. /** RG_INTEGER */
  75013. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  75014. /** RGB_INTEGER */
  75015. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  75016. /** RGBA_INTEGER */
  75017. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  75018. /** UNSIGNED_BYTE */
  75019. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  75020. /** UNSIGNED_BYTE (2nd reference) */
  75021. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  75022. /** FLOAT */
  75023. static readonly TEXTURETYPE_FLOAT: number;
  75024. /** HALF_FLOAT */
  75025. static readonly TEXTURETYPE_HALF_FLOAT: number;
  75026. /** BYTE */
  75027. static readonly TEXTURETYPE_BYTE: number;
  75028. /** SHORT */
  75029. static readonly TEXTURETYPE_SHORT: number;
  75030. /** UNSIGNED_SHORT */
  75031. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  75032. /** INT */
  75033. static readonly TEXTURETYPE_INT: number;
  75034. /** UNSIGNED_INT */
  75035. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  75036. /** UNSIGNED_SHORT_4_4_4_4 */
  75037. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  75038. /** UNSIGNED_SHORT_5_5_5_1 */
  75039. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  75040. /** UNSIGNED_SHORT_5_6_5 */
  75041. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  75042. /** UNSIGNED_INT_2_10_10_10_REV */
  75043. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  75044. /** UNSIGNED_INT_24_8 */
  75045. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  75046. /** UNSIGNED_INT_10F_11F_11F_REV */
  75047. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  75048. /** UNSIGNED_INT_5_9_9_9_REV */
  75049. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  75050. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  75051. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75052. /** nearest is mag = nearest and min = nearest and no mip */
  75053. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  75054. /** mag = nearest and min = nearest and mip = none */
  75055. static readonly TEXTURE_NEAREST_NEAREST: number;
  75056. /** Bilinear is mag = linear and min = linear and no mip */
  75057. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  75058. /** mag = linear and min = linear and mip = none */
  75059. static readonly TEXTURE_LINEAR_LINEAR: number;
  75060. /** Trilinear is mag = linear and min = linear and mip = linear */
  75061. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  75062. /** Trilinear is mag = linear and min = linear and mip = linear */
  75063. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  75064. /** mag = nearest and min = nearest and mip = nearest */
  75065. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  75066. /** mag = nearest and min = linear and mip = nearest */
  75067. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  75068. /** mag = nearest and min = linear and mip = linear */
  75069. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  75070. /** mag = nearest and min = linear and mip = none */
  75071. static readonly TEXTURE_NEAREST_LINEAR: number;
  75072. /** nearest is mag = nearest and min = nearest and mip = linear */
  75073. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  75074. /** mag = linear and min = nearest and mip = nearest */
  75075. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  75076. /** mag = linear and min = nearest and mip = linear */
  75077. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  75078. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75079. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  75080. /** mag = linear and min = nearest and mip = none */
  75081. static readonly TEXTURE_LINEAR_NEAREST: number;
  75082. /** Explicit coordinates mode */
  75083. static readonly TEXTURE_EXPLICIT_MODE: number;
  75084. /** Spherical coordinates mode */
  75085. static readonly TEXTURE_SPHERICAL_MODE: number;
  75086. /** Planar coordinates mode */
  75087. static readonly TEXTURE_PLANAR_MODE: number;
  75088. /** Cubic coordinates mode */
  75089. static readonly TEXTURE_CUBIC_MODE: number;
  75090. /** Projection coordinates mode */
  75091. static readonly TEXTURE_PROJECTION_MODE: number;
  75092. /** Skybox coordinates mode */
  75093. static readonly TEXTURE_SKYBOX_MODE: number;
  75094. /** Inverse Cubic coordinates mode */
  75095. static readonly TEXTURE_INVCUBIC_MODE: number;
  75096. /** Equirectangular coordinates mode */
  75097. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  75098. /** Equirectangular Fixed coordinates mode */
  75099. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  75100. /** Equirectangular Fixed Mirrored coordinates mode */
  75101. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75102. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  75103. static readonly SCALEMODE_FLOOR: number;
  75104. /** Defines that texture rescaling will look for the nearest power of 2 size */
  75105. static readonly SCALEMODE_NEAREST: number;
  75106. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  75107. static readonly SCALEMODE_CEILING: number;
  75108. /**
  75109. * The dirty texture flag value
  75110. */
  75111. static readonly MATERIAL_TextureDirtyFlag: number;
  75112. /**
  75113. * The dirty light flag value
  75114. */
  75115. static readonly MATERIAL_LightDirtyFlag: number;
  75116. /**
  75117. * The dirty fresnel flag value
  75118. */
  75119. static readonly MATERIAL_FresnelDirtyFlag: number;
  75120. /**
  75121. * The dirty attribute flag value
  75122. */
  75123. static readonly MATERIAL_AttributesDirtyFlag: number;
  75124. /**
  75125. * The dirty misc flag value
  75126. */
  75127. static readonly MATERIAL_MiscDirtyFlag: number;
  75128. /**
  75129. * The all dirty flag value
  75130. */
  75131. static readonly MATERIAL_AllDirtyFlag: number;
  75132. /**
  75133. * Returns the triangle fill mode
  75134. */
  75135. static readonly MATERIAL_TriangleFillMode: number;
  75136. /**
  75137. * Returns the wireframe mode
  75138. */
  75139. static readonly MATERIAL_WireFrameFillMode: number;
  75140. /**
  75141. * Returns the point fill mode
  75142. */
  75143. static readonly MATERIAL_PointFillMode: number;
  75144. /**
  75145. * Returns the point list draw mode
  75146. */
  75147. static readonly MATERIAL_PointListDrawMode: number;
  75148. /**
  75149. * Returns the line list draw mode
  75150. */
  75151. static readonly MATERIAL_LineListDrawMode: number;
  75152. /**
  75153. * Returns the line loop draw mode
  75154. */
  75155. static readonly MATERIAL_LineLoopDrawMode: number;
  75156. /**
  75157. * Returns the line strip draw mode
  75158. */
  75159. static readonly MATERIAL_LineStripDrawMode: number;
  75160. /**
  75161. * Returns the triangle strip draw mode
  75162. */
  75163. static readonly MATERIAL_TriangleStripDrawMode: number;
  75164. /**
  75165. * Returns the triangle fan draw mode
  75166. */
  75167. static readonly MATERIAL_TriangleFanDrawMode: number;
  75168. /**
  75169. * Stores the clock-wise side orientation
  75170. */
  75171. static readonly MATERIAL_ClockWiseSideOrientation: number;
  75172. /**
  75173. * Stores the counter clock-wise side orientation
  75174. */
  75175. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  75176. /**
  75177. * Nothing
  75178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75179. */
  75180. static readonly ACTION_NothingTrigger: number;
  75181. /**
  75182. * On pick
  75183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75184. */
  75185. static readonly ACTION_OnPickTrigger: number;
  75186. /**
  75187. * On left pick
  75188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75189. */
  75190. static readonly ACTION_OnLeftPickTrigger: number;
  75191. /**
  75192. * On right pick
  75193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75194. */
  75195. static readonly ACTION_OnRightPickTrigger: number;
  75196. /**
  75197. * On center pick
  75198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75199. */
  75200. static readonly ACTION_OnCenterPickTrigger: number;
  75201. /**
  75202. * On pick down
  75203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75204. */
  75205. static readonly ACTION_OnPickDownTrigger: number;
  75206. /**
  75207. * On double pick
  75208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75209. */
  75210. static readonly ACTION_OnDoublePickTrigger: number;
  75211. /**
  75212. * On pick up
  75213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75214. */
  75215. static readonly ACTION_OnPickUpTrigger: number;
  75216. /**
  75217. * On pick out.
  75218. * This trigger will only be raised if you also declared a OnPickDown
  75219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75220. */
  75221. static readonly ACTION_OnPickOutTrigger: number;
  75222. /**
  75223. * On long press
  75224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75225. */
  75226. static readonly ACTION_OnLongPressTrigger: number;
  75227. /**
  75228. * On pointer over
  75229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75230. */
  75231. static readonly ACTION_OnPointerOverTrigger: number;
  75232. /**
  75233. * On pointer out
  75234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75235. */
  75236. static readonly ACTION_OnPointerOutTrigger: number;
  75237. /**
  75238. * On every frame
  75239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75240. */
  75241. static readonly ACTION_OnEveryFrameTrigger: number;
  75242. /**
  75243. * On intersection enter
  75244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75245. */
  75246. static readonly ACTION_OnIntersectionEnterTrigger: number;
  75247. /**
  75248. * On intersection exit
  75249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75250. */
  75251. static readonly ACTION_OnIntersectionExitTrigger: number;
  75252. /**
  75253. * On key down
  75254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75255. */
  75256. static readonly ACTION_OnKeyDownTrigger: number;
  75257. /**
  75258. * On key up
  75259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75260. */
  75261. static readonly ACTION_OnKeyUpTrigger: number;
  75262. /**
  75263. * Billboard mode will only apply to Y axis
  75264. */
  75265. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  75266. /**
  75267. * Billboard mode will apply to all axes
  75268. */
  75269. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  75270. /**
  75271. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75272. */
  75273. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  75274. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75275. * Test order :
  75276. * Is the bounding sphere outside the frustum ?
  75277. * If not, are the bounding box vertices outside the frustum ?
  75278. * It not, then the cullable object is in the frustum.
  75279. */
  75280. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  75281. /** Culling strategy : Bounding Sphere Only.
  75282. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75283. * It's also less accurate than the standard because some not visible objects can still be selected.
  75284. * Test : is the bounding sphere outside the frustum ?
  75285. * If not, then the cullable object is in the frustum.
  75286. */
  75287. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  75288. /** Culling strategy : Optimistic Inclusion.
  75289. * This in an inclusion test first, then the standard exclusion test.
  75290. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75291. * 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.
  75292. * Anyway, it's as accurate as the standard strategy.
  75293. * Test :
  75294. * Is the cullable object bounding sphere center in the frustum ?
  75295. * If not, apply the default culling strategy.
  75296. */
  75297. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  75298. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75299. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75300. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75301. * 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.
  75302. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75303. * Test :
  75304. * Is the cullable object bounding sphere center in the frustum ?
  75305. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75306. */
  75307. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  75308. /**
  75309. * No logging while loading
  75310. */
  75311. static readonly SCENELOADER_NO_LOGGING: number;
  75312. /**
  75313. * Minimal logging while loading
  75314. */
  75315. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  75316. /**
  75317. * Summary logging while loading
  75318. */
  75319. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  75320. /**
  75321. * Detailled logging while loading
  75322. */
  75323. static readonly SCENELOADER_DETAILED_LOGGING: number;
  75324. }
  75325. }
  75326. declare module BABYLON {
  75327. /**
  75328. * This represents the required contract to create a new type of texture loader.
  75329. */
  75330. export interface IInternalTextureLoader {
  75331. /**
  75332. * Defines wether the loader supports cascade loading the different faces.
  75333. */
  75334. supportCascades: boolean;
  75335. /**
  75336. * This returns if the loader support the current file information.
  75337. * @param extension defines the file extension of the file being loaded
  75338. * @returns true if the loader can load the specified file
  75339. */
  75340. canLoad(extension: string): boolean;
  75341. /**
  75342. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  75343. * @param data contains the texture data
  75344. * @param texture defines the BabylonJS internal texture
  75345. * @param createPolynomials will be true if polynomials have been requested
  75346. * @param onLoad defines the callback to trigger once the texture is ready
  75347. * @param onError defines the callback to trigger in case of error
  75348. */
  75349. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  75350. /**
  75351. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  75352. * @param data contains the texture data
  75353. * @param texture defines the BabylonJS internal texture
  75354. * @param callback defines the method to call once ready to upload
  75355. */
  75356. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  75357. }
  75358. }
  75359. declare module BABYLON {
  75360. /**
  75361. * Class used to store and describe the pipeline context associated with an effect
  75362. */
  75363. export interface IPipelineContext {
  75364. /**
  75365. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  75366. */
  75367. isAsync: boolean;
  75368. /**
  75369. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  75370. */
  75371. isReady: boolean;
  75372. /** @hidden */
  75373. _getVertexShaderCode(): string | null;
  75374. /** @hidden */
  75375. _getFragmentShaderCode(): string | null;
  75376. /** @hidden */
  75377. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  75378. }
  75379. }
  75380. declare module BABYLON {
  75381. /**
  75382. * Class used to store gfx data (like WebGLBuffer)
  75383. */
  75384. export class DataBuffer {
  75385. /**
  75386. * Gets or sets the number of objects referencing this buffer
  75387. */
  75388. references: number;
  75389. /** Gets or sets the size of the underlying buffer */
  75390. capacity: number;
  75391. /**
  75392. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  75393. */
  75394. is32Bits: boolean;
  75395. /**
  75396. * Gets the underlying buffer
  75397. */
  75398. get underlyingResource(): any;
  75399. }
  75400. }
  75401. declare module BABYLON {
  75402. /** @hidden */
  75403. export interface IShaderProcessor {
  75404. attributeProcessor?: (attribute: string) => string;
  75405. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  75406. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  75407. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  75408. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  75409. lineProcessor?: (line: string, isFragment: boolean) => string;
  75410. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75411. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75412. }
  75413. }
  75414. declare module BABYLON {
  75415. /** @hidden */
  75416. export interface ProcessingOptions {
  75417. defines: string[];
  75418. indexParameters: any;
  75419. isFragment: boolean;
  75420. shouldUseHighPrecisionShader: boolean;
  75421. supportsUniformBuffers: boolean;
  75422. shadersRepository: string;
  75423. includesShadersStore: {
  75424. [key: string]: string;
  75425. };
  75426. processor?: IShaderProcessor;
  75427. version: string;
  75428. platformName: string;
  75429. lookForClosingBracketForUniformBuffer?: boolean;
  75430. }
  75431. }
  75432. declare module BABYLON {
  75433. /** @hidden */
  75434. export class ShaderCodeNode {
  75435. line: string;
  75436. children: ShaderCodeNode[];
  75437. additionalDefineKey?: string;
  75438. additionalDefineValue?: string;
  75439. isValid(preprocessors: {
  75440. [key: string]: string;
  75441. }): boolean;
  75442. process(preprocessors: {
  75443. [key: string]: string;
  75444. }, options: ProcessingOptions): string;
  75445. }
  75446. }
  75447. declare module BABYLON {
  75448. /** @hidden */
  75449. export class ShaderCodeCursor {
  75450. private _lines;
  75451. lineIndex: number;
  75452. get currentLine(): string;
  75453. get canRead(): boolean;
  75454. set lines(value: string[]);
  75455. }
  75456. }
  75457. declare module BABYLON {
  75458. /** @hidden */
  75459. export class ShaderCodeConditionNode extends ShaderCodeNode {
  75460. process(preprocessors: {
  75461. [key: string]: string;
  75462. }, options: ProcessingOptions): string;
  75463. }
  75464. }
  75465. declare module BABYLON {
  75466. /** @hidden */
  75467. export class ShaderDefineExpression {
  75468. isTrue(preprocessors: {
  75469. [key: string]: string;
  75470. }): boolean;
  75471. private static _OperatorPriority;
  75472. private static _Stack;
  75473. static postfixToInfix(postfix: string[]): string;
  75474. static infixToPostfix(infix: string): string[];
  75475. }
  75476. }
  75477. declare module BABYLON {
  75478. /** @hidden */
  75479. export class ShaderCodeTestNode extends ShaderCodeNode {
  75480. testExpression: ShaderDefineExpression;
  75481. isValid(preprocessors: {
  75482. [key: string]: string;
  75483. }): boolean;
  75484. }
  75485. }
  75486. declare module BABYLON {
  75487. /** @hidden */
  75488. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  75489. define: string;
  75490. not: boolean;
  75491. constructor(define: string, not?: boolean);
  75492. isTrue(preprocessors: {
  75493. [key: string]: string;
  75494. }): boolean;
  75495. }
  75496. }
  75497. declare module BABYLON {
  75498. /** @hidden */
  75499. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  75500. leftOperand: ShaderDefineExpression;
  75501. rightOperand: ShaderDefineExpression;
  75502. isTrue(preprocessors: {
  75503. [key: string]: string;
  75504. }): boolean;
  75505. }
  75506. }
  75507. declare module BABYLON {
  75508. /** @hidden */
  75509. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  75510. leftOperand: ShaderDefineExpression;
  75511. rightOperand: ShaderDefineExpression;
  75512. isTrue(preprocessors: {
  75513. [key: string]: string;
  75514. }): boolean;
  75515. }
  75516. }
  75517. declare module BABYLON {
  75518. /** @hidden */
  75519. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  75520. define: string;
  75521. operand: string;
  75522. testValue: string;
  75523. constructor(define: string, operand: string, testValue: string);
  75524. isTrue(preprocessors: {
  75525. [key: string]: string;
  75526. }): boolean;
  75527. }
  75528. }
  75529. declare module BABYLON {
  75530. /**
  75531. * Class used to enable access to offline support
  75532. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75533. */
  75534. export interface IOfflineProvider {
  75535. /**
  75536. * Gets a boolean indicating if scene must be saved in the database
  75537. */
  75538. enableSceneOffline: boolean;
  75539. /**
  75540. * Gets a boolean indicating if textures must be saved in the database
  75541. */
  75542. enableTexturesOffline: boolean;
  75543. /**
  75544. * Open the offline support and make it available
  75545. * @param successCallback defines the callback to call on success
  75546. * @param errorCallback defines the callback to call on error
  75547. */
  75548. open(successCallback: () => void, errorCallback: () => void): void;
  75549. /**
  75550. * Loads an image from the offline support
  75551. * @param url defines the url to load from
  75552. * @param image defines the target DOM image
  75553. */
  75554. loadImage(url: string, image: HTMLImageElement): void;
  75555. /**
  75556. * Loads a file from offline support
  75557. * @param url defines the URL to load from
  75558. * @param sceneLoaded defines a callback to call on success
  75559. * @param progressCallBack defines a callback to call when progress changed
  75560. * @param errorCallback defines a callback to call on error
  75561. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75562. */
  75563. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75564. }
  75565. }
  75566. declare module BABYLON {
  75567. /**
  75568. * Class used to help managing file picking and drag'n'drop
  75569. * File Storage
  75570. */
  75571. export class FilesInputStore {
  75572. /**
  75573. * List of files ready to be loaded
  75574. */
  75575. static FilesToLoad: {
  75576. [key: string]: File;
  75577. };
  75578. }
  75579. }
  75580. declare module BABYLON {
  75581. /**
  75582. * Class used to define a retry strategy when error happens while loading assets
  75583. */
  75584. export class RetryStrategy {
  75585. /**
  75586. * Function used to defines an exponential back off strategy
  75587. * @param maxRetries defines the maximum number of retries (3 by default)
  75588. * @param baseInterval defines the interval between retries
  75589. * @returns the strategy function to use
  75590. */
  75591. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  75592. }
  75593. }
  75594. declare module BABYLON {
  75595. /**
  75596. * @ignore
  75597. * Application error to support additional information when loading a file
  75598. */
  75599. export abstract class BaseError extends Error {
  75600. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75601. }
  75602. }
  75603. declare module BABYLON {
  75604. /** @ignore */
  75605. export class LoadFileError extends BaseError {
  75606. request?: WebRequest;
  75607. file?: File;
  75608. /**
  75609. * Creates a new LoadFileError
  75610. * @param message defines the message of the error
  75611. * @param request defines the optional web request
  75612. * @param file defines the optional file
  75613. */
  75614. constructor(message: string, object?: WebRequest | File);
  75615. }
  75616. /** @ignore */
  75617. export class RequestFileError extends BaseError {
  75618. request: WebRequest;
  75619. /**
  75620. * Creates a new LoadFileError
  75621. * @param message defines the message of the error
  75622. * @param request defines the optional web request
  75623. */
  75624. constructor(message: string, request: WebRequest);
  75625. }
  75626. /** @ignore */
  75627. export class ReadFileError extends BaseError {
  75628. file: File;
  75629. /**
  75630. * Creates a new ReadFileError
  75631. * @param message defines the message of the error
  75632. * @param file defines the optional file
  75633. */
  75634. constructor(message: string, file: File);
  75635. }
  75636. /**
  75637. * @hidden
  75638. */
  75639. export class FileTools {
  75640. /**
  75641. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75642. */
  75643. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75644. /**
  75645. * Gets or sets the base URL to use to load assets
  75646. */
  75647. static BaseUrl: string;
  75648. /**
  75649. * Default behaviour for cors in the application.
  75650. * It can be a string if the expected behavior is identical in the entire app.
  75651. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75652. */
  75653. static CorsBehavior: string | ((url: string | string[]) => string);
  75654. /**
  75655. * Gets or sets a function used to pre-process url before using them to load assets
  75656. */
  75657. static PreprocessUrl: (url: string) => string;
  75658. /**
  75659. * Removes unwanted characters from an url
  75660. * @param url defines the url to clean
  75661. * @returns the cleaned url
  75662. */
  75663. private static _CleanUrl;
  75664. /**
  75665. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75666. * @param url define the url we are trying
  75667. * @param element define the dom element where to configure the cors policy
  75668. */
  75669. static SetCorsBehavior(url: string | string[], element: {
  75670. crossOrigin: string | null;
  75671. }): void;
  75672. /**
  75673. * Loads an image as an HTMLImageElement.
  75674. * @param input url string, ArrayBuffer, or Blob to load
  75675. * @param onLoad callback called when the image successfully loads
  75676. * @param onError callback called when the image fails to load
  75677. * @param offlineProvider offline provider for caching
  75678. * @param mimeType optional mime type
  75679. * @returns the HTMLImageElement of the loaded image
  75680. */
  75681. 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>;
  75682. /**
  75683. * Reads a file from a File object
  75684. * @param file defines the file to load
  75685. * @param onSuccess defines the callback to call when data is loaded
  75686. * @param onProgress defines the callback to call during loading process
  75687. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75688. * @param onError defines the callback to call when an error occurs
  75689. * @returns a file request object
  75690. */
  75691. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75692. /**
  75693. * Loads a file from a url
  75694. * @param url url to load
  75695. * @param onSuccess callback called when the file successfully loads
  75696. * @param onProgress callback called while file is loading (if the server supports this mode)
  75697. * @param offlineProvider defines the offline provider for caching
  75698. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75699. * @param onError callback called when the file fails to load
  75700. * @returns a file request object
  75701. */
  75702. 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;
  75703. /**
  75704. * Loads a file
  75705. * @param url url to load
  75706. * @param onSuccess callback called when the file successfully loads
  75707. * @param onProgress callback called while file is loading (if the server supports this mode)
  75708. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75709. * @param onError callback called when the file fails to load
  75710. * @param onOpened callback called when the web request is opened
  75711. * @returns a file request object
  75712. */
  75713. 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;
  75714. /**
  75715. * Checks if the loaded document was accessed via `file:`-Protocol.
  75716. * @returns boolean
  75717. */
  75718. static IsFileURL(): boolean;
  75719. }
  75720. }
  75721. declare module BABYLON {
  75722. /** @hidden */
  75723. export class ShaderProcessor {
  75724. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75725. private static _ProcessPrecision;
  75726. private static _ExtractOperation;
  75727. private static _BuildSubExpression;
  75728. private static _BuildExpression;
  75729. private static _MoveCursorWithinIf;
  75730. private static _MoveCursor;
  75731. private static _EvaluatePreProcessors;
  75732. private static _PreparePreProcessors;
  75733. private static _ProcessShaderConversion;
  75734. private static _ProcessIncludes;
  75735. /**
  75736. * Loads a file from a url
  75737. * @param url url to load
  75738. * @param onSuccess callback called when the file successfully loads
  75739. * @param onProgress callback called while file is loading (if the server supports this mode)
  75740. * @param offlineProvider defines the offline provider for caching
  75741. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75742. * @param onError callback called when the file fails to load
  75743. * @returns a file request object
  75744. * @hidden
  75745. */
  75746. 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;
  75747. }
  75748. }
  75749. declare module BABYLON {
  75750. /**
  75751. * @hidden
  75752. */
  75753. export interface IColor4Like {
  75754. r: float;
  75755. g: float;
  75756. b: float;
  75757. a: float;
  75758. }
  75759. /**
  75760. * @hidden
  75761. */
  75762. export interface IColor3Like {
  75763. r: float;
  75764. g: float;
  75765. b: float;
  75766. }
  75767. /**
  75768. * @hidden
  75769. */
  75770. export interface IVector4Like {
  75771. x: float;
  75772. y: float;
  75773. z: float;
  75774. w: float;
  75775. }
  75776. /**
  75777. * @hidden
  75778. */
  75779. export interface IVector3Like {
  75780. x: float;
  75781. y: float;
  75782. z: float;
  75783. }
  75784. /**
  75785. * @hidden
  75786. */
  75787. export interface IVector2Like {
  75788. x: float;
  75789. y: float;
  75790. }
  75791. /**
  75792. * @hidden
  75793. */
  75794. export interface IMatrixLike {
  75795. toArray(): DeepImmutable<Float32Array>;
  75796. updateFlag: int;
  75797. }
  75798. /**
  75799. * @hidden
  75800. */
  75801. export interface IViewportLike {
  75802. x: float;
  75803. y: float;
  75804. width: float;
  75805. height: float;
  75806. }
  75807. /**
  75808. * @hidden
  75809. */
  75810. export interface IPlaneLike {
  75811. normal: IVector3Like;
  75812. d: float;
  75813. normalize(): void;
  75814. }
  75815. }
  75816. declare module BABYLON {
  75817. /**
  75818. * Interface used to define common properties for effect fallbacks
  75819. */
  75820. export interface IEffectFallbacks {
  75821. /**
  75822. * Removes the defines that should be removed when falling back.
  75823. * @param currentDefines defines the current define statements for the shader.
  75824. * @param effect defines the current effect we try to compile
  75825. * @returns The resulting defines with defines of the current rank removed.
  75826. */
  75827. reduce(currentDefines: string, effect: Effect): string;
  75828. /**
  75829. * Removes the fallback from the bound mesh.
  75830. */
  75831. unBindMesh(): void;
  75832. /**
  75833. * Checks to see if more fallbacks are still availible.
  75834. */
  75835. hasMoreFallbacks: boolean;
  75836. }
  75837. }
  75838. declare module BABYLON {
  75839. /**
  75840. * Class used to evalaute queries containing `and` and `or` operators
  75841. */
  75842. export class AndOrNotEvaluator {
  75843. /**
  75844. * Evaluate a query
  75845. * @param query defines the query to evaluate
  75846. * @param evaluateCallback defines the callback used to filter result
  75847. * @returns true if the query matches
  75848. */
  75849. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75850. private static _HandleParenthesisContent;
  75851. private static _SimplifyNegation;
  75852. }
  75853. }
  75854. declare module BABYLON {
  75855. /**
  75856. * Class used to store custom tags
  75857. */
  75858. export class Tags {
  75859. /**
  75860. * Adds support for tags on the given object
  75861. * @param obj defines the object to use
  75862. */
  75863. static EnableFor(obj: any): void;
  75864. /**
  75865. * Removes tags support
  75866. * @param obj defines the object to use
  75867. */
  75868. static DisableFor(obj: any): void;
  75869. /**
  75870. * Gets a boolean indicating if the given object has tags
  75871. * @param obj defines the object to use
  75872. * @returns a boolean
  75873. */
  75874. static HasTags(obj: any): boolean;
  75875. /**
  75876. * Gets the tags available on a given object
  75877. * @param obj defines the object to use
  75878. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75879. * @returns the tags
  75880. */
  75881. static GetTags(obj: any, asString?: boolean): any;
  75882. /**
  75883. * Adds tags to an object
  75884. * @param obj defines the object to use
  75885. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75886. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75887. */
  75888. static AddTagsTo(obj: any, tagsString: string): void;
  75889. /**
  75890. * @hidden
  75891. */
  75892. static _AddTagTo(obj: any, tag: string): void;
  75893. /**
  75894. * Removes specific tags from a specific object
  75895. * @param obj defines the object to use
  75896. * @param tagsString defines the tags to remove
  75897. */
  75898. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75899. /**
  75900. * @hidden
  75901. */
  75902. static _RemoveTagFrom(obj: any, tag: string): void;
  75903. /**
  75904. * Defines if tags hosted on an object match a given query
  75905. * @param obj defines the object to use
  75906. * @param tagsQuery defines the tag query
  75907. * @returns a boolean
  75908. */
  75909. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75910. }
  75911. }
  75912. declare module BABYLON {
  75913. /**
  75914. * Scalar computation library
  75915. */
  75916. export class Scalar {
  75917. /**
  75918. * Two pi constants convenient for computation.
  75919. */
  75920. static TwoPi: number;
  75921. /**
  75922. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75923. * @param a number
  75924. * @param b number
  75925. * @param epsilon (default = 1.401298E-45)
  75926. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75927. */
  75928. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75929. /**
  75930. * Returns a string : the upper case translation of the number i to hexadecimal.
  75931. * @param i number
  75932. * @returns the upper case translation of the number i to hexadecimal.
  75933. */
  75934. static ToHex(i: number): string;
  75935. /**
  75936. * Returns -1 if value is negative and +1 is value is positive.
  75937. * @param value the value
  75938. * @returns the value itself if it's equal to zero.
  75939. */
  75940. static Sign(value: number): number;
  75941. /**
  75942. * Returns the value itself if it's between min and max.
  75943. * Returns min if the value is lower than min.
  75944. * Returns max if the value is greater than max.
  75945. * @param value the value to clmap
  75946. * @param min the min value to clamp to (default: 0)
  75947. * @param max the max value to clamp to (default: 1)
  75948. * @returns the clamped value
  75949. */
  75950. static Clamp(value: number, min?: number, max?: number): number;
  75951. /**
  75952. * the log2 of value.
  75953. * @param value the value to compute log2 of
  75954. * @returns the log2 of value.
  75955. */
  75956. static Log2(value: number): number;
  75957. /**
  75958. * Loops the value, so that it is never larger than length and never smaller than 0.
  75959. *
  75960. * This is similar to the modulo operator but it works with floating point numbers.
  75961. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75962. * With t = 5 and length = 2.5, the result would be 0.0.
  75963. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75964. * @param value the value
  75965. * @param length the length
  75966. * @returns the looped value
  75967. */
  75968. static Repeat(value: number, length: number): number;
  75969. /**
  75970. * Normalize the value between 0.0 and 1.0 using min and max values
  75971. * @param value value to normalize
  75972. * @param min max to normalize between
  75973. * @param max min to normalize between
  75974. * @returns the normalized value
  75975. */
  75976. static Normalize(value: number, min: number, max: number): number;
  75977. /**
  75978. * Denormalize the value from 0.0 and 1.0 using min and max values
  75979. * @param normalized value to denormalize
  75980. * @param min max to denormalize between
  75981. * @param max min to denormalize between
  75982. * @returns the denormalized value
  75983. */
  75984. static Denormalize(normalized: number, min: number, max: number): number;
  75985. /**
  75986. * Calculates the shortest difference between two given angles given in degrees.
  75987. * @param current current angle in degrees
  75988. * @param target target angle in degrees
  75989. * @returns the delta
  75990. */
  75991. static DeltaAngle(current: number, target: number): number;
  75992. /**
  75993. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75994. * @param tx value
  75995. * @param length length
  75996. * @returns The returned value will move back and forth between 0 and length
  75997. */
  75998. static PingPong(tx: number, length: number): number;
  75999. /**
  76000. * Interpolates between min and max with smoothing at the limits.
  76001. *
  76002. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  76003. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  76004. * @param from from
  76005. * @param to to
  76006. * @param tx value
  76007. * @returns the smooth stepped value
  76008. */
  76009. static SmoothStep(from: number, to: number, tx: number): number;
  76010. /**
  76011. * Moves a value current towards target.
  76012. *
  76013. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  76014. * Negative values of maxDelta pushes the value away from target.
  76015. * @param current current value
  76016. * @param target target value
  76017. * @param maxDelta max distance to move
  76018. * @returns resulting value
  76019. */
  76020. static MoveTowards(current: number, target: number, maxDelta: number): number;
  76021. /**
  76022. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76023. *
  76024. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  76025. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  76026. * @param current current value
  76027. * @param target target value
  76028. * @param maxDelta max distance to move
  76029. * @returns resulting angle
  76030. */
  76031. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  76032. /**
  76033. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  76034. * @param start start value
  76035. * @param end target value
  76036. * @param amount amount to lerp between
  76037. * @returns the lerped value
  76038. */
  76039. static Lerp(start: number, end: number, amount: number): number;
  76040. /**
  76041. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76042. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  76043. * @param start start value
  76044. * @param end target value
  76045. * @param amount amount to lerp between
  76046. * @returns the lerped value
  76047. */
  76048. static LerpAngle(start: number, end: number, amount: number): number;
  76049. /**
  76050. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  76051. * @param a start value
  76052. * @param b target value
  76053. * @param value value between a and b
  76054. * @returns the inverseLerp value
  76055. */
  76056. static InverseLerp(a: number, b: number, value: number): number;
  76057. /**
  76058. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  76059. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  76060. * @param value1 spline value
  76061. * @param tangent1 spline value
  76062. * @param value2 spline value
  76063. * @param tangent2 spline value
  76064. * @param amount input value
  76065. * @returns hermite result
  76066. */
  76067. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  76068. /**
  76069. * Returns a random float number between and min and max values
  76070. * @param min min value of random
  76071. * @param max max value of random
  76072. * @returns random value
  76073. */
  76074. static RandomRange(min: number, max: number): number;
  76075. /**
  76076. * This function returns percentage of a number in a given range.
  76077. *
  76078. * RangeToPercent(40,20,60) will return 0.5 (50%)
  76079. * RangeToPercent(34,0,100) will return 0.34 (34%)
  76080. * @param number to convert to percentage
  76081. * @param min min range
  76082. * @param max max range
  76083. * @returns the percentage
  76084. */
  76085. static RangeToPercent(number: number, min: number, max: number): number;
  76086. /**
  76087. * This function returns number that corresponds to the percentage in a given range.
  76088. *
  76089. * PercentToRange(0.34,0,100) will return 34.
  76090. * @param percent to convert to number
  76091. * @param min min range
  76092. * @param max max range
  76093. * @returns the number
  76094. */
  76095. static PercentToRange(percent: number, min: number, max: number): number;
  76096. /**
  76097. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  76098. * @param angle The angle to normalize in radian.
  76099. * @return The converted angle.
  76100. */
  76101. static NormalizeRadians(angle: number): number;
  76102. }
  76103. }
  76104. declare module BABYLON {
  76105. /**
  76106. * Constant used to convert a value to gamma space
  76107. * @ignorenaming
  76108. */
  76109. export const ToGammaSpace: number;
  76110. /**
  76111. * Constant used to convert a value to linear space
  76112. * @ignorenaming
  76113. */
  76114. export const ToLinearSpace = 2.2;
  76115. /**
  76116. * Constant used to define the minimal number value in Babylon.js
  76117. * @ignorenaming
  76118. */
  76119. let Epsilon: number;
  76120. }
  76121. declare module BABYLON {
  76122. /**
  76123. * Class used to represent a viewport on screen
  76124. */
  76125. export class Viewport {
  76126. /** viewport left coordinate */
  76127. x: number;
  76128. /** viewport top coordinate */
  76129. y: number;
  76130. /**viewport width */
  76131. width: number;
  76132. /** viewport height */
  76133. height: number;
  76134. /**
  76135. * Creates a Viewport object located at (x, y) and sized (width, height)
  76136. * @param x defines viewport left coordinate
  76137. * @param y defines viewport top coordinate
  76138. * @param width defines the viewport width
  76139. * @param height defines the viewport height
  76140. */
  76141. constructor(
  76142. /** viewport left coordinate */
  76143. x: number,
  76144. /** viewport top coordinate */
  76145. y: number,
  76146. /**viewport width */
  76147. width: number,
  76148. /** viewport height */
  76149. height: number);
  76150. /**
  76151. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76152. * @param renderWidth defines the rendering width
  76153. * @param renderHeight defines the rendering height
  76154. * @returns a new Viewport
  76155. */
  76156. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  76157. /**
  76158. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76159. * @param renderWidth defines the rendering width
  76160. * @param renderHeight defines the rendering height
  76161. * @param ref defines the target viewport
  76162. * @returns the current viewport
  76163. */
  76164. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  76165. /**
  76166. * Returns a new Viewport copied from the current one
  76167. * @returns a new Viewport
  76168. */
  76169. clone(): Viewport;
  76170. }
  76171. }
  76172. declare module BABYLON {
  76173. /**
  76174. * Class containing a set of static utilities functions for arrays.
  76175. */
  76176. export class ArrayTools {
  76177. /**
  76178. * Returns an array of the given size filled with element built from the given constructor and the paramters
  76179. * @param size the number of element to construct and put in the array
  76180. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  76181. * @returns a new array filled with new objects
  76182. */
  76183. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  76184. }
  76185. }
  76186. declare module BABYLON {
  76187. /**
  76188. * Class representing a vector containing 2 coordinates
  76189. */
  76190. export class Vector2 {
  76191. /** defines the first coordinate */
  76192. x: number;
  76193. /** defines the second coordinate */
  76194. y: number;
  76195. /**
  76196. * Creates a new Vector2 from the given x and y coordinates
  76197. * @param x defines the first coordinate
  76198. * @param y defines the second coordinate
  76199. */
  76200. constructor(
  76201. /** defines the first coordinate */
  76202. x?: number,
  76203. /** defines the second coordinate */
  76204. y?: number);
  76205. /**
  76206. * Gets a string with the Vector2 coordinates
  76207. * @returns a string with the Vector2 coordinates
  76208. */
  76209. toString(): string;
  76210. /**
  76211. * Gets class name
  76212. * @returns the string "Vector2"
  76213. */
  76214. getClassName(): string;
  76215. /**
  76216. * Gets current vector hash code
  76217. * @returns the Vector2 hash code as a number
  76218. */
  76219. getHashCode(): number;
  76220. /**
  76221. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  76222. * @param array defines the source array
  76223. * @param index defines the offset in source array
  76224. * @returns the current Vector2
  76225. */
  76226. toArray(array: FloatArray, index?: number): Vector2;
  76227. /**
  76228. * Copy the current vector to an array
  76229. * @returns a new array with 2 elements: the Vector2 coordinates.
  76230. */
  76231. asArray(): number[];
  76232. /**
  76233. * Sets the Vector2 coordinates with the given Vector2 coordinates
  76234. * @param source defines the source Vector2
  76235. * @returns the current updated Vector2
  76236. */
  76237. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  76238. /**
  76239. * Sets the Vector2 coordinates with the given floats
  76240. * @param x defines the first coordinate
  76241. * @param y defines the second coordinate
  76242. * @returns the current updated Vector2
  76243. */
  76244. copyFromFloats(x: number, y: number): Vector2;
  76245. /**
  76246. * Sets the Vector2 coordinates with the given floats
  76247. * @param x defines the first coordinate
  76248. * @param y defines the second coordinate
  76249. * @returns the current updated Vector2
  76250. */
  76251. set(x: number, y: number): Vector2;
  76252. /**
  76253. * Add another vector with the current one
  76254. * @param otherVector defines the other vector
  76255. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  76256. */
  76257. add(otherVector: DeepImmutable<Vector2>): Vector2;
  76258. /**
  76259. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  76260. * @param otherVector defines the other vector
  76261. * @param result defines the target vector
  76262. * @returns the unmodified current Vector2
  76263. */
  76264. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76265. /**
  76266. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  76267. * @param otherVector defines the other vector
  76268. * @returns the current updated Vector2
  76269. */
  76270. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76271. /**
  76272. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  76273. * @param otherVector defines the other vector
  76274. * @returns a new Vector2
  76275. */
  76276. addVector3(otherVector: Vector3): Vector2;
  76277. /**
  76278. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  76279. * @param otherVector defines the other vector
  76280. * @returns a new Vector2
  76281. */
  76282. subtract(otherVector: Vector2): Vector2;
  76283. /**
  76284. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  76285. * @param otherVector defines the other vector
  76286. * @param result defines the target vector
  76287. * @returns the unmodified current Vector2
  76288. */
  76289. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76290. /**
  76291. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  76292. * @param otherVector defines the other vector
  76293. * @returns the current updated Vector2
  76294. */
  76295. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76296. /**
  76297. * Multiplies in place the current Vector2 coordinates by the given ones
  76298. * @param otherVector defines the other vector
  76299. * @returns the current updated Vector2
  76300. */
  76301. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76302. /**
  76303. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  76304. * @param otherVector defines the other vector
  76305. * @returns a new Vector2
  76306. */
  76307. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  76308. /**
  76309. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  76310. * @param otherVector defines the other vector
  76311. * @param result defines the target vector
  76312. * @returns the unmodified current Vector2
  76313. */
  76314. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76315. /**
  76316. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  76317. * @param x defines the first coordinate
  76318. * @param y defines the second coordinate
  76319. * @returns a new Vector2
  76320. */
  76321. multiplyByFloats(x: number, y: number): Vector2;
  76322. /**
  76323. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  76324. * @param otherVector defines the other vector
  76325. * @returns a new Vector2
  76326. */
  76327. divide(otherVector: Vector2): Vector2;
  76328. /**
  76329. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  76330. * @param otherVector defines the other vector
  76331. * @param result defines the target vector
  76332. * @returns the unmodified current Vector2
  76333. */
  76334. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76335. /**
  76336. * Divides the current Vector2 coordinates by the given ones
  76337. * @param otherVector defines the other vector
  76338. * @returns the current updated Vector2
  76339. */
  76340. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76341. /**
  76342. * Gets a new Vector2 with current Vector2 negated coordinates
  76343. * @returns a new Vector2
  76344. */
  76345. negate(): Vector2;
  76346. /**
  76347. * Negate this vector in place
  76348. * @returns this
  76349. */
  76350. negateInPlace(): Vector2;
  76351. /**
  76352. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  76353. * @param result defines the Vector3 object where to store the result
  76354. * @returns the current Vector2
  76355. */
  76356. negateToRef(result: Vector2): Vector2;
  76357. /**
  76358. * Multiply the Vector2 coordinates by scale
  76359. * @param scale defines the scaling factor
  76360. * @returns the current updated Vector2
  76361. */
  76362. scaleInPlace(scale: number): Vector2;
  76363. /**
  76364. * Returns a new Vector2 scaled by "scale" from the current Vector2
  76365. * @param scale defines the scaling factor
  76366. * @returns a new Vector2
  76367. */
  76368. scale(scale: number): Vector2;
  76369. /**
  76370. * Scale the current Vector2 values by a factor to a given Vector2
  76371. * @param scale defines the scale factor
  76372. * @param result defines the Vector2 object where to store the result
  76373. * @returns the unmodified current Vector2
  76374. */
  76375. scaleToRef(scale: number, result: Vector2): Vector2;
  76376. /**
  76377. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  76378. * @param scale defines the scale factor
  76379. * @param result defines the Vector2 object where to store the result
  76380. * @returns the unmodified current Vector2
  76381. */
  76382. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  76383. /**
  76384. * Gets a boolean if two vectors are equals
  76385. * @param otherVector defines the other vector
  76386. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  76387. */
  76388. equals(otherVector: DeepImmutable<Vector2>): boolean;
  76389. /**
  76390. * Gets a boolean if two vectors are equals (using an epsilon value)
  76391. * @param otherVector defines the other vector
  76392. * @param epsilon defines the minimal distance to consider equality
  76393. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  76394. */
  76395. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  76396. /**
  76397. * Gets a new Vector2 from current Vector2 floored values
  76398. * @returns a new Vector2
  76399. */
  76400. floor(): Vector2;
  76401. /**
  76402. * Gets a new Vector2 from current Vector2 floored values
  76403. * @returns a new Vector2
  76404. */
  76405. fract(): Vector2;
  76406. /**
  76407. * Gets the length of the vector
  76408. * @returns the vector length (float)
  76409. */
  76410. length(): number;
  76411. /**
  76412. * Gets the vector squared length
  76413. * @returns the vector squared length (float)
  76414. */
  76415. lengthSquared(): number;
  76416. /**
  76417. * Normalize the vector
  76418. * @returns the current updated Vector2
  76419. */
  76420. normalize(): Vector2;
  76421. /**
  76422. * Gets a new Vector2 copied from the Vector2
  76423. * @returns a new Vector2
  76424. */
  76425. clone(): Vector2;
  76426. /**
  76427. * Gets a new Vector2(0, 0)
  76428. * @returns a new Vector2
  76429. */
  76430. static Zero(): Vector2;
  76431. /**
  76432. * Gets a new Vector2(1, 1)
  76433. * @returns a new Vector2
  76434. */
  76435. static One(): Vector2;
  76436. /**
  76437. * Gets a new Vector2 set from the given index element of the given array
  76438. * @param array defines the data source
  76439. * @param offset defines the offset in the data source
  76440. * @returns a new Vector2
  76441. */
  76442. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  76443. /**
  76444. * Sets "result" from the given index element of the given array
  76445. * @param array defines the data source
  76446. * @param offset defines the offset in the data source
  76447. * @param result defines the target vector
  76448. */
  76449. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  76450. /**
  76451. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  76452. * @param value1 defines 1st point of control
  76453. * @param value2 defines 2nd point of control
  76454. * @param value3 defines 3rd point of control
  76455. * @param value4 defines 4th point of control
  76456. * @param amount defines the interpolation factor
  76457. * @returns a new Vector2
  76458. */
  76459. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  76460. /**
  76461. * 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".
  76462. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  76463. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  76464. * @param value defines the value to clamp
  76465. * @param min defines the lower limit
  76466. * @param max defines the upper limit
  76467. * @returns a new Vector2
  76468. */
  76469. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  76470. /**
  76471. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  76472. * @param value1 defines the 1st control point
  76473. * @param tangent1 defines the outgoing tangent
  76474. * @param value2 defines the 2nd control point
  76475. * @param tangent2 defines the incoming tangent
  76476. * @param amount defines the interpolation factor
  76477. * @returns a new Vector2
  76478. */
  76479. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  76480. /**
  76481. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  76482. * @param start defines the start vector
  76483. * @param end defines the end vector
  76484. * @param amount defines the interpolation factor
  76485. * @returns a new Vector2
  76486. */
  76487. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  76488. /**
  76489. * Gets the dot product of the vector "left" and the vector "right"
  76490. * @param left defines first vector
  76491. * @param right defines second vector
  76492. * @returns the dot product (float)
  76493. */
  76494. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  76495. /**
  76496. * Returns a new Vector2 equal to the normalized given vector
  76497. * @param vector defines the vector to normalize
  76498. * @returns a new Vector2
  76499. */
  76500. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  76501. /**
  76502. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  76503. * @param left defines 1st vector
  76504. * @param right defines 2nd vector
  76505. * @returns a new Vector2
  76506. */
  76507. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76508. /**
  76509. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  76510. * @param left defines 1st vector
  76511. * @param right defines 2nd vector
  76512. * @returns a new Vector2
  76513. */
  76514. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76515. /**
  76516. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  76517. * @param vector defines the vector to transform
  76518. * @param transformation defines the matrix to apply
  76519. * @returns a new Vector2
  76520. */
  76521. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  76522. /**
  76523. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  76524. * @param vector defines the vector to transform
  76525. * @param transformation defines the matrix to apply
  76526. * @param result defines the target vector
  76527. */
  76528. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  76529. /**
  76530. * Determines if a given vector is included in a triangle
  76531. * @param p defines the vector to test
  76532. * @param p0 defines 1st triangle point
  76533. * @param p1 defines 2nd triangle point
  76534. * @param p2 defines 3rd triangle point
  76535. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  76536. */
  76537. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  76538. /**
  76539. * Gets the distance between the vectors "value1" and "value2"
  76540. * @param value1 defines first vector
  76541. * @param value2 defines second vector
  76542. * @returns the distance between vectors
  76543. */
  76544. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76545. /**
  76546. * Returns the squared distance between the vectors "value1" and "value2"
  76547. * @param value1 defines first vector
  76548. * @param value2 defines second vector
  76549. * @returns the squared distance between vectors
  76550. */
  76551. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76552. /**
  76553. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  76554. * @param value1 defines first vector
  76555. * @param value2 defines second vector
  76556. * @returns a new Vector2
  76557. */
  76558. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  76559. /**
  76560. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  76561. * @param p defines the middle point
  76562. * @param segA defines one point of the segment
  76563. * @param segB defines the other point of the segment
  76564. * @returns the shortest distance
  76565. */
  76566. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  76567. }
  76568. /**
  76569. * Class used to store (x,y,z) vector representation
  76570. * A Vector3 is the main object used in 3D geometry
  76571. * It can represent etiher the coordinates of a point the space, either a direction
  76572. * Reminder: js uses a left handed forward facing system
  76573. */
  76574. export class Vector3 {
  76575. /**
  76576. * Defines the first coordinates (on X axis)
  76577. */
  76578. x: number;
  76579. /**
  76580. * Defines the second coordinates (on Y axis)
  76581. */
  76582. y: number;
  76583. /**
  76584. * Defines the third coordinates (on Z axis)
  76585. */
  76586. z: number;
  76587. private static _UpReadOnly;
  76588. private static _ZeroReadOnly;
  76589. /**
  76590. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  76591. * @param x defines the first coordinates (on X axis)
  76592. * @param y defines the second coordinates (on Y axis)
  76593. * @param z defines the third coordinates (on Z axis)
  76594. */
  76595. constructor(
  76596. /**
  76597. * Defines the first coordinates (on X axis)
  76598. */
  76599. x?: number,
  76600. /**
  76601. * Defines the second coordinates (on Y axis)
  76602. */
  76603. y?: number,
  76604. /**
  76605. * Defines the third coordinates (on Z axis)
  76606. */
  76607. z?: number);
  76608. /**
  76609. * Creates a string representation of the Vector3
  76610. * @returns a string with the Vector3 coordinates.
  76611. */
  76612. toString(): string;
  76613. /**
  76614. * Gets the class name
  76615. * @returns the string "Vector3"
  76616. */
  76617. getClassName(): string;
  76618. /**
  76619. * Creates the Vector3 hash code
  76620. * @returns a number which tends to be unique between Vector3 instances
  76621. */
  76622. getHashCode(): number;
  76623. /**
  76624. * Creates an array containing three elements : the coordinates of the Vector3
  76625. * @returns a new array of numbers
  76626. */
  76627. asArray(): number[];
  76628. /**
  76629. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76630. * @param array defines the destination array
  76631. * @param index defines the offset in the destination array
  76632. * @returns the current Vector3
  76633. */
  76634. toArray(array: FloatArray, index?: number): Vector3;
  76635. /**
  76636. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76637. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76638. */
  76639. toQuaternion(): Quaternion;
  76640. /**
  76641. * Adds the given vector to the current Vector3
  76642. * @param otherVector defines the second operand
  76643. * @returns the current updated Vector3
  76644. */
  76645. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76646. /**
  76647. * Adds the given coordinates to the current Vector3
  76648. * @param x defines the x coordinate of the operand
  76649. * @param y defines the y coordinate of the operand
  76650. * @param z defines the z coordinate of the operand
  76651. * @returns the current updated Vector3
  76652. */
  76653. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76654. /**
  76655. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76656. * @param otherVector defines the second operand
  76657. * @returns the resulting Vector3
  76658. */
  76659. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76660. /**
  76661. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76662. * @param otherVector defines the second operand
  76663. * @param result defines the Vector3 object where to store the result
  76664. * @returns the current Vector3
  76665. */
  76666. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76667. /**
  76668. * Subtract the given vector from the current Vector3
  76669. * @param otherVector defines the second operand
  76670. * @returns the current updated Vector3
  76671. */
  76672. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76673. /**
  76674. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76675. * @param otherVector defines the second operand
  76676. * @returns the resulting Vector3
  76677. */
  76678. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76679. /**
  76680. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76681. * @param otherVector defines the second operand
  76682. * @param result defines the Vector3 object where to store the result
  76683. * @returns the current Vector3
  76684. */
  76685. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76686. /**
  76687. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76688. * @param x defines the x coordinate of the operand
  76689. * @param y defines the y coordinate of the operand
  76690. * @param z defines the z coordinate of the operand
  76691. * @returns the resulting Vector3
  76692. */
  76693. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76694. /**
  76695. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76696. * @param x defines the x coordinate of the operand
  76697. * @param y defines the y coordinate of the operand
  76698. * @param z defines the z coordinate of the operand
  76699. * @param result defines the Vector3 object where to store the result
  76700. * @returns the current Vector3
  76701. */
  76702. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76703. /**
  76704. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76705. * @returns a new Vector3
  76706. */
  76707. negate(): Vector3;
  76708. /**
  76709. * Negate this vector in place
  76710. * @returns this
  76711. */
  76712. negateInPlace(): Vector3;
  76713. /**
  76714. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76715. * @param result defines the Vector3 object where to store the result
  76716. * @returns the current Vector3
  76717. */
  76718. negateToRef(result: Vector3): Vector3;
  76719. /**
  76720. * Multiplies the Vector3 coordinates by the float "scale"
  76721. * @param scale defines the multiplier factor
  76722. * @returns the current updated Vector3
  76723. */
  76724. scaleInPlace(scale: number): Vector3;
  76725. /**
  76726. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76727. * @param scale defines the multiplier factor
  76728. * @returns a new Vector3
  76729. */
  76730. scale(scale: number): Vector3;
  76731. /**
  76732. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76733. * @param scale defines the multiplier factor
  76734. * @param result defines the Vector3 object where to store the result
  76735. * @returns the current Vector3
  76736. */
  76737. scaleToRef(scale: number, result: Vector3): Vector3;
  76738. /**
  76739. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76740. * @param scale defines the scale factor
  76741. * @param result defines the Vector3 object where to store the result
  76742. * @returns the unmodified current Vector3
  76743. */
  76744. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76745. /**
  76746. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76747. * @param otherVector defines the second operand
  76748. * @returns true if both vectors are equals
  76749. */
  76750. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76751. /**
  76752. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76753. * @param otherVector defines the second operand
  76754. * @param epsilon defines the minimal distance to define values as equals
  76755. * @returns true if both vectors are distant less than epsilon
  76756. */
  76757. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76758. /**
  76759. * Returns true if the current Vector3 coordinates equals the given floats
  76760. * @param x defines the x coordinate of the operand
  76761. * @param y defines the y coordinate of the operand
  76762. * @param z defines the z coordinate of the operand
  76763. * @returns true if both vectors are equals
  76764. */
  76765. equalsToFloats(x: number, y: number, z: number): boolean;
  76766. /**
  76767. * Multiplies the current Vector3 coordinates by the given ones
  76768. * @param otherVector defines the second operand
  76769. * @returns the current updated Vector3
  76770. */
  76771. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76772. /**
  76773. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76774. * @param otherVector defines the second operand
  76775. * @returns the new Vector3
  76776. */
  76777. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76778. /**
  76779. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76780. * @param otherVector defines the second operand
  76781. * @param result defines the Vector3 object where to store the result
  76782. * @returns the current Vector3
  76783. */
  76784. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76785. /**
  76786. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76787. * @param x defines the x coordinate of the operand
  76788. * @param y defines the y coordinate of the operand
  76789. * @param z defines the z coordinate of the operand
  76790. * @returns the new Vector3
  76791. */
  76792. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76793. /**
  76794. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76795. * @param otherVector defines the second operand
  76796. * @returns the new Vector3
  76797. */
  76798. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76799. /**
  76800. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76801. * @param otherVector defines the second operand
  76802. * @param result defines the Vector3 object where to store the result
  76803. * @returns the current Vector3
  76804. */
  76805. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76806. /**
  76807. * Divides the current Vector3 coordinates by the given ones.
  76808. * @param otherVector defines the second operand
  76809. * @returns the current updated Vector3
  76810. */
  76811. divideInPlace(otherVector: Vector3): Vector3;
  76812. /**
  76813. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76814. * @param other defines the second operand
  76815. * @returns the current updated Vector3
  76816. */
  76817. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76818. /**
  76819. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76820. * @param other defines the second operand
  76821. * @returns the current updated Vector3
  76822. */
  76823. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76824. /**
  76825. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76826. * @param x defines the x coordinate of the operand
  76827. * @param y defines the y coordinate of the operand
  76828. * @param z defines the z coordinate of the operand
  76829. * @returns the current updated Vector3
  76830. */
  76831. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76832. /**
  76833. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76834. * @param x defines the x coordinate of the operand
  76835. * @param y defines the y coordinate of the operand
  76836. * @param z defines the z coordinate of the operand
  76837. * @returns the current updated Vector3
  76838. */
  76839. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76840. /**
  76841. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76842. * Check if is non uniform within a certain amount of decimal places to account for this
  76843. * @param epsilon the amount the values can differ
  76844. * @returns if the the vector is non uniform to a certain number of decimal places
  76845. */
  76846. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76847. /**
  76848. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76849. */
  76850. get isNonUniform(): boolean;
  76851. /**
  76852. * Gets a new Vector3 from current Vector3 floored values
  76853. * @returns a new Vector3
  76854. */
  76855. floor(): Vector3;
  76856. /**
  76857. * Gets a new Vector3 from current Vector3 floored values
  76858. * @returns a new Vector3
  76859. */
  76860. fract(): Vector3;
  76861. /**
  76862. * Gets the length of the Vector3
  76863. * @returns the length of the Vector3
  76864. */
  76865. length(): number;
  76866. /**
  76867. * Gets the squared length of the Vector3
  76868. * @returns squared length of the Vector3
  76869. */
  76870. lengthSquared(): number;
  76871. /**
  76872. * Normalize the current Vector3.
  76873. * Please note that this is an in place operation.
  76874. * @returns the current updated Vector3
  76875. */
  76876. normalize(): Vector3;
  76877. /**
  76878. * Reorders the x y z properties of the vector in place
  76879. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76880. * @returns the current updated vector
  76881. */
  76882. reorderInPlace(order: string): this;
  76883. /**
  76884. * Rotates the vector around 0,0,0 by a quaternion
  76885. * @param quaternion the rotation quaternion
  76886. * @param result vector to store the result
  76887. * @returns the resulting vector
  76888. */
  76889. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76890. /**
  76891. * Rotates a vector around a given point
  76892. * @param quaternion the rotation quaternion
  76893. * @param point the point to rotate around
  76894. * @param result vector to store the result
  76895. * @returns the resulting vector
  76896. */
  76897. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76898. /**
  76899. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76900. * The cross product is then orthogonal to both current and "other"
  76901. * @param other defines the right operand
  76902. * @returns the cross product
  76903. */
  76904. cross(other: Vector3): Vector3;
  76905. /**
  76906. * Normalize the current Vector3 with the given input length.
  76907. * Please note that this is an in place operation.
  76908. * @param len the length of the vector
  76909. * @returns the current updated Vector3
  76910. */
  76911. normalizeFromLength(len: number): Vector3;
  76912. /**
  76913. * Normalize the current Vector3 to a new vector
  76914. * @returns the new Vector3
  76915. */
  76916. normalizeToNew(): Vector3;
  76917. /**
  76918. * Normalize the current Vector3 to the reference
  76919. * @param reference define the Vector3 to update
  76920. * @returns the updated Vector3
  76921. */
  76922. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76923. /**
  76924. * Creates a new Vector3 copied from the current Vector3
  76925. * @returns the new Vector3
  76926. */
  76927. clone(): Vector3;
  76928. /**
  76929. * Copies the given vector coordinates to the current Vector3 ones
  76930. * @param source defines the source Vector3
  76931. * @returns the current updated Vector3
  76932. */
  76933. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76934. /**
  76935. * Copies the given floats to the current Vector3 coordinates
  76936. * @param x defines the x coordinate of the operand
  76937. * @param y defines the y coordinate of the operand
  76938. * @param z defines the z coordinate of the operand
  76939. * @returns the current updated Vector3
  76940. */
  76941. copyFromFloats(x: number, y: number, z: number): Vector3;
  76942. /**
  76943. * Copies the given floats to the current Vector3 coordinates
  76944. * @param x defines the x coordinate of the operand
  76945. * @param y defines the y coordinate of the operand
  76946. * @param z defines the z coordinate of the operand
  76947. * @returns the current updated Vector3
  76948. */
  76949. set(x: number, y: number, z: number): Vector3;
  76950. /**
  76951. * Copies the given float to the current Vector3 coordinates
  76952. * @param v defines the x, y and z coordinates of the operand
  76953. * @returns the current updated Vector3
  76954. */
  76955. setAll(v: number): Vector3;
  76956. /**
  76957. * Get the clip factor between two vectors
  76958. * @param vector0 defines the first operand
  76959. * @param vector1 defines the second operand
  76960. * @param axis defines the axis to use
  76961. * @param size defines the size along the axis
  76962. * @returns the clip factor
  76963. */
  76964. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76965. /**
  76966. * Get angle between two vectors
  76967. * @param vector0 angle between vector0 and vector1
  76968. * @param vector1 angle between vector0 and vector1
  76969. * @param normal direction of the normal
  76970. * @return the angle between vector0 and vector1
  76971. */
  76972. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76973. /**
  76974. * Returns a new Vector3 set from the index "offset" of the given array
  76975. * @param array defines the source array
  76976. * @param offset defines the offset in the source array
  76977. * @returns the new Vector3
  76978. */
  76979. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76980. /**
  76981. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76982. * @param array defines the source array
  76983. * @param offset defines the offset in the source array
  76984. * @returns the new Vector3
  76985. * @deprecated Please use FromArray instead.
  76986. */
  76987. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76988. /**
  76989. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76990. * @param array defines the source array
  76991. * @param offset defines the offset in the source array
  76992. * @param result defines the Vector3 where to store the result
  76993. */
  76994. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76995. /**
  76996. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76997. * @param array defines the source array
  76998. * @param offset defines the offset in the source array
  76999. * @param result defines the Vector3 where to store the result
  77000. * @deprecated Please use FromArrayToRef instead.
  77001. */
  77002. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  77003. /**
  77004. * Sets the given vector "result" with the given floats.
  77005. * @param x defines the x coordinate of the source
  77006. * @param y defines the y coordinate of the source
  77007. * @param z defines the z coordinate of the source
  77008. * @param result defines the Vector3 where to store the result
  77009. */
  77010. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  77011. /**
  77012. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  77013. * @returns a new empty Vector3
  77014. */
  77015. static Zero(): Vector3;
  77016. /**
  77017. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  77018. * @returns a new unit Vector3
  77019. */
  77020. static One(): Vector3;
  77021. /**
  77022. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  77023. * @returns a new up Vector3
  77024. */
  77025. static Up(): Vector3;
  77026. /**
  77027. * Gets a up Vector3 that must not be updated
  77028. */
  77029. static get UpReadOnly(): DeepImmutable<Vector3>;
  77030. /**
  77031. * Gets a zero Vector3 that must not be updated
  77032. */
  77033. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  77034. /**
  77035. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  77036. * @returns a new down Vector3
  77037. */
  77038. static Down(): Vector3;
  77039. /**
  77040. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  77041. * @returns a new forward Vector3
  77042. */
  77043. static Forward(): Vector3;
  77044. /**
  77045. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  77046. * @returns a new forward Vector3
  77047. */
  77048. static Backward(): Vector3;
  77049. /**
  77050. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  77051. * @returns a new right Vector3
  77052. */
  77053. static Right(): Vector3;
  77054. /**
  77055. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  77056. * @returns a new left Vector3
  77057. */
  77058. static Left(): Vector3;
  77059. /**
  77060. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  77061. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77062. * @param vector defines the Vector3 to transform
  77063. * @param transformation defines the transformation matrix
  77064. * @returns the transformed Vector3
  77065. */
  77066. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77067. /**
  77068. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  77069. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77070. * @param vector defines the Vector3 to transform
  77071. * @param transformation defines the transformation matrix
  77072. * @param result defines the Vector3 where to store the result
  77073. */
  77074. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77075. /**
  77076. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  77077. * This method computes tranformed coordinates only, not transformed direction vectors
  77078. * @param x define the x coordinate of the source vector
  77079. * @param y define the y coordinate of the source vector
  77080. * @param z define the z coordinate of the source vector
  77081. * @param transformation defines the transformation matrix
  77082. * @param result defines the Vector3 where to store the result
  77083. */
  77084. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77085. /**
  77086. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  77087. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77088. * @param vector defines the Vector3 to transform
  77089. * @param transformation defines the transformation matrix
  77090. * @returns the new Vector3
  77091. */
  77092. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77093. /**
  77094. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  77095. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77096. * @param vector defines the Vector3 to transform
  77097. * @param transformation defines the transformation matrix
  77098. * @param result defines the Vector3 where to store the result
  77099. */
  77100. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77101. /**
  77102. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  77103. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77104. * @param x define the x coordinate of the source vector
  77105. * @param y define the y coordinate of the source vector
  77106. * @param z define the z coordinate of the source vector
  77107. * @param transformation defines the transformation matrix
  77108. * @param result defines the Vector3 where to store the result
  77109. */
  77110. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77111. /**
  77112. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  77113. * @param value1 defines the first control point
  77114. * @param value2 defines the second control point
  77115. * @param value3 defines the third control point
  77116. * @param value4 defines the fourth control point
  77117. * @param amount defines the amount on the spline to use
  77118. * @returns the new Vector3
  77119. */
  77120. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  77121. /**
  77122. * 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"
  77123. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77124. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77125. * @param value defines the current value
  77126. * @param min defines the lower range value
  77127. * @param max defines the upper range value
  77128. * @returns the new Vector3
  77129. */
  77130. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  77131. /**
  77132. * 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"
  77133. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77134. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77135. * @param value defines the current value
  77136. * @param min defines the lower range value
  77137. * @param max defines the upper range value
  77138. * @param result defines the Vector3 where to store the result
  77139. */
  77140. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  77141. /**
  77142. * Checks if a given vector is inside a specific range
  77143. * @param v defines the vector to test
  77144. * @param min defines the minimum range
  77145. * @param max defines the maximum range
  77146. */
  77147. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  77148. /**
  77149. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  77150. * @param value1 defines the first control point
  77151. * @param tangent1 defines the first tangent vector
  77152. * @param value2 defines the second control point
  77153. * @param tangent2 defines the second tangent vector
  77154. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  77155. * @returns the new Vector3
  77156. */
  77157. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  77158. /**
  77159. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  77160. * @param start defines the start value
  77161. * @param end defines the end value
  77162. * @param amount max defines amount between both (between 0 and 1)
  77163. * @returns the new Vector3
  77164. */
  77165. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  77166. /**
  77167. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  77168. * @param start defines the start value
  77169. * @param end defines the end value
  77170. * @param amount max defines amount between both (between 0 and 1)
  77171. * @param result defines the Vector3 where to store the result
  77172. */
  77173. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  77174. /**
  77175. * Returns the dot product (float) between the vectors "left" and "right"
  77176. * @param left defines the left operand
  77177. * @param right defines the right operand
  77178. * @returns the dot product
  77179. */
  77180. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  77181. /**
  77182. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  77183. * The cross product is then orthogonal to both "left" and "right"
  77184. * @param left defines the left operand
  77185. * @param right defines the right operand
  77186. * @returns the cross product
  77187. */
  77188. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77189. /**
  77190. * Sets the given vector "result" with the cross product of "left" and "right"
  77191. * The cross product is then orthogonal to both "left" and "right"
  77192. * @param left defines the left operand
  77193. * @param right defines the right operand
  77194. * @param result defines the Vector3 where to store the result
  77195. */
  77196. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  77197. /**
  77198. * Returns a new Vector3 as the normalization of the given vector
  77199. * @param vector defines the Vector3 to normalize
  77200. * @returns the new Vector3
  77201. */
  77202. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  77203. /**
  77204. * Sets the given vector "result" with the normalization of the given first vector
  77205. * @param vector defines the Vector3 to normalize
  77206. * @param result defines the Vector3 where to store the result
  77207. */
  77208. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  77209. /**
  77210. * Project a Vector3 onto screen space
  77211. * @param vector defines the Vector3 to project
  77212. * @param world defines the world matrix to use
  77213. * @param transform defines the transform (view x projection) matrix to use
  77214. * @param viewport defines the screen viewport to use
  77215. * @returns the new Vector3
  77216. */
  77217. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  77218. /** @hidden */
  77219. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  77220. /**
  77221. * Unproject from screen space to object space
  77222. * @param source defines the screen space Vector3 to use
  77223. * @param viewportWidth defines the current width of the viewport
  77224. * @param viewportHeight defines the current height of the viewport
  77225. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77226. * @param transform defines the transform (view x projection) matrix to use
  77227. * @returns the new Vector3
  77228. */
  77229. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  77230. /**
  77231. * Unproject from screen space to object space
  77232. * @param source defines the screen space Vector3 to use
  77233. * @param viewportWidth defines the current width of the viewport
  77234. * @param viewportHeight defines the current height of the viewport
  77235. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77236. * @param view defines the view matrix to use
  77237. * @param projection defines the projection matrix to use
  77238. * @returns the new Vector3
  77239. */
  77240. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  77241. /**
  77242. * Unproject from screen space to object space
  77243. * @param source defines the screen space Vector3 to use
  77244. * @param viewportWidth defines the current width of the viewport
  77245. * @param viewportHeight defines the current height of the viewport
  77246. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77247. * @param view defines the view matrix to use
  77248. * @param projection defines the projection matrix to use
  77249. * @param result defines the Vector3 where to store the result
  77250. */
  77251. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77252. /**
  77253. * Unproject from screen space to object space
  77254. * @param sourceX defines the screen space x coordinate to use
  77255. * @param sourceY defines the screen space y coordinate to use
  77256. * @param sourceZ defines the screen space z coordinate to use
  77257. * @param viewportWidth defines the current width of the viewport
  77258. * @param viewportHeight defines the current height of the viewport
  77259. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77260. * @param view defines the view matrix to use
  77261. * @param projection defines the projection matrix to use
  77262. * @param result defines the Vector3 where to store the result
  77263. */
  77264. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77265. /**
  77266. * Gets the minimal coordinate values between two Vector3
  77267. * @param left defines the first operand
  77268. * @param right defines the second operand
  77269. * @returns the new Vector3
  77270. */
  77271. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77272. /**
  77273. * Gets the maximal coordinate values between two Vector3
  77274. * @param left defines the first operand
  77275. * @param right defines the second operand
  77276. * @returns the new Vector3
  77277. */
  77278. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77279. /**
  77280. * Returns the distance between the vectors "value1" and "value2"
  77281. * @param value1 defines the first operand
  77282. * @param value2 defines the second operand
  77283. * @returns the distance
  77284. */
  77285. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77286. /**
  77287. * Returns the squared distance between the vectors "value1" and "value2"
  77288. * @param value1 defines the first operand
  77289. * @param value2 defines the second operand
  77290. * @returns the squared distance
  77291. */
  77292. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77293. /**
  77294. * Returns a new Vector3 located at the center between "value1" and "value2"
  77295. * @param value1 defines the first operand
  77296. * @param value2 defines the second operand
  77297. * @returns the new Vector3
  77298. */
  77299. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  77300. /**
  77301. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  77302. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  77303. * to something in order to rotate it from its local system to the given target system
  77304. * Note: axis1, axis2 and axis3 are normalized during this operation
  77305. * @param axis1 defines the first axis
  77306. * @param axis2 defines the second axis
  77307. * @param axis3 defines the third axis
  77308. * @returns a new Vector3
  77309. */
  77310. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  77311. /**
  77312. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  77313. * @param axis1 defines the first axis
  77314. * @param axis2 defines the second axis
  77315. * @param axis3 defines the third axis
  77316. * @param ref defines the Vector3 where to store the result
  77317. */
  77318. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  77319. }
  77320. /**
  77321. * Vector4 class created for EulerAngle class conversion to Quaternion
  77322. */
  77323. export class Vector4 {
  77324. /** x value of the vector */
  77325. x: number;
  77326. /** y value of the vector */
  77327. y: number;
  77328. /** z value of the vector */
  77329. z: number;
  77330. /** w value of the vector */
  77331. w: number;
  77332. /**
  77333. * Creates a Vector4 object from the given floats.
  77334. * @param x x value of the vector
  77335. * @param y y value of the vector
  77336. * @param z z value of the vector
  77337. * @param w w value of the vector
  77338. */
  77339. constructor(
  77340. /** x value of the vector */
  77341. x: number,
  77342. /** y value of the vector */
  77343. y: number,
  77344. /** z value of the vector */
  77345. z: number,
  77346. /** w value of the vector */
  77347. w: number);
  77348. /**
  77349. * Returns the string with the Vector4 coordinates.
  77350. * @returns a string containing all the vector values
  77351. */
  77352. toString(): string;
  77353. /**
  77354. * Returns the string "Vector4".
  77355. * @returns "Vector4"
  77356. */
  77357. getClassName(): string;
  77358. /**
  77359. * Returns the Vector4 hash code.
  77360. * @returns a unique hash code
  77361. */
  77362. getHashCode(): number;
  77363. /**
  77364. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  77365. * @returns the resulting array
  77366. */
  77367. asArray(): number[];
  77368. /**
  77369. * Populates the given array from the given index with the Vector4 coordinates.
  77370. * @param array array to populate
  77371. * @param index index of the array to start at (default: 0)
  77372. * @returns the Vector4.
  77373. */
  77374. toArray(array: FloatArray, index?: number): Vector4;
  77375. /**
  77376. * Adds the given vector to the current Vector4.
  77377. * @param otherVector the vector to add
  77378. * @returns the updated Vector4.
  77379. */
  77380. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77381. /**
  77382. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  77383. * @param otherVector the vector to add
  77384. * @returns the resulting vector
  77385. */
  77386. add(otherVector: DeepImmutable<Vector4>): Vector4;
  77387. /**
  77388. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  77389. * @param otherVector the vector to add
  77390. * @param result the vector to store the result
  77391. * @returns the current Vector4.
  77392. */
  77393. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77394. /**
  77395. * Subtract in place the given vector from the current Vector4.
  77396. * @param otherVector the vector to subtract
  77397. * @returns the updated Vector4.
  77398. */
  77399. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77400. /**
  77401. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  77402. * @param otherVector the vector to add
  77403. * @returns the new vector with the result
  77404. */
  77405. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  77406. /**
  77407. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  77408. * @param otherVector the vector to subtract
  77409. * @param result the vector to store the result
  77410. * @returns the current Vector4.
  77411. */
  77412. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77413. /**
  77414. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77415. */
  77416. /**
  77417. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77418. * @param x value to subtract
  77419. * @param y value to subtract
  77420. * @param z value to subtract
  77421. * @param w value to subtract
  77422. * @returns new vector containing the result
  77423. */
  77424. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77425. /**
  77426. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77427. * @param x value to subtract
  77428. * @param y value to subtract
  77429. * @param z value to subtract
  77430. * @param w value to subtract
  77431. * @param result the vector to store the result in
  77432. * @returns the current Vector4.
  77433. */
  77434. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  77435. /**
  77436. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  77437. * @returns a new vector with the negated values
  77438. */
  77439. negate(): Vector4;
  77440. /**
  77441. * Negate this vector in place
  77442. * @returns this
  77443. */
  77444. negateInPlace(): Vector4;
  77445. /**
  77446. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  77447. * @param result defines the Vector3 object where to store the result
  77448. * @returns the current Vector4
  77449. */
  77450. negateToRef(result: Vector4): Vector4;
  77451. /**
  77452. * Multiplies the current Vector4 coordinates by scale (float).
  77453. * @param scale the number to scale with
  77454. * @returns the updated Vector4.
  77455. */
  77456. scaleInPlace(scale: number): Vector4;
  77457. /**
  77458. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  77459. * @param scale the number to scale with
  77460. * @returns a new vector with the result
  77461. */
  77462. scale(scale: number): Vector4;
  77463. /**
  77464. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  77465. * @param scale the number to scale with
  77466. * @param result a vector to store the result in
  77467. * @returns the current Vector4.
  77468. */
  77469. scaleToRef(scale: number, result: Vector4): Vector4;
  77470. /**
  77471. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  77472. * @param scale defines the scale factor
  77473. * @param result defines the Vector4 object where to store the result
  77474. * @returns the unmodified current Vector4
  77475. */
  77476. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  77477. /**
  77478. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  77479. * @param otherVector the vector to compare against
  77480. * @returns true if they are equal
  77481. */
  77482. equals(otherVector: DeepImmutable<Vector4>): boolean;
  77483. /**
  77484. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  77485. * @param otherVector vector to compare against
  77486. * @param epsilon (Default: very small number)
  77487. * @returns true if they are equal
  77488. */
  77489. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  77490. /**
  77491. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  77492. * @param x x value to compare against
  77493. * @param y y value to compare against
  77494. * @param z z value to compare against
  77495. * @param w w value to compare against
  77496. * @returns true if equal
  77497. */
  77498. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  77499. /**
  77500. * Multiplies in place the current Vector4 by the given one.
  77501. * @param otherVector vector to multiple with
  77502. * @returns the updated Vector4.
  77503. */
  77504. multiplyInPlace(otherVector: Vector4): Vector4;
  77505. /**
  77506. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  77507. * @param otherVector vector to multiple with
  77508. * @returns resulting new vector
  77509. */
  77510. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  77511. /**
  77512. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  77513. * @param otherVector vector to multiple with
  77514. * @param result vector to store the result
  77515. * @returns the current Vector4.
  77516. */
  77517. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77518. /**
  77519. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  77520. * @param x x value multiply with
  77521. * @param y y value multiply with
  77522. * @param z z value multiply with
  77523. * @param w w value multiply with
  77524. * @returns resulting new vector
  77525. */
  77526. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  77527. /**
  77528. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  77529. * @param otherVector vector to devide with
  77530. * @returns resulting new vector
  77531. */
  77532. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  77533. /**
  77534. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  77535. * @param otherVector vector to devide with
  77536. * @param result vector to store the result
  77537. * @returns the current Vector4.
  77538. */
  77539. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77540. /**
  77541. * Divides the current Vector3 coordinates by the given ones.
  77542. * @param otherVector vector to devide with
  77543. * @returns the updated Vector3.
  77544. */
  77545. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77546. /**
  77547. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  77548. * @param other defines the second operand
  77549. * @returns the current updated Vector4
  77550. */
  77551. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77552. /**
  77553. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  77554. * @param other defines the second operand
  77555. * @returns the current updated Vector4
  77556. */
  77557. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77558. /**
  77559. * Gets a new Vector4 from current Vector4 floored values
  77560. * @returns a new Vector4
  77561. */
  77562. floor(): Vector4;
  77563. /**
  77564. * Gets a new Vector4 from current Vector3 floored values
  77565. * @returns a new Vector4
  77566. */
  77567. fract(): Vector4;
  77568. /**
  77569. * Returns the Vector4 length (float).
  77570. * @returns the length
  77571. */
  77572. length(): number;
  77573. /**
  77574. * Returns the Vector4 squared length (float).
  77575. * @returns the length squared
  77576. */
  77577. lengthSquared(): number;
  77578. /**
  77579. * Normalizes in place the Vector4.
  77580. * @returns the updated Vector4.
  77581. */
  77582. normalize(): Vector4;
  77583. /**
  77584. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  77585. * @returns this converted to a new vector3
  77586. */
  77587. toVector3(): Vector3;
  77588. /**
  77589. * Returns a new Vector4 copied from the current one.
  77590. * @returns the new cloned vector
  77591. */
  77592. clone(): Vector4;
  77593. /**
  77594. * Updates the current Vector4 with the given one coordinates.
  77595. * @param source the source vector to copy from
  77596. * @returns the updated Vector4.
  77597. */
  77598. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77599. /**
  77600. * Updates the current Vector4 coordinates with the given floats.
  77601. * @param x float to copy from
  77602. * @param y float to copy from
  77603. * @param z float to copy from
  77604. * @param w float to copy from
  77605. * @returns the updated Vector4.
  77606. */
  77607. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77608. /**
  77609. * Updates the current Vector4 coordinates with the given floats.
  77610. * @param x float to set from
  77611. * @param y float to set from
  77612. * @param z float to set from
  77613. * @param w float to set from
  77614. * @returns the updated Vector4.
  77615. */
  77616. set(x: number, y: number, z: number, w: number): Vector4;
  77617. /**
  77618. * Copies the given float to the current Vector3 coordinates
  77619. * @param v defines the x, y, z and w coordinates of the operand
  77620. * @returns the current updated Vector3
  77621. */
  77622. setAll(v: number): Vector4;
  77623. /**
  77624. * Returns a new Vector4 set from the starting index of the given array.
  77625. * @param array the array to pull values from
  77626. * @param offset the offset into the array to start at
  77627. * @returns the new vector
  77628. */
  77629. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77630. /**
  77631. * Updates the given vector "result" from the starting index of the given array.
  77632. * @param array the array to pull values from
  77633. * @param offset the offset into the array to start at
  77634. * @param result the vector to store the result in
  77635. */
  77636. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77637. /**
  77638. * Updates the given vector "result" from the starting index of the given Float32Array.
  77639. * @param array the array to pull values from
  77640. * @param offset the offset into the array to start at
  77641. * @param result the vector to store the result in
  77642. */
  77643. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77644. /**
  77645. * Updates the given vector "result" coordinates from the given floats.
  77646. * @param x float to set from
  77647. * @param y float to set from
  77648. * @param z float to set from
  77649. * @param w float to set from
  77650. * @param result the vector to the floats in
  77651. */
  77652. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77653. /**
  77654. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77655. * @returns the new vector
  77656. */
  77657. static Zero(): Vector4;
  77658. /**
  77659. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77660. * @returns the new vector
  77661. */
  77662. static One(): Vector4;
  77663. /**
  77664. * Returns a new normalized Vector4 from the given one.
  77665. * @param vector the vector to normalize
  77666. * @returns the vector
  77667. */
  77668. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77669. /**
  77670. * Updates the given vector "result" from the normalization of the given one.
  77671. * @param vector the vector to normalize
  77672. * @param result the vector to store the result in
  77673. */
  77674. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77675. /**
  77676. * Returns a vector with the minimum values from the left and right vectors
  77677. * @param left left vector to minimize
  77678. * @param right right vector to minimize
  77679. * @returns a new vector with the minimum of the left and right vector values
  77680. */
  77681. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77682. /**
  77683. * Returns a vector with the maximum values from the left and right vectors
  77684. * @param left left vector to maximize
  77685. * @param right right vector to maximize
  77686. * @returns a new vector with the maximum of the left and right vector values
  77687. */
  77688. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77689. /**
  77690. * Returns the distance (float) between the vectors "value1" and "value2".
  77691. * @param value1 value to calulate the distance between
  77692. * @param value2 value to calulate the distance between
  77693. * @return the distance between the two vectors
  77694. */
  77695. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77696. /**
  77697. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77698. * @param value1 value to calulate the distance between
  77699. * @param value2 value to calulate the distance between
  77700. * @return the distance between the two vectors squared
  77701. */
  77702. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77703. /**
  77704. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77705. * @param value1 value to calulate the center between
  77706. * @param value2 value to calulate the center between
  77707. * @return the center between the two vectors
  77708. */
  77709. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77710. /**
  77711. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77712. * This methods computes transformed normalized direction vectors only.
  77713. * @param vector the vector to transform
  77714. * @param transformation the transformation matrix to apply
  77715. * @returns the new vector
  77716. */
  77717. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77718. /**
  77719. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77720. * This methods computes transformed normalized direction vectors only.
  77721. * @param vector the vector to transform
  77722. * @param transformation the transformation matrix to apply
  77723. * @param result the vector to store the result in
  77724. */
  77725. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77726. /**
  77727. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77728. * This methods computes transformed normalized direction vectors only.
  77729. * @param x value to transform
  77730. * @param y value to transform
  77731. * @param z value to transform
  77732. * @param w value to transform
  77733. * @param transformation the transformation matrix to apply
  77734. * @param result the vector to store the results in
  77735. */
  77736. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77737. /**
  77738. * Creates a new Vector4 from a Vector3
  77739. * @param source defines the source data
  77740. * @param w defines the 4th component (default is 0)
  77741. * @returns a new Vector4
  77742. */
  77743. static FromVector3(source: Vector3, w?: number): Vector4;
  77744. }
  77745. /**
  77746. * Class used to store quaternion data
  77747. * @see https://en.wikipedia.org/wiki/Quaternion
  77748. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77749. */
  77750. export class Quaternion {
  77751. /** defines the first component (0 by default) */
  77752. x: number;
  77753. /** defines the second component (0 by default) */
  77754. y: number;
  77755. /** defines the third component (0 by default) */
  77756. z: number;
  77757. /** defines the fourth component (1.0 by default) */
  77758. w: number;
  77759. /**
  77760. * Creates a new Quaternion from the given floats
  77761. * @param x defines the first component (0 by default)
  77762. * @param y defines the second component (0 by default)
  77763. * @param z defines the third component (0 by default)
  77764. * @param w defines the fourth component (1.0 by default)
  77765. */
  77766. constructor(
  77767. /** defines the first component (0 by default) */
  77768. x?: number,
  77769. /** defines the second component (0 by default) */
  77770. y?: number,
  77771. /** defines the third component (0 by default) */
  77772. z?: number,
  77773. /** defines the fourth component (1.0 by default) */
  77774. w?: number);
  77775. /**
  77776. * Gets a string representation for the current quaternion
  77777. * @returns a string with the Quaternion coordinates
  77778. */
  77779. toString(): string;
  77780. /**
  77781. * Gets the class name of the quaternion
  77782. * @returns the string "Quaternion"
  77783. */
  77784. getClassName(): string;
  77785. /**
  77786. * Gets a hash code for this quaternion
  77787. * @returns the quaternion hash code
  77788. */
  77789. getHashCode(): number;
  77790. /**
  77791. * Copy the quaternion to an array
  77792. * @returns a new array populated with 4 elements from the quaternion coordinates
  77793. */
  77794. asArray(): number[];
  77795. /**
  77796. * Check if two quaternions are equals
  77797. * @param otherQuaternion defines the second operand
  77798. * @return true if the current quaternion and the given one coordinates are strictly equals
  77799. */
  77800. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77801. /**
  77802. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77803. * @param otherQuaternion defines the other quaternion
  77804. * @param epsilon defines the minimal distance to consider equality
  77805. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77806. */
  77807. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77808. /**
  77809. * Clone the current quaternion
  77810. * @returns a new quaternion copied from the current one
  77811. */
  77812. clone(): Quaternion;
  77813. /**
  77814. * Copy a quaternion to the current one
  77815. * @param other defines the other quaternion
  77816. * @returns the updated current quaternion
  77817. */
  77818. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77819. /**
  77820. * Updates the current quaternion with the given float coordinates
  77821. * @param x defines the x coordinate
  77822. * @param y defines the y coordinate
  77823. * @param z defines the z coordinate
  77824. * @param w defines the w coordinate
  77825. * @returns the updated current quaternion
  77826. */
  77827. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77828. /**
  77829. * Updates the current quaternion from the given float coordinates
  77830. * @param x defines the x coordinate
  77831. * @param y defines the y coordinate
  77832. * @param z defines the z coordinate
  77833. * @param w defines the w coordinate
  77834. * @returns the updated current quaternion
  77835. */
  77836. set(x: number, y: number, z: number, w: number): Quaternion;
  77837. /**
  77838. * Adds two quaternions
  77839. * @param other defines the second operand
  77840. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77841. */
  77842. add(other: DeepImmutable<Quaternion>): Quaternion;
  77843. /**
  77844. * Add a quaternion to the current one
  77845. * @param other defines the quaternion to add
  77846. * @returns the current quaternion
  77847. */
  77848. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77849. /**
  77850. * Subtract two quaternions
  77851. * @param other defines the second operand
  77852. * @returns a new quaternion as the subtraction result of the given one from the current one
  77853. */
  77854. subtract(other: Quaternion): Quaternion;
  77855. /**
  77856. * Multiplies the current quaternion by a scale factor
  77857. * @param value defines the scale factor
  77858. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77859. */
  77860. scale(value: number): Quaternion;
  77861. /**
  77862. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77863. * @param scale defines the scale factor
  77864. * @param result defines the Quaternion object where to store the result
  77865. * @returns the unmodified current quaternion
  77866. */
  77867. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77868. /**
  77869. * Multiplies in place the current quaternion by a scale factor
  77870. * @param value defines the scale factor
  77871. * @returns the current modified quaternion
  77872. */
  77873. scaleInPlace(value: number): Quaternion;
  77874. /**
  77875. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77876. * @param scale defines the scale factor
  77877. * @param result defines the Quaternion object where to store the result
  77878. * @returns the unmodified current quaternion
  77879. */
  77880. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77881. /**
  77882. * Multiplies two quaternions
  77883. * @param q1 defines the second operand
  77884. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77885. */
  77886. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77887. /**
  77888. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77889. * @param q1 defines the second operand
  77890. * @param result defines the target quaternion
  77891. * @returns the current quaternion
  77892. */
  77893. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77894. /**
  77895. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77896. * @param q1 defines the second operand
  77897. * @returns the currentupdated quaternion
  77898. */
  77899. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77900. /**
  77901. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77902. * @param ref defines the target quaternion
  77903. * @returns the current quaternion
  77904. */
  77905. conjugateToRef(ref: Quaternion): Quaternion;
  77906. /**
  77907. * Conjugates in place (1-q) the current quaternion
  77908. * @returns the current updated quaternion
  77909. */
  77910. conjugateInPlace(): Quaternion;
  77911. /**
  77912. * Conjugates in place (1-q) the current quaternion
  77913. * @returns a new quaternion
  77914. */
  77915. conjugate(): Quaternion;
  77916. /**
  77917. * Gets length of current quaternion
  77918. * @returns the quaternion length (float)
  77919. */
  77920. length(): number;
  77921. /**
  77922. * Normalize in place the current quaternion
  77923. * @returns the current updated quaternion
  77924. */
  77925. normalize(): Quaternion;
  77926. /**
  77927. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77928. * @param order is a reserved parameter and is ignore for now
  77929. * @returns a new Vector3 containing the Euler angles
  77930. */
  77931. toEulerAngles(order?: string): Vector3;
  77932. /**
  77933. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77934. * @param result defines the vector which will be filled with the Euler angles
  77935. * @param order is a reserved parameter and is ignore for now
  77936. * @returns the current unchanged quaternion
  77937. */
  77938. toEulerAnglesToRef(result: Vector3): Quaternion;
  77939. /**
  77940. * Updates the given rotation matrix with the current quaternion values
  77941. * @param result defines the target matrix
  77942. * @returns the current unchanged quaternion
  77943. */
  77944. toRotationMatrix(result: Matrix): Quaternion;
  77945. /**
  77946. * Updates the current quaternion from the given rotation matrix values
  77947. * @param matrix defines the source matrix
  77948. * @returns the current updated quaternion
  77949. */
  77950. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77951. /**
  77952. * Creates a new quaternion from a rotation matrix
  77953. * @param matrix defines the source matrix
  77954. * @returns a new quaternion created from the given rotation matrix values
  77955. */
  77956. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77957. /**
  77958. * Updates the given quaternion with the given rotation matrix values
  77959. * @param matrix defines the source matrix
  77960. * @param result defines the target quaternion
  77961. */
  77962. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77963. /**
  77964. * Returns the dot product (float) between the quaternions "left" and "right"
  77965. * @param left defines the left operand
  77966. * @param right defines the right operand
  77967. * @returns the dot product
  77968. */
  77969. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77970. /**
  77971. * Checks if the two quaternions are close to each other
  77972. * @param quat0 defines the first quaternion to check
  77973. * @param quat1 defines the second quaternion to check
  77974. * @returns true if the two quaternions are close to each other
  77975. */
  77976. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77977. /**
  77978. * Creates an empty quaternion
  77979. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77980. */
  77981. static Zero(): Quaternion;
  77982. /**
  77983. * Inverse a given quaternion
  77984. * @param q defines the source quaternion
  77985. * @returns a new quaternion as the inverted current quaternion
  77986. */
  77987. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77988. /**
  77989. * Inverse a given quaternion
  77990. * @param q defines the source quaternion
  77991. * @param result the quaternion the result will be stored in
  77992. * @returns the result quaternion
  77993. */
  77994. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77995. /**
  77996. * Creates an identity quaternion
  77997. * @returns the identity quaternion
  77998. */
  77999. static Identity(): Quaternion;
  78000. /**
  78001. * Gets a boolean indicating if the given quaternion is identity
  78002. * @param quaternion defines the quaternion to check
  78003. * @returns true if the quaternion is identity
  78004. */
  78005. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  78006. /**
  78007. * Creates a quaternion from a rotation around an axis
  78008. * @param axis defines the axis to use
  78009. * @param angle defines the angle to use
  78010. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  78011. */
  78012. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  78013. /**
  78014. * Creates a rotation around an axis and stores it into the given quaternion
  78015. * @param axis defines the axis to use
  78016. * @param angle defines the angle to use
  78017. * @param result defines the target quaternion
  78018. * @returns the target quaternion
  78019. */
  78020. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  78021. /**
  78022. * Creates a new quaternion from data stored into an array
  78023. * @param array defines the data source
  78024. * @param offset defines the offset in the source array where the data starts
  78025. * @returns a new quaternion
  78026. */
  78027. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  78028. /**
  78029. * Updates the given quaternion "result" from the starting index of the given array.
  78030. * @param array the array to pull values from
  78031. * @param offset the offset into the array to start at
  78032. * @param result the quaternion to store the result in
  78033. */
  78034. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  78035. /**
  78036. * Create a quaternion from Euler rotation angles
  78037. * @param x Pitch
  78038. * @param y Yaw
  78039. * @param z Roll
  78040. * @returns the new Quaternion
  78041. */
  78042. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  78043. /**
  78044. * Updates a quaternion from Euler rotation angles
  78045. * @param x Pitch
  78046. * @param y Yaw
  78047. * @param z Roll
  78048. * @param result the quaternion to store the result
  78049. * @returns the updated quaternion
  78050. */
  78051. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  78052. /**
  78053. * Create a quaternion from Euler rotation vector
  78054. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78055. * @returns the new Quaternion
  78056. */
  78057. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  78058. /**
  78059. * Updates a quaternion from Euler rotation vector
  78060. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78061. * @param result the quaternion to store the result
  78062. * @returns the updated quaternion
  78063. */
  78064. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  78065. /**
  78066. * Creates a new quaternion from the given Euler float angles (y, x, z)
  78067. * @param yaw defines the rotation around Y axis
  78068. * @param pitch defines the rotation around X axis
  78069. * @param roll defines the rotation around Z axis
  78070. * @returns the new quaternion
  78071. */
  78072. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  78073. /**
  78074. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  78075. * @param yaw defines the rotation around Y axis
  78076. * @param pitch defines the rotation around X axis
  78077. * @param roll defines the rotation around Z axis
  78078. * @param result defines the target quaternion
  78079. */
  78080. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  78081. /**
  78082. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  78083. * @param alpha defines the rotation around first axis
  78084. * @param beta defines the rotation around second axis
  78085. * @param gamma defines the rotation around third axis
  78086. * @returns the new quaternion
  78087. */
  78088. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  78089. /**
  78090. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  78091. * @param alpha defines the rotation around first axis
  78092. * @param beta defines the rotation around second axis
  78093. * @param gamma defines the rotation around third axis
  78094. * @param result defines the target quaternion
  78095. */
  78096. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  78097. /**
  78098. * 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)
  78099. * @param axis1 defines the first axis
  78100. * @param axis2 defines the second axis
  78101. * @param axis3 defines the third axis
  78102. * @returns the new quaternion
  78103. */
  78104. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  78105. /**
  78106. * 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
  78107. * @param axis1 defines the first axis
  78108. * @param axis2 defines the second axis
  78109. * @param axis3 defines the third axis
  78110. * @param ref defines the target quaternion
  78111. */
  78112. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  78113. /**
  78114. * Interpolates between two quaternions
  78115. * @param left defines first quaternion
  78116. * @param right defines second quaternion
  78117. * @param amount defines the gradient to use
  78118. * @returns the new interpolated quaternion
  78119. */
  78120. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78121. /**
  78122. * Interpolates between two quaternions and stores it into a target quaternion
  78123. * @param left defines first quaternion
  78124. * @param right defines second quaternion
  78125. * @param amount defines the gradient to use
  78126. * @param result defines the target quaternion
  78127. */
  78128. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  78129. /**
  78130. * Interpolate between two quaternions using Hermite interpolation
  78131. * @param value1 defines first quaternion
  78132. * @param tangent1 defines the incoming tangent
  78133. * @param value2 defines second quaternion
  78134. * @param tangent2 defines the outgoing tangent
  78135. * @param amount defines the target quaternion
  78136. * @returns the new interpolated quaternion
  78137. */
  78138. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78139. }
  78140. /**
  78141. * Class used to store matrix data (4x4)
  78142. */
  78143. export class Matrix {
  78144. private static _updateFlagSeed;
  78145. private static _identityReadOnly;
  78146. private _isIdentity;
  78147. private _isIdentityDirty;
  78148. private _isIdentity3x2;
  78149. private _isIdentity3x2Dirty;
  78150. /**
  78151. * Gets the update flag of the matrix which is an unique number for the matrix.
  78152. * It will be incremented every time the matrix data change.
  78153. * You can use it to speed the comparison between two versions of the same matrix.
  78154. */
  78155. updateFlag: number;
  78156. private readonly _m;
  78157. /**
  78158. * Gets the internal data of the matrix
  78159. */
  78160. get m(): DeepImmutable<Float32Array>;
  78161. /** @hidden */
  78162. _markAsUpdated(): void;
  78163. /** @hidden */
  78164. private _updateIdentityStatus;
  78165. /**
  78166. * Creates an empty matrix (filled with zeros)
  78167. */
  78168. constructor();
  78169. /**
  78170. * Check if the current matrix is identity
  78171. * @returns true is the matrix is the identity matrix
  78172. */
  78173. isIdentity(): boolean;
  78174. /**
  78175. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  78176. * @returns true is the matrix is the identity matrix
  78177. */
  78178. isIdentityAs3x2(): boolean;
  78179. /**
  78180. * Gets the determinant of the matrix
  78181. * @returns the matrix determinant
  78182. */
  78183. determinant(): number;
  78184. /**
  78185. * Returns the matrix as a Float32Array
  78186. * @returns the matrix underlying array
  78187. */
  78188. toArray(): DeepImmutable<Float32Array>;
  78189. /**
  78190. * Returns the matrix as a Float32Array
  78191. * @returns the matrix underlying array.
  78192. */
  78193. asArray(): DeepImmutable<Float32Array>;
  78194. /**
  78195. * Inverts the current matrix in place
  78196. * @returns the current inverted matrix
  78197. */
  78198. invert(): Matrix;
  78199. /**
  78200. * Sets all the matrix elements to zero
  78201. * @returns the current matrix
  78202. */
  78203. reset(): Matrix;
  78204. /**
  78205. * Adds the current matrix with a second one
  78206. * @param other defines the matrix to add
  78207. * @returns a new matrix as the addition of the current matrix and the given one
  78208. */
  78209. add(other: DeepImmutable<Matrix>): Matrix;
  78210. /**
  78211. * Sets the given matrix "result" to the addition of the current matrix and the given one
  78212. * @param other defines the matrix to add
  78213. * @param result defines the target matrix
  78214. * @returns the current matrix
  78215. */
  78216. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78217. /**
  78218. * Adds in place the given matrix to the current matrix
  78219. * @param other defines the second operand
  78220. * @returns the current updated matrix
  78221. */
  78222. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  78223. /**
  78224. * Sets the given matrix to the current inverted Matrix
  78225. * @param other defines the target matrix
  78226. * @returns the unmodified current matrix
  78227. */
  78228. invertToRef(other: Matrix): Matrix;
  78229. /**
  78230. * add a value at the specified position in the current Matrix
  78231. * @param index the index of the value within the matrix. between 0 and 15.
  78232. * @param value the value to be added
  78233. * @returns the current updated matrix
  78234. */
  78235. addAtIndex(index: number, value: number): Matrix;
  78236. /**
  78237. * mutiply the specified position in the current Matrix by a value
  78238. * @param index the index of the value within the matrix. between 0 and 15.
  78239. * @param value the value to be added
  78240. * @returns the current updated matrix
  78241. */
  78242. multiplyAtIndex(index: number, value: number): Matrix;
  78243. /**
  78244. * Inserts the translation vector (using 3 floats) in the current matrix
  78245. * @param x defines the 1st component of the translation
  78246. * @param y defines the 2nd component of the translation
  78247. * @param z defines the 3rd component of the translation
  78248. * @returns the current updated matrix
  78249. */
  78250. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78251. /**
  78252. * Adds the translation vector (using 3 floats) in the current matrix
  78253. * @param x defines the 1st component of the translation
  78254. * @param y defines the 2nd component of the translation
  78255. * @param z defines the 3rd component of the translation
  78256. * @returns the current updated matrix
  78257. */
  78258. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78259. /**
  78260. * Inserts the translation vector in the current matrix
  78261. * @param vector3 defines the translation to insert
  78262. * @returns the current updated matrix
  78263. */
  78264. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  78265. /**
  78266. * Gets the translation value of the current matrix
  78267. * @returns a new Vector3 as the extracted translation from the matrix
  78268. */
  78269. getTranslation(): Vector3;
  78270. /**
  78271. * Fill a Vector3 with the extracted translation from the matrix
  78272. * @param result defines the Vector3 where to store the translation
  78273. * @returns the current matrix
  78274. */
  78275. getTranslationToRef(result: Vector3): Matrix;
  78276. /**
  78277. * Remove rotation and scaling part from the matrix
  78278. * @returns the updated matrix
  78279. */
  78280. removeRotationAndScaling(): Matrix;
  78281. /**
  78282. * Multiply two matrices
  78283. * @param other defines the second operand
  78284. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  78285. */
  78286. multiply(other: DeepImmutable<Matrix>): Matrix;
  78287. /**
  78288. * Copy the current matrix from the given one
  78289. * @param other defines the source matrix
  78290. * @returns the current updated matrix
  78291. */
  78292. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  78293. /**
  78294. * Populates the given array from the starting index with the current matrix values
  78295. * @param array defines the target array
  78296. * @param offset defines the offset in the target array where to start storing values
  78297. * @returns the current matrix
  78298. */
  78299. copyToArray(array: Float32Array, offset?: number): Matrix;
  78300. /**
  78301. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  78302. * @param other defines the second operand
  78303. * @param result defines the matrix where to store the multiplication
  78304. * @returns the current matrix
  78305. */
  78306. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78307. /**
  78308. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  78309. * @param other defines the second operand
  78310. * @param result defines the array where to store the multiplication
  78311. * @param offset defines the offset in the target array where to start storing values
  78312. * @returns the current matrix
  78313. */
  78314. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  78315. /**
  78316. * Check equality between this matrix and a second one
  78317. * @param value defines the second matrix to compare
  78318. * @returns true is the current matrix and the given one values are strictly equal
  78319. */
  78320. equals(value: DeepImmutable<Matrix>): boolean;
  78321. /**
  78322. * Clone the current matrix
  78323. * @returns a new matrix from the current matrix
  78324. */
  78325. clone(): Matrix;
  78326. /**
  78327. * Returns the name of the current matrix class
  78328. * @returns the string "Matrix"
  78329. */
  78330. getClassName(): string;
  78331. /**
  78332. * Gets the hash code of the current matrix
  78333. * @returns the hash code
  78334. */
  78335. getHashCode(): number;
  78336. /**
  78337. * Decomposes the current Matrix into a translation, rotation and scaling components
  78338. * @param scale defines the scale vector3 given as a reference to update
  78339. * @param rotation defines the rotation quaternion given as a reference to update
  78340. * @param translation defines the translation vector3 given as a reference to update
  78341. * @returns true if operation was successful
  78342. */
  78343. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  78344. /**
  78345. * Gets specific row of the matrix
  78346. * @param index defines the number of the row to get
  78347. * @returns the index-th row of the current matrix as a new Vector4
  78348. */
  78349. getRow(index: number): Nullable<Vector4>;
  78350. /**
  78351. * Sets the index-th row of the current matrix to the vector4 values
  78352. * @param index defines the number of the row to set
  78353. * @param row defines the target vector4
  78354. * @returns the updated current matrix
  78355. */
  78356. setRow(index: number, row: Vector4): Matrix;
  78357. /**
  78358. * Compute the transpose of the matrix
  78359. * @returns the new transposed matrix
  78360. */
  78361. transpose(): Matrix;
  78362. /**
  78363. * Compute the transpose of the matrix and store it in a given matrix
  78364. * @param result defines the target matrix
  78365. * @returns the current matrix
  78366. */
  78367. transposeToRef(result: Matrix): Matrix;
  78368. /**
  78369. * Sets the index-th row of the current matrix with the given 4 x float values
  78370. * @param index defines the row index
  78371. * @param x defines the x component to set
  78372. * @param y defines the y component to set
  78373. * @param z defines the z component to set
  78374. * @param w defines the w component to set
  78375. * @returns the updated current matrix
  78376. */
  78377. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  78378. /**
  78379. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  78380. * @param scale defines the scale factor
  78381. * @returns a new matrix
  78382. */
  78383. scale(scale: number): Matrix;
  78384. /**
  78385. * Scale the current matrix values by a factor to a given result matrix
  78386. * @param scale defines the scale factor
  78387. * @param result defines the matrix to store the result
  78388. * @returns the current matrix
  78389. */
  78390. scaleToRef(scale: number, result: Matrix): Matrix;
  78391. /**
  78392. * Scale the current matrix values by a factor and add the result to a given matrix
  78393. * @param scale defines the scale factor
  78394. * @param result defines the Matrix to store the result
  78395. * @returns the current matrix
  78396. */
  78397. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  78398. /**
  78399. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  78400. * @param ref matrix to store the result
  78401. */
  78402. toNormalMatrix(ref: Matrix): void;
  78403. /**
  78404. * Gets only rotation part of the current matrix
  78405. * @returns a new matrix sets to the extracted rotation matrix from the current one
  78406. */
  78407. getRotationMatrix(): Matrix;
  78408. /**
  78409. * Extracts the rotation matrix from the current one and sets it as the given "result"
  78410. * @param result defines the target matrix to store data to
  78411. * @returns the current matrix
  78412. */
  78413. getRotationMatrixToRef(result: Matrix): Matrix;
  78414. /**
  78415. * Toggles model matrix from being right handed to left handed in place and vice versa
  78416. */
  78417. toggleModelMatrixHandInPlace(): void;
  78418. /**
  78419. * Toggles projection matrix from being right handed to left handed in place and vice versa
  78420. */
  78421. toggleProjectionMatrixHandInPlace(): void;
  78422. /**
  78423. * Creates a matrix from an array
  78424. * @param array defines the source array
  78425. * @param offset defines an offset in the source array
  78426. * @returns a new Matrix set from the starting index of the given array
  78427. */
  78428. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  78429. /**
  78430. * Copy the content of an array into a given matrix
  78431. * @param array defines the source array
  78432. * @param offset defines an offset in the source array
  78433. * @param result defines the target matrix
  78434. */
  78435. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  78436. /**
  78437. * Stores an array into a matrix after having multiplied each component by a given factor
  78438. * @param array defines the source array
  78439. * @param offset defines the offset in the source array
  78440. * @param scale defines the scaling factor
  78441. * @param result defines the target matrix
  78442. */
  78443. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  78444. /**
  78445. * Gets an identity matrix that must not be updated
  78446. */
  78447. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  78448. /**
  78449. * Stores a list of values (16) inside a given matrix
  78450. * @param initialM11 defines 1st value of 1st row
  78451. * @param initialM12 defines 2nd value of 1st row
  78452. * @param initialM13 defines 3rd value of 1st row
  78453. * @param initialM14 defines 4th value of 1st row
  78454. * @param initialM21 defines 1st value of 2nd row
  78455. * @param initialM22 defines 2nd value of 2nd row
  78456. * @param initialM23 defines 3rd value of 2nd row
  78457. * @param initialM24 defines 4th value of 2nd row
  78458. * @param initialM31 defines 1st value of 3rd row
  78459. * @param initialM32 defines 2nd value of 3rd row
  78460. * @param initialM33 defines 3rd value of 3rd row
  78461. * @param initialM34 defines 4th value of 3rd row
  78462. * @param initialM41 defines 1st value of 4th row
  78463. * @param initialM42 defines 2nd value of 4th row
  78464. * @param initialM43 defines 3rd value of 4th row
  78465. * @param initialM44 defines 4th value of 4th row
  78466. * @param result defines the target matrix
  78467. */
  78468. 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;
  78469. /**
  78470. * Creates new matrix from a list of values (16)
  78471. * @param initialM11 defines 1st value of 1st row
  78472. * @param initialM12 defines 2nd value of 1st row
  78473. * @param initialM13 defines 3rd value of 1st row
  78474. * @param initialM14 defines 4th value of 1st row
  78475. * @param initialM21 defines 1st value of 2nd row
  78476. * @param initialM22 defines 2nd value of 2nd row
  78477. * @param initialM23 defines 3rd value of 2nd row
  78478. * @param initialM24 defines 4th value of 2nd row
  78479. * @param initialM31 defines 1st value of 3rd row
  78480. * @param initialM32 defines 2nd value of 3rd row
  78481. * @param initialM33 defines 3rd value of 3rd row
  78482. * @param initialM34 defines 4th value of 3rd row
  78483. * @param initialM41 defines 1st value of 4th row
  78484. * @param initialM42 defines 2nd value of 4th row
  78485. * @param initialM43 defines 3rd value of 4th row
  78486. * @param initialM44 defines 4th value of 4th row
  78487. * @returns the new matrix
  78488. */
  78489. 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;
  78490. /**
  78491. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78492. * @param scale defines the scale vector3
  78493. * @param rotation defines the rotation quaternion
  78494. * @param translation defines the translation vector3
  78495. * @returns a new matrix
  78496. */
  78497. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  78498. /**
  78499. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78500. * @param scale defines the scale vector3
  78501. * @param rotation defines the rotation quaternion
  78502. * @param translation defines the translation vector3
  78503. * @param result defines the target matrix
  78504. */
  78505. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  78506. /**
  78507. * Creates a new identity matrix
  78508. * @returns a new identity matrix
  78509. */
  78510. static Identity(): Matrix;
  78511. /**
  78512. * Creates a new identity matrix and stores the result in a given matrix
  78513. * @param result defines the target matrix
  78514. */
  78515. static IdentityToRef(result: Matrix): void;
  78516. /**
  78517. * Creates a new zero matrix
  78518. * @returns a new zero matrix
  78519. */
  78520. static Zero(): Matrix;
  78521. /**
  78522. * Creates a new rotation matrix for "angle" radians around the X axis
  78523. * @param angle defines the angle (in radians) to use
  78524. * @return the new matrix
  78525. */
  78526. static RotationX(angle: number): Matrix;
  78527. /**
  78528. * Creates a new matrix as the invert of a given matrix
  78529. * @param source defines the source matrix
  78530. * @returns the new matrix
  78531. */
  78532. static Invert(source: DeepImmutable<Matrix>): Matrix;
  78533. /**
  78534. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  78535. * @param angle defines the angle (in radians) to use
  78536. * @param result defines the target matrix
  78537. */
  78538. static RotationXToRef(angle: number, result: Matrix): void;
  78539. /**
  78540. * Creates a new rotation matrix for "angle" radians around the Y axis
  78541. * @param angle defines the angle (in radians) to use
  78542. * @return the new matrix
  78543. */
  78544. static RotationY(angle: number): Matrix;
  78545. /**
  78546. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  78547. * @param angle defines the angle (in radians) to use
  78548. * @param result defines the target matrix
  78549. */
  78550. static RotationYToRef(angle: number, result: Matrix): void;
  78551. /**
  78552. * Creates a new rotation matrix for "angle" radians around the Z axis
  78553. * @param angle defines the angle (in radians) to use
  78554. * @return the new matrix
  78555. */
  78556. static RotationZ(angle: number): Matrix;
  78557. /**
  78558. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  78559. * @param angle defines the angle (in radians) to use
  78560. * @param result defines the target matrix
  78561. */
  78562. static RotationZToRef(angle: number, result: Matrix): void;
  78563. /**
  78564. * Creates a new rotation matrix for "angle" radians around the given axis
  78565. * @param axis defines the axis to use
  78566. * @param angle defines the angle (in radians) to use
  78567. * @return the new matrix
  78568. */
  78569. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  78570. /**
  78571. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  78572. * @param axis defines the axis to use
  78573. * @param angle defines the angle (in radians) to use
  78574. * @param result defines the target matrix
  78575. */
  78576. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  78577. /**
  78578. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  78579. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  78580. * @param from defines the vector to align
  78581. * @param to defines the vector to align to
  78582. * @param result defines the target matrix
  78583. */
  78584. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  78585. /**
  78586. * Creates a rotation matrix
  78587. * @param yaw defines the yaw angle in radians (Y axis)
  78588. * @param pitch defines the pitch angle in radians (X axis)
  78589. * @param roll defines the roll angle in radians (X axis)
  78590. * @returns the new rotation matrix
  78591. */
  78592. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  78593. /**
  78594. * Creates a rotation matrix and stores it in a given matrix
  78595. * @param yaw defines the yaw angle in radians (Y axis)
  78596. * @param pitch defines the pitch angle in radians (X axis)
  78597. * @param roll defines the roll angle in radians (X axis)
  78598. * @param result defines the target matrix
  78599. */
  78600. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78601. /**
  78602. * Creates a scaling matrix
  78603. * @param x defines the scale factor on X axis
  78604. * @param y defines the scale factor on Y axis
  78605. * @param z defines the scale factor on Z axis
  78606. * @returns the new matrix
  78607. */
  78608. static Scaling(x: number, y: number, z: number): Matrix;
  78609. /**
  78610. * Creates a scaling matrix and stores it in a given matrix
  78611. * @param x defines the scale factor on X axis
  78612. * @param y defines the scale factor on Y axis
  78613. * @param z defines the scale factor on Z axis
  78614. * @param result defines the target matrix
  78615. */
  78616. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78617. /**
  78618. * Creates a translation matrix
  78619. * @param x defines the translation on X axis
  78620. * @param y defines the translation on Y axis
  78621. * @param z defines the translationon Z axis
  78622. * @returns the new matrix
  78623. */
  78624. static Translation(x: number, y: number, z: number): Matrix;
  78625. /**
  78626. * Creates a translation matrix and stores it in a given matrix
  78627. * @param x defines the translation on X axis
  78628. * @param y defines the translation on Y axis
  78629. * @param z defines the translationon Z axis
  78630. * @param result defines the target matrix
  78631. */
  78632. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78633. /**
  78634. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78635. * @param startValue defines the start value
  78636. * @param endValue defines the end value
  78637. * @param gradient defines the gradient factor
  78638. * @returns the new matrix
  78639. */
  78640. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78641. /**
  78642. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78643. * @param startValue defines the start value
  78644. * @param endValue defines the end value
  78645. * @param gradient defines the gradient factor
  78646. * @param result defines the Matrix object where to store data
  78647. */
  78648. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78649. /**
  78650. * Builds a new matrix whose values are computed by:
  78651. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78652. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78653. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78654. * @param startValue defines the first matrix
  78655. * @param endValue defines the second matrix
  78656. * @param gradient defines the gradient between the two matrices
  78657. * @returns the new matrix
  78658. */
  78659. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78660. /**
  78661. * Update a matrix to values which are computed by:
  78662. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78663. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78664. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78665. * @param startValue defines the first matrix
  78666. * @param endValue defines the second matrix
  78667. * @param gradient defines the gradient between the two matrices
  78668. * @param result defines the target matrix
  78669. */
  78670. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78671. /**
  78672. * 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"
  78673. * This function works in left handed mode
  78674. * @param eye defines the final position of the entity
  78675. * @param target defines where the entity should look at
  78676. * @param up defines the up vector for the entity
  78677. * @returns the new matrix
  78678. */
  78679. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78680. /**
  78681. * 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".
  78682. * This function works in left handed mode
  78683. * @param eye defines the final position of the entity
  78684. * @param target defines where the entity should look at
  78685. * @param up defines the up vector for the entity
  78686. * @param result defines the target matrix
  78687. */
  78688. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78689. /**
  78690. * 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"
  78691. * This function works in right handed mode
  78692. * @param eye defines the final position of the entity
  78693. * @param target defines where the entity should look at
  78694. * @param up defines the up vector for the entity
  78695. * @returns the new matrix
  78696. */
  78697. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78698. /**
  78699. * 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".
  78700. * This function works in right handed mode
  78701. * @param eye defines the final position of the entity
  78702. * @param target defines where the entity should look at
  78703. * @param up defines the up vector for the entity
  78704. * @param result defines the target matrix
  78705. */
  78706. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78707. /**
  78708. * Create a left-handed orthographic projection matrix
  78709. * @param width defines the viewport width
  78710. * @param height defines the viewport height
  78711. * @param znear defines the near clip plane
  78712. * @param zfar defines the far clip plane
  78713. * @returns a new matrix as a left-handed orthographic projection matrix
  78714. */
  78715. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78716. /**
  78717. * Store a left-handed orthographic projection to a given matrix
  78718. * @param width defines the viewport width
  78719. * @param height defines the viewport height
  78720. * @param znear defines the near clip plane
  78721. * @param zfar defines the far clip plane
  78722. * @param result defines the target matrix
  78723. */
  78724. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78725. /**
  78726. * Create a left-handed orthographic projection matrix
  78727. * @param left defines the viewport left coordinate
  78728. * @param right defines the viewport right coordinate
  78729. * @param bottom defines the viewport bottom coordinate
  78730. * @param top defines the viewport top coordinate
  78731. * @param znear defines the near clip plane
  78732. * @param zfar defines the far clip plane
  78733. * @returns a new matrix as a left-handed orthographic projection matrix
  78734. */
  78735. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78736. /**
  78737. * Stores a left-handed orthographic projection into a given matrix
  78738. * @param left defines the viewport left coordinate
  78739. * @param right defines the viewport right coordinate
  78740. * @param bottom defines the viewport bottom coordinate
  78741. * @param top defines the viewport top coordinate
  78742. * @param znear defines the near clip plane
  78743. * @param zfar defines the far clip plane
  78744. * @param result defines the target matrix
  78745. */
  78746. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78747. /**
  78748. * Creates a right-handed orthographic projection matrix
  78749. * @param left defines the viewport left coordinate
  78750. * @param right defines the viewport right coordinate
  78751. * @param bottom defines the viewport bottom coordinate
  78752. * @param top defines the viewport top coordinate
  78753. * @param znear defines the near clip plane
  78754. * @param zfar defines the far clip plane
  78755. * @returns a new matrix as a right-handed orthographic projection matrix
  78756. */
  78757. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78758. /**
  78759. * Stores a right-handed orthographic projection into a given matrix
  78760. * @param left defines the viewport left coordinate
  78761. * @param right defines the viewport right coordinate
  78762. * @param bottom defines the viewport bottom coordinate
  78763. * @param top defines the viewport top coordinate
  78764. * @param znear defines the near clip plane
  78765. * @param zfar defines the far clip plane
  78766. * @param result defines the target matrix
  78767. */
  78768. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78769. /**
  78770. * Creates a left-handed perspective projection matrix
  78771. * @param width defines the viewport width
  78772. * @param height defines the viewport height
  78773. * @param znear defines the near clip plane
  78774. * @param zfar defines the far clip plane
  78775. * @returns a new matrix as a left-handed perspective projection matrix
  78776. */
  78777. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78778. /**
  78779. * Creates a left-handed perspective projection matrix
  78780. * @param fov defines the horizontal field of view
  78781. * @param aspect defines the aspect ratio
  78782. * @param znear defines the near clip plane
  78783. * @param zfar defines the far clip plane
  78784. * @returns a new matrix as a left-handed perspective projection matrix
  78785. */
  78786. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78787. /**
  78788. * Stores a left-handed perspective projection into a given matrix
  78789. * @param fov defines the horizontal field of view
  78790. * @param aspect defines the aspect ratio
  78791. * @param znear defines the near clip plane
  78792. * @param zfar defines the far clip plane
  78793. * @param result defines the target matrix
  78794. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78795. */
  78796. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78797. /**
  78798. * Stores a left-handed perspective projection into a given matrix with depth reversed
  78799. * @param fov defines the horizontal field of view
  78800. * @param aspect defines the aspect ratio
  78801. * @param znear defines the near clip plane
  78802. * @param zfar not used as infinity is used as far clip
  78803. * @param result defines the target matrix
  78804. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78805. */
  78806. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78807. /**
  78808. * Creates a right-handed perspective projection matrix
  78809. * @param fov defines the horizontal field of view
  78810. * @param aspect defines the aspect ratio
  78811. * @param znear defines the near clip plane
  78812. * @param zfar defines the far clip plane
  78813. * @returns a new matrix as a right-handed perspective projection matrix
  78814. */
  78815. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78816. /**
  78817. * Stores a right-handed perspective projection into a given matrix
  78818. * @param fov defines the horizontal field of view
  78819. * @param aspect defines the aspect ratio
  78820. * @param znear defines the near clip plane
  78821. * @param zfar defines the far clip plane
  78822. * @param result defines the target matrix
  78823. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78824. */
  78825. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78826. /**
  78827. * Stores a right-handed perspective projection into a given matrix
  78828. * @param fov defines the horizontal field of view
  78829. * @param aspect defines the aspect ratio
  78830. * @param znear defines the near clip plane
  78831. * @param zfar not used as infinity is used as far clip
  78832. * @param result defines the target matrix
  78833. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78834. */
  78835. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78836. /**
  78837. * Stores a perspective projection for WebVR info a given matrix
  78838. * @param fov defines the field of view
  78839. * @param znear defines the near clip plane
  78840. * @param zfar defines the far clip plane
  78841. * @param result defines the target matrix
  78842. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78843. */
  78844. static PerspectiveFovWebVRToRef(fov: {
  78845. upDegrees: number;
  78846. downDegrees: number;
  78847. leftDegrees: number;
  78848. rightDegrees: number;
  78849. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78850. /**
  78851. * Computes a complete transformation matrix
  78852. * @param viewport defines the viewport to use
  78853. * @param world defines the world matrix
  78854. * @param view defines the view matrix
  78855. * @param projection defines the projection matrix
  78856. * @param zmin defines the near clip plane
  78857. * @param zmax defines the far clip plane
  78858. * @returns the transformation matrix
  78859. */
  78860. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78861. /**
  78862. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78863. * @param matrix defines the matrix to use
  78864. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78865. */
  78866. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78867. /**
  78868. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78869. * @param matrix defines the matrix to use
  78870. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78871. */
  78872. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78873. /**
  78874. * Compute the transpose of a given matrix
  78875. * @param matrix defines the matrix to transpose
  78876. * @returns the new matrix
  78877. */
  78878. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78879. /**
  78880. * Compute the transpose of a matrix and store it in a target matrix
  78881. * @param matrix defines the matrix to transpose
  78882. * @param result defines the target matrix
  78883. */
  78884. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78885. /**
  78886. * Computes a reflection matrix from a plane
  78887. * @param plane defines the reflection plane
  78888. * @returns a new matrix
  78889. */
  78890. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78891. /**
  78892. * Computes a reflection matrix from a plane
  78893. * @param plane defines the reflection plane
  78894. * @param result defines the target matrix
  78895. */
  78896. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78897. /**
  78898. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78899. * @param xaxis defines the value of the 1st axis
  78900. * @param yaxis defines the value of the 2nd axis
  78901. * @param zaxis defines the value of the 3rd axis
  78902. * @param result defines the target matrix
  78903. */
  78904. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78905. /**
  78906. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78907. * @param quat defines the quaternion to use
  78908. * @param result defines the target matrix
  78909. */
  78910. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78911. }
  78912. /**
  78913. * @hidden
  78914. */
  78915. export class TmpVectors {
  78916. static Vector2: Vector2[];
  78917. static Vector3: Vector3[];
  78918. static Vector4: Vector4[];
  78919. static Quaternion: Quaternion[];
  78920. static Matrix: Matrix[];
  78921. }
  78922. }
  78923. declare module BABYLON {
  78924. /**
  78925. * Defines potential orientation for back face culling
  78926. */
  78927. export enum Orientation {
  78928. /**
  78929. * Clockwise
  78930. */
  78931. CW = 0,
  78932. /** Counter clockwise */
  78933. CCW = 1
  78934. }
  78935. /** Class used to represent a Bezier curve */
  78936. export class BezierCurve {
  78937. /**
  78938. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78939. * @param t defines the time
  78940. * @param x1 defines the left coordinate on X axis
  78941. * @param y1 defines the left coordinate on Y axis
  78942. * @param x2 defines the right coordinate on X axis
  78943. * @param y2 defines the right coordinate on Y axis
  78944. * @returns the interpolated value
  78945. */
  78946. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78947. }
  78948. /**
  78949. * Defines angle representation
  78950. */
  78951. export class Angle {
  78952. private _radians;
  78953. /**
  78954. * Creates an Angle object of "radians" radians (float).
  78955. * @param radians the angle in radians
  78956. */
  78957. constructor(radians: number);
  78958. /**
  78959. * Get value in degrees
  78960. * @returns the Angle value in degrees (float)
  78961. */
  78962. degrees(): number;
  78963. /**
  78964. * Get value in radians
  78965. * @returns the Angle value in radians (float)
  78966. */
  78967. radians(): number;
  78968. /**
  78969. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78970. * @param a defines first vector
  78971. * @param b defines second vector
  78972. * @returns a new Angle
  78973. */
  78974. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78975. /**
  78976. * Gets a new Angle object from the given float in radians
  78977. * @param radians defines the angle value in radians
  78978. * @returns a new Angle
  78979. */
  78980. static FromRadians(radians: number): Angle;
  78981. /**
  78982. * Gets a new Angle object from the given float in degrees
  78983. * @param degrees defines the angle value in degrees
  78984. * @returns a new Angle
  78985. */
  78986. static FromDegrees(degrees: number): Angle;
  78987. }
  78988. /**
  78989. * This represents an arc in a 2d space.
  78990. */
  78991. export class Arc2 {
  78992. /** Defines the start point of the arc */
  78993. startPoint: Vector2;
  78994. /** Defines the mid point of the arc */
  78995. midPoint: Vector2;
  78996. /** Defines the end point of the arc */
  78997. endPoint: Vector2;
  78998. /**
  78999. * Defines the center point of the arc.
  79000. */
  79001. centerPoint: Vector2;
  79002. /**
  79003. * Defines the radius of the arc.
  79004. */
  79005. radius: number;
  79006. /**
  79007. * Defines the angle of the arc (from mid point to end point).
  79008. */
  79009. angle: Angle;
  79010. /**
  79011. * Defines the start angle of the arc (from start point to middle point).
  79012. */
  79013. startAngle: Angle;
  79014. /**
  79015. * Defines the orientation of the arc (clock wise/counter clock wise).
  79016. */
  79017. orientation: Orientation;
  79018. /**
  79019. * Creates an Arc object from the three given points : start, middle and end.
  79020. * @param startPoint Defines the start point of the arc
  79021. * @param midPoint Defines the midlle point of the arc
  79022. * @param endPoint Defines the end point of the arc
  79023. */
  79024. constructor(
  79025. /** Defines the start point of the arc */
  79026. startPoint: Vector2,
  79027. /** Defines the mid point of the arc */
  79028. midPoint: Vector2,
  79029. /** Defines the end point of the arc */
  79030. endPoint: Vector2);
  79031. }
  79032. /**
  79033. * Represents a 2D path made up of multiple 2D points
  79034. */
  79035. export class Path2 {
  79036. private _points;
  79037. private _length;
  79038. /**
  79039. * If the path start and end point are the same
  79040. */
  79041. closed: boolean;
  79042. /**
  79043. * Creates a Path2 object from the starting 2D coordinates x and y.
  79044. * @param x the starting points x value
  79045. * @param y the starting points y value
  79046. */
  79047. constructor(x: number, y: number);
  79048. /**
  79049. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  79050. * @param x the added points x value
  79051. * @param y the added points y value
  79052. * @returns the updated Path2.
  79053. */
  79054. addLineTo(x: number, y: number): Path2;
  79055. /**
  79056. * 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.
  79057. * @param midX middle point x value
  79058. * @param midY middle point y value
  79059. * @param endX end point x value
  79060. * @param endY end point y value
  79061. * @param numberOfSegments (default: 36)
  79062. * @returns the updated Path2.
  79063. */
  79064. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  79065. /**
  79066. * Closes the Path2.
  79067. * @returns the Path2.
  79068. */
  79069. close(): Path2;
  79070. /**
  79071. * Gets the sum of the distance between each sequential point in the path
  79072. * @returns the Path2 total length (float).
  79073. */
  79074. length(): number;
  79075. /**
  79076. * Gets the points which construct the path
  79077. * @returns the Path2 internal array of points.
  79078. */
  79079. getPoints(): Vector2[];
  79080. /**
  79081. * Retreives the point at the distance aways from the starting point
  79082. * @param normalizedLengthPosition the length along the path to retreive the point from
  79083. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  79084. */
  79085. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  79086. /**
  79087. * Creates a new path starting from an x and y position
  79088. * @param x starting x value
  79089. * @param y starting y value
  79090. * @returns a new Path2 starting at the coordinates (x, y).
  79091. */
  79092. static StartingAt(x: number, y: number): Path2;
  79093. }
  79094. /**
  79095. * Represents a 3D path made up of multiple 3D points
  79096. */
  79097. export class Path3D {
  79098. /**
  79099. * an array of Vector3, the curve axis of the Path3D
  79100. */
  79101. path: Vector3[];
  79102. private _curve;
  79103. private _distances;
  79104. private _tangents;
  79105. private _normals;
  79106. private _binormals;
  79107. private _raw;
  79108. private _alignTangentsWithPath;
  79109. private readonly _pointAtData;
  79110. /**
  79111. * new Path3D(path, normal, raw)
  79112. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  79113. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  79114. * @param path an array of Vector3, the curve axis of the Path3D
  79115. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  79116. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  79117. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  79118. */
  79119. constructor(
  79120. /**
  79121. * an array of Vector3, the curve axis of the Path3D
  79122. */
  79123. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  79124. /**
  79125. * Returns the Path3D array of successive Vector3 designing its curve.
  79126. * @returns the Path3D array of successive Vector3 designing its curve.
  79127. */
  79128. getCurve(): Vector3[];
  79129. /**
  79130. * Returns the Path3D array of successive Vector3 designing its curve.
  79131. * @returns the Path3D array of successive Vector3 designing its curve.
  79132. */
  79133. getPoints(): Vector3[];
  79134. /**
  79135. * @returns the computed length (float) of the path.
  79136. */
  79137. length(): number;
  79138. /**
  79139. * Returns an array populated with tangent vectors on each Path3D curve point.
  79140. * @returns an array populated with tangent vectors on each Path3D curve point.
  79141. */
  79142. getTangents(): Vector3[];
  79143. /**
  79144. * Returns an array populated with normal vectors on each Path3D curve point.
  79145. * @returns an array populated with normal vectors on each Path3D curve point.
  79146. */
  79147. getNormals(): Vector3[];
  79148. /**
  79149. * Returns an array populated with binormal vectors on each Path3D curve point.
  79150. * @returns an array populated with binormal vectors on each Path3D curve point.
  79151. */
  79152. getBinormals(): Vector3[];
  79153. /**
  79154. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  79155. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  79156. */
  79157. getDistances(): number[];
  79158. /**
  79159. * Returns an interpolated point along this path
  79160. * @param position the position of the point along this path, from 0.0 to 1.0
  79161. * @returns a new Vector3 as the point
  79162. */
  79163. getPointAt(position: number): Vector3;
  79164. /**
  79165. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79166. * @param position the position of the point along this path, from 0.0 to 1.0
  79167. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  79168. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  79169. */
  79170. getTangentAt(position: number, interpolated?: boolean): Vector3;
  79171. /**
  79172. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79173. * @param position the position of the point along this path, from 0.0 to 1.0
  79174. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  79175. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  79176. */
  79177. getNormalAt(position: number, interpolated?: boolean): Vector3;
  79178. /**
  79179. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  79180. * @param position the position of the point along this path, from 0.0 to 1.0
  79181. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  79182. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  79183. */
  79184. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  79185. /**
  79186. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  79187. * @param position the position of the point along this path, from 0.0 to 1.0
  79188. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  79189. */
  79190. getDistanceAt(position: number): number;
  79191. /**
  79192. * Returns the array index of the previous point of an interpolated point along this path
  79193. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79194. * @returns the array index
  79195. */
  79196. getPreviousPointIndexAt(position: number): number;
  79197. /**
  79198. * 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)
  79199. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79200. * @returns the sub position
  79201. */
  79202. getSubPositionAt(position: number): number;
  79203. /**
  79204. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  79205. * @param target the vector of which to get the closest position to
  79206. * @returns the position of the closest virtual point on this path to the target vector
  79207. */
  79208. getClosestPositionTo(target: Vector3): number;
  79209. /**
  79210. * Returns a sub path (slice) of this path
  79211. * @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
  79212. * @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
  79213. * @returns a sub path (slice) of this path
  79214. */
  79215. slice(start?: number, end?: number): Path3D;
  79216. /**
  79217. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79218. * @param path path which all values are copied into the curves points
  79219. * @param firstNormal which should be projected onto the curve
  79220. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  79221. * @returns the same object updated.
  79222. */
  79223. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  79224. private _compute;
  79225. private _getFirstNonNullVector;
  79226. private _getLastNonNullVector;
  79227. private _normalVector;
  79228. /**
  79229. * Updates the point at data for an interpolated point along this curve
  79230. * @param position the position of the point along this curve, from 0.0 to 1.0
  79231. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  79232. * @returns the (updated) point at data
  79233. */
  79234. private _updatePointAtData;
  79235. /**
  79236. * Updates the point at data from the specified parameters
  79237. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  79238. * @param point the interpolated point
  79239. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  79240. */
  79241. private _setPointAtData;
  79242. /**
  79243. * Updates the point at interpolation matrix for the tangents, normals and binormals
  79244. */
  79245. private _updateInterpolationMatrix;
  79246. }
  79247. /**
  79248. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79249. * A Curve3 is designed from a series of successive Vector3.
  79250. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79251. */
  79252. export class Curve3 {
  79253. private _points;
  79254. private _length;
  79255. /**
  79256. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79257. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79258. * @param v1 (Vector3) the control point
  79259. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79260. * @param nbPoints (integer) the wanted number of points in the curve
  79261. * @returns the created Curve3
  79262. */
  79263. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79264. /**
  79265. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79266. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79267. * @param v1 (Vector3) the first control point
  79268. * @param v2 (Vector3) the second control point
  79269. * @param v3 (Vector3) the end point of the Cubic Bezier
  79270. * @param nbPoints (integer) the wanted number of points in the curve
  79271. * @returns the created Curve3
  79272. */
  79273. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79274. /**
  79275. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79276. * @param p1 (Vector3) the origin point of the Hermite Spline
  79277. * @param t1 (Vector3) the tangent vector at the origin point
  79278. * @param p2 (Vector3) the end point of the Hermite Spline
  79279. * @param t2 (Vector3) the tangent vector at the end point
  79280. * @param nbPoints (integer) the wanted number of points in the curve
  79281. * @returns the created Curve3
  79282. */
  79283. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79284. /**
  79285. * Returns a Curve3 object along a CatmullRom Spline curve :
  79286. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79287. * @param nbPoints (integer) the wanted number of points between each curve control points
  79288. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79289. * @returns the created Curve3
  79290. */
  79291. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  79292. /**
  79293. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79294. * A Curve3 is designed from a series of successive Vector3.
  79295. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79296. * @param points points which make up the curve
  79297. */
  79298. constructor(points: Vector3[]);
  79299. /**
  79300. * @returns the Curve3 stored array of successive Vector3
  79301. */
  79302. getPoints(): Vector3[];
  79303. /**
  79304. * @returns the computed length (float) of the curve.
  79305. */
  79306. length(): number;
  79307. /**
  79308. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79309. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79310. * curveA and curveB keep unchanged.
  79311. * @param curve the curve to continue from this curve
  79312. * @returns the newly constructed curve
  79313. */
  79314. continue(curve: DeepImmutable<Curve3>): Curve3;
  79315. private _computeLength;
  79316. }
  79317. }
  79318. declare module BABYLON {
  79319. /**
  79320. * This represents the main contract an easing function should follow.
  79321. * Easing functions are used throughout the animation system.
  79322. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79323. */
  79324. export interface IEasingFunction {
  79325. /**
  79326. * Given an input gradient between 0 and 1, this returns the corrseponding value
  79327. * of the easing function.
  79328. * The link below provides some of the most common examples of easing functions.
  79329. * @see https://easings.net/
  79330. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79331. * @returns the corresponding value on the curve defined by the easing function
  79332. */
  79333. ease(gradient: number): number;
  79334. }
  79335. /**
  79336. * Base class used for every default easing function.
  79337. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79338. */
  79339. export class EasingFunction implements IEasingFunction {
  79340. /**
  79341. * Interpolation follows the mathematical formula associated with the easing function.
  79342. */
  79343. static readonly EASINGMODE_EASEIN: number;
  79344. /**
  79345. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  79346. */
  79347. static readonly EASINGMODE_EASEOUT: number;
  79348. /**
  79349. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  79350. */
  79351. static readonly EASINGMODE_EASEINOUT: number;
  79352. private _easingMode;
  79353. /**
  79354. * Sets the easing mode of the current function.
  79355. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  79356. */
  79357. setEasingMode(easingMode: number): void;
  79358. /**
  79359. * Gets the current easing mode.
  79360. * @returns the easing mode
  79361. */
  79362. getEasingMode(): number;
  79363. /**
  79364. * @hidden
  79365. */
  79366. easeInCore(gradient: number): number;
  79367. /**
  79368. * Given an input gradient between 0 and 1, this returns the corresponding value
  79369. * of the easing function.
  79370. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79371. * @returns the corresponding value on the curve defined by the easing function
  79372. */
  79373. ease(gradient: number): number;
  79374. }
  79375. /**
  79376. * Easing function with a circle shape (see link below).
  79377. * @see https://easings.net/#easeInCirc
  79378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79379. */
  79380. export class CircleEase extends EasingFunction implements IEasingFunction {
  79381. /** @hidden */
  79382. easeInCore(gradient: number): number;
  79383. }
  79384. /**
  79385. * Easing function with a ease back shape (see link below).
  79386. * @see https://easings.net/#easeInBack
  79387. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79388. */
  79389. export class BackEase extends EasingFunction implements IEasingFunction {
  79390. /** Defines the amplitude of the function */
  79391. amplitude: number;
  79392. /**
  79393. * Instantiates a back ease easing
  79394. * @see https://easings.net/#easeInBack
  79395. * @param amplitude Defines the amplitude of the function
  79396. */
  79397. constructor(
  79398. /** Defines the amplitude of the function */
  79399. amplitude?: number);
  79400. /** @hidden */
  79401. easeInCore(gradient: number): number;
  79402. }
  79403. /**
  79404. * Easing function with a bouncing shape (see link below).
  79405. * @see https://easings.net/#easeInBounce
  79406. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79407. */
  79408. export class BounceEase extends EasingFunction implements IEasingFunction {
  79409. /** Defines the number of bounces */
  79410. bounces: number;
  79411. /** Defines the amplitude of the bounce */
  79412. bounciness: number;
  79413. /**
  79414. * Instantiates a bounce easing
  79415. * @see https://easings.net/#easeInBounce
  79416. * @param bounces Defines the number of bounces
  79417. * @param bounciness Defines the amplitude of the bounce
  79418. */
  79419. constructor(
  79420. /** Defines the number of bounces */
  79421. bounces?: number,
  79422. /** Defines the amplitude of the bounce */
  79423. bounciness?: number);
  79424. /** @hidden */
  79425. easeInCore(gradient: number): number;
  79426. }
  79427. /**
  79428. * Easing function with a power of 3 shape (see link below).
  79429. * @see https://easings.net/#easeInCubic
  79430. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79431. */
  79432. export class CubicEase extends EasingFunction implements IEasingFunction {
  79433. /** @hidden */
  79434. easeInCore(gradient: number): number;
  79435. }
  79436. /**
  79437. * Easing function with an elastic shape (see link below).
  79438. * @see https://easings.net/#easeInElastic
  79439. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79440. */
  79441. export class ElasticEase extends EasingFunction implements IEasingFunction {
  79442. /** Defines the number of oscillations*/
  79443. oscillations: number;
  79444. /** Defines the amplitude of the oscillations*/
  79445. springiness: number;
  79446. /**
  79447. * Instantiates an elastic easing function
  79448. * @see https://easings.net/#easeInElastic
  79449. * @param oscillations Defines the number of oscillations
  79450. * @param springiness Defines the amplitude of the oscillations
  79451. */
  79452. constructor(
  79453. /** Defines the number of oscillations*/
  79454. oscillations?: number,
  79455. /** Defines the amplitude of the oscillations*/
  79456. springiness?: number);
  79457. /** @hidden */
  79458. easeInCore(gradient: number): number;
  79459. }
  79460. /**
  79461. * Easing function with an exponential shape (see link below).
  79462. * @see https://easings.net/#easeInExpo
  79463. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79464. */
  79465. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  79466. /** Defines the exponent of the function */
  79467. exponent: number;
  79468. /**
  79469. * Instantiates an exponential easing function
  79470. * @see https://easings.net/#easeInExpo
  79471. * @param exponent Defines the exponent of the function
  79472. */
  79473. constructor(
  79474. /** Defines the exponent of the function */
  79475. exponent?: number);
  79476. /** @hidden */
  79477. easeInCore(gradient: number): number;
  79478. }
  79479. /**
  79480. * Easing function with a power shape (see link below).
  79481. * @see https://easings.net/#easeInQuad
  79482. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79483. */
  79484. export class PowerEase extends EasingFunction implements IEasingFunction {
  79485. /** Defines the power of the function */
  79486. power: number;
  79487. /**
  79488. * Instantiates an power base easing function
  79489. * @see https://easings.net/#easeInQuad
  79490. * @param power Defines the power of the function
  79491. */
  79492. constructor(
  79493. /** Defines the power of the function */
  79494. power?: number);
  79495. /** @hidden */
  79496. easeInCore(gradient: number): number;
  79497. }
  79498. /**
  79499. * Easing function with a power of 2 shape (see link below).
  79500. * @see https://easings.net/#easeInQuad
  79501. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79502. */
  79503. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  79504. /** @hidden */
  79505. easeInCore(gradient: number): number;
  79506. }
  79507. /**
  79508. * Easing function with a power of 4 shape (see link below).
  79509. * @see https://easings.net/#easeInQuart
  79510. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79511. */
  79512. export class QuarticEase extends EasingFunction implements IEasingFunction {
  79513. /** @hidden */
  79514. easeInCore(gradient: number): number;
  79515. }
  79516. /**
  79517. * Easing function with a power of 5 shape (see link below).
  79518. * @see https://easings.net/#easeInQuint
  79519. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79520. */
  79521. export class QuinticEase extends EasingFunction implements IEasingFunction {
  79522. /** @hidden */
  79523. easeInCore(gradient: number): number;
  79524. }
  79525. /**
  79526. * Easing function with a sin shape (see link below).
  79527. * @see https://easings.net/#easeInSine
  79528. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79529. */
  79530. export class SineEase extends EasingFunction implements IEasingFunction {
  79531. /** @hidden */
  79532. easeInCore(gradient: number): number;
  79533. }
  79534. /**
  79535. * Easing function with a bezier shape (see link below).
  79536. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79538. */
  79539. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  79540. /** Defines the x component of the start tangent in the bezier curve */
  79541. x1: number;
  79542. /** Defines the y component of the start tangent in the bezier curve */
  79543. y1: number;
  79544. /** Defines the x component of the end tangent in the bezier curve */
  79545. x2: number;
  79546. /** Defines the y component of the end tangent in the bezier curve */
  79547. y2: number;
  79548. /**
  79549. * Instantiates a bezier function
  79550. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79551. * @param x1 Defines the x component of the start tangent in the bezier curve
  79552. * @param y1 Defines the y component of the start tangent in the bezier curve
  79553. * @param x2 Defines the x component of the end tangent in the bezier curve
  79554. * @param y2 Defines the y component of the end tangent in the bezier curve
  79555. */
  79556. constructor(
  79557. /** Defines the x component of the start tangent in the bezier curve */
  79558. x1?: number,
  79559. /** Defines the y component of the start tangent in the bezier curve */
  79560. y1?: number,
  79561. /** Defines the x component of the end tangent in the bezier curve */
  79562. x2?: number,
  79563. /** Defines the y component of the end tangent in the bezier curve */
  79564. y2?: number);
  79565. /** @hidden */
  79566. easeInCore(gradient: number): number;
  79567. }
  79568. }
  79569. declare module BABYLON {
  79570. /**
  79571. * Class used to hold a RBG color
  79572. */
  79573. export class Color3 {
  79574. /**
  79575. * Defines the red component (between 0 and 1, default is 0)
  79576. */
  79577. r: number;
  79578. /**
  79579. * Defines the green component (between 0 and 1, default is 0)
  79580. */
  79581. g: number;
  79582. /**
  79583. * Defines the blue component (between 0 and 1, default is 0)
  79584. */
  79585. b: number;
  79586. /**
  79587. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  79588. * @param r defines the red component (between 0 and 1, default is 0)
  79589. * @param g defines the green component (between 0 and 1, default is 0)
  79590. * @param b defines the blue component (between 0 and 1, default is 0)
  79591. */
  79592. constructor(
  79593. /**
  79594. * Defines the red component (between 0 and 1, default is 0)
  79595. */
  79596. r?: number,
  79597. /**
  79598. * Defines the green component (between 0 and 1, default is 0)
  79599. */
  79600. g?: number,
  79601. /**
  79602. * Defines the blue component (between 0 and 1, default is 0)
  79603. */
  79604. b?: number);
  79605. /**
  79606. * Creates a string with the Color3 current values
  79607. * @returns the string representation of the Color3 object
  79608. */
  79609. toString(): string;
  79610. /**
  79611. * Returns the string "Color3"
  79612. * @returns "Color3"
  79613. */
  79614. getClassName(): string;
  79615. /**
  79616. * Compute the Color3 hash code
  79617. * @returns an unique number that can be used to hash Color3 objects
  79618. */
  79619. getHashCode(): number;
  79620. /**
  79621. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79622. * @param array defines the array where to store the r,g,b components
  79623. * @param index defines an optional index in the target array to define where to start storing values
  79624. * @returns the current Color3 object
  79625. */
  79626. toArray(array: FloatArray, index?: number): Color3;
  79627. /**
  79628. * Returns a new Color4 object from the current Color3 and the given alpha
  79629. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79630. * @returns a new Color4 object
  79631. */
  79632. toColor4(alpha?: number): Color4;
  79633. /**
  79634. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79635. * @returns the new array
  79636. */
  79637. asArray(): number[];
  79638. /**
  79639. * Returns the luminance value
  79640. * @returns a float value
  79641. */
  79642. toLuminance(): number;
  79643. /**
  79644. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79645. * @param otherColor defines the second operand
  79646. * @returns the new Color3 object
  79647. */
  79648. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79649. /**
  79650. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79651. * @param otherColor defines the second operand
  79652. * @param result defines the Color3 object where to store the result
  79653. * @returns the current Color3
  79654. */
  79655. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79656. /**
  79657. * Determines equality between Color3 objects
  79658. * @param otherColor defines the second operand
  79659. * @returns true if the rgb values are equal to the given ones
  79660. */
  79661. equals(otherColor: DeepImmutable<Color3>): boolean;
  79662. /**
  79663. * Determines equality between the current Color3 object and a set of r,b,g values
  79664. * @param r defines the red component to check
  79665. * @param g defines the green component to check
  79666. * @param b defines the blue component to check
  79667. * @returns true if the rgb values are equal to the given ones
  79668. */
  79669. equalsFloats(r: number, g: number, b: number): boolean;
  79670. /**
  79671. * Multiplies in place each rgb value by scale
  79672. * @param scale defines the scaling factor
  79673. * @returns the updated Color3
  79674. */
  79675. scale(scale: number): Color3;
  79676. /**
  79677. * Multiplies the rgb values by scale and stores the result into "result"
  79678. * @param scale defines the scaling factor
  79679. * @param result defines the Color3 object where to store the result
  79680. * @returns the unmodified current Color3
  79681. */
  79682. scaleToRef(scale: number, result: Color3): Color3;
  79683. /**
  79684. * Scale the current Color3 values by a factor and add the result to a given Color3
  79685. * @param scale defines the scale factor
  79686. * @param result defines color to store the result into
  79687. * @returns the unmodified current Color3
  79688. */
  79689. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79690. /**
  79691. * Clamps the rgb values by the min and max values and stores the result into "result"
  79692. * @param min defines minimum clamping value (default is 0)
  79693. * @param max defines maximum clamping value (default is 1)
  79694. * @param result defines color to store the result into
  79695. * @returns the original Color3
  79696. */
  79697. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79698. /**
  79699. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79700. * @param otherColor defines the second operand
  79701. * @returns the new Color3
  79702. */
  79703. add(otherColor: DeepImmutable<Color3>): Color3;
  79704. /**
  79705. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79706. * @param otherColor defines the second operand
  79707. * @param result defines Color3 object to store the result into
  79708. * @returns the unmodified current Color3
  79709. */
  79710. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79711. /**
  79712. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79713. * @param otherColor defines the second operand
  79714. * @returns the new Color3
  79715. */
  79716. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79717. /**
  79718. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79719. * @param otherColor defines the second operand
  79720. * @param result defines Color3 object to store the result into
  79721. * @returns the unmodified current Color3
  79722. */
  79723. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79724. /**
  79725. * Copy the current object
  79726. * @returns a new Color3 copied the current one
  79727. */
  79728. clone(): Color3;
  79729. /**
  79730. * Copies the rgb values from the source in the current Color3
  79731. * @param source defines the source Color3 object
  79732. * @returns the updated Color3 object
  79733. */
  79734. copyFrom(source: DeepImmutable<Color3>): Color3;
  79735. /**
  79736. * Updates the Color3 rgb values from the given floats
  79737. * @param r defines the red component to read from
  79738. * @param g defines the green component to read from
  79739. * @param b defines the blue component to read from
  79740. * @returns the current Color3 object
  79741. */
  79742. copyFromFloats(r: number, g: number, b: number): Color3;
  79743. /**
  79744. * Updates the Color3 rgb values from the given floats
  79745. * @param r defines the red component to read from
  79746. * @param g defines the green component to read from
  79747. * @param b defines the blue component to read from
  79748. * @returns the current Color3 object
  79749. */
  79750. set(r: number, g: number, b: number): Color3;
  79751. /**
  79752. * Compute the Color3 hexadecimal code as a string
  79753. * @returns a string containing the hexadecimal representation of the Color3 object
  79754. */
  79755. toHexString(): string;
  79756. /**
  79757. * Computes a new Color3 converted from the current one to linear space
  79758. * @returns a new Color3 object
  79759. */
  79760. toLinearSpace(): Color3;
  79761. /**
  79762. * Converts current color in rgb space to HSV values
  79763. * @returns a new color3 representing the HSV values
  79764. */
  79765. toHSV(): Color3;
  79766. /**
  79767. * Converts current color in rgb space to HSV values
  79768. * @param result defines the Color3 where to store the HSV values
  79769. */
  79770. toHSVToRef(result: Color3): void;
  79771. /**
  79772. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79773. * @param convertedColor defines the Color3 object where to store the linear space version
  79774. * @returns the unmodified Color3
  79775. */
  79776. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79777. /**
  79778. * Computes a new Color3 converted from the current one to gamma space
  79779. * @returns a new Color3 object
  79780. */
  79781. toGammaSpace(): Color3;
  79782. /**
  79783. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79784. * @param convertedColor defines the Color3 object where to store the gamma space version
  79785. * @returns the unmodified Color3
  79786. */
  79787. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79788. private static _BlackReadOnly;
  79789. /**
  79790. * Convert Hue, saturation and value to a Color3 (RGB)
  79791. * @param hue defines the hue
  79792. * @param saturation defines the saturation
  79793. * @param value defines the value
  79794. * @param result defines the Color3 where to store the RGB values
  79795. */
  79796. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79797. /**
  79798. * Creates a new Color3 from the string containing valid hexadecimal values
  79799. * @param hex defines a string containing valid hexadecimal values
  79800. * @returns a new Color3 object
  79801. */
  79802. static FromHexString(hex: string): Color3;
  79803. /**
  79804. * Creates a new Color3 from the starting index of the given array
  79805. * @param array defines the source array
  79806. * @param offset defines an offset in the source array
  79807. * @returns a new Color3 object
  79808. */
  79809. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79810. /**
  79811. * Creates a new Color3 from integer values (< 256)
  79812. * @param r defines the red component to read from (value between 0 and 255)
  79813. * @param g defines the green component to read from (value between 0 and 255)
  79814. * @param b defines the blue component to read from (value between 0 and 255)
  79815. * @returns a new Color3 object
  79816. */
  79817. static FromInts(r: number, g: number, b: number): Color3;
  79818. /**
  79819. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79820. * @param start defines the start Color3 value
  79821. * @param end defines the end Color3 value
  79822. * @param amount defines the gradient value between start and end
  79823. * @returns a new Color3 object
  79824. */
  79825. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79826. /**
  79827. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79828. * @param left defines the start value
  79829. * @param right defines the end value
  79830. * @param amount defines the gradient factor
  79831. * @param result defines the Color3 object where to store the result
  79832. */
  79833. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79834. /**
  79835. * Returns a Color3 value containing a red color
  79836. * @returns a new Color3 object
  79837. */
  79838. static Red(): Color3;
  79839. /**
  79840. * Returns a Color3 value containing a green color
  79841. * @returns a new Color3 object
  79842. */
  79843. static Green(): Color3;
  79844. /**
  79845. * Returns a Color3 value containing a blue color
  79846. * @returns a new Color3 object
  79847. */
  79848. static Blue(): Color3;
  79849. /**
  79850. * Returns a Color3 value containing a black color
  79851. * @returns a new Color3 object
  79852. */
  79853. static Black(): Color3;
  79854. /**
  79855. * Gets a Color3 value containing a black color that must not be updated
  79856. */
  79857. static get BlackReadOnly(): DeepImmutable<Color3>;
  79858. /**
  79859. * Returns a Color3 value containing a white color
  79860. * @returns a new Color3 object
  79861. */
  79862. static White(): Color3;
  79863. /**
  79864. * Returns a Color3 value containing a purple color
  79865. * @returns a new Color3 object
  79866. */
  79867. static Purple(): Color3;
  79868. /**
  79869. * Returns a Color3 value containing a magenta color
  79870. * @returns a new Color3 object
  79871. */
  79872. static Magenta(): Color3;
  79873. /**
  79874. * Returns a Color3 value containing a yellow color
  79875. * @returns a new Color3 object
  79876. */
  79877. static Yellow(): Color3;
  79878. /**
  79879. * Returns a Color3 value containing a gray color
  79880. * @returns a new Color3 object
  79881. */
  79882. static Gray(): Color3;
  79883. /**
  79884. * Returns a Color3 value containing a teal color
  79885. * @returns a new Color3 object
  79886. */
  79887. static Teal(): Color3;
  79888. /**
  79889. * Returns a Color3 value containing a random color
  79890. * @returns a new Color3 object
  79891. */
  79892. static Random(): Color3;
  79893. }
  79894. /**
  79895. * Class used to hold a RBGA color
  79896. */
  79897. export class Color4 {
  79898. /**
  79899. * Defines the red component (between 0 and 1, default is 0)
  79900. */
  79901. r: number;
  79902. /**
  79903. * Defines the green component (between 0 and 1, default is 0)
  79904. */
  79905. g: number;
  79906. /**
  79907. * Defines the blue component (between 0 and 1, default is 0)
  79908. */
  79909. b: number;
  79910. /**
  79911. * Defines the alpha component (between 0 and 1, default is 1)
  79912. */
  79913. a: number;
  79914. /**
  79915. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79916. * @param r defines the red component (between 0 and 1, default is 0)
  79917. * @param g defines the green component (between 0 and 1, default is 0)
  79918. * @param b defines the blue component (between 0 and 1, default is 0)
  79919. * @param a defines the alpha component (between 0 and 1, default is 1)
  79920. */
  79921. constructor(
  79922. /**
  79923. * Defines the red component (between 0 and 1, default is 0)
  79924. */
  79925. r?: number,
  79926. /**
  79927. * Defines the green component (between 0 and 1, default is 0)
  79928. */
  79929. g?: number,
  79930. /**
  79931. * Defines the blue component (between 0 and 1, default is 0)
  79932. */
  79933. b?: number,
  79934. /**
  79935. * Defines the alpha component (between 0 and 1, default is 1)
  79936. */
  79937. a?: number);
  79938. /**
  79939. * Adds in place the given Color4 values to the current Color4 object
  79940. * @param right defines the second operand
  79941. * @returns the current updated Color4 object
  79942. */
  79943. addInPlace(right: DeepImmutable<Color4>): Color4;
  79944. /**
  79945. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79946. * @returns the new array
  79947. */
  79948. asArray(): number[];
  79949. /**
  79950. * Stores from the starting index in the given array the Color4 successive values
  79951. * @param array defines the array where to store the r,g,b components
  79952. * @param index defines an optional index in the target array to define where to start storing values
  79953. * @returns the current Color4 object
  79954. */
  79955. toArray(array: number[], index?: number): Color4;
  79956. /**
  79957. * Determines equality between Color4 objects
  79958. * @param otherColor defines the second operand
  79959. * @returns true if the rgba values are equal to the given ones
  79960. */
  79961. equals(otherColor: DeepImmutable<Color4>): boolean;
  79962. /**
  79963. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79964. * @param right defines the second operand
  79965. * @returns a new Color4 object
  79966. */
  79967. add(right: DeepImmutable<Color4>): Color4;
  79968. /**
  79969. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79970. * @param right defines the second operand
  79971. * @returns a new Color4 object
  79972. */
  79973. subtract(right: DeepImmutable<Color4>): Color4;
  79974. /**
  79975. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79976. * @param right defines the second operand
  79977. * @param result defines the Color4 object where to store the result
  79978. * @returns the current Color4 object
  79979. */
  79980. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79981. /**
  79982. * Creates a new Color4 with the current Color4 values multiplied by scale
  79983. * @param scale defines the scaling factor to apply
  79984. * @returns a new Color4 object
  79985. */
  79986. scale(scale: number): Color4;
  79987. /**
  79988. * Multiplies the current Color4 values by scale and stores the result in "result"
  79989. * @param scale defines the scaling factor to apply
  79990. * @param result defines the Color4 object where to store the result
  79991. * @returns the current unmodified Color4
  79992. */
  79993. scaleToRef(scale: number, result: Color4): Color4;
  79994. /**
  79995. * Scale the current Color4 values by a factor and add the result to a given Color4
  79996. * @param scale defines the scale factor
  79997. * @param result defines the Color4 object where to store the result
  79998. * @returns the unmodified current Color4
  79999. */
  80000. scaleAndAddToRef(scale: number, result: Color4): Color4;
  80001. /**
  80002. * Clamps the rgb values by the min and max values and stores the result into "result"
  80003. * @param min defines minimum clamping value (default is 0)
  80004. * @param max defines maximum clamping value (default is 1)
  80005. * @param result defines color to store the result into.
  80006. * @returns the cuurent Color4
  80007. */
  80008. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  80009. /**
  80010. * Multipy an Color4 value by another and return a new Color4 object
  80011. * @param color defines the Color4 value to multiply by
  80012. * @returns a new Color4 object
  80013. */
  80014. multiply(color: Color4): Color4;
  80015. /**
  80016. * Multipy a Color4 value by another and push the result in a reference value
  80017. * @param color defines the Color4 value to multiply by
  80018. * @param result defines the Color4 to fill the result in
  80019. * @returns the result Color4
  80020. */
  80021. multiplyToRef(color: Color4, result: Color4): Color4;
  80022. /**
  80023. * Creates a string with the Color4 current values
  80024. * @returns the string representation of the Color4 object
  80025. */
  80026. toString(): string;
  80027. /**
  80028. * Returns the string "Color4"
  80029. * @returns "Color4"
  80030. */
  80031. getClassName(): string;
  80032. /**
  80033. * Compute the Color4 hash code
  80034. * @returns an unique number that can be used to hash Color4 objects
  80035. */
  80036. getHashCode(): number;
  80037. /**
  80038. * Creates a new Color4 copied from the current one
  80039. * @returns a new Color4 object
  80040. */
  80041. clone(): Color4;
  80042. /**
  80043. * Copies the given Color4 values into the current one
  80044. * @param source defines the source Color4 object
  80045. * @returns the current updated Color4 object
  80046. */
  80047. copyFrom(source: Color4): Color4;
  80048. /**
  80049. * Copies the given float values into the current one
  80050. * @param r defines the red component to read from
  80051. * @param g defines the green component to read from
  80052. * @param b defines the blue component to read from
  80053. * @param a defines the alpha component to read from
  80054. * @returns the current updated Color4 object
  80055. */
  80056. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  80057. /**
  80058. * Copies the given float values into the current one
  80059. * @param r defines the red component to read from
  80060. * @param g defines the green component to read from
  80061. * @param b defines the blue component to read from
  80062. * @param a defines the alpha component to read from
  80063. * @returns the current updated Color4 object
  80064. */
  80065. set(r: number, g: number, b: number, a: number): Color4;
  80066. /**
  80067. * Compute the Color4 hexadecimal code as a string
  80068. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  80069. * @returns a string containing the hexadecimal representation of the Color4 object
  80070. */
  80071. toHexString(returnAsColor3?: boolean): string;
  80072. /**
  80073. * Computes a new Color4 converted from the current one to linear space
  80074. * @returns a new Color4 object
  80075. */
  80076. toLinearSpace(): Color4;
  80077. /**
  80078. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  80079. * @param convertedColor defines the Color4 object where to store the linear space version
  80080. * @returns the unmodified Color4
  80081. */
  80082. toLinearSpaceToRef(convertedColor: Color4): Color4;
  80083. /**
  80084. * Computes a new Color4 converted from the current one to gamma space
  80085. * @returns a new Color4 object
  80086. */
  80087. toGammaSpace(): Color4;
  80088. /**
  80089. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  80090. * @param convertedColor defines the Color4 object where to store the gamma space version
  80091. * @returns the unmodified Color4
  80092. */
  80093. toGammaSpaceToRef(convertedColor: Color4): Color4;
  80094. /**
  80095. * Creates a new Color4 from the string containing valid hexadecimal values
  80096. * @param hex defines a string containing valid hexadecimal values
  80097. * @returns a new Color4 object
  80098. */
  80099. static FromHexString(hex: string): Color4;
  80100. /**
  80101. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80102. * @param left defines the start value
  80103. * @param right defines the end value
  80104. * @param amount defines the gradient factor
  80105. * @returns a new Color4 object
  80106. */
  80107. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  80108. /**
  80109. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80110. * @param left defines the start value
  80111. * @param right defines the end value
  80112. * @param amount defines the gradient factor
  80113. * @param result defines the Color4 object where to store data
  80114. */
  80115. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  80116. /**
  80117. * Creates a new Color4 from a Color3 and an alpha value
  80118. * @param color3 defines the source Color3 to read from
  80119. * @param alpha defines the alpha component (1.0 by default)
  80120. * @returns a new Color4 object
  80121. */
  80122. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  80123. /**
  80124. * Creates a new Color4 from the starting index element of the given array
  80125. * @param array defines the source array to read from
  80126. * @param offset defines the offset in the source array
  80127. * @returns a new Color4 object
  80128. */
  80129. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  80130. /**
  80131. * Creates a new Color3 from integer values (< 256)
  80132. * @param r defines the red component to read from (value between 0 and 255)
  80133. * @param g defines the green component to read from (value between 0 and 255)
  80134. * @param b defines the blue component to read from (value between 0 and 255)
  80135. * @param a defines the alpha component to read from (value between 0 and 255)
  80136. * @returns a new Color3 object
  80137. */
  80138. static FromInts(r: number, g: number, b: number, a: number): Color4;
  80139. /**
  80140. * Check the content of a given array and convert it to an array containing RGBA data
  80141. * If the original array was already containing count * 4 values then it is returned directly
  80142. * @param colors defines the array to check
  80143. * @param count defines the number of RGBA data to expect
  80144. * @returns an array containing count * 4 values (RGBA)
  80145. */
  80146. static CheckColors4(colors: number[], count: number): number[];
  80147. }
  80148. /**
  80149. * @hidden
  80150. */
  80151. export class TmpColors {
  80152. static Color3: Color3[];
  80153. static Color4: Color4[];
  80154. }
  80155. }
  80156. declare module BABYLON {
  80157. /**
  80158. * Defines an interface which represents an animation key frame
  80159. */
  80160. export interface IAnimationKey {
  80161. /**
  80162. * Frame of the key frame
  80163. */
  80164. frame: number;
  80165. /**
  80166. * Value at the specifies key frame
  80167. */
  80168. value: any;
  80169. /**
  80170. * The input tangent for the cubic hermite spline
  80171. */
  80172. inTangent?: any;
  80173. /**
  80174. * The output tangent for the cubic hermite spline
  80175. */
  80176. outTangent?: any;
  80177. /**
  80178. * The animation interpolation type
  80179. */
  80180. interpolation?: AnimationKeyInterpolation;
  80181. }
  80182. /**
  80183. * Enum for the animation key frame interpolation type
  80184. */
  80185. export enum AnimationKeyInterpolation {
  80186. /**
  80187. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  80188. */
  80189. STEP = 1
  80190. }
  80191. }
  80192. declare module BABYLON {
  80193. /**
  80194. * Represents the range of an animation
  80195. */
  80196. export class AnimationRange {
  80197. /**The name of the animation range**/
  80198. name: string;
  80199. /**The starting frame of the animation */
  80200. from: number;
  80201. /**The ending frame of the animation*/
  80202. to: number;
  80203. /**
  80204. * Initializes the range of an animation
  80205. * @param name The name of the animation range
  80206. * @param from The starting frame of the animation
  80207. * @param to The ending frame of the animation
  80208. */
  80209. constructor(
  80210. /**The name of the animation range**/
  80211. name: string,
  80212. /**The starting frame of the animation */
  80213. from: number,
  80214. /**The ending frame of the animation*/
  80215. to: number);
  80216. /**
  80217. * Makes a copy of the animation range
  80218. * @returns A copy of the animation range
  80219. */
  80220. clone(): AnimationRange;
  80221. }
  80222. }
  80223. declare module BABYLON {
  80224. /**
  80225. * Composed of a frame, and an action function
  80226. */
  80227. export class AnimationEvent {
  80228. /** The frame for which the event is triggered **/
  80229. frame: number;
  80230. /** The event to perform when triggered **/
  80231. action: (currentFrame: number) => void;
  80232. /** Specifies if the event should be triggered only once**/
  80233. onlyOnce?: boolean | undefined;
  80234. /**
  80235. * Specifies if the animation event is done
  80236. */
  80237. isDone: boolean;
  80238. /**
  80239. * Initializes the animation event
  80240. * @param frame The frame for which the event is triggered
  80241. * @param action The event to perform when triggered
  80242. * @param onlyOnce Specifies if the event should be triggered only once
  80243. */
  80244. constructor(
  80245. /** The frame for which the event is triggered **/
  80246. frame: number,
  80247. /** The event to perform when triggered **/
  80248. action: (currentFrame: number) => void,
  80249. /** Specifies if the event should be triggered only once**/
  80250. onlyOnce?: boolean | undefined);
  80251. /** @hidden */
  80252. _clone(): AnimationEvent;
  80253. }
  80254. }
  80255. declare module BABYLON {
  80256. /**
  80257. * Interface used to define a behavior
  80258. */
  80259. export interface Behavior<T> {
  80260. /** gets or sets behavior's name */
  80261. name: string;
  80262. /**
  80263. * Function called when the behavior needs to be initialized (after attaching it to a target)
  80264. */
  80265. init(): void;
  80266. /**
  80267. * Called when the behavior is attached to a target
  80268. * @param target defines the target where the behavior is attached to
  80269. */
  80270. attach(target: T): void;
  80271. /**
  80272. * Called when the behavior is detached from its target
  80273. */
  80274. detach(): void;
  80275. }
  80276. /**
  80277. * Interface implemented by classes supporting behaviors
  80278. */
  80279. export interface IBehaviorAware<T> {
  80280. /**
  80281. * Attach a behavior
  80282. * @param behavior defines the behavior to attach
  80283. * @returns the current host
  80284. */
  80285. addBehavior(behavior: Behavior<T>): T;
  80286. /**
  80287. * Remove a behavior from the current object
  80288. * @param behavior defines the behavior to detach
  80289. * @returns the current host
  80290. */
  80291. removeBehavior(behavior: Behavior<T>): T;
  80292. /**
  80293. * Gets a behavior using its name to search
  80294. * @param name defines the name to search
  80295. * @returns the behavior or null if not found
  80296. */
  80297. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  80298. }
  80299. }
  80300. declare module BABYLON {
  80301. /**
  80302. * Defines an array and its length.
  80303. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  80304. */
  80305. export interface ISmartArrayLike<T> {
  80306. /**
  80307. * The data of the array.
  80308. */
  80309. data: Array<T>;
  80310. /**
  80311. * The active length of the array.
  80312. */
  80313. length: number;
  80314. }
  80315. /**
  80316. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80317. */
  80318. export class SmartArray<T> implements ISmartArrayLike<T> {
  80319. /**
  80320. * The full set of data from the array.
  80321. */
  80322. data: Array<T>;
  80323. /**
  80324. * The active length of the array.
  80325. */
  80326. length: number;
  80327. protected _id: number;
  80328. /**
  80329. * Instantiates a Smart Array.
  80330. * @param capacity defines the default capacity of the array.
  80331. */
  80332. constructor(capacity: number);
  80333. /**
  80334. * Pushes a value at the end of the active data.
  80335. * @param value defines the object to push in the array.
  80336. */
  80337. push(value: T): void;
  80338. /**
  80339. * Iterates over the active data and apply the lambda to them.
  80340. * @param func defines the action to apply on each value.
  80341. */
  80342. forEach(func: (content: T) => void): void;
  80343. /**
  80344. * Sorts the full sets of data.
  80345. * @param compareFn defines the comparison function to apply.
  80346. */
  80347. sort(compareFn: (a: T, b: T) => number): void;
  80348. /**
  80349. * Resets the active data to an empty array.
  80350. */
  80351. reset(): void;
  80352. /**
  80353. * Releases all the data from the array as well as the array.
  80354. */
  80355. dispose(): void;
  80356. /**
  80357. * Concats the active data with a given array.
  80358. * @param array defines the data to concatenate with.
  80359. */
  80360. concat(array: any): void;
  80361. /**
  80362. * Returns the position of a value in the active data.
  80363. * @param value defines the value to find the index for
  80364. * @returns the index if found in the active data otherwise -1
  80365. */
  80366. indexOf(value: T): number;
  80367. /**
  80368. * Returns whether an element is part of the active data.
  80369. * @param value defines the value to look for
  80370. * @returns true if found in the active data otherwise false
  80371. */
  80372. contains(value: T): boolean;
  80373. private static _GlobalId;
  80374. }
  80375. /**
  80376. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80377. * The data in this array can only be present once
  80378. */
  80379. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  80380. private _duplicateId;
  80381. /**
  80382. * Pushes a value at the end of the active data.
  80383. * THIS DOES NOT PREVENT DUPPLICATE DATA
  80384. * @param value defines the object to push in the array.
  80385. */
  80386. push(value: T): void;
  80387. /**
  80388. * Pushes a value at the end of the active data.
  80389. * If the data is already present, it won t be added again
  80390. * @param value defines the object to push in the array.
  80391. * @returns true if added false if it was already present
  80392. */
  80393. pushNoDuplicate(value: T): boolean;
  80394. /**
  80395. * Resets the active data to an empty array.
  80396. */
  80397. reset(): void;
  80398. /**
  80399. * Concats the active data with a given array.
  80400. * This ensures no dupplicate will be present in the result.
  80401. * @param array defines the data to concatenate with.
  80402. */
  80403. concatWithNoDuplicate(array: any): void;
  80404. }
  80405. }
  80406. declare module BABYLON {
  80407. /**
  80408. * @ignore
  80409. * This is a list of all the different input types that are available in the application.
  80410. * Fo instance: ArcRotateCameraGamepadInput...
  80411. */
  80412. export var CameraInputTypes: {};
  80413. /**
  80414. * This is the contract to implement in order to create a new input class.
  80415. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  80416. */
  80417. export interface ICameraInput<TCamera extends Camera> {
  80418. /**
  80419. * Defines the camera the input is attached to.
  80420. */
  80421. camera: Nullable<TCamera>;
  80422. /**
  80423. * Gets the class name of the current intput.
  80424. * @returns the class name
  80425. */
  80426. getClassName(): string;
  80427. /**
  80428. * Get the friendly name associated with the input class.
  80429. * @returns the input friendly name
  80430. */
  80431. getSimpleName(): string;
  80432. /**
  80433. * Attach the input controls to a specific dom element to get the input from.
  80434. * @param element Defines the element the controls should be listened from
  80435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80436. */
  80437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80438. /**
  80439. * Detach the current controls from the specified dom element.
  80440. * @param element Defines the element to stop listening the inputs from
  80441. */
  80442. detachControl(element: Nullable<HTMLElement>): void;
  80443. /**
  80444. * Update the current camera state depending on the inputs that have been used this frame.
  80445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80446. */
  80447. checkInputs?: () => void;
  80448. }
  80449. /**
  80450. * Represents a map of input types to input instance or input index to input instance.
  80451. */
  80452. export interface CameraInputsMap<TCamera extends Camera> {
  80453. /**
  80454. * Accessor to the input by input type.
  80455. */
  80456. [name: string]: ICameraInput<TCamera>;
  80457. /**
  80458. * Accessor to the input by input index.
  80459. */
  80460. [idx: number]: ICameraInput<TCamera>;
  80461. }
  80462. /**
  80463. * This represents the input manager used within a camera.
  80464. * It helps dealing with all the different kind of input attached to a camera.
  80465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80466. */
  80467. export class CameraInputsManager<TCamera extends Camera> {
  80468. /**
  80469. * Defines the list of inputs attahed to the camera.
  80470. */
  80471. attached: CameraInputsMap<TCamera>;
  80472. /**
  80473. * Defines the dom element the camera is collecting inputs from.
  80474. * This is null if the controls have not been attached.
  80475. */
  80476. attachedElement: Nullable<HTMLElement>;
  80477. /**
  80478. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80479. */
  80480. noPreventDefault: boolean;
  80481. /**
  80482. * Defined the camera the input manager belongs to.
  80483. */
  80484. camera: TCamera;
  80485. /**
  80486. * Update the current camera state depending on the inputs that have been used this frame.
  80487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80488. */
  80489. checkInputs: () => void;
  80490. /**
  80491. * Instantiate a new Camera Input Manager.
  80492. * @param camera Defines the camera the input manager blongs to
  80493. */
  80494. constructor(camera: TCamera);
  80495. /**
  80496. * Add an input method to a camera
  80497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80498. * @param input camera input method
  80499. */
  80500. add(input: ICameraInput<TCamera>): void;
  80501. /**
  80502. * Remove a specific input method from a camera
  80503. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  80504. * @param inputToRemove camera input method
  80505. */
  80506. remove(inputToRemove: ICameraInput<TCamera>): void;
  80507. /**
  80508. * Remove a specific input type from a camera
  80509. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  80510. * @param inputType the type of the input to remove
  80511. */
  80512. removeByType(inputType: string): void;
  80513. private _addCheckInputs;
  80514. /**
  80515. * Attach the input controls to the currently attached dom element to listen the events from.
  80516. * @param input Defines the input to attach
  80517. */
  80518. attachInput(input: ICameraInput<TCamera>): void;
  80519. /**
  80520. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  80521. * @param element Defines the dom element to collect the events from
  80522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80523. */
  80524. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  80525. /**
  80526. * Detach the current manager inputs controls from a specific dom element.
  80527. * @param element Defines the dom element to collect the events from
  80528. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  80529. */
  80530. detachElement(element: HTMLElement, disconnect?: boolean): void;
  80531. /**
  80532. * Rebuild the dynamic inputCheck function from the current list of
  80533. * defined inputs in the manager.
  80534. */
  80535. rebuildInputCheck(): void;
  80536. /**
  80537. * Remove all attached input methods from a camera
  80538. */
  80539. clear(): void;
  80540. /**
  80541. * Serialize the current input manager attached to a camera.
  80542. * This ensures than once parsed,
  80543. * the input associated to the camera will be identical to the current ones
  80544. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  80545. */
  80546. serialize(serializedCamera: any): void;
  80547. /**
  80548. * Parses an input manager serialized JSON to restore the previous list of inputs
  80549. * and states associated to a camera.
  80550. * @param parsedCamera Defines the JSON to parse
  80551. */
  80552. parse(parsedCamera: any): void;
  80553. }
  80554. }
  80555. declare module BABYLON {
  80556. /**
  80557. * Class used to store data that will be store in GPU memory
  80558. */
  80559. export class Buffer {
  80560. private _engine;
  80561. private _buffer;
  80562. /** @hidden */
  80563. _data: Nullable<DataArray>;
  80564. private _updatable;
  80565. private _instanced;
  80566. private _divisor;
  80567. /**
  80568. * Gets the byte stride.
  80569. */
  80570. readonly byteStride: number;
  80571. /**
  80572. * Constructor
  80573. * @param engine the engine
  80574. * @param data the data to use for this buffer
  80575. * @param updatable whether the data is updatable
  80576. * @param stride the stride (optional)
  80577. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80578. * @param instanced whether the buffer is instanced (optional)
  80579. * @param useBytes set to true if the stride in in bytes (optional)
  80580. * @param divisor sets an optional divisor for instances (1 by default)
  80581. */
  80582. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  80583. /**
  80584. * Create a new VertexBuffer based on the current buffer
  80585. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80586. * @param offset defines offset in the buffer (0 by default)
  80587. * @param size defines the size in floats of attributes (position is 3 for instance)
  80588. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80589. * @param instanced defines if the vertex buffer contains indexed data
  80590. * @param useBytes defines if the offset and stride are in bytes *
  80591. * @param divisor sets an optional divisor for instances (1 by default)
  80592. * @returns the new vertex buffer
  80593. */
  80594. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80595. /**
  80596. * Gets a boolean indicating if the Buffer is updatable?
  80597. * @returns true if the buffer is updatable
  80598. */
  80599. isUpdatable(): boolean;
  80600. /**
  80601. * Gets current buffer's data
  80602. * @returns a DataArray or null
  80603. */
  80604. getData(): Nullable<DataArray>;
  80605. /**
  80606. * Gets underlying native buffer
  80607. * @returns underlying native buffer
  80608. */
  80609. getBuffer(): Nullable<DataBuffer>;
  80610. /**
  80611. * Gets the stride in float32 units (i.e. byte stride / 4).
  80612. * May not be an integer if the byte stride is not divisible by 4.
  80613. * @returns the stride in float32 units
  80614. * @deprecated Please use byteStride instead.
  80615. */
  80616. getStrideSize(): number;
  80617. /**
  80618. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80619. * @param data defines the data to store
  80620. */
  80621. create(data?: Nullable<DataArray>): void;
  80622. /** @hidden */
  80623. _rebuild(): void;
  80624. /**
  80625. * Update current buffer data
  80626. * @param data defines the data to store
  80627. */
  80628. update(data: DataArray): void;
  80629. /**
  80630. * Updates the data directly.
  80631. * @param data the new data
  80632. * @param offset the new offset
  80633. * @param vertexCount the vertex count (optional)
  80634. * @param useBytes set to true if the offset is in bytes
  80635. */
  80636. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80637. /**
  80638. * Release all resources
  80639. */
  80640. dispose(): void;
  80641. }
  80642. /**
  80643. * Specialized buffer used to store vertex data
  80644. */
  80645. export class VertexBuffer {
  80646. /** @hidden */
  80647. _buffer: Buffer;
  80648. private _kind;
  80649. private _size;
  80650. private _ownsBuffer;
  80651. private _instanced;
  80652. private _instanceDivisor;
  80653. /**
  80654. * The byte type.
  80655. */
  80656. static readonly BYTE: number;
  80657. /**
  80658. * The unsigned byte type.
  80659. */
  80660. static readonly UNSIGNED_BYTE: number;
  80661. /**
  80662. * The short type.
  80663. */
  80664. static readonly SHORT: number;
  80665. /**
  80666. * The unsigned short type.
  80667. */
  80668. static readonly UNSIGNED_SHORT: number;
  80669. /**
  80670. * The integer type.
  80671. */
  80672. static readonly INT: number;
  80673. /**
  80674. * The unsigned integer type.
  80675. */
  80676. static readonly UNSIGNED_INT: number;
  80677. /**
  80678. * The float type.
  80679. */
  80680. static readonly FLOAT: number;
  80681. /**
  80682. * Gets or sets the instance divisor when in instanced mode
  80683. */
  80684. get instanceDivisor(): number;
  80685. set instanceDivisor(value: number);
  80686. /**
  80687. * Gets the byte stride.
  80688. */
  80689. readonly byteStride: number;
  80690. /**
  80691. * Gets the byte offset.
  80692. */
  80693. readonly byteOffset: number;
  80694. /**
  80695. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80696. */
  80697. readonly normalized: boolean;
  80698. /**
  80699. * Gets the data type of each component in the array.
  80700. */
  80701. readonly type: number;
  80702. /**
  80703. * Constructor
  80704. * @param engine the engine
  80705. * @param data the data to use for this vertex buffer
  80706. * @param kind the vertex buffer kind
  80707. * @param updatable whether the data is updatable
  80708. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80709. * @param stride the stride (optional)
  80710. * @param instanced whether the buffer is instanced (optional)
  80711. * @param offset the offset of the data (optional)
  80712. * @param size the number of components (optional)
  80713. * @param type the type of the component (optional)
  80714. * @param normalized whether the data contains normalized data (optional)
  80715. * @param useBytes set to true if stride and offset are in bytes (optional)
  80716. * @param divisor defines the instance divisor to use (1 by default)
  80717. */
  80718. 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);
  80719. /** @hidden */
  80720. _rebuild(): void;
  80721. /**
  80722. * Returns the kind of the VertexBuffer (string)
  80723. * @returns a string
  80724. */
  80725. getKind(): string;
  80726. /**
  80727. * Gets a boolean indicating if the VertexBuffer is updatable?
  80728. * @returns true if the buffer is updatable
  80729. */
  80730. isUpdatable(): boolean;
  80731. /**
  80732. * Gets current buffer's data
  80733. * @returns a DataArray or null
  80734. */
  80735. getData(): Nullable<DataArray>;
  80736. /**
  80737. * Gets underlying native buffer
  80738. * @returns underlying native buffer
  80739. */
  80740. getBuffer(): Nullable<DataBuffer>;
  80741. /**
  80742. * Gets the stride in float32 units (i.e. byte stride / 4).
  80743. * May not be an integer if the byte stride is not divisible by 4.
  80744. * @returns the stride in float32 units
  80745. * @deprecated Please use byteStride instead.
  80746. */
  80747. getStrideSize(): number;
  80748. /**
  80749. * Returns the offset as a multiple of the type byte length.
  80750. * @returns the offset in bytes
  80751. * @deprecated Please use byteOffset instead.
  80752. */
  80753. getOffset(): number;
  80754. /**
  80755. * Returns the number of components per vertex attribute (integer)
  80756. * @returns the size in float
  80757. */
  80758. getSize(): number;
  80759. /**
  80760. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80761. * @returns true if this buffer is instanced
  80762. */
  80763. getIsInstanced(): boolean;
  80764. /**
  80765. * Returns the instancing divisor, zero for non-instanced (integer).
  80766. * @returns a number
  80767. */
  80768. getInstanceDivisor(): number;
  80769. /**
  80770. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80771. * @param data defines the data to store
  80772. */
  80773. create(data?: DataArray): void;
  80774. /**
  80775. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80776. * This function will create a new buffer if the current one is not updatable
  80777. * @param data defines the data to store
  80778. */
  80779. update(data: DataArray): void;
  80780. /**
  80781. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80782. * Returns the directly updated WebGLBuffer.
  80783. * @param data the new data
  80784. * @param offset the new offset
  80785. * @param useBytes set to true if the offset is in bytes
  80786. */
  80787. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80788. /**
  80789. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80790. */
  80791. dispose(): void;
  80792. /**
  80793. * Enumerates each value of this vertex buffer as numbers.
  80794. * @param count the number of values to enumerate
  80795. * @param callback the callback function called for each value
  80796. */
  80797. forEach(count: number, callback: (value: number, index: number) => void): void;
  80798. /**
  80799. * Positions
  80800. */
  80801. static readonly PositionKind: string;
  80802. /**
  80803. * Normals
  80804. */
  80805. static readonly NormalKind: string;
  80806. /**
  80807. * Tangents
  80808. */
  80809. static readonly TangentKind: string;
  80810. /**
  80811. * Texture coordinates
  80812. */
  80813. static readonly UVKind: string;
  80814. /**
  80815. * Texture coordinates 2
  80816. */
  80817. static readonly UV2Kind: string;
  80818. /**
  80819. * Texture coordinates 3
  80820. */
  80821. static readonly UV3Kind: string;
  80822. /**
  80823. * Texture coordinates 4
  80824. */
  80825. static readonly UV4Kind: string;
  80826. /**
  80827. * Texture coordinates 5
  80828. */
  80829. static readonly UV5Kind: string;
  80830. /**
  80831. * Texture coordinates 6
  80832. */
  80833. static readonly UV6Kind: string;
  80834. /**
  80835. * Colors
  80836. */
  80837. static readonly ColorKind: string;
  80838. /**
  80839. * Matrix indices (for bones)
  80840. */
  80841. static readonly MatricesIndicesKind: string;
  80842. /**
  80843. * Matrix weights (for bones)
  80844. */
  80845. static readonly MatricesWeightsKind: string;
  80846. /**
  80847. * Additional matrix indices (for bones)
  80848. */
  80849. static readonly MatricesIndicesExtraKind: string;
  80850. /**
  80851. * Additional matrix weights (for bones)
  80852. */
  80853. static readonly MatricesWeightsExtraKind: string;
  80854. /**
  80855. * Deduces the stride given a kind.
  80856. * @param kind The kind string to deduce
  80857. * @returns The deduced stride
  80858. */
  80859. static DeduceStride(kind: string): number;
  80860. /**
  80861. * Gets the byte length of the given type.
  80862. * @param type the type
  80863. * @returns the number of bytes
  80864. */
  80865. static GetTypeByteLength(type: number): number;
  80866. /**
  80867. * Enumerates each value of the given parameters as numbers.
  80868. * @param data the data to enumerate
  80869. * @param byteOffset the byte offset of the data
  80870. * @param byteStride the byte stride of the data
  80871. * @param componentCount the number of components per element
  80872. * @param componentType the type of the component
  80873. * @param count the number of values to enumerate
  80874. * @param normalized whether the data is normalized
  80875. * @param callback the callback function called for each value
  80876. */
  80877. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80878. private static _GetFloatValue;
  80879. }
  80880. }
  80881. declare module BABYLON {
  80882. /**
  80883. * @hidden
  80884. */
  80885. export class IntersectionInfo {
  80886. bu: Nullable<number>;
  80887. bv: Nullable<number>;
  80888. distance: number;
  80889. faceId: number;
  80890. subMeshId: number;
  80891. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80892. }
  80893. }
  80894. declare module BABYLON {
  80895. /**
  80896. * Represens a plane by the equation ax + by + cz + d = 0
  80897. */
  80898. export class Plane {
  80899. private static _TmpMatrix;
  80900. /**
  80901. * Normal of the plane (a,b,c)
  80902. */
  80903. normal: Vector3;
  80904. /**
  80905. * d component of the plane
  80906. */
  80907. d: number;
  80908. /**
  80909. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80910. * @param a a component of the plane
  80911. * @param b b component of the plane
  80912. * @param c c component of the plane
  80913. * @param d d component of the plane
  80914. */
  80915. constructor(a: number, b: number, c: number, d: number);
  80916. /**
  80917. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80918. */
  80919. asArray(): number[];
  80920. /**
  80921. * @returns a new plane copied from the current Plane.
  80922. */
  80923. clone(): Plane;
  80924. /**
  80925. * @returns the string "Plane".
  80926. */
  80927. getClassName(): string;
  80928. /**
  80929. * @returns the Plane hash code.
  80930. */
  80931. getHashCode(): number;
  80932. /**
  80933. * Normalize the current Plane in place.
  80934. * @returns the updated Plane.
  80935. */
  80936. normalize(): Plane;
  80937. /**
  80938. * Applies a transformation the plane and returns the result
  80939. * @param transformation the transformation matrix to be applied to the plane
  80940. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80941. */
  80942. transform(transformation: DeepImmutable<Matrix>): Plane;
  80943. /**
  80944. * Calcualtte the dot product between the point and the plane normal
  80945. * @param point point to calculate the dot product with
  80946. * @returns the dot product (float) of the point coordinates and the plane normal.
  80947. */
  80948. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80949. /**
  80950. * Updates the current Plane from the plane defined by the three given points.
  80951. * @param point1 one of the points used to contruct the plane
  80952. * @param point2 one of the points used to contruct the plane
  80953. * @param point3 one of the points used to contruct the plane
  80954. * @returns the updated Plane.
  80955. */
  80956. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80957. /**
  80958. * Checks if the plane is facing a given direction
  80959. * @param direction the direction to check if the plane is facing
  80960. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80961. * @returns True is the vector "direction" is the same side than the plane normal.
  80962. */
  80963. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80964. /**
  80965. * Calculates the distance to a point
  80966. * @param point point to calculate distance to
  80967. * @returns the signed distance (float) from the given point to the Plane.
  80968. */
  80969. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80970. /**
  80971. * Creates a plane from an array
  80972. * @param array the array to create a plane from
  80973. * @returns a new Plane from the given array.
  80974. */
  80975. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80976. /**
  80977. * Creates a plane from three points
  80978. * @param point1 point used to create the plane
  80979. * @param point2 point used to create the plane
  80980. * @param point3 point used to create the plane
  80981. * @returns a new Plane defined by the three given points.
  80982. */
  80983. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80984. /**
  80985. * Creates a plane from an origin point and a normal
  80986. * @param origin origin of the plane to be constructed
  80987. * @param normal normal of the plane to be constructed
  80988. * @returns a new Plane the normal vector to this plane at the given origin point.
  80989. * Note : the vector "normal" is updated because normalized.
  80990. */
  80991. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80992. /**
  80993. * Calculates the distance from a plane and a point
  80994. * @param origin origin of the plane to be constructed
  80995. * @param normal normal of the plane to be constructed
  80996. * @param point point to calculate distance to
  80997. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80998. */
  80999. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81000. }
  81001. }
  81002. declare module BABYLON {
  81003. /**
  81004. * Class used to store bounding sphere information
  81005. */
  81006. export class BoundingSphere {
  81007. /**
  81008. * Gets the center of the bounding sphere in local space
  81009. */
  81010. readonly center: Vector3;
  81011. /**
  81012. * Radius of the bounding sphere in local space
  81013. */
  81014. radius: number;
  81015. /**
  81016. * Gets the center of the bounding sphere in world space
  81017. */
  81018. readonly centerWorld: Vector3;
  81019. /**
  81020. * Radius of the bounding sphere in world space
  81021. */
  81022. radiusWorld: number;
  81023. /**
  81024. * Gets the minimum vector in local space
  81025. */
  81026. readonly minimum: Vector3;
  81027. /**
  81028. * Gets the maximum vector in local space
  81029. */
  81030. readonly maximum: Vector3;
  81031. private _worldMatrix;
  81032. private static readonly TmpVector3;
  81033. /**
  81034. * Creates a new bounding sphere
  81035. * @param min defines the minimum vector (in local space)
  81036. * @param max defines the maximum vector (in local space)
  81037. * @param worldMatrix defines the new world matrix
  81038. */
  81039. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81040. /**
  81041. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  81042. * @param min defines the new minimum vector (in local space)
  81043. * @param max defines the new maximum vector (in local space)
  81044. * @param worldMatrix defines the new world matrix
  81045. */
  81046. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81047. /**
  81048. * Scale the current bounding sphere by applying a scale factor
  81049. * @param factor defines the scale factor to apply
  81050. * @returns the current bounding box
  81051. */
  81052. scale(factor: number): BoundingSphere;
  81053. /**
  81054. * Gets the world matrix of the bounding box
  81055. * @returns a matrix
  81056. */
  81057. getWorldMatrix(): DeepImmutable<Matrix>;
  81058. /** @hidden */
  81059. _update(worldMatrix: DeepImmutable<Matrix>): void;
  81060. /**
  81061. * Tests if the bounding sphere is intersecting the frustum planes
  81062. * @param frustumPlanes defines the frustum planes to test
  81063. * @returns true if there is an intersection
  81064. */
  81065. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81066. /**
  81067. * Tests if the bounding sphere center is in between the frustum planes.
  81068. * Used for optimistic fast inclusion.
  81069. * @param frustumPlanes defines the frustum planes to test
  81070. * @returns true if the sphere center is in between the frustum planes
  81071. */
  81072. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81073. /**
  81074. * Tests if a point is inside the bounding sphere
  81075. * @param point defines the point to test
  81076. * @returns true if the point is inside the bounding sphere
  81077. */
  81078. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81079. /**
  81080. * Checks if two sphere intersct
  81081. * @param sphere0 sphere 0
  81082. * @param sphere1 sphere 1
  81083. * @returns true if the speres intersect
  81084. */
  81085. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  81086. }
  81087. }
  81088. declare module BABYLON {
  81089. /**
  81090. * Class used to store bounding box information
  81091. */
  81092. export class BoundingBox implements ICullable {
  81093. /**
  81094. * Gets the 8 vectors representing the bounding box in local space
  81095. */
  81096. readonly vectors: Vector3[];
  81097. /**
  81098. * Gets the center of the bounding box in local space
  81099. */
  81100. readonly center: Vector3;
  81101. /**
  81102. * Gets the center of the bounding box in world space
  81103. */
  81104. readonly centerWorld: Vector3;
  81105. /**
  81106. * Gets the extend size in local space
  81107. */
  81108. readonly extendSize: Vector3;
  81109. /**
  81110. * Gets the extend size in world space
  81111. */
  81112. readonly extendSizeWorld: Vector3;
  81113. /**
  81114. * Gets the OBB (object bounding box) directions
  81115. */
  81116. readonly directions: Vector3[];
  81117. /**
  81118. * Gets the 8 vectors representing the bounding box in world space
  81119. */
  81120. readonly vectorsWorld: Vector3[];
  81121. /**
  81122. * Gets the minimum vector in world space
  81123. */
  81124. readonly minimumWorld: Vector3;
  81125. /**
  81126. * Gets the maximum vector in world space
  81127. */
  81128. readonly maximumWorld: Vector3;
  81129. /**
  81130. * Gets the minimum vector in local space
  81131. */
  81132. readonly minimum: Vector3;
  81133. /**
  81134. * Gets the maximum vector in local space
  81135. */
  81136. readonly maximum: Vector3;
  81137. private _worldMatrix;
  81138. private static readonly TmpVector3;
  81139. /**
  81140. * @hidden
  81141. */
  81142. _tag: number;
  81143. /**
  81144. * Creates a new bounding box
  81145. * @param min defines the minimum vector (in local space)
  81146. * @param max defines the maximum vector (in local space)
  81147. * @param worldMatrix defines the new world matrix
  81148. */
  81149. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81150. /**
  81151. * Recreates the entire bounding box from scratch as if we call the constructor in place
  81152. * @param min defines the new minimum vector (in local space)
  81153. * @param max defines the new maximum vector (in local space)
  81154. * @param worldMatrix defines the new world matrix
  81155. */
  81156. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81157. /**
  81158. * Scale the current bounding box by applying a scale factor
  81159. * @param factor defines the scale factor to apply
  81160. * @returns the current bounding box
  81161. */
  81162. scale(factor: number): BoundingBox;
  81163. /**
  81164. * Gets the world matrix of the bounding box
  81165. * @returns a matrix
  81166. */
  81167. getWorldMatrix(): DeepImmutable<Matrix>;
  81168. /** @hidden */
  81169. _update(world: DeepImmutable<Matrix>): void;
  81170. /**
  81171. * Tests if the bounding box is intersecting the frustum planes
  81172. * @param frustumPlanes defines the frustum planes to test
  81173. * @returns true if there is an intersection
  81174. */
  81175. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81176. /**
  81177. * Tests if the bounding box is entirely inside the frustum planes
  81178. * @param frustumPlanes defines the frustum planes to test
  81179. * @returns true if there is an inclusion
  81180. */
  81181. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81182. /**
  81183. * Tests if a point is inside the bounding box
  81184. * @param point defines the point to test
  81185. * @returns true if the point is inside the bounding box
  81186. */
  81187. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81188. /**
  81189. * Tests if the bounding box intersects with a bounding sphere
  81190. * @param sphere defines the sphere to test
  81191. * @returns true if there is an intersection
  81192. */
  81193. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  81194. /**
  81195. * Tests if the bounding box intersects with a box defined by a min and max vectors
  81196. * @param min defines the min vector to use
  81197. * @param max defines the max vector to use
  81198. * @returns true if there is an intersection
  81199. */
  81200. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  81201. /**
  81202. * Tests if two bounding boxes are intersections
  81203. * @param box0 defines the first box to test
  81204. * @param box1 defines the second box to test
  81205. * @returns true if there is an intersection
  81206. */
  81207. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  81208. /**
  81209. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  81210. * @param minPoint defines the minimum vector of the bounding box
  81211. * @param maxPoint defines the maximum vector of the bounding box
  81212. * @param sphereCenter defines the sphere center
  81213. * @param sphereRadius defines the sphere radius
  81214. * @returns true if there is an intersection
  81215. */
  81216. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  81217. /**
  81218. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  81219. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81220. * @param frustumPlanes defines the frustum planes to test
  81221. * @return true if there is an inclusion
  81222. */
  81223. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81224. /**
  81225. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  81226. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81227. * @param frustumPlanes defines the frustum planes to test
  81228. * @return true if there is an intersection
  81229. */
  81230. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81231. }
  81232. }
  81233. declare module BABYLON {
  81234. /** @hidden */
  81235. export class Collider {
  81236. /** Define if a collision was found */
  81237. collisionFound: boolean;
  81238. /**
  81239. * Define last intersection point in local space
  81240. */
  81241. intersectionPoint: Vector3;
  81242. /**
  81243. * Define last collided mesh
  81244. */
  81245. collidedMesh: Nullable<AbstractMesh>;
  81246. private _collisionPoint;
  81247. private _planeIntersectionPoint;
  81248. private _tempVector;
  81249. private _tempVector2;
  81250. private _tempVector3;
  81251. private _tempVector4;
  81252. private _edge;
  81253. private _baseToVertex;
  81254. private _destinationPoint;
  81255. private _slidePlaneNormal;
  81256. private _displacementVector;
  81257. /** @hidden */
  81258. _radius: Vector3;
  81259. /** @hidden */
  81260. _retry: number;
  81261. private _velocity;
  81262. private _basePoint;
  81263. private _epsilon;
  81264. /** @hidden */
  81265. _velocityWorldLength: number;
  81266. /** @hidden */
  81267. _basePointWorld: Vector3;
  81268. private _velocityWorld;
  81269. private _normalizedVelocity;
  81270. /** @hidden */
  81271. _initialVelocity: Vector3;
  81272. /** @hidden */
  81273. _initialPosition: Vector3;
  81274. private _nearestDistance;
  81275. private _collisionMask;
  81276. get collisionMask(): number;
  81277. set collisionMask(mask: number);
  81278. /**
  81279. * Gets the plane normal used to compute the sliding response (in local space)
  81280. */
  81281. get slidePlaneNormal(): Vector3;
  81282. /** @hidden */
  81283. _initialize(source: Vector3, dir: Vector3, e: number): void;
  81284. /** @hidden */
  81285. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  81286. /** @hidden */
  81287. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  81288. /** @hidden */
  81289. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81290. /** @hidden */
  81291. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81292. /** @hidden */
  81293. _getResponse(pos: Vector3, vel: Vector3): void;
  81294. }
  81295. }
  81296. declare module BABYLON {
  81297. /**
  81298. * Interface for cullable objects
  81299. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  81300. */
  81301. export interface ICullable {
  81302. /**
  81303. * Checks if the object or part of the object is in the frustum
  81304. * @param frustumPlanes Camera near/planes
  81305. * @returns true if the object is in frustum otherwise false
  81306. */
  81307. isInFrustum(frustumPlanes: Plane[]): boolean;
  81308. /**
  81309. * Checks if a cullable object (mesh...) is in the camera frustum
  81310. * Unlike isInFrustum this cheks the full bounding box
  81311. * @param frustumPlanes Camera near/planes
  81312. * @returns true if the object is in frustum otherwise false
  81313. */
  81314. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81315. }
  81316. /**
  81317. * Info for a bounding data of a mesh
  81318. */
  81319. export class BoundingInfo implements ICullable {
  81320. /**
  81321. * Bounding box for the mesh
  81322. */
  81323. readonly boundingBox: BoundingBox;
  81324. /**
  81325. * Bounding sphere for the mesh
  81326. */
  81327. readonly boundingSphere: BoundingSphere;
  81328. private _isLocked;
  81329. private static readonly TmpVector3;
  81330. /**
  81331. * Constructs bounding info
  81332. * @param minimum min vector of the bounding box/sphere
  81333. * @param maximum max vector of the bounding box/sphere
  81334. * @param worldMatrix defines the new world matrix
  81335. */
  81336. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81337. /**
  81338. * Recreates the entire bounding info from scratch as if we call the constructor in place
  81339. * @param min defines the new minimum vector (in local space)
  81340. * @param max defines the new maximum vector (in local space)
  81341. * @param worldMatrix defines the new world matrix
  81342. */
  81343. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81344. /**
  81345. * min vector of the bounding box/sphere
  81346. */
  81347. get minimum(): Vector3;
  81348. /**
  81349. * max vector of the bounding box/sphere
  81350. */
  81351. get maximum(): Vector3;
  81352. /**
  81353. * If the info is locked and won't be updated to avoid perf overhead
  81354. */
  81355. get isLocked(): boolean;
  81356. set isLocked(value: boolean);
  81357. /**
  81358. * Updates the bounding sphere and box
  81359. * @param world world matrix to be used to update
  81360. */
  81361. update(world: DeepImmutable<Matrix>): void;
  81362. /**
  81363. * Recreate the bounding info to be centered around a specific point given a specific extend.
  81364. * @param center New center of the bounding info
  81365. * @param extend New extend of the bounding info
  81366. * @returns the current bounding info
  81367. */
  81368. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  81369. /**
  81370. * Scale the current bounding info by applying a scale factor
  81371. * @param factor defines the scale factor to apply
  81372. * @returns the current bounding info
  81373. */
  81374. scale(factor: number): BoundingInfo;
  81375. /**
  81376. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  81377. * @param frustumPlanes defines the frustum to test
  81378. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  81379. * @returns true if the bounding info is in the frustum planes
  81380. */
  81381. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  81382. /**
  81383. * Gets the world distance between the min and max points of the bounding box
  81384. */
  81385. get diagonalLength(): number;
  81386. /**
  81387. * Checks if a cullable object (mesh...) is in the camera frustum
  81388. * Unlike isInFrustum this cheks the full bounding box
  81389. * @param frustumPlanes Camera near/planes
  81390. * @returns true if the object is in frustum otherwise false
  81391. */
  81392. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81393. /** @hidden */
  81394. _checkCollision(collider: Collider): boolean;
  81395. /**
  81396. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  81397. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81398. * @param point the point to check intersection with
  81399. * @returns if the point intersects
  81400. */
  81401. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81402. /**
  81403. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  81404. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81405. * @param boundingInfo the bounding info to check intersection with
  81406. * @param precise if the intersection should be done using OBB
  81407. * @returns if the bounding info intersects
  81408. */
  81409. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  81410. }
  81411. }
  81412. declare module BABYLON {
  81413. /**
  81414. * Extracts minimum and maximum values from a list of indexed positions
  81415. * @param positions defines the positions to use
  81416. * @param indices defines the indices to the positions
  81417. * @param indexStart defines the start index
  81418. * @param indexCount defines the end index
  81419. * @param bias defines bias value to add to the result
  81420. * @return minimum and maximum values
  81421. */
  81422. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  81423. minimum: Vector3;
  81424. maximum: Vector3;
  81425. };
  81426. /**
  81427. * Extracts minimum and maximum values from a list of positions
  81428. * @param positions defines the positions to use
  81429. * @param start defines the start index in the positions array
  81430. * @param count defines the number of positions to handle
  81431. * @param bias defines bias value to add to the result
  81432. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81433. * @return minimum and maximum values
  81434. */
  81435. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  81436. minimum: Vector3;
  81437. maximum: Vector3;
  81438. };
  81439. }
  81440. declare module BABYLON {
  81441. /** @hidden */
  81442. export class WebGLDataBuffer extends DataBuffer {
  81443. private _buffer;
  81444. constructor(resource: WebGLBuffer);
  81445. get underlyingResource(): any;
  81446. }
  81447. }
  81448. declare module BABYLON {
  81449. /** @hidden */
  81450. export class WebGLPipelineContext implements IPipelineContext {
  81451. engine: ThinEngine;
  81452. program: Nullable<WebGLProgram>;
  81453. context?: WebGLRenderingContext;
  81454. vertexShader?: WebGLShader;
  81455. fragmentShader?: WebGLShader;
  81456. isParallelCompiled: boolean;
  81457. onCompiled?: () => void;
  81458. transformFeedback?: WebGLTransformFeedback | null;
  81459. vertexCompilationError: Nullable<string>;
  81460. fragmentCompilationError: Nullable<string>;
  81461. programLinkError: Nullable<string>;
  81462. programValidationError: Nullable<string>;
  81463. get isAsync(): boolean;
  81464. get isReady(): boolean;
  81465. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  81466. _getVertexShaderCode(): string | null;
  81467. _getFragmentShaderCode(): string | null;
  81468. }
  81469. }
  81470. declare module BABYLON {
  81471. interface ThinEngine {
  81472. /**
  81473. * Create an uniform buffer
  81474. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81475. * @param elements defines the content of the uniform buffer
  81476. * @returns the webGL uniform buffer
  81477. */
  81478. createUniformBuffer(elements: FloatArray): DataBuffer;
  81479. /**
  81480. * Create a dynamic uniform buffer
  81481. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81482. * @param elements defines the content of the uniform buffer
  81483. * @returns the webGL uniform buffer
  81484. */
  81485. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  81486. /**
  81487. * Update an existing uniform buffer
  81488. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81489. * @param uniformBuffer defines the target uniform buffer
  81490. * @param elements defines the content to update
  81491. * @param offset defines the offset in the uniform buffer where update should start
  81492. * @param count defines the size of the data to update
  81493. */
  81494. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  81495. /**
  81496. * Bind an uniform buffer to the current webGL context
  81497. * @param buffer defines the buffer to bind
  81498. */
  81499. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  81500. /**
  81501. * Bind a buffer to the current webGL context at a given location
  81502. * @param buffer defines the buffer to bind
  81503. * @param location defines the index where to bind the buffer
  81504. */
  81505. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  81506. /**
  81507. * Bind a specific block at a given index in a specific shader program
  81508. * @param pipelineContext defines the pipeline context to use
  81509. * @param blockName defines the block name
  81510. * @param index defines the index where to bind the block
  81511. */
  81512. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  81513. }
  81514. }
  81515. declare module BABYLON {
  81516. /**
  81517. * Uniform buffer objects.
  81518. *
  81519. * Handles blocks of uniform on the GPU.
  81520. *
  81521. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81522. *
  81523. * For more information, please refer to :
  81524. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81525. */
  81526. export class UniformBuffer {
  81527. private _engine;
  81528. private _buffer;
  81529. private _data;
  81530. private _bufferData;
  81531. private _dynamic?;
  81532. private _uniformLocations;
  81533. private _uniformSizes;
  81534. private _uniformLocationPointer;
  81535. private _needSync;
  81536. private _noUBO;
  81537. private _currentEffect;
  81538. /** @hidden */
  81539. _alreadyBound: boolean;
  81540. private static _MAX_UNIFORM_SIZE;
  81541. private static _tempBuffer;
  81542. /**
  81543. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81544. * This is dynamic to allow compat with webgl 1 and 2.
  81545. * You will need to pass the name of the uniform as well as the value.
  81546. */
  81547. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81548. /**
  81549. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81550. * This is dynamic to allow compat with webgl 1 and 2.
  81551. * You will need to pass the name of the uniform as well as the value.
  81552. */
  81553. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81554. /**
  81555. * Lambda to Update a single float in a uniform buffer.
  81556. * This is dynamic to allow compat with webgl 1 and 2.
  81557. * You will need to pass the name of the uniform as well as the value.
  81558. */
  81559. updateFloat: (name: string, x: number) => void;
  81560. /**
  81561. * Lambda to Update a vec2 of float in a uniform buffer.
  81562. * This is dynamic to allow compat with webgl 1 and 2.
  81563. * You will need to pass the name of the uniform as well as the value.
  81564. */
  81565. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81566. /**
  81567. * Lambda to Update a vec3 of float in a uniform buffer.
  81568. * This is dynamic to allow compat with webgl 1 and 2.
  81569. * You will need to pass the name of the uniform as well as the value.
  81570. */
  81571. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81572. /**
  81573. * Lambda to Update a vec4 of float in a uniform buffer.
  81574. * This is dynamic to allow compat with webgl 1 and 2.
  81575. * You will need to pass the name of the uniform as well as the value.
  81576. */
  81577. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81578. /**
  81579. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81580. * This is dynamic to allow compat with webgl 1 and 2.
  81581. * You will need to pass the name of the uniform as well as the value.
  81582. */
  81583. updateMatrix: (name: string, mat: Matrix) => void;
  81584. /**
  81585. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81586. * This is dynamic to allow compat with webgl 1 and 2.
  81587. * You will need to pass the name of the uniform as well as the value.
  81588. */
  81589. updateVector3: (name: string, vector: Vector3) => void;
  81590. /**
  81591. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81592. * This is dynamic to allow compat with webgl 1 and 2.
  81593. * You will need to pass the name of the uniform as well as the value.
  81594. */
  81595. updateVector4: (name: string, vector: Vector4) => void;
  81596. /**
  81597. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81598. * This is dynamic to allow compat with webgl 1 and 2.
  81599. * You will need to pass the name of the uniform as well as the value.
  81600. */
  81601. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81602. /**
  81603. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81604. * This is dynamic to allow compat with webgl 1 and 2.
  81605. * You will need to pass the name of the uniform as well as the value.
  81606. */
  81607. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81608. /**
  81609. * Instantiates a new Uniform buffer objects.
  81610. *
  81611. * Handles blocks of uniform on the GPU.
  81612. *
  81613. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81614. *
  81615. * For more information, please refer to :
  81616. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81617. * @param engine Define the engine the buffer is associated with
  81618. * @param data Define the data contained in the buffer
  81619. * @param dynamic Define if the buffer is updatable
  81620. */
  81621. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81622. /**
  81623. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81624. * or just falling back on setUniformXXX calls.
  81625. */
  81626. get useUbo(): boolean;
  81627. /**
  81628. * Indicates if the WebGL underlying uniform buffer is in sync
  81629. * with the javascript cache data.
  81630. */
  81631. get isSync(): boolean;
  81632. /**
  81633. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81634. * Also, a dynamic UniformBuffer will disable cache verification and always
  81635. * update the underlying WebGL uniform buffer to the GPU.
  81636. * @returns if Dynamic, otherwise false
  81637. */
  81638. isDynamic(): boolean;
  81639. /**
  81640. * The data cache on JS side.
  81641. * @returns the underlying data as a float array
  81642. */
  81643. getData(): Float32Array;
  81644. /**
  81645. * The underlying WebGL Uniform buffer.
  81646. * @returns the webgl buffer
  81647. */
  81648. getBuffer(): Nullable<DataBuffer>;
  81649. /**
  81650. * std140 layout specifies how to align data within an UBO structure.
  81651. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81652. * for specs.
  81653. */
  81654. private _fillAlignment;
  81655. /**
  81656. * Adds an uniform in the buffer.
  81657. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81658. * for the layout to be correct !
  81659. * @param name Name of the uniform, as used in the uniform block in the shader.
  81660. * @param size Data size, or data directly.
  81661. */
  81662. addUniform(name: string, size: number | number[]): void;
  81663. /**
  81664. * Adds a Matrix 4x4 to the uniform buffer.
  81665. * @param name Name of the uniform, as used in the uniform block in the shader.
  81666. * @param mat A 4x4 matrix.
  81667. */
  81668. addMatrix(name: string, mat: Matrix): void;
  81669. /**
  81670. * Adds a vec2 to the uniform buffer.
  81671. * @param name Name of the uniform, as used in the uniform block in the shader.
  81672. * @param x Define the x component value of the vec2
  81673. * @param y Define the y component value of the vec2
  81674. */
  81675. addFloat2(name: string, x: number, y: number): void;
  81676. /**
  81677. * Adds a vec3 to the uniform buffer.
  81678. * @param name Name of the uniform, as used in the uniform block in the shader.
  81679. * @param x Define the x component value of the vec3
  81680. * @param y Define the y component value of the vec3
  81681. * @param z Define the z component value of the vec3
  81682. */
  81683. addFloat3(name: string, x: number, y: number, z: number): void;
  81684. /**
  81685. * Adds a vec3 to the uniform buffer.
  81686. * @param name Name of the uniform, as used in the uniform block in the shader.
  81687. * @param color Define the vec3 from a Color
  81688. */
  81689. addColor3(name: string, color: Color3): void;
  81690. /**
  81691. * Adds a vec4 to the uniform buffer.
  81692. * @param name Name of the uniform, as used in the uniform block in the shader.
  81693. * @param color Define the rgb components from a Color
  81694. * @param alpha Define the a component of the vec4
  81695. */
  81696. addColor4(name: string, color: Color3, alpha: number): void;
  81697. /**
  81698. * Adds a vec3 to the uniform buffer.
  81699. * @param name Name of the uniform, as used in the uniform block in the shader.
  81700. * @param vector Define the vec3 components from a Vector
  81701. */
  81702. addVector3(name: string, vector: Vector3): void;
  81703. /**
  81704. * Adds a Matrix 3x3 to the uniform buffer.
  81705. * @param name Name of the uniform, as used in the uniform block in the shader.
  81706. */
  81707. addMatrix3x3(name: string): void;
  81708. /**
  81709. * Adds a Matrix 2x2 to the uniform buffer.
  81710. * @param name Name of the uniform, as used in the uniform block in the shader.
  81711. */
  81712. addMatrix2x2(name: string): void;
  81713. /**
  81714. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81715. */
  81716. create(): void;
  81717. /** @hidden */
  81718. _rebuild(): void;
  81719. /**
  81720. * Updates the WebGL Uniform Buffer on the GPU.
  81721. * If the `dynamic` flag is set to true, no cache comparison is done.
  81722. * Otherwise, the buffer will be updated only if the cache differs.
  81723. */
  81724. update(): void;
  81725. /**
  81726. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81727. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81728. * @param data Define the flattened data
  81729. * @param size Define the size of the data.
  81730. */
  81731. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81732. private _valueCache;
  81733. private _cacheMatrix;
  81734. private _updateMatrix3x3ForUniform;
  81735. private _updateMatrix3x3ForEffect;
  81736. private _updateMatrix2x2ForEffect;
  81737. private _updateMatrix2x2ForUniform;
  81738. private _updateFloatForEffect;
  81739. private _updateFloatForUniform;
  81740. private _updateFloat2ForEffect;
  81741. private _updateFloat2ForUniform;
  81742. private _updateFloat3ForEffect;
  81743. private _updateFloat3ForUniform;
  81744. private _updateFloat4ForEffect;
  81745. private _updateFloat4ForUniform;
  81746. private _updateMatrixForEffect;
  81747. private _updateMatrixForUniform;
  81748. private _updateVector3ForEffect;
  81749. private _updateVector3ForUniform;
  81750. private _updateVector4ForEffect;
  81751. private _updateVector4ForUniform;
  81752. private _updateColor3ForEffect;
  81753. private _updateColor3ForUniform;
  81754. private _updateColor4ForEffect;
  81755. private _updateColor4ForUniform;
  81756. /**
  81757. * Sets a sampler uniform on the effect.
  81758. * @param name Define the name of the sampler.
  81759. * @param texture Define the texture to set in the sampler
  81760. */
  81761. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81762. /**
  81763. * Directly updates the value of the uniform in the cache AND on the GPU.
  81764. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81765. * @param data Define the flattened data
  81766. */
  81767. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81768. /**
  81769. * Binds this uniform buffer to an effect.
  81770. * @param effect Define the effect to bind the buffer to
  81771. * @param name Name of the uniform block in the shader.
  81772. */
  81773. bindToEffect(effect: Effect, name: string): void;
  81774. /**
  81775. * Disposes the uniform buffer.
  81776. */
  81777. dispose(): void;
  81778. }
  81779. }
  81780. declare module BABYLON {
  81781. /**
  81782. * Enum that determines the text-wrapping mode to use.
  81783. */
  81784. export enum InspectableType {
  81785. /**
  81786. * Checkbox for booleans
  81787. */
  81788. Checkbox = 0,
  81789. /**
  81790. * Sliders for numbers
  81791. */
  81792. Slider = 1,
  81793. /**
  81794. * Vector3
  81795. */
  81796. Vector3 = 2,
  81797. /**
  81798. * Quaternions
  81799. */
  81800. Quaternion = 3,
  81801. /**
  81802. * Color3
  81803. */
  81804. Color3 = 4,
  81805. /**
  81806. * String
  81807. */
  81808. String = 5
  81809. }
  81810. /**
  81811. * Interface used to define custom inspectable properties.
  81812. * This interface is used by the inspector to display custom property grids
  81813. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81814. */
  81815. export interface IInspectable {
  81816. /**
  81817. * Gets the label to display
  81818. */
  81819. label: string;
  81820. /**
  81821. * Gets the name of the property to edit
  81822. */
  81823. propertyName: string;
  81824. /**
  81825. * Gets the type of the editor to use
  81826. */
  81827. type: InspectableType;
  81828. /**
  81829. * Gets the minimum value of the property when using in "slider" mode
  81830. */
  81831. min?: number;
  81832. /**
  81833. * Gets the maximum value of the property when using in "slider" mode
  81834. */
  81835. max?: number;
  81836. /**
  81837. * Gets the setp to use when using in "slider" mode
  81838. */
  81839. step?: number;
  81840. }
  81841. }
  81842. declare module BABYLON {
  81843. /**
  81844. * Class used to provide helper for timing
  81845. */
  81846. export class TimingTools {
  81847. /**
  81848. * Polyfill for setImmediate
  81849. * @param action defines the action to execute after the current execution block
  81850. */
  81851. static SetImmediate(action: () => void): void;
  81852. }
  81853. }
  81854. declare module BABYLON {
  81855. /**
  81856. * Class used to enable instatition of objects by class name
  81857. */
  81858. export class InstantiationTools {
  81859. /**
  81860. * Use this object to register external classes like custom textures or material
  81861. * to allow the laoders to instantiate them
  81862. */
  81863. static RegisteredExternalClasses: {
  81864. [key: string]: Object;
  81865. };
  81866. /**
  81867. * Tries to instantiate a new object from a given class name
  81868. * @param className defines the class name to instantiate
  81869. * @returns the new object or null if the system was not able to do the instantiation
  81870. */
  81871. static Instantiate(className: string): any;
  81872. }
  81873. }
  81874. declare module BABYLON {
  81875. /**
  81876. * Define options used to create a depth texture
  81877. */
  81878. export class DepthTextureCreationOptions {
  81879. /** Specifies whether or not a stencil should be allocated in the texture */
  81880. generateStencil?: boolean;
  81881. /** Specifies whether or not bilinear filtering is enable on the texture */
  81882. bilinearFiltering?: boolean;
  81883. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81884. comparisonFunction?: number;
  81885. /** Specifies if the created texture is a cube texture */
  81886. isCube?: boolean;
  81887. }
  81888. }
  81889. declare module BABYLON {
  81890. interface ThinEngine {
  81891. /**
  81892. * Creates a depth stencil cube texture.
  81893. * This is only available in WebGL 2.
  81894. * @param size The size of face edge in the cube texture.
  81895. * @param options The options defining the cube texture.
  81896. * @returns The cube texture
  81897. */
  81898. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81899. /**
  81900. * Creates a cube texture
  81901. * @param rootUrl defines the url where the files to load is located
  81902. * @param scene defines the current scene
  81903. * @param files defines the list of files to load (1 per face)
  81904. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81905. * @param onLoad defines an optional callback raised when the texture is loaded
  81906. * @param onError defines an optional callback raised if there is an issue to load the texture
  81907. * @param format defines the format of the data
  81908. * @param forcedExtension defines the extension to use to pick the right loader
  81909. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81910. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81911. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81912. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81913. * @returns the cube texture as an InternalTexture
  81914. */
  81915. 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;
  81916. /**
  81917. * Creates a cube texture
  81918. * @param rootUrl defines the url where the files to load is located
  81919. * @param scene defines the current scene
  81920. * @param files defines the list of files to load (1 per face)
  81921. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81922. * @param onLoad defines an optional callback raised when the texture is loaded
  81923. * @param onError defines an optional callback raised if there is an issue to load the texture
  81924. * @param format defines the format of the data
  81925. * @param forcedExtension defines the extension to use to pick the right loader
  81926. * @returns the cube texture as an InternalTexture
  81927. */
  81928. 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;
  81929. /**
  81930. * Creates a cube texture
  81931. * @param rootUrl defines the url where the files to load is located
  81932. * @param scene defines the current scene
  81933. * @param files defines the list of files to load (1 per face)
  81934. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81935. * @param onLoad defines an optional callback raised when the texture is loaded
  81936. * @param onError defines an optional callback raised if there is an issue to load the texture
  81937. * @param format defines the format of the data
  81938. * @param forcedExtension defines the extension to use to pick the right loader
  81939. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81940. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81941. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81942. * @returns the cube texture as an InternalTexture
  81943. */
  81944. 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;
  81945. /** @hidden */
  81946. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81947. /** @hidden */
  81948. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81949. /** @hidden */
  81950. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81951. /** @hidden */
  81952. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81953. /**
  81954. * @hidden
  81955. */
  81956. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81957. }
  81958. }
  81959. declare module BABYLON {
  81960. /**
  81961. * Class for creating a cube texture
  81962. */
  81963. export class CubeTexture extends BaseTexture {
  81964. private _delayedOnLoad;
  81965. /**
  81966. * Observable triggered once the texture has been loaded.
  81967. */
  81968. onLoadObservable: Observable<CubeTexture>;
  81969. /**
  81970. * The url of the texture
  81971. */
  81972. url: string;
  81973. /**
  81974. * Gets or sets the center of the bounding box associated with the cube texture.
  81975. * It must define where the camera used to render the texture was set
  81976. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81977. */
  81978. boundingBoxPosition: Vector3;
  81979. private _boundingBoxSize;
  81980. /**
  81981. * Gets or sets the size of the bounding box associated with the cube texture
  81982. * When defined, the cubemap will switch to local mode
  81983. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81984. * @example https://www.babylonjs-playground.com/#RNASML
  81985. */
  81986. set boundingBoxSize(value: Vector3);
  81987. /**
  81988. * Returns the bounding box size
  81989. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81990. */
  81991. get boundingBoxSize(): Vector3;
  81992. protected _rotationY: number;
  81993. /**
  81994. * Sets texture matrix rotation angle around Y axis in radians.
  81995. */
  81996. set rotationY(value: number);
  81997. /**
  81998. * Gets texture matrix rotation angle around Y axis radians.
  81999. */
  82000. get rotationY(): number;
  82001. /**
  82002. * Are mip maps generated for this texture or not.
  82003. */
  82004. get noMipmap(): boolean;
  82005. private _noMipmap;
  82006. private _files;
  82007. protected _forcedExtension: Nullable<string>;
  82008. private _extensions;
  82009. private _textureMatrix;
  82010. private _format;
  82011. private _createPolynomials;
  82012. /** @hidden */
  82013. _prefiltered: boolean;
  82014. /**
  82015. * Creates a cube texture from an array of image urls
  82016. * @param files defines an array of image urls
  82017. * @param scene defines the hosting scene
  82018. * @param noMipmap specifies if mip maps are not used
  82019. * @returns a cube texture
  82020. */
  82021. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  82022. /**
  82023. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  82024. * @param url defines the url of the prefiltered texture
  82025. * @param scene defines the scene the texture is attached to
  82026. * @param forcedExtension defines the extension of the file if different from the url
  82027. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82028. * @return the prefiltered texture
  82029. */
  82030. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  82031. /**
  82032. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  82033. * as prefiltered data.
  82034. * @param rootUrl defines the url of the texture or the root name of the six images
  82035. * @param scene defines the scene the texture is attached to
  82036. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  82037. * @param noMipmap defines if mipmaps should be created or not
  82038. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  82039. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  82040. * @param onError defines a callback triggered in case of error during load
  82041. * @param format defines the internal format to use for the texture once loaded
  82042. * @param prefiltered defines whether or not the texture is created from prefiltered data
  82043. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  82044. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82045. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82046. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82047. * @return the cube texture
  82048. */
  82049. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  82050. /**
  82051. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  82052. */
  82053. get isPrefiltered(): boolean;
  82054. /**
  82055. * Get the current class name of the texture useful for serialization or dynamic coding.
  82056. * @returns "CubeTexture"
  82057. */
  82058. getClassName(): string;
  82059. /**
  82060. * Update the url (and optional buffer) of this texture if url was null during construction.
  82061. * @param url the url of the texture
  82062. * @param forcedExtension defines the extension to use
  82063. * @param onLoad callback called when the texture is loaded (defaults to null)
  82064. * @param prefiltered Defines whether the updated texture is prefiltered or not
  82065. */
  82066. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  82067. /**
  82068. * Delays loading of the cube texture
  82069. * @param forcedExtension defines the extension to use
  82070. */
  82071. delayLoad(forcedExtension?: string): void;
  82072. /**
  82073. * Returns the reflection texture matrix
  82074. * @returns the reflection texture matrix
  82075. */
  82076. getReflectionTextureMatrix(): Matrix;
  82077. /**
  82078. * Sets the reflection texture matrix
  82079. * @param value Reflection texture matrix
  82080. */
  82081. setReflectionTextureMatrix(value: Matrix): void;
  82082. /**
  82083. * Parses text to create a cube texture
  82084. * @param parsedTexture define the serialized text to read from
  82085. * @param scene defines the hosting scene
  82086. * @param rootUrl defines the root url of the cube texture
  82087. * @returns a cube texture
  82088. */
  82089. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  82090. /**
  82091. * Makes a clone, or deep copy, of the cube texture
  82092. * @returns a new cube texture
  82093. */
  82094. clone(): CubeTexture;
  82095. }
  82096. }
  82097. declare module BABYLON {
  82098. /**
  82099. * Manages the defines for the Material
  82100. */
  82101. export class MaterialDefines {
  82102. /** @hidden */
  82103. protected _keys: string[];
  82104. private _isDirty;
  82105. /** @hidden */
  82106. _renderId: number;
  82107. /** @hidden */
  82108. _areLightsDirty: boolean;
  82109. /** @hidden */
  82110. _areLightsDisposed: boolean;
  82111. /** @hidden */
  82112. _areAttributesDirty: boolean;
  82113. /** @hidden */
  82114. _areTexturesDirty: boolean;
  82115. /** @hidden */
  82116. _areFresnelDirty: boolean;
  82117. /** @hidden */
  82118. _areMiscDirty: boolean;
  82119. /** @hidden */
  82120. _areImageProcessingDirty: boolean;
  82121. /** @hidden */
  82122. _normals: boolean;
  82123. /** @hidden */
  82124. _uvs: boolean;
  82125. /** @hidden */
  82126. _needNormals: boolean;
  82127. /** @hidden */
  82128. _needUVs: boolean;
  82129. [id: string]: any;
  82130. /**
  82131. * Specifies if the material needs to be re-calculated
  82132. */
  82133. get isDirty(): boolean;
  82134. /**
  82135. * Marks the material to indicate that it has been re-calculated
  82136. */
  82137. markAsProcessed(): void;
  82138. /**
  82139. * Marks the material to indicate that it needs to be re-calculated
  82140. */
  82141. markAsUnprocessed(): void;
  82142. /**
  82143. * Marks the material to indicate all of its defines need to be re-calculated
  82144. */
  82145. markAllAsDirty(): void;
  82146. /**
  82147. * Marks the material to indicate that image processing needs to be re-calculated
  82148. */
  82149. markAsImageProcessingDirty(): void;
  82150. /**
  82151. * Marks the material to indicate the lights need to be re-calculated
  82152. * @param disposed Defines whether the light is dirty due to dispose or not
  82153. */
  82154. markAsLightDirty(disposed?: boolean): void;
  82155. /**
  82156. * Marks the attribute state as changed
  82157. */
  82158. markAsAttributesDirty(): void;
  82159. /**
  82160. * Marks the texture state as changed
  82161. */
  82162. markAsTexturesDirty(): void;
  82163. /**
  82164. * Marks the fresnel state as changed
  82165. */
  82166. markAsFresnelDirty(): void;
  82167. /**
  82168. * Marks the misc state as changed
  82169. */
  82170. markAsMiscDirty(): void;
  82171. /**
  82172. * Rebuilds the material defines
  82173. */
  82174. rebuild(): void;
  82175. /**
  82176. * Specifies if two material defines are equal
  82177. * @param other - A material define instance to compare to
  82178. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  82179. */
  82180. isEqual(other: MaterialDefines): boolean;
  82181. /**
  82182. * Clones this instance's defines to another instance
  82183. * @param other - material defines to clone values to
  82184. */
  82185. cloneTo(other: MaterialDefines): void;
  82186. /**
  82187. * Resets the material define values
  82188. */
  82189. reset(): void;
  82190. /**
  82191. * Converts the material define values to a string
  82192. * @returns - String of material define information
  82193. */
  82194. toString(): string;
  82195. }
  82196. }
  82197. declare module BABYLON {
  82198. /**
  82199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  82200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  82201. * 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;
  82202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  82203. */
  82204. export class ColorCurves {
  82205. private _dirty;
  82206. private _tempColor;
  82207. private _globalCurve;
  82208. private _highlightsCurve;
  82209. private _midtonesCurve;
  82210. private _shadowsCurve;
  82211. private _positiveCurve;
  82212. private _negativeCurve;
  82213. private _globalHue;
  82214. private _globalDensity;
  82215. private _globalSaturation;
  82216. private _globalExposure;
  82217. /**
  82218. * Gets the global Hue value.
  82219. * 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).
  82220. */
  82221. get globalHue(): number;
  82222. /**
  82223. * Sets the global Hue value.
  82224. * 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).
  82225. */
  82226. set globalHue(value: number);
  82227. /**
  82228. * Gets the global Density value.
  82229. * 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.
  82230. * Values less than zero provide a filter of opposite hue.
  82231. */
  82232. get globalDensity(): number;
  82233. /**
  82234. * Sets the global Density value.
  82235. * 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.
  82236. * Values less than zero provide a filter of opposite hue.
  82237. */
  82238. set globalDensity(value: number);
  82239. /**
  82240. * Gets the global Saturation value.
  82241. * 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.
  82242. */
  82243. get globalSaturation(): number;
  82244. /**
  82245. * Sets the global Saturation value.
  82246. * 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.
  82247. */
  82248. set globalSaturation(value: number);
  82249. /**
  82250. * Gets the global Exposure value.
  82251. * 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.
  82252. */
  82253. get globalExposure(): number;
  82254. /**
  82255. * Sets the global Exposure value.
  82256. * 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.
  82257. */
  82258. set globalExposure(value: number);
  82259. private _highlightsHue;
  82260. private _highlightsDensity;
  82261. private _highlightsSaturation;
  82262. private _highlightsExposure;
  82263. /**
  82264. * Gets the highlights Hue value.
  82265. * 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).
  82266. */
  82267. get highlightsHue(): number;
  82268. /**
  82269. * Sets the highlights Hue value.
  82270. * 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).
  82271. */
  82272. set highlightsHue(value: number);
  82273. /**
  82274. * Gets the highlights Density value.
  82275. * 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.
  82276. * Values less than zero provide a filter of opposite hue.
  82277. */
  82278. get highlightsDensity(): number;
  82279. /**
  82280. * Sets the highlights Density value.
  82281. * 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.
  82282. * Values less than zero provide a filter of opposite hue.
  82283. */
  82284. set highlightsDensity(value: number);
  82285. /**
  82286. * Gets the highlights Saturation value.
  82287. * 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.
  82288. */
  82289. get highlightsSaturation(): number;
  82290. /**
  82291. * Sets the highlights Saturation value.
  82292. * 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.
  82293. */
  82294. set highlightsSaturation(value: number);
  82295. /**
  82296. * Gets the highlights Exposure value.
  82297. * 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.
  82298. */
  82299. get highlightsExposure(): number;
  82300. /**
  82301. * Sets the highlights Exposure value.
  82302. * 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.
  82303. */
  82304. set highlightsExposure(value: number);
  82305. private _midtonesHue;
  82306. private _midtonesDensity;
  82307. private _midtonesSaturation;
  82308. private _midtonesExposure;
  82309. /**
  82310. * Gets the midtones Hue value.
  82311. * 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).
  82312. */
  82313. get midtonesHue(): number;
  82314. /**
  82315. * Sets the midtones Hue value.
  82316. * 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).
  82317. */
  82318. set midtonesHue(value: number);
  82319. /**
  82320. * Gets the midtones Density value.
  82321. * 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.
  82322. * Values less than zero provide a filter of opposite hue.
  82323. */
  82324. get midtonesDensity(): number;
  82325. /**
  82326. * Sets the midtones Density value.
  82327. * 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.
  82328. * Values less than zero provide a filter of opposite hue.
  82329. */
  82330. set midtonesDensity(value: number);
  82331. /**
  82332. * Gets the midtones Saturation value.
  82333. * 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.
  82334. */
  82335. get midtonesSaturation(): number;
  82336. /**
  82337. * Sets the midtones Saturation value.
  82338. * 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.
  82339. */
  82340. set midtonesSaturation(value: number);
  82341. /**
  82342. * Gets the midtones Exposure value.
  82343. * 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.
  82344. */
  82345. get midtonesExposure(): number;
  82346. /**
  82347. * Sets the midtones Exposure value.
  82348. * 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.
  82349. */
  82350. set midtonesExposure(value: number);
  82351. private _shadowsHue;
  82352. private _shadowsDensity;
  82353. private _shadowsSaturation;
  82354. private _shadowsExposure;
  82355. /**
  82356. * Gets the shadows Hue value.
  82357. * 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).
  82358. */
  82359. get shadowsHue(): number;
  82360. /**
  82361. * Sets the shadows Hue value.
  82362. * 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).
  82363. */
  82364. set shadowsHue(value: number);
  82365. /**
  82366. * Gets the shadows Density value.
  82367. * 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.
  82368. * Values less than zero provide a filter of opposite hue.
  82369. */
  82370. get shadowsDensity(): number;
  82371. /**
  82372. * Sets the shadows Density value.
  82373. * 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.
  82374. * Values less than zero provide a filter of opposite hue.
  82375. */
  82376. set shadowsDensity(value: number);
  82377. /**
  82378. * Gets the shadows Saturation value.
  82379. * 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.
  82380. */
  82381. get shadowsSaturation(): number;
  82382. /**
  82383. * Sets the shadows Saturation value.
  82384. * 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.
  82385. */
  82386. set shadowsSaturation(value: number);
  82387. /**
  82388. * Gets the shadows Exposure value.
  82389. * 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.
  82390. */
  82391. get shadowsExposure(): number;
  82392. /**
  82393. * Sets the shadows Exposure value.
  82394. * 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.
  82395. */
  82396. set shadowsExposure(value: number);
  82397. /**
  82398. * Returns the class name
  82399. * @returns The class name
  82400. */
  82401. getClassName(): string;
  82402. /**
  82403. * Binds the color curves to the shader.
  82404. * @param colorCurves The color curve to bind
  82405. * @param effect The effect to bind to
  82406. * @param positiveUniform The positive uniform shader parameter
  82407. * @param neutralUniform The neutral uniform shader parameter
  82408. * @param negativeUniform The negative uniform shader parameter
  82409. */
  82410. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  82411. /**
  82412. * Prepare the list of uniforms associated with the ColorCurves effects.
  82413. * @param uniformsList The list of uniforms used in the effect
  82414. */
  82415. static PrepareUniforms(uniformsList: string[]): void;
  82416. /**
  82417. * Returns color grading data based on a hue, density, saturation and exposure value.
  82418. * @param filterHue The hue of the color filter.
  82419. * @param filterDensity The density of the color filter.
  82420. * @param saturation The saturation.
  82421. * @param exposure The exposure.
  82422. * @param result The result data container.
  82423. */
  82424. private getColorGradingDataToRef;
  82425. /**
  82426. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  82427. * @param value The input slider value in range [-100,100].
  82428. * @returns Adjusted value.
  82429. */
  82430. private static applyColorGradingSliderNonlinear;
  82431. /**
  82432. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  82433. * @param hue The hue (H) input.
  82434. * @param saturation The saturation (S) input.
  82435. * @param brightness The brightness (B) input.
  82436. * @result An RGBA color represented as Vector4.
  82437. */
  82438. private static fromHSBToRef;
  82439. /**
  82440. * Returns a value clamped between min and max
  82441. * @param value The value to clamp
  82442. * @param min The minimum of value
  82443. * @param max The maximum of value
  82444. * @returns The clamped value.
  82445. */
  82446. private static clamp;
  82447. /**
  82448. * Clones the current color curve instance.
  82449. * @return The cloned curves
  82450. */
  82451. clone(): ColorCurves;
  82452. /**
  82453. * Serializes the current color curve instance to a json representation.
  82454. * @return a JSON representation
  82455. */
  82456. serialize(): any;
  82457. /**
  82458. * Parses the color curve from a json representation.
  82459. * @param source the JSON source to parse
  82460. * @return The parsed curves
  82461. */
  82462. static Parse(source: any): ColorCurves;
  82463. }
  82464. }
  82465. declare module BABYLON {
  82466. /**
  82467. * Interface to follow in your material defines to integrate easily the
  82468. * Image proccessing functions.
  82469. * @hidden
  82470. */
  82471. export interface IImageProcessingConfigurationDefines {
  82472. IMAGEPROCESSING: boolean;
  82473. VIGNETTE: boolean;
  82474. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82475. VIGNETTEBLENDMODEOPAQUE: boolean;
  82476. TONEMAPPING: boolean;
  82477. TONEMAPPING_ACES: boolean;
  82478. CONTRAST: boolean;
  82479. EXPOSURE: boolean;
  82480. COLORCURVES: boolean;
  82481. COLORGRADING: boolean;
  82482. COLORGRADING3D: boolean;
  82483. SAMPLER3DGREENDEPTH: boolean;
  82484. SAMPLER3DBGRMAP: boolean;
  82485. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82486. }
  82487. /**
  82488. * @hidden
  82489. */
  82490. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  82491. IMAGEPROCESSING: boolean;
  82492. VIGNETTE: boolean;
  82493. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82494. VIGNETTEBLENDMODEOPAQUE: boolean;
  82495. TONEMAPPING: boolean;
  82496. TONEMAPPING_ACES: boolean;
  82497. CONTRAST: boolean;
  82498. COLORCURVES: boolean;
  82499. COLORGRADING: boolean;
  82500. COLORGRADING3D: boolean;
  82501. SAMPLER3DGREENDEPTH: boolean;
  82502. SAMPLER3DBGRMAP: boolean;
  82503. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82504. EXPOSURE: boolean;
  82505. constructor();
  82506. }
  82507. /**
  82508. * This groups together the common properties used for image processing either in direct forward pass
  82509. * or through post processing effect depending on the use of the image processing pipeline in your scene
  82510. * or not.
  82511. */
  82512. export class ImageProcessingConfiguration {
  82513. /**
  82514. * Default tone mapping applied in BabylonJS.
  82515. */
  82516. static readonly TONEMAPPING_STANDARD: number;
  82517. /**
  82518. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  82519. * to other engines rendering to increase portability.
  82520. */
  82521. static readonly TONEMAPPING_ACES: number;
  82522. /**
  82523. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  82524. */
  82525. colorCurves: Nullable<ColorCurves>;
  82526. private _colorCurvesEnabled;
  82527. /**
  82528. * Gets wether the color curves effect is enabled.
  82529. */
  82530. get colorCurvesEnabled(): boolean;
  82531. /**
  82532. * Sets wether the color curves effect is enabled.
  82533. */
  82534. set colorCurvesEnabled(value: boolean);
  82535. private _colorGradingTexture;
  82536. /**
  82537. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82538. */
  82539. get colorGradingTexture(): Nullable<BaseTexture>;
  82540. /**
  82541. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82542. */
  82543. set colorGradingTexture(value: Nullable<BaseTexture>);
  82544. private _colorGradingEnabled;
  82545. /**
  82546. * Gets wether the color grading effect is enabled.
  82547. */
  82548. get colorGradingEnabled(): boolean;
  82549. /**
  82550. * Sets wether the color grading effect is enabled.
  82551. */
  82552. set colorGradingEnabled(value: boolean);
  82553. private _colorGradingWithGreenDepth;
  82554. /**
  82555. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  82556. */
  82557. get colorGradingWithGreenDepth(): boolean;
  82558. /**
  82559. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  82560. */
  82561. set colorGradingWithGreenDepth(value: boolean);
  82562. private _colorGradingBGR;
  82563. /**
  82564. * Gets wether the color grading texture contains BGR values.
  82565. */
  82566. get colorGradingBGR(): boolean;
  82567. /**
  82568. * Sets wether the color grading texture contains BGR values.
  82569. */
  82570. set colorGradingBGR(value: boolean);
  82571. /** @hidden */
  82572. _exposure: number;
  82573. /**
  82574. * Gets the Exposure used in the effect.
  82575. */
  82576. get exposure(): number;
  82577. /**
  82578. * Sets the Exposure used in the effect.
  82579. */
  82580. set exposure(value: number);
  82581. private _toneMappingEnabled;
  82582. /**
  82583. * Gets wether the tone mapping effect is enabled.
  82584. */
  82585. get toneMappingEnabled(): boolean;
  82586. /**
  82587. * Sets wether the tone mapping effect is enabled.
  82588. */
  82589. set toneMappingEnabled(value: boolean);
  82590. private _toneMappingType;
  82591. /**
  82592. * Gets the type of tone mapping effect.
  82593. */
  82594. get toneMappingType(): number;
  82595. /**
  82596. * Sets the type of tone mapping effect used in BabylonJS.
  82597. */
  82598. set toneMappingType(value: number);
  82599. protected _contrast: number;
  82600. /**
  82601. * Gets the contrast used in the effect.
  82602. */
  82603. get contrast(): number;
  82604. /**
  82605. * Sets the contrast used in the effect.
  82606. */
  82607. set contrast(value: number);
  82608. /**
  82609. * Vignette stretch size.
  82610. */
  82611. vignetteStretch: number;
  82612. /**
  82613. * Vignette centre X Offset.
  82614. */
  82615. vignetteCentreX: number;
  82616. /**
  82617. * Vignette centre Y Offset.
  82618. */
  82619. vignetteCentreY: number;
  82620. /**
  82621. * Vignette weight or intensity of the vignette effect.
  82622. */
  82623. vignetteWeight: number;
  82624. /**
  82625. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82626. * if vignetteEnabled is set to true.
  82627. */
  82628. vignetteColor: Color4;
  82629. /**
  82630. * Camera field of view used by the Vignette effect.
  82631. */
  82632. vignetteCameraFov: number;
  82633. private _vignetteBlendMode;
  82634. /**
  82635. * Gets the vignette blend mode allowing different kind of effect.
  82636. */
  82637. get vignetteBlendMode(): number;
  82638. /**
  82639. * Sets the vignette blend mode allowing different kind of effect.
  82640. */
  82641. set vignetteBlendMode(value: number);
  82642. private _vignetteEnabled;
  82643. /**
  82644. * Gets wether the vignette effect is enabled.
  82645. */
  82646. get vignetteEnabled(): boolean;
  82647. /**
  82648. * Sets wether the vignette effect is enabled.
  82649. */
  82650. set vignetteEnabled(value: boolean);
  82651. private _applyByPostProcess;
  82652. /**
  82653. * Gets wether the image processing is applied through a post process or not.
  82654. */
  82655. get applyByPostProcess(): boolean;
  82656. /**
  82657. * Sets wether the image processing is applied through a post process or not.
  82658. */
  82659. set applyByPostProcess(value: boolean);
  82660. private _isEnabled;
  82661. /**
  82662. * Gets wether the image processing is enabled or not.
  82663. */
  82664. get isEnabled(): boolean;
  82665. /**
  82666. * Sets wether the image processing is enabled or not.
  82667. */
  82668. set isEnabled(value: boolean);
  82669. /**
  82670. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82671. */
  82672. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82673. /**
  82674. * Method called each time the image processing information changes requires to recompile the effect.
  82675. */
  82676. protected _updateParameters(): void;
  82677. /**
  82678. * Gets the current class name.
  82679. * @return "ImageProcessingConfiguration"
  82680. */
  82681. getClassName(): string;
  82682. /**
  82683. * Prepare the list of uniforms associated with the Image Processing effects.
  82684. * @param uniforms The list of uniforms used in the effect
  82685. * @param defines the list of defines currently in use
  82686. */
  82687. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82688. /**
  82689. * Prepare the list of samplers associated with the Image Processing effects.
  82690. * @param samplersList The list of uniforms used in the effect
  82691. * @param defines the list of defines currently in use
  82692. */
  82693. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82694. /**
  82695. * Prepare the list of defines associated to the shader.
  82696. * @param defines the list of defines to complete
  82697. * @param forPostProcess Define if we are currently in post process mode or not
  82698. */
  82699. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82700. /**
  82701. * Returns true if all the image processing information are ready.
  82702. * @returns True if ready, otherwise, false
  82703. */
  82704. isReady(): boolean;
  82705. /**
  82706. * Binds the image processing to the shader.
  82707. * @param effect The effect to bind to
  82708. * @param overrideAspectRatio Override the aspect ratio of the effect
  82709. */
  82710. bind(effect: Effect, overrideAspectRatio?: number): void;
  82711. /**
  82712. * Clones the current image processing instance.
  82713. * @return The cloned image processing
  82714. */
  82715. clone(): ImageProcessingConfiguration;
  82716. /**
  82717. * Serializes the current image processing instance to a json representation.
  82718. * @return a JSON representation
  82719. */
  82720. serialize(): any;
  82721. /**
  82722. * Parses the image processing from a json representation.
  82723. * @param source the JSON source to parse
  82724. * @return The parsed image processing
  82725. */
  82726. static Parse(source: any): ImageProcessingConfiguration;
  82727. private static _VIGNETTEMODE_MULTIPLY;
  82728. private static _VIGNETTEMODE_OPAQUE;
  82729. /**
  82730. * Used to apply the vignette as a mix with the pixel color.
  82731. */
  82732. static get VIGNETTEMODE_MULTIPLY(): number;
  82733. /**
  82734. * Used to apply the vignette as a replacement of the pixel color.
  82735. */
  82736. static get VIGNETTEMODE_OPAQUE(): number;
  82737. }
  82738. }
  82739. declare module BABYLON {
  82740. /** @hidden */
  82741. export var postprocessVertexShader: {
  82742. name: string;
  82743. shader: string;
  82744. };
  82745. }
  82746. declare module BABYLON {
  82747. interface ThinEngine {
  82748. /**
  82749. * Creates a new render target texture
  82750. * @param size defines the size of the texture
  82751. * @param options defines the options used to create the texture
  82752. * @returns a new render target texture stored in an InternalTexture
  82753. */
  82754. createRenderTargetTexture(size: number | {
  82755. width: number;
  82756. height: number;
  82757. layers?: number;
  82758. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82759. /**
  82760. * Creates a depth stencil texture.
  82761. * This is only available in WebGL 2 or with the depth texture extension available.
  82762. * @param size The size of face edge in the texture.
  82763. * @param options The options defining the texture.
  82764. * @returns The texture
  82765. */
  82766. createDepthStencilTexture(size: number | {
  82767. width: number;
  82768. height: number;
  82769. layers?: number;
  82770. }, options: DepthTextureCreationOptions): InternalTexture;
  82771. /** @hidden */
  82772. _createDepthStencilTexture(size: number | {
  82773. width: number;
  82774. height: number;
  82775. layers?: number;
  82776. }, options: DepthTextureCreationOptions): InternalTexture;
  82777. }
  82778. }
  82779. declare module BABYLON {
  82780. /** Defines supported spaces */
  82781. export enum Space {
  82782. /** Local (object) space */
  82783. LOCAL = 0,
  82784. /** World space */
  82785. WORLD = 1,
  82786. /** Bone space */
  82787. BONE = 2
  82788. }
  82789. /** Defines the 3 main axes */
  82790. export class Axis {
  82791. /** X axis */
  82792. static X: Vector3;
  82793. /** Y axis */
  82794. static Y: Vector3;
  82795. /** Z axis */
  82796. static Z: Vector3;
  82797. }
  82798. }
  82799. declare module BABYLON {
  82800. /**
  82801. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82802. * This is the base of the follow, arc rotate cameras and Free camera
  82803. * @see http://doc.babylonjs.com/features/cameras
  82804. */
  82805. export class TargetCamera extends Camera {
  82806. private static _RigCamTransformMatrix;
  82807. private static _TargetTransformMatrix;
  82808. private static _TargetFocalPoint;
  82809. /**
  82810. * Define the current direction the camera is moving to
  82811. */
  82812. cameraDirection: Vector3;
  82813. /**
  82814. * Define the current rotation the camera is rotating to
  82815. */
  82816. cameraRotation: Vector2;
  82817. /**
  82818. * When set, the up vector of the camera will be updated by the rotation of the camera
  82819. */
  82820. updateUpVectorFromRotation: boolean;
  82821. private _tmpQuaternion;
  82822. /**
  82823. * Define the current rotation of the camera
  82824. */
  82825. rotation: Vector3;
  82826. /**
  82827. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82828. */
  82829. rotationQuaternion: Quaternion;
  82830. /**
  82831. * Define the current speed of the camera
  82832. */
  82833. speed: number;
  82834. /**
  82835. * Add constraint to the camera to prevent it to move freely in all directions and
  82836. * around all axis.
  82837. */
  82838. noRotationConstraint: boolean;
  82839. /**
  82840. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82841. * panning
  82842. */
  82843. invertRotation: boolean;
  82844. /**
  82845. * Speed multiplier for inverse camera panning
  82846. */
  82847. inverseRotationSpeed: number;
  82848. /**
  82849. * Define the current target of the camera as an object or a position.
  82850. */
  82851. lockedTarget: any;
  82852. /** @hidden */
  82853. _currentTarget: Vector3;
  82854. /** @hidden */
  82855. _initialFocalDistance: number;
  82856. /** @hidden */
  82857. _viewMatrix: Matrix;
  82858. /** @hidden */
  82859. _camMatrix: Matrix;
  82860. /** @hidden */
  82861. _cameraTransformMatrix: Matrix;
  82862. /** @hidden */
  82863. _cameraRotationMatrix: Matrix;
  82864. /** @hidden */
  82865. _referencePoint: Vector3;
  82866. /** @hidden */
  82867. _transformedReferencePoint: Vector3;
  82868. protected _globalCurrentTarget: Vector3;
  82869. protected _globalCurrentUpVector: Vector3;
  82870. /** @hidden */
  82871. _reset: () => void;
  82872. private _defaultUp;
  82873. /**
  82874. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82875. * This is the base of the follow, arc rotate cameras and Free camera
  82876. * @see http://doc.babylonjs.com/features/cameras
  82877. * @param name Defines the name of the camera in the scene
  82878. * @param position Defines the start position of the camera in the scene
  82879. * @param scene Defines the scene the camera belongs to
  82880. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82881. */
  82882. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82883. /**
  82884. * Gets the position in front of the camera at a given distance.
  82885. * @param distance The distance from the camera we want the position to be
  82886. * @returns the position
  82887. */
  82888. getFrontPosition(distance: number): Vector3;
  82889. /** @hidden */
  82890. _getLockedTargetPosition(): Nullable<Vector3>;
  82891. private _storedPosition;
  82892. private _storedRotation;
  82893. private _storedRotationQuaternion;
  82894. /**
  82895. * Store current camera state of the camera (fov, position, rotation, etc..)
  82896. * @returns the camera
  82897. */
  82898. storeState(): Camera;
  82899. /**
  82900. * Restored camera state. You must call storeState() first
  82901. * @returns whether it was successful or not
  82902. * @hidden
  82903. */
  82904. _restoreStateValues(): boolean;
  82905. /** @hidden */
  82906. _initCache(): void;
  82907. /** @hidden */
  82908. _updateCache(ignoreParentClass?: boolean): void;
  82909. /** @hidden */
  82910. _isSynchronizedViewMatrix(): boolean;
  82911. /** @hidden */
  82912. _computeLocalCameraSpeed(): number;
  82913. /**
  82914. * Defines the target the camera should look at.
  82915. * @param target Defines the new target as a Vector or a mesh
  82916. */
  82917. setTarget(target: Vector3): void;
  82918. /**
  82919. * Return the current target position of the camera. This value is expressed in local space.
  82920. * @returns the target position
  82921. */
  82922. getTarget(): Vector3;
  82923. /** @hidden */
  82924. _decideIfNeedsToMove(): boolean;
  82925. /** @hidden */
  82926. _updatePosition(): void;
  82927. /** @hidden */
  82928. _checkInputs(): void;
  82929. protected _updateCameraRotationMatrix(): void;
  82930. /**
  82931. * 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)
  82932. * @returns the current camera
  82933. */
  82934. private _rotateUpVectorWithCameraRotationMatrix;
  82935. private _cachedRotationZ;
  82936. private _cachedQuaternionRotationZ;
  82937. /** @hidden */
  82938. _getViewMatrix(): Matrix;
  82939. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82940. /**
  82941. * @hidden
  82942. */
  82943. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82944. /**
  82945. * @hidden
  82946. */
  82947. _updateRigCameras(): void;
  82948. private _getRigCamPositionAndTarget;
  82949. /**
  82950. * Gets the current object class name.
  82951. * @return the class name
  82952. */
  82953. getClassName(): string;
  82954. }
  82955. }
  82956. declare module BABYLON {
  82957. /**
  82958. * Gather the list of keyboard event types as constants.
  82959. */
  82960. export class KeyboardEventTypes {
  82961. /**
  82962. * The keydown event is fired when a key becomes active (pressed).
  82963. */
  82964. static readonly KEYDOWN: number;
  82965. /**
  82966. * The keyup event is fired when a key has been released.
  82967. */
  82968. static readonly KEYUP: number;
  82969. }
  82970. /**
  82971. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82972. */
  82973. export class KeyboardInfo {
  82974. /**
  82975. * Defines the type of event (KeyboardEventTypes)
  82976. */
  82977. type: number;
  82978. /**
  82979. * Defines the related dom event
  82980. */
  82981. event: KeyboardEvent;
  82982. /**
  82983. * Instantiates a new keyboard info.
  82984. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82985. * @param type Defines the type of event (KeyboardEventTypes)
  82986. * @param event Defines the related dom event
  82987. */
  82988. constructor(
  82989. /**
  82990. * Defines the type of event (KeyboardEventTypes)
  82991. */
  82992. type: number,
  82993. /**
  82994. * Defines the related dom event
  82995. */
  82996. event: KeyboardEvent);
  82997. }
  82998. /**
  82999. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83000. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  83001. */
  83002. export class KeyboardInfoPre extends KeyboardInfo {
  83003. /**
  83004. * Defines the type of event (KeyboardEventTypes)
  83005. */
  83006. type: number;
  83007. /**
  83008. * Defines the related dom event
  83009. */
  83010. event: KeyboardEvent;
  83011. /**
  83012. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  83013. */
  83014. skipOnPointerObservable: boolean;
  83015. /**
  83016. * Instantiates a new keyboard pre info.
  83017. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83018. * @param type Defines the type of event (KeyboardEventTypes)
  83019. * @param event Defines the related dom event
  83020. */
  83021. constructor(
  83022. /**
  83023. * Defines the type of event (KeyboardEventTypes)
  83024. */
  83025. type: number,
  83026. /**
  83027. * Defines the related dom event
  83028. */
  83029. event: KeyboardEvent);
  83030. }
  83031. }
  83032. declare module BABYLON {
  83033. /**
  83034. * Manage the keyboard inputs to control the movement of a free camera.
  83035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83036. */
  83037. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  83038. /**
  83039. * Defines the camera the input is attached to.
  83040. */
  83041. camera: FreeCamera;
  83042. /**
  83043. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83044. */
  83045. keysUp: number[];
  83046. /**
  83047. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  83048. */
  83049. keysUpward: number[];
  83050. /**
  83051. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83052. */
  83053. keysDown: number[];
  83054. /**
  83055. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  83056. */
  83057. keysDownward: number[];
  83058. /**
  83059. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83060. */
  83061. keysLeft: number[];
  83062. /**
  83063. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83064. */
  83065. keysRight: number[];
  83066. private _keys;
  83067. private _onCanvasBlurObserver;
  83068. private _onKeyboardObserver;
  83069. private _engine;
  83070. private _scene;
  83071. /**
  83072. * Attach the input controls to a specific dom element to get the input from.
  83073. * @param element Defines the element the controls should be listened from
  83074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83075. */
  83076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83077. /**
  83078. * Detach the current controls from the specified dom element.
  83079. * @param element Defines the element to stop listening the inputs from
  83080. */
  83081. detachControl(element: Nullable<HTMLElement>): void;
  83082. /**
  83083. * Update the current camera state depending on the inputs that have been used this frame.
  83084. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83085. */
  83086. checkInputs(): void;
  83087. /**
  83088. * Gets the class name of the current intput.
  83089. * @returns the class name
  83090. */
  83091. getClassName(): string;
  83092. /** @hidden */
  83093. _onLostFocus(): void;
  83094. /**
  83095. * Get the friendly name associated with the input class.
  83096. * @returns the input friendly name
  83097. */
  83098. getSimpleName(): string;
  83099. }
  83100. }
  83101. declare module BABYLON {
  83102. /**
  83103. * Interface describing all the common properties and methods a shadow light needs to implement.
  83104. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  83105. * as well as binding the different shadow properties to the effects.
  83106. */
  83107. export interface IShadowLight extends Light {
  83108. /**
  83109. * The light id in the scene (used in scene.findLighById for instance)
  83110. */
  83111. id: string;
  83112. /**
  83113. * The position the shdow will be casted from.
  83114. */
  83115. position: Vector3;
  83116. /**
  83117. * In 2d mode (needCube being false), the direction used to cast the shadow.
  83118. */
  83119. direction: Vector3;
  83120. /**
  83121. * The transformed position. Position of the light in world space taking parenting in account.
  83122. */
  83123. transformedPosition: Vector3;
  83124. /**
  83125. * The transformed direction. Direction of the light in world space taking parenting in account.
  83126. */
  83127. transformedDirection: Vector3;
  83128. /**
  83129. * The friendly name of the light in the scene.
  83130. */
  83131. name: string;
  83132. /**
  83133. * Defines the shadow projection clipping minimum z value.
  83134. */
  83135. shadowMinZ: number;
  83136. /**
  83137. * Defines the shadow projection clipping maximum z value.
  83138. */
  83139. shadowMaxZ: number;
  83140. /**
  83141. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83142. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83143. */
  83144. computeTransformedInformation(): boolean;
  83145. /**
  83146. * Gets the scene the light belongs to.
  83147. * @returns The scene
  83148. */
  83149. getScene(): Scene;
  83150. /**
  83151. * Callback defining a custom Projection Matrix Builder.
  83152. * This can be used to override the default projection matrix computation.
  83153. */
  83154. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83155. /**
  83156. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83157. * @param matrix The materix to updated with the projection information
  83158. * @param viewMatrix The transform matrix of the light
  83159. * @param renderList The list of mesh to render in the map
  83160. * @returns The current light
  83161. */
  83162. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83163. /**
  83164. * Gets the current depth scale used in ESM.
  83165. * @returns The scale
  83166. */
  83167. getDepthScale(): number;
  83168. /**
  83169. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83170. * @returns true if a cube texture needs to be use
  83171. */
  83172. needCube(): boolean;
  83173. /**
  83174. * Detects if the projection matrix requires to be recomputed this frame.
  83175. * @returns true if it requires to be recomputed otherwise, false.
  83176. */
  83177. needProjectionMatrixCompute(): boolean;
  83178. /**
  83179. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83180. */
  83181. forceProjectionMatrixCompute(): void;
  83182. /**
  83183. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83184. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83185. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83186. */
  83187. getShadowDirection(faceIndex?: number): Vector3;
  83188. /**
  83189. * Gets the minZ used for shadow according to both the scene and the light.
  83190. * @param activeCamera The camera we are returning the min for
  83191. * @returns the depth min z
  83192. */
  83193. getDepthMinZ(activeCamera: Camera): number;
  83194. /**
  83195. * Gets the maxZ used for shadow according to both the scene and the light.
  83196. * @param activeCamera The camera we are returning the max for
  83197. * @returns the depth max z
  83198. */
  83199. getDepthMaxZ(activeCamera: Camera): number;
  83200. }
  83201. /**
  83202. * Base implementation IShadowLight
  83203. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  83204. */
  83205. export abstract class ShadowLight extends Light implements IShadowLight {
  83206. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  83207. protected _position: Vector3;
  83208. protected _setPosition(value: Vector3): void;
  83209. /**
  83210. * Sets the position the shadow will be casted from. Also use as the light position for both
  83211. * point and spot lights.
  83212. */
  83213. get position(): Vector3;
  83214. /**
  83215. * Sets the position the shadow will be casted from. Also use as the light position for both
  83216. * point and spot lights.
  83217. */
  83218. set position(value: Vector3);
  83219. protected _direction: Vector3;
  83220. protected _setDirection(value: Vector3): void;
  83221. /**
  83222. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  83223. * Also use as the light direction on spot and directional lights.
  83224. */
  83225. get direction(): Vector3;
  83226. /**
  83227. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  83228. * Also use as the light direction on spot and directional lights.
  83229. */
  83230. set direction(value: Vector3);
  83231. protected _shadowMinZ: number;
  83232. /**
  83233. * Gets the shadow projection clipping minimum z value.
  83234. */
  83235. get shadowMinZ(): number;
  83236. /**
  83237. * Sets the shadow projection clipping minimum z value.
  83238. */
  83239. set shadowMinZ(value: number);
  83240. protected _shadowMaxZ: number;
  83241. /**
  83242. * Sets the shadow projection clipping maximum z value.
  83243. */
  83244. get shadowMaxZ(): number;
  83245. /**
  83246. * Gets the shadow projection clipping maximum z value.
  83247. */
  83248. set shadowMaxZ(value: number);
  83249. /**
  83250. * Callback defining a custom Projection Matrix Builder.
  83251. * This can be used to override the default projection matrix computation.
  83252. */
  83253. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83254. /**
  83255. * The transformed position. Position of the light in world space taking parenting in account.
  83256. */
  83257. transformedPosition: Vector3;
  83258. /**
  83259. * The transformed direction. Direction of the light in world space taking parenting in account.
  83260. */
  83261. transformedDirection: Vector3;
  83262. private _needProjectionMatrixCompute;
  83263. /**
  83264. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83265. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83266. */
  83267. computeTransformedInformation(): boolean;
  83268. /**
  83269. * Return the depth scale used for the shadow map.
  83270. * @returns the depth scale.
  83271. */
  83272. getDepthScale(): number;
  83273. /**
  83274. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83275. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83276. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83277. */
  83278. getShadowDirection(faceIndex?: number): Vector3;
  83279. /**
  83280. * Returns the ShadowLight absolute position in the World.
  83281. * @returns the position vector in world space
  83282. */
  83283. getAbsolutePosition(): Vector3;
  83284. /**
  83285. * Sets the ShadowLight direction toward the passed target.
  83286. * @param target The point to target in local space
  83287. * @returns the updated ShadowLight direction
  83288. */
  83289. setDirectionToTarget(target: Vector3): Vector3;
  83290. /**
  83291. * Returns the light rotation in euler definition.
  83292. * @returns the x y z rotation in local space.
  83293. */
  83294. getRotation(): Vector3;
  83295. /**
  83296. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83297. * @returns true if a cube texture needs to be use
  83298. */
  83299. needCube(): boolean;
  83300. /**
  83301. * Detects if the projection matrix requires to be recomputed this frame.
  83302. * @returns true if it requires to be recomputed otherwise, false.
  83303. */
  83304. needProjectionMatrixCompute(): boolean;
  83305. /**
  83306. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83307. */
  83308. forceProjectionMatrixCompute(): void;
  83309. /** @hidden */
  83310. _initCache(): void;
  83311. /** @hidden */
  83312. _isSynchronized(): boolean;
  83313. /**
  83314. * Computes the world matrix of the node
  83315. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83316. * @returns the world matrix
  83317. */
  83318. computeWorldMatrix(force?: boolean): Matrix;
  83319. /**
  83320. * Gets the minZ used for shadow according to both the scene and the light.
  83321. * @param activeCamera The camera we are returning the min for
  83322. * @returns the depth min z
  83323. */
  83324. getDepthMinZ(activeCamera: Camera): number;
  83325. /**
  83326. * Gets the maxZ used for shadow according to both the scene and the light.
  83327. * @param activeCamera The camera we are returning the max for
  83328. * @returns the depth max z
  83329. */
  83330. getDepthMaxZ(activeCamera: Camera): number;
  83331. /**
  83332. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83333. * @param matrix The materix to updated with the projection information
  83334. * @param viewMatrix The transform matrix of the light
  83335. * @param renderList The list of mesh to render in the map
  83336. * @returns The current light
  83337. */
  83338. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83339. }
  83340. }
  83341. declare module BABYLON {
  83342. /**
  83343. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  83344. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  83345. */
  83346. export class EffectFallbacks implements IEffectFallbacks {
  83347. private _defines;
  83348. private _currentRank;
  83349. private _maxRank;
  83350. private _mesh;
  83351. /**
  83352. * Removes the fallback from the bound mesh.
  83353. */
  83354. unBindMesh(): void;
  83355. /**
  83356. * Adds a fallback on the specified property.
  83357. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83358. * @param define The name of the define in the shader
  83359. */
  83360. addFallback(rank: number, define: string): void;
  83361. /**
  83362. * Sets the mesh to use CPU skinning when needing to fallback.
  83363. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83364. * @param mesh The mesh to use the fallbacks.
  83365. */
  83366. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  83367. /**
  83368. * Checks to see if more fallbacks are still availible.
  83369. */
  83370. get hasMoreFallbacks(): boolean;
  83371. /**
  83372. * Removes the defines that should be removed when falling back.
  83373. * @param currentDefines defines the current define statements for the shader.
  83374. * @param effect defines the current effect we try to compile
  83375. * @returns The resulting defines with defines of the current rank removed.
  83376. */
  83377. reduce(currentDefines: string, effect: Effect): string;
  83378. }
  83379. }
  83380. declare module BABYLON {
  83381. /**
  83382. * "Static Class" containing the most commonly used helper while dealing with material for
  83383. * rendering purpose.
  83384. *
  83385. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  83386. *
  83387. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  83388. */
  83389. export class MaterialHelper {
  83390. /**
  83391. * Bind the current view position to an effect.
  83392. * @param effect The effect to be bound
  83393. * @param scene The scene the eyes position is used from
  83394. */
  83395. static BindEyePosition(effect: Effect, scene: Scene): void;
  83396. /**
  83397. * Helps preparing the defines values about the UVs in used in the effect.
  83398. * UVs are shared as much as we can accross channels in the shaders.
  83399. * @param texture The texture we are preparing the UVs for
  83400. * @param defines The defines to update
  83401. * @param key The channel key "diffuse", "specular"... used in the shader
  83402. */
  83403. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  83404. /**
  83405. * Binds a texture matrix value to its corrsponding uniform
  83406. * @param texture The texture to bind the matrix for
  83407. * @param uniformBuffer The uniform buffer receivin the data
  83408. * @param key The channel key "diffuse", "specular"... used in the shader
  83409. */
  83410. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  83411. /**
  83412. * Gets the current status of the fog (should it be enabled?)
  83413. * @param mesh defines the mesh to evaluate for fog support
  83414. * @param scene defines the hosting scene
  83415. * @returns true if fog must be enabled
  83416. */
  83417. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  83418. /**
  83419. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  83420. * @param mesh defines the current mesh
  83421. * @param scene defines the current scene
  83422. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  83423. * @param pointsCloud defines if point cloud rendering has to be turned on
  83424. * @param fogEnabled defines if fog has to be turned on
  83425. * @param alphaTest defines if alpha testing has to be turned on
  83426. * @param defines defines the current list of defines
  83427. */
  83428. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  83429. /**
  83430. * Helper used to prepare the list of defines associated with frame values for shader compilation
  83431. * @param scene defines the current scene
  83432. * @param engine defines the current engine
  83433. * @param defines specifies the list of active defines
  83434. * @param useInstances defines if instances have to be turned on
  83435. * @param useClipPlane defines if clip plane have to be turned on
  83436. */
  83437. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  83438. /**
  83439. * Prepares the defines for bones
  83440. * @param mesh The mesh containing the geometry data we will draw
  83441. * @param defines The defines to update
  83442. */
  83443. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  83444. /**
  83445. * Prepares the defines for morph targets
  83446. * @param mesh The mesh containing the geometry data we will draw
  83447. * @param defines The defines to update
  83448. */
  83449. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  83450. /**
  83451. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  83452. * @param mesh The mesh containing the geometry data we will draw
  83453. * @param defines The defines to update
  83454. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  83455. * @param useBones Precise whether bones should be used or not (override mesh info)
  83456. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  83457. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  83458. * @returns false if defines are considered not dirty and have not been checked
  83459. */
  83460. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  83461. /**
  83462. * Prepares the defines related to multiview
  83463. * @param scene The scene we are intending to draw
  83464. * @param defines The defines to update
  83465. */
  83466. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  83467. /**
  83468. * Prepares the defines related to the light information passed in parameter
  83469. * @param scene The scene we are intending to draw
  83470. * @param mesh The mesh the effect is compiling for
  83471. * @param light The light the effect is compiling for
  83472. * @param lightIndex The index of the light
  83473. * @param defines The defines to update
  83474. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83475. * @param state Defines the current state regarding what is needed (normals, etc...)
  83476. */
  83477. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  83478. needNormals: boolean;
  83479. needRebuild: boolean;
  83480. shadowEnabled: boolean;
  83481. specularEnabled: boolean;
  83482. lightmapMode: boolean;
  83483. }): void;
  83484. /**
  83485. * Prepares the defines related to the light information passed in parameter
  83486. * @param scene The scene we are intending to draw
  83487. * @param mesh The mesh the effect is compiling for
  83488. * @param defines The defines to update
  83489. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83490. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  83491. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  83492. * @returns true if normals will be required for the rest of the effect
  83493. */
  83494. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  83495. /**
  83496. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  83497. * @param lightIndex defines the light index
  83498. * @param uniformsList The uniform list
  83499. * @param samplersList The sampler list
  83500. * @param projectedLightTexture defines if projected texture must be used
  83501. * @param uniformBuffersList defines an optional list of uniform buffers
  83502. */
  83503. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  83504. /**
  83505. * Prepares the uniforms and samplers list to be used in the effect
  83506. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  83507. * @param samplersList The sampler list
  83508. * @param defines The defines helping in the list generation
  83509. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  83510. */
  83511. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  83512. /**
  83513. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  83514. * @param defines The defines to update while falling back
  83515. * @param fallbacks The authorized effect fallbacks
  83516. * @param maxSimultaneousLights The maximum number of lights allowed
  83517. * @param rank the current rank of the Effect
  83518. * @returns The newly affected rank
  83519. */
  83520. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  83521. private static _TmpMorphInfluencers;
  83522. /**
  83523. * Prepares the list of attributes required for morph targets according to the effect defines.
  83524. * @param attribs The current list of supported attribs
  83525. * @param mesh The mesh to prepare the morph targets attributes for
  83526. * @param influencers The number of influencers
  83527. */
  83528. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  83529. /**
  83530. * Prepares the list of attributes required for morph targets according to the effect defines.
  83531. * @param attribs The current list of supported attribs
  83532. * @param mesh The mesh to prepare the morph targets attributes for
  83533. * @param defines The current Defines of the effect
  83534. */
  83535. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  83536. /**
  83537. * Prepares the list of attributes required for bones according to the effect defines.
  83538. * @param attribs The current list of supported attribs
  83539. * @param mesh The mesh to prepare the bones attributes for
  83540. * @param defines The current Defines of the effect
  83541. * @param fallbacks The current efffect fallback strategy
  83542. */
  83543. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  83544. /**
  83545. * Check and prepare the list of attributes required for instances according to the effect defines.
  83546. * @param attribs The current list of supported attribs
  83547. * @param defines The current MaterialDefines of the effect
  83548. */
  83549. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  83550. /**
  83551. * Add the list of attributes required for instances to the attribs array.
  83552. * @param attribs The current list of supported attribs
  83553. */
  83554. static PushAttributesForInstances(attribs: string[]): void;
  83555. /**
  83556. * Binds the light information to the effect.
  83557. * @param light The light containing the generator
  83558. * @param effect The effect we are binding the data to
  83559. * @param lightIndex The light index in the effect used to render
  83560. */
  83561. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  83562. /**
  83563. * Binds the lights information from the scene to the effect for the given mesh.
  83564. * @param light Light to bind
  83565. * @param lightIndex Light index
  83566. * @param scene The scene where the light belongs to
  83567. * @param effect The effect we are binding the data to
  83568. * @param useSpecular Defines if specular is supported
  83569. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83570. */
  83571. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83572. /**
  83573. * Binds the lights information from the scene to the effect for the given mesh.
  83574. * @param scene The scene the lights belongs to
  83575. * @param mesh The mesh we are binding the information to render
  83576. * @param effect The effect we are binding the data to
  83577. * @param defines The generated defines for the effect
  83578. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  83579. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83580. */
  83581. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  83582. private static _tempFogColor;
  83583. /**
  83584. * Binds the fog information from the scene to the effect for the given mesh.
  83585. * @param scene The scene the lights belongs to
  83586. * @param mesh The mesh we are binding the information to render
  83587. * @param effect The effect we are binding the data to
  83588. * @param linearSpace Defines if the fog effect is applied in linear space
  83589. */
  83590. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  83591. /**
  83592. * Binds the bones information from the mesh to the effect.
  83593. * @param mesh The mesh we are binding the information to render
  83594. * @param effect The effect we are binding the data to
  83595. */
  83596. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83597. /**
  83598. * Binds the morph targets information from the mesh to the effect.
  83599. * @param abstractMesh The mesh we are binding the information to render
  83600. * @param effect The effect we are binding the data to
  83601. */
  83602. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83603. /**
  83604. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83605. * @param defines The generated defines used in the effect
  83606. * @param effect The effect we are binding the data to
  83607. * @param scene The scene we are willing to render with logarithmic scale for
  83608. */
  83609. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83610. /**
  83611. * Binds the clip plane information from the scene to the effect.
  83612. * @param scene The scene the clip plane information are extracted from
  83613. * @param effect The effect we are binding the data to
  83614. */
  83615. static BindClipPlane(effect: Effect, scene: Scene): void;
  83616. }
  83617. }
  83618. declare module BABYLON {
  83619. /** @hidden */
  83620. export var packingFunctions: {
  83621. name: string;
  83622. shader: string;
  83623. };
  83624. }
  83625. declare module BABYLON {
  83626. /** @hidden */
  83627. export var clipPlaneFragmentDeclaration: {
  83628. name: string;
  83629. shader: string;
  83630. };
  83631. }
  83632. declare module BABYLON {
  83633. /** @hidden */
  83634. export var clipPlaneFragment: {
  83635. name: string;
  83636. shader: string;
  83637. };
  83638. }
  83639. declare module BABYLON {
  83640. /** @hidden */
  83641. export var shadowMapPixelShader: {
  83642. name: string;
  83643. shader: string;
  83644. };
  83645. }
  83646. declare module BABYLON {
  83647. /** @hidden */
  83648. export var bonesDeclaration: {
  83649. name: string;
  83650. shader: string;
  83651. };
  83652. }
  83653. declare module BABYLON {
  83654. /** @hidden */
  83655. export var morphTargetsVertexGlobalDeclaration: {
  83656. name: string;
  83657. shader: string;
  83658. };
  83659. }
  83660. declare module BABYLON {
  83661. /** @hidden */
  83662. export var morphTargetsVertexDeclaration: {
  83663. name: string;
  83664. shader: string;
  83665. };
  83666. }
  83667. declare module BABYLON {
  83668. /** @hidden */
  83669. export var instancesDeclaration: {
  83670. name: string;
  83671. shader: string;
  83672. };
  83673. }
  83674. declare module BABYLON {
  83675. /** @hidden */
  83676. export var helperFunctions: {
  83677. name: string;
  83678. shader: string;
  83679. };
  83680. }
  83681. declare module BABYLON {
  83682. /** @hidden */
  83683. export var clipPlaneVertexDeclaration: {
  83684. name: string;
  83685. shader: string;
  83686. };
  83687. }
  83688. declare module BABYLON {
  83689. /** @hidden */
  83690. export var morphTargetsVertex: {
  83691. name: string;
  83692. shader: string;
  83693. };
  83694. }
  83695. declare module BABYLON {
  83696. /** @hidden */
  83697. export var instancesVertex: {
  83698. name: string;
  83699. shader: string;
  83700. };
  83701. }
  83702. declare module BABYLON {
  83703. /** @hidden */
  83704. export var bonesVertex: {
  83705. name: string;
  83706. shader: string;
  83707. };
  83708. }
  83709. declare module BABYLON {
  83710. /** @hidden */
  83711. export var clipPlaneVertex: {
  83712. name: string;
  83713. shader: string;
  83714. };
  83715. }
  83716. declare module BABYLON {
  83717. /** @hidden */
  83718. export var shadowMapVertexShader: {
  83719. name: string;
  83720. shader: string;
  83721. };
  83722. }
  83723. declare module BABYLON {
  83724. /** @hidden */
  83725. export var depthBoxBlurPixelShader: {
  83726. name: string;
  83727. shader: string;
  83728. };
  83729. }
  83730. declare module BABYLON {
  83731. /**
  83732. * Class representing a ray with position and direction
  83733. */
  83734. export class Ray {
  83735. /** origin point */
  83736. origin: Vector3;
  83737. /** direction */
  83738. direction: Vector3;
  83739. /** length of the ray */
  83740. length: number;
  83741. private static readonly TmpVector3;
  83742. private _tmpRay;
  83743. /**
  83744. * Creates a new ray
  83745. * @param origin origin point
  83746. * @param direction direction
  83747. * @param length length of the ray
  83748. */
  83749. constructor(
  83750. /** origin point */
  83751. origin: Vector3,
  83752. /** direction */
  83753. direction: Vector3,
  83754. /** length of the ray */
  83755. length?: number);
  83756. /**
  83757. * Checks if the ray intersects a box
  83758. * @param minimum bound of the box
  83759. * @param maximum bound of the box
  83760. * @param intersectionTreshold extra extend to be added to the box in all direction
  83761. * @returns if the box was hit
  83762. */
  83763. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83764. /**
  83765. * Checks if the ray intersects a box
  83766. * @param box the bounding box to check
  83767. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83768. * @returns if the box was hit
  83769. */
  83770. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83771. /**
  83772. * If the ray hits a sphere
  83773. * @param sphere the bounding sphere to check
  83774. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83775. * @returns true if it hits the sphere
  83776. */
  83777. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83778. /**
  83779. * If the ray hits a triange
  83780. * @param vertex0 triangle vertex
  83781. * @param vertex1 triangle vertex
  83782. * @param vertex2 triangle vertex
  83783. * @returns intersection information if hit
  83784. */
  83785. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83786. /**
  83787. * Checks if ray intersects a plane
  83788. * @param plane the plane to check
  83789. * @returns the distance away it was hit
  83790. */
  83791. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83792. /**
  83793. * Calculate the intercept of a ray on a given axis
  83794. * @param axis to check 'x' | 'y' | 'z'
  83795. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83796. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83797. */
  83798. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83799. /**
  83800. * Checks if ray intersects a mesh
  83801. * @param mesh the mesh to check
  83802. * @param fastCheck if only the bounding box should checked
  83803. * @returns picking info of the intersecton
  83804. */
  83805. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83806. /**
  83807. * Checks if ray intersects a mesh
  83808. * @param meshes the meshes to check
  83809. * @param fastCheck if only the bounding box should checked
  83810. * @param results array to store result in
  83811. * @returns Array of picking infos
  83812. */
  83813. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83814. private _comparePickingInfo;
  83815. private static smallnum;
  83816. private static rayl;
  83817. /**
  83818. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83819. * @param sega the first point of the segment to test the intersection against
  83820. * @param segb the second point of the segment to test the intersection against
  83821. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83822. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83823. */
  83824. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83825. /**
  83826. * Update the ray from viewport position
  83827. * @param x position
  83828. * @param y y position
  83829. * @param viewportWidth viewport width
  83830. * @param viewportHeight viewport height
  83831. * @param world world matrix
  83832. * @param view view matrix
  83833. * @param projection projection matrix
  83834. * @returns this ray updated
  83835. */
  83836. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83837. /**
  83838. * Creates a ray with origin and direction of 0,0,0
  83839. * @returns the new ray
  83840. */
  83841. static Zero(): Ray;
  83842. /**
  83843. * Creates a new ray from screen space and viewport
  83844. * @param x position
  83845. * @param y y position
  83846. * @param viewportWidth viewport width
  83847. * @param viewportHeight viewport height
  83848. * @param world world matrix
  83849. * @param view view matrix
  83850. * @param projection projection matrix
  83851. * @returns new ray
  83852. */
  83853. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83854. /**
  83855. * 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
  83856. * transformed to the given world matrix.
  83857. * @param origin The origin point
  83858. * @param end The end point
  83859. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83860. * @returns the new ray
  83861. */
  83862. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83863. /**
  83864. * Transforms a ray by a matrix
  83865. * @param ray ray to transform
  83866. * @param matrix matrix to apply
  83867. * @returns the resulting new ray
  83868. */
  83869. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83870. /**
  83871. * Transforms a ray by a matrix
  83872. * @param ray ray to transform
  83873. * @param matrix matrix to apply
  83874. * @param result ray to store result in
  83875. */
  83876. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83877. /**
  83878. * Unproject a ray from screen space to object space
  83879. * @param sourceX defines the screen space x coordinate to use
  83880. * @param sourceY defines the screen space y coordinate to use
  83881. * @param viewportWidth defines the current width of the viewport
  83882. * @param viewportHeight defines the current height of the viewport
  83883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83884. * @param view defines the view matrix to use
  83885. * @param projection defines the projection matrix to use
  83886. */
  83887. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83888. }
  83889. /**
  83890. * Type used to define predicate used to select faces when a mesh intersection is detected
  83891. */
  83892. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83893. interface Scene {
  83894. /** @hidden */
  83895. _tempPickingRay: Nullable<Ray>;
  83896. /** @hidden */
  83897. _cachedRayForTransform: Ray;
  83898. /** @hidden */
  83899. _pickWithRayInverseMatrix: Matrix;
  83900. /** @hidden */
  83901. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83902. /** @hidden */
  83903. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83904. }
  83905. }
  83906. declare module BABYLON {
  83907. /**
  83908. * Groups all the scene component constants in one place to ease maintenance.
  83909. * @hidden
  83910. */
  83911. export class SceneComponentConstants {
  83912. static readonly NAME_EFFECTLAYER: string;
  83913. static readonly NAME_LAYER: string;
  83914. static readonly NAME_LENSFLARESYSTEM: string;
  83915. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83916. static readonly NAME_PARTICLESYSTEM: string;
  83917. static readonly NAME_GAMEPAD: string;
  83918. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83919. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83920. static readonly NAME_DEPTHRENDERER: string;
  83921. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83922. static readonly NAME_SPRITE: string;
  83923. static readonly NAME_OUTLINERENDERER: string;
  83924. static readonly NAME_PROCEDURALTEXTURE: string;
  83925. static readonly NAME_SHADOWGENERATOR: string;
  83926. static readonly NAME_OCTREE: string;
  83927. static readonly NAME_PHYSICSENGINE: string;
  83928. static readonly NAME_AUDIO: string;
  83929. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83930. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83931. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83932. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83933. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83934. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83935. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83936. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83937. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83938. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83939. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83940. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83941. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83942. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83943. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83944. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83945. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83946. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83947. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83948. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83949. static readonly STEP_AFTERRENDER_AUDIO: number;
  83950. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83951. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83952. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83953. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83954. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83955. static readonly STEP_POINTERMOVE_SPRITE: number;
  83956. static readonly STEP_POINTERDOWN_SPRITE: number;
  83957. static readonly STEP_POINTERUP_SPRITE: number;
  83958. }
  83959. /**
  83960. * This represents a scene component.
  83961. *
  83962. * This is used to decouple the dependency the scene is having on the different workloads like
  83963. * layers, post processes...
  83964. */
  83965. export interface ISceneComponent {
  83966. /**
  83967. * The name of the component. Each component must have a unique name.
  83968. */
  83969. name: string;
  83970. /**
  83971. * The scene the component belongs to.
  83972. */
  83973. scene: Scene;
  83974. /**
  83975. * Register the component to one instance of a scene.
  83976. */
  83977. register(): void;
  83978. /**
  83979. * Rebuilds the elements related to this component in case of
  83980. * context lost for instance.
  83981. */
  83982. rebuild(): void;
  83983. /**
  83984. * Disposes the component and the associated ressources.
  83985. */
  83986. dispose(): void;
  83987. }
  83988. /**
  83989. * This represents a SERIALIZABLE scene component.
  83990. *
  83991. * This extends Scene Component to add Serialization methods on top.
  83992. */
  83993. export interface ISceneSerializableComponent extends ISceneComponent {
  83994. /**
  83995. * Adds all the elements from the container to the scene
  83996. * @param container the container holding the elements
  83997. */
  83998. addFromContainer(container: AbstractScene): void;
  83999. /**
  84000. * Removes all the elements in the container from the scene
  84001. * @param container contains the elements to remove
  84002. * @param dispose if the removed element should be disposed (default: false)
  84003. */
  84004. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84005. /**
  84006. * Serializes the component data to the specified json object
  84007. * @param serializationObject The object to serialize to
  84008. */
  84009. serialize(serializationObject: any): void;
  84010. }
  84011. /**
  84012. * Strong typing of a Mesh related stage step action
  84013. */
  84014. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84015. /**
  84016. * Strong typing of a Evaluate Sub Mesh related stage step action
  84017. */
  84018. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84019. /**
  84020. * Strong typing of a Active Mesh related stage step action
  84021. */
  84022. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84023. /**
  84024. * Strong typing of a Camera related stage step action
  84025. */
  84026. export type CameraStageAction = (camera: Camera) => void;
  84027. /**
  84028. * Strong typing of a Camera Frame buffer related stage step action
  84029. */
  84030. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84031. /**
  84032. * Strong typing of a Render Target related stage step action
  84033. */
  84034. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84035. /**
  84036. * Strong typing of a RenderingGroup related stage step action
  84037. */
  84038. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84039. /**
  84040. * Strong typing of a Mesh Render related stage step action
  84041. */
  84042. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84043. /**
  84044. * Strong typing of a simple stage step action
  84045. */
  84046. export type SimpleStageAction = () => void;
  84047. /**
  84048. * Strong typing of a render target action.
  84049. */
  84050. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84051. /**
  84052. * Strong typing of a pointer move action.
  84053. */
  84054. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84055. /**
  84056. * Strong typing of a pointer up/down action.
  84057. */
  84058. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84059. /**
  84060. * Representation of a stage in the scene (Basically a list of ordered steps)
  84061. * @hidden
  84062. */
  84063. export class Stage<T extends Function> extends Array<{
  84064. index: number;
  84065. component: ISceneComponent;
  84066. action: T;
  84067. }> {
  84068. /**
  84069. * Hide ctor from the rest of the world.
  84070. * @param items The items to add.
  84071. */
  84072. private constructor();
  84073. /**
  84074. * Creates a new Stage.
  84075. * @returns A new instance of a Stage
  84076. */
  84077. static Create<T extends Function>(): Stage<T>;
  84078. /**
  84079. * Registers a step in an ordered way in the targeted stage.
  84080. * @param index Defines the position to register the step in
  84081. * @param component Defines the component attached to the step
  84082. * @param action Defines the action to launch during the step
  84083. */
  84084. registerStep(index: number, component: ISceneComponent, action: T): void;
  84085. /**
  84086. * Clears all the steps from the stage.
  84087. */
  84088. clear(): void;
  84089. }
  84090. }
  84091. declare module BABYLON {
  84092. interface Scene {
  84093. /** @hidden */
  84094. _pointerOverSprite: Nullable<Sprite>;
  84095. /** @hidden */
  84096. _pickedDownSprite: Nullable<Sprite>;
  84097. /** @hidden */
  84098. _tempSpritePickingRay: Nullable<Ray>;
  84099. /**
  84100. * All of the sprite managers added to this scene
  84101. * @see http://doc.babylonjs.com/babylon101/sprites
  84102. */
  84103. spriteManagers: Array<ISpriteManager>;
  84104. /**
  84105. * An event triggered when sprites rendering is about to start
  84106. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84107. */
  84108. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84109. /**
  84110. * An event triggered when sprites rendering is done
  84111. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84112. */
  84113. onAfterSpritesRenderingObservable: Observable<Scene>;
  84114. /** @hidden */
  84115. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84116. /** Launch a ray to try to pick a sprite in the scene
  84117. * @param x position on screen
  84118. * @param y position on screen
  84119. * @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
  84120. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84121. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84122. * @returns a PickingInfo
  84123. */
  84124. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84125. /** Use the given ray to pick a sprite in the scene
  84126. * @param ray The ray (in world space) to use to pick meshes
  84127. * @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
  84128. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84129. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84130. * @returns a PickingInfo
  84131. */
  84132. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84133. /** @hidden */
  84134. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84135. /** Launch a ray to try to pick sprites in the scene
  84136. * @param x position on screen
  84137. * @param y position on screen
  84138. * @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
  84139. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84140. * @returns a PickingInfo array
  84141. */
  84142. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84143. /** Use the given ray to pick sprites in the scene
  84144. * @param ray The ray (in world space) to use to pick meshes
  84145. * @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
  84146. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84147. * @returns a PickingInfo array
  84148. */
  84149. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84150. /**
  84151. * Force the sprite under the pointer
  84152. * @param sprite defines the sprite to use
  84153. */
  84154. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84155. /**
  84156. * Gets the sprite under the pointer
  84157. * @returns a Sprite or null if no sprite is under the pointer
  84158. */
  84159. getPointerOverSprite(): Nullable<Sprite>;
  84160. }
  84161. /**
  84162. * Defines the sprite scene component responsible to manage sprites
  84163. * in a given scene.
  84164. */
  84165. export class SpriteSceneComponent implements ISceneComponent {
  84166. /**
  84167. * The component name helpfull to identify the component in the list of scene components.
  84168. */
  84169. readonly name: string;
  84170. /**
  84171. * The scene the component belongs to.
  84172. */
  84173. scene: Scene;
  84174. /** @hidden */
  84175. private _spritePredicate;
  84176. /**
  84177. * Creates a new instance of the component for the given scene
  84178. * @param scene Defines the scene to register the component in
  84179. */
  84180. constructor(scene: Scene);
  84181. /**
  84182. * Registers the component in a given scene
  84183. */
  84184. register(): void;
  84185. /**
  84186. * Rebuilds the elements related to this component in case of
  84187. * context lost for instance.
  84188. */
  84189. rebuild(): void;
  84190. /**
  84191. * Disposes the component and the associated ressources.
  84192. */
  84193. dispose(): void;
  84194. private _pickSpriteButKeepRay;
  84195. private _pointerMove;
  84196. private _pointerDown;
  84197. private _pointerUp;
  84198. }
  84199. }
  84200. declare module BABYLON {
  84201. /** @hidden */
  84202. export var fogFragmentDeclaration: {
  84203. name: string;
  84204. shader: string;
  84205. };
  84206. }
  84207. declare module BABYLON {
  84208. /** @hidden */
  84209. export var fogFragment: {
  84210. name: string;
  84211. shader: string;
  84212. };
  84213. }
  84214. declare module BABYLON {
  84215. /** @hidden */
  84216. export var spritesPixelShader: {
  84217. name: string;
  84218. shader: string;
  84219. };
  84220. }
  84221. declare module BABYLON {
  84222. /** @hidden */
  84223. export var fogVertexDeclaration: {
  84224. name: string;
  84225. shader: string;
  84226. };
  84227. }
  84228. declare module BABYLON {
  84229. /** @hidden */
  84230. export var spritesVertexShader: {
  84231. name: string;
  84232. shader: string;
  84233. };
  84234. }
  84235. declare module BABYLON {
  84236. /**
  84237. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84238. */
  84239. export interface ISpriteManager extends IDisposable {
  84240. /**
  84241. * Restricts the camera to viewing objects with the same layerMask.
  84242. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84243. */
  84244. layerMask: number;
  84245. /**
  84246. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84247. */
  84248. isPickable: boolean;
  84249. /**
  84250. * Specifies the rendering group id for this mesh (0 by default)
  84251. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84252. */
  84253. renderingGroupId: number;
  84254. /**
  84255. * Defines the list of sprites managed by the manager.
  84256. */
  84257. sprites: Array<Sprite>;
  84258. /**
  84259. * Tests the intersection of a sprite with a specific ray.
  84260. * @param ray The ray we are sending to test the collision
  84261. * @param camera The camera space we are sending rays in
  84262. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84263. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84264. * @returns picking info or null.
  84265. */
  84266. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84267. /**
  84268. * Intersects the sprites with a ray
  84269. * @param ray defines the ray to intersect with
  84270. * @param camera defines the current active camera
  84271. * @param predicate defines a predicate used to select candidate sprites
  84272. * @returns null if no hit or a PickingInfo array
  84273. */
  84274. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84275. /**
  84276. * Renders the list of sprites on screen.
  84277. */
  84278. render(): void;
  84279. }
  84280. /**
  84281. * Class used to manage multiple sprites on the same spritesheet
  84282. * @see http://doc.babylonjs.com/babylon101/sprites
  84283. */
  84284. export class SpriteManager implements ISpriteManager {
  84285. /** defines the manager's name */
  84286. name: string;
  84287. /** Gets the list of sprites */
  84288. sprites: Sprite[];
  84289. /** Gets or sets the rendering group id (0 by default) */
  84290. renderingGroupId: number;
  84291. /** Gets or sets camera layer mask */
  84292. layerMask: number;
  84293. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84294. fogEnabled: boolean;
  84295. /** Gets or sets a boolean indicating if the sprites are pickable */
  84296. isPickable: boolean;
  84297. /** Defines the default width of a cell in the spritesheet */
  84298. cellWidth: number;
  84299. /** Defines the default height of a cell in the spritesheet */
  84300. cellHeight: number;
  84301. /** Associative array from JSON sprite data file */
  84302. private _cellData;
  84303. /** Array of sprite names from JSON sprite data file */
  84304. private _spriteMap;
  84305. /** True when packed cell data from JSON file is ready*/
  84306. private _packedAndReady;
  84307. /**
  84308. * An event triggered when the manager is disposed.
  84309. */
  84310. onDisposeObservable: Observable<SpriteManager>;
  84311. private _onDisposeObserver;
  84312. /**
  84313. * Callback called when the manager is disposed
  84314. */
  84315. set onDispose(callback: () => void);
  84316. private _capacity;
  84317. private _fromPacked;
  84318. private _spriteTexture;
  84319. private _epsilon;
  84320. private _scene;
  84321. private _vertexData;
  84322. private _buffer;
  84323. private _vertexBuffers;
  84324. private _indexBuffer;
  84325. private _effectBase;
  84326. private _effectFog;
  84327. /**
  84328. * Gets or sets the spritesheet texture
  84329. */
  84330. get texture(): Texture;
  84331. set texture(value: Texture);
  84332. private _blendMode;
  84333. /**
  84334. * Blend mode use to render the particle, it can be any of
  84335. * the static Constants.ALPHA_x properties provided in this class.
  84336. * Default value is Constants.ALPHA_COMBINE
  84337. */
  84338. get blendMode(): number;
  84339. set blendMode(blendMode: number);
  84340. /** Disables writing to the depth buffer when rendering the sprites.
  84341. * It can be handy to disable depth writing when using textures without alpha channel
  84342. * and setting some specific blend modes.
  84343. */
  84344. disableDepthWrite: boolean;
  84345. /**
  84346. * Creates a new sprite manager
  84347. * @param name defines the manager's name
  84348. * @param imgUrl defines the sprite sheet url
  84349. * @param capacity defines the maximum allowed number of sprites
  84350. * @param cellSize defines the size of a sprite cell
  84351. * @param scene defines the hosting scene
  84352. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84353. * @param samplingMode defines the smapling mode to use with spritesheet
  84354. * @param fromPacked set to false; do not alter
  84355. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84356. */
  84357. constructor(
  84358. /** defines the manager's name */
  84359. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84360. private _makePacked;
  84361. private _appendSpriteVertex;
  84362. /**
  84363. * Intersects the sprites with a ray
  84364. * @param ray defines the ray to intersect with
  84365. * @param camera defines the current active camera
  84366. * @param predicate defines a predicate used to select candidate sprites
  84367. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84368. * @returns null if no hit or a PickingInfo
  84369. */
  84370. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84371. /**
  84372. * Intersects the sprites with a ray
  84373. * @param ray defines the ray to intersect with
  84374. * @param camera defines the current active camera
  84375. * @param predicate defines a predicate used to select candidate sprites
  84376. * @returns null if no hit or a PickingInfo array
  84377. */
  84378. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84379. /**
  84380. * Render all child sprites
  84381. */
  84382. render(): void;
  84383. /**
  84384. * Release associated resources
  84385. */
  84386. dispose(): void;
  84387. }
  84388. }
  84389. declare module BABYLON {
  84390. /** Interface used by value gradients (color, factor, ...) */
  84391. export interface IValueGradient {
  84392. /**
  84393. * Gets or sets the gradient value (between 0 and 1)
  84394. */
  84395. gradient: number;
  84396. }
  84397. /** Class used to store color4 gradient */
  84398. export class ColorGradient implements IValueGradient {
  84399. /**
  84400. * Gets or sets the gradient value (between 0 and 1)
  84401. */
  84402. gradient: number;
  84403. /**
  84404. * Gets or sets first associated color
  84405. */
  84406. color1: Color4;
  84407. /**
  84408. * Gets or sets second associated color
  84409. */
  84410. color2?: Color4 | undefined;
  84411. /**
  84412. * Creates a new color4 gradient
  84413. * @param gradient gets or sets the gradient value (between 0 and 1)
  84414. * @param color1 gets or sets first associated color
  84415. * @param color2 gets or sets first second color
  84416. */
  84417. constructor(
  84418. /**
  84419. * Gets or sets the gradient value (between 0 and 1)
  84420. */
  84421. gradient: number,
  84422. /**
  84423. * Gets or sets first associated color
  84424. */
  84425. color1: Color4,
  84426. /**
  84427. * Gets or sets second associated color
  84428. */
  84429. color2?: Color4 | undefined);
  84430. /**
  84431. * Will get a color picked randomly between color1 and color2.
  84432. * If color2 is undefined then color1 will be used
  84433. * @param result defines the target Color4 to store the result in
  84434. */
  84435. getColorToRef(result: Color4): void;
  84436. }
  84437. /** Class used to store color 3 gradient */
  84438. export class Color3Gradient implements IValueGradient {
  84439. /**
  84440. * Gets or sets the gradient value (between 0 and 1)
  84441. */
  84442. gradient: number;
  84443. /**
  84444. * Gets or sets the associated color
  84445. */
  84446. color: Color3;
  84447. /**
  84448. * Creates a new color3 gradient
  84449. * @param gradient gets or sets the gradient value (between 0 and 1)
  84450. * @param color gets or sets associated color
  84451. */
  84452. constructor(
  84453. /**
  84454. * Gets or sets the gradient value (between 0 and 1)
  84455. */
  84456. gradient: number,
  84457. /**
  84458. * Gets or sets the associated color
  84459. */
  84460. color: Color3);
  84461. }
  84462. /** Class used to store factor gradient */
  84463. export class FactorGradient implements IValueGradient {
  84464. /**
  84465. * Gets or sets the gradient value (between 0 and 1)
  84466. */
  84467. gradient: number;
  84468. /**
  84469. * Gets or sets first associated factor
  84470. */
  84471. factor1: number;
  84472. /**
  84473. * Gets or sets second associated factor
  84474. */
  84475. factor2?: number | undefined;
  84476. /**
  84477. * Creates a new factor gradient
  84478. * @param gradient gets or sets the gradient value (between 0 and 1)
  84479. * @param factor1 gets or sets first associated factor
  84480. * @param factor2 gets or sets second associated factor
  84481. */
  84482. constructor(
  84483. /**
  84484. * Gets or sets the gradient value (between 0 and 1)
  84485. */
  84486. gradient: number,
  84487. /**
  84488. * Gets or sets first associated factor
  84489. */
  84490. factor1: number,
  84491. /**
  84492. * Gets or sets second associated factor
  84493. */
  84494. factor2?: number | undefined);
  84495. /**
  84496. * Will get a number picked randomly between factor1 and factor2.
  84497. * If factor2 is undefined then factor1 will be used
  84498. * @returns the picked number
  84499. */
  84500. getFactor(): number;
  84501. }
  84502. /**
  84503. * Helper used to simplify some generic gradient tasks
  84504. */
  84505. export class GradientHelper {
  84506. /**
  84507. * Gets the current gradient from an array of IValueGradient
  84508. * @param ratio defines the current ratio to get
  84509. * @param gradients defines the array of IValueGradient
  84510. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84511. */
  84512. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84513. }
  84514. }
  84515. declare module BABYLON {
  84516. /**
  84517. * Interface for the size containing width and height
  84518. */
  84519. export interface ISize {
  84520. /**
  84521. * Width
  84522. */
  84523. width: number;
  84524. /**
  84525. * Heighht
  84526. */
  84527. height: number;
  84528. }
  84529. /**
  84530. * Size containing widht and height
  84531. */
  84532. export class Size implements ISize {
  84533. /**
  84534. * Width
  84535. */
  84536. width: number;
  84537. /**
  84538. * Height
  84539. */
  84540. height: number;
  84541. /**
  84542. * Creates a Size object from the given width and height (floats).
  84543. * @param width width of the new size
  84544. * @param height height of the new size
  84545. */
  84546. constructor(width: number, height: number);
  84547. /**
  84548. * Returns a string with the Size width and height
  84549. * @returns a string with the Size width and height
  84550. */
  84551. toString(): string;
  84552. /**
  84553. * "Size"
  84554. * @returns the string "Size"
  84555. */
  84556. getClassName(): string;
  84557. /**
  84558. * Returns the Size hash code.
  84559. * @returns a hash code for a unique width and height
  84560. */
  84561. getHashCode(): number;
  84562. /**
  84563. * Updates the current size from the given one.
  84564. * @param src the given size
  84565. */
  84566. copyFrom(src: Size): void;
  84567. /**
  84568. * Updates in place the current Size from the given floats.
  84569. * @param width width of the new size
  84570. * @param height height of the new size
  84571. * @returns the updated Size.
  84572. */
  84573. copyFromFloats(width: number, height: number): Size;
  84574. /**
  84575. * Updates in place the current Size from the given floats.
  84576. * @param width width to set
  84577. * @param height height to set
  84578. * @returns the updated Size.
  84579. */
  84580. set(width: number, height: number): Size;
  84581. /**
  84582. * Multiplies the width and height by numbers
  84583. * @param w factor to multiple the width by
  84584. * @param h factor to multiple the height by
  84585. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84586. */
  84587. multiplyByFloats(w: number, h: number): Size;
  84588. /**
  84589. * Clones the size
  84590. * @returns a new Size copied from the given one.
  84591. */
  84592. clone(): Size;
  84593. /**
  84594. * True if the current Size and the given one width and height are strictly equal.
  84595. * @param other the other size to compare against
  84596. * @returns True if the current Size and the given one width and height are strictly equal.
  84597. */
  84598. equals(other: Size): boolean;
  84599. /**
  84600. * The surface of the Size : width * height (float).
  84601. */
  84602. get surface(): number;
  84603. /**
  84604. * Create a new size of zero
  84605. * @returns a new Size set to (0.0, 0.0)
  84606. */
  84607. static Zero(): Size;
  84608. /**
  84609. * Sums the width and height of two sizes
  84610. * @param otherSize size to add to this size
  84611. * @returns a new Size set as the addition result of the current Size and the given one.
  84612. */
  84613. add(otherSize: Size): Size;
  84614. /**
  84615. * Subtracts the width and height of two
  84616. * @param otherSize size to subtract to this size
  84617. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84618. */
  84619. subtract(otherSize: Size): Size;
  84620. /**
  84621. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84622. * @param start starting size to lerp between
  84623. * @param end end size to lerp between
  84624. * @param amount amount to lerp between the start and end values
  84625. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84626. */
  84627. static Lerp(start: Size, end: Size, amount: number): Size;
  84628. }
  84629. }
  84630. declare module BABYLON {
  84631. interface ThinEngine {
  84632. /**
  84633. * Creates a dynamic texture
  84634. * @param width defines the width of the texture
  84635. * @param height defines the height of the texture
  84636. * @param generateMipMaps defines if the engine should generate the mip levels
  84637. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84638. * @returns the dynamic texture inside an InternalTexture
  84639. */
  84640. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84641. /**
  84642. * Update the content of a dynamic texture
  84643. * @param texture defines the texture to update
  84644. * @param canvas defines the canvas containing the source
  84645. * @param invertY defines if data must be stored with Y axis inverted
  84646. * @param premulAlpha defines if alpha is stored as premultiplied
  84647. * @param format defines the format of the data
  84648. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84649. */
  84650. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84651. }
  84652. }
  84653. declare module BABYLON {
  84654. /**
  84655. * Helper class used to generate a canvas to manipulate images
  84656. */
  84657. export class CanvasGenerator {
  84658. /**
  84659. * Create a new canvas (or offscreen canvas depending on the context)
  84660. * @param width defines the expected width
  84661. * @param height defines the expected height
  84662. * @return a new canvas or offscreen canvas
  84663. */
  84664. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84665. }
  84666. }
  84667. declare module BABYLON {
  84668. /**
  84669. * A class extending Texture allowing drawing on a texture
  84670. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84671. */
  84672. export class DynamicTexture extends Texture {
  84673. private _generateMipMaps;
  84674. private _canvas;
  84675. private _context;
  84676. private _engine;
  84677. /**
  84678. * Creates a DynamicTexture
  84679. * @param name defines the name of the texture
  84680. * @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
  84681. * @param scene defines the scene where you want the texture
  84682. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84683. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84684. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84685. */
  84686. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84687. /**
  84688. * Get the current class name of the texture useful for serialization or dynamic coding.
  84689. * @returns "DynamicTexture"
  84690. */
  84691. getClassName(): string;
  84692. /**
  84693. * Gets the current state of canRescale
  84694. */
  84695. get canRescale(): boolean;
  84696. private _recreate;
  84697. /**
  84698. * Scales the texture
  84699. * @param ratio the scale factor to apply to both width and height
  84700. */
  84701. scale(ratio: number): void;
  84702. /**
  84703. * Resizes the texture
  84704. * @param width the new width
  84705. * @param height the new height
  84706. */
  84707. scaleTo(width: number, height: number): void;
  84708. /**
  84709. * Gets the context of the canvas used by the texture
  84710. * @returns the canvas context of the dynamic texture
  84711. */
  84712. getContext(): CanvasRenderingContext2D;
  84713. /**
  84714. * Clears the texture
  84715. */
  84716. clear(): void;
  84717. /**
  84718. * Updates the texture
  84719. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84720. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84721. */
  84722. update(invertY?: boolean, premulAlpha?: boolean): void;
  84723. /**
  84724. * Draws text onto the texture
  84725. * @param text defines the text to be drawn
  84726. * @param x defines the placement of the text from the left
  84727. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84728. * @param font defines the font to be used with font-style, font-size, font-name
  84729. * @param color defines the color used for the text
  84730. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84731. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84732. * @param update defines whether texture is immediately update (default is true)
  84733. */
  84734. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  84735. /**
  84736. * Clones the texture
  84737. * @returns the clone of the texture.
  84738. */
  84739. clone(): DynamicTexture;
  84740. /**
  84741. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84742. * @returns a serialized dynamic texture object
  84743. */
  84744. serialize(): any;
  84745. /** @hidden */
  84746. _rebuild(): void;
  84747. }
  84748. }
  84749. declare module BABYLON {
  84750. interface Engine {
  84751. /**
  84752. * Creates a raw texture
  84753. * @param data defines the data to store in the texture
  84754. * @param width defines the width of the texture
  84755. * @param height defines the height of the texture
  84756. * @param format defines the format of the data
  84757. * @param generateMipMaps defines if the engine should generate the mip levels
  84758. * @param invertY defines if data must be stored with Y axis inverted
  84759. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84760. * @param compression defines the compression used (null by default)
  84761. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84762. * @returns the raw texture inside an InternalTexture
  84763. */
  84764. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84765. /**
  84766. * Update a raw texture
  84767. * @param texture defines the texture to update
  84768. * @param data defines the data to store in the texture
  84769. * @param format defines the format of the data
  84770. * @param invertY defines if data must be stored with Y axis inverted
  84771. */
  84772. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84773. /**
  84774. * Update a raw texture
  84775. * @param texture defines the texture to update
  84776. * @param data defines the data to store in the texture
  84777. * @param format defines the format of the data
  84778. * @param invertY defines if data must be stored with Y axis inverted
  84779. * @param compression defines the compression used (null by default)
  84780. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84781. */
  84782. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84783. /**
  84784. * Creates a new raw cube texture
  84785. * @param data defines the array of data to use to create each face
  84786. * @param size defines the size of the textures
  84787. * @param format defines the format of the data
  84788. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84789. * @param generateMipMaps defines if the engine should generate the mip levels
  84790. * @param invertY defines if data must be stored with Y axis inverted
  84791. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84792. * @param compression defines the compression used (null by default)
  84793. * @returns the cube texture as an InternalTexture
  84794. */
  84795. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84796. /**
  84797. * Update a raw cube texture
  84798. * @param texture defines the texture to udpdate
  84799. * @param data defines the data to store
  84800. * @param format defines the data format
  84801. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84802. * @param invertY defines if data must be stored with Y axis inverted
  84803. */
  84804. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84805. /**
  84806. * Update a raw cube texture
  84807. * @param texture defines the texture to udpdate
  84808. * @param data defines the data to store
  84809. * @param format defines the data format
  84810. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84811. * @param invertY defines if data must be stored with Y axis inverted
  84812. * @param compression defines the compression used (null by default)
  84813. */
  84814. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84815. /**
  84816. * Update a raw cube texture
  84817. * @param texture defines the texture to udpdate
  84818. * @param data defines the data to store
  84819. * @param format defines the data format
  84820. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84821. * @param invertY defines if data must be stored with Y axis inverted
  84822. * @param compression defines the compression used (null by default)
  84823. * @param level defines which level of the texture to update
  84824. */
  84825. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84826. /**
  84827. * Creates a new raw cube texture from a specified url
  84828. * @param url defines the url where the data is located
  84829. * @param scene defines the current scene
  84830. * @param size defines the size of the textures
  84831. * @param format defines the format of the data
  84832. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84833. * @param noMipmap defines if the engine should avoid generating the mip levels
  84834. * @param callback defines a callback used to extract texture data from loaded data
  84835. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84836. * @param onLoad defines a callback called when texture is loaded
  84837. * @param onError defines a callback called if there is an error
  84838. * @returns the cube texture as an InternalTexture
  84839. */
  84840. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  84841. /**
  84842. * Creates a new raw cube texture from a specified url
  84843. * @param url defines the url where the data is located
  84844. * @param scene defines the current scene
  84845. * @param size defines the size of the textures
  84846. * @param format defines the format of the data
  84847. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84848. * @param noMipmap defines if the engine should avoid generating the mip levels
  84849. * @param callback defines a callback used to extract texture data from loaded data
  84850. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84851. * @param onLoad defines a callback called when texture is loaded
  84852. * @param onError defines a callback called if there is an error
  84853. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84854. * @param invertY defines if data must be stored with Y axis inverted
  84855. * @returns the cube texture as an InternalTexture
  84856. */
  84857. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  84858. /**
  84859. * Creates a new raw 3D texture
  84860. * @param data defines the data used to create the texture
  84861. * @param width defines the width of the texture
  84862. * @param height defines the height of the texture
  84863. * @param depth defines the depth of the texture
  84864. * @param format defines the format of the texture
  84865. * @param generateMipMaps defines if the engine must generate mip levels
  84866. * @param invertY defines if data must be stored with Y axis inverted
  84867. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84868. * @param compression defines the compressed used (can be null)
  84869. * @param textureType defines the compressed used (can be null)
  84870. * @returns a new raw 3D texture (stored in an InternalTexture)
  84871. */
  84872. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84873. /**
  84874. * Update a raw 3D texture
  84875. * @param texture defines the texture to update
  84876. * @param data defines the data to store
  84877. * @param format defines the data format
  84878. * @param invertY defines if data must be stored with Y axis inverted
  84879. */
  84880. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84881. /**
  84882. * Update a raw 3D texture
  84883. * @param texture defines the texture to update
  84884. * @param data defines the data to store
  84885. * @param format defines the data format
  84886. * @param invertY defines if data must be stored with Y axis inverted
  84887. * @param compression defines the used compression (can be null)
  84888. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84889. */
  84890. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84891. /**
  84892. * Creates a new raw 2D array texture
  84893. * @param data defines the data used to create the texture
  84894. * @param width defines the width of the texture
  84895. * @param height defines the height of the texture
  84896. * @param depth defines the number of layers of the texture
  84897. * @param format defines the format of the texture
  84898. * @param generateMipMaps defines if the engine must generate mip levels
  84899. * @param invertY defines if data must be stored with Y axis inverted
  84900. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84901. * @param compression defines the compressed used (can be null)
  84902. * @param textureType defines the compressed used (can be null)
  84903. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84904. */
  84905. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84906. /**
  84907. * Update a raw 2D array texture
  84908. * @param texture defines the texture to update
  84909. * @param data defines the data to store
  84910. * @param format defines the data format
  84911. * @param invertY defines if data must be stored with Y axis inverted
  84912. */
  84913. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84914. /**
  84915. * Update a raw 2D array texture
  84916. * @param texture defines the texture to update
  84917. * @param data defines the data to store
  84918. * @param format defines the data format
  84919. * @param invertY defines if data must be stored with Y axis inverted
  84920. * @param compression defines the used compression (can be null)
  84921. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84922. */
  84923. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84924. }
  84925. }
  84926. declare module BABYLON {
  84927. /**
  84928. * Raw texture can help creating a texture directly from an array of data.
  84929. * This can be super useful if you either get the data from an uncompressed source or
  84930. * if you wish to create your texture pixel by pixel.
  84931. */
  84932. export class RawTexture extends Texture {
  84933. /**
  84934. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84935. */
  84936. format: number;
  84937. private _engine;
  84938. /**
  84939. * Instantiates a new RawTexture.
  84940. * Raw texture can help creating a texture directly from an array of data.
  84941. * This can be super useful if you either get the data from an uncompressed source or
  84942. * if you wish to create your texture pixel by pixel.
  84943. * @param data define the array of data to use to create the texture
  84944. * @param width define the width of the texture
  84945. * @param height define the height of the texture
  84946. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84947. * @param scene define the scene the texture belongs to
  84948. * @param generateMipMaps define whether mip maps should be generated or not
  84949. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84950. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84951. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84952. */
  84953. constructor(data: ArrayBufferView, width: number, height: number,
  84954. /**
  84955. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84956. */
  84957. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84958. /**
  84959. * Updates the texture underlying data.
  84960. * @param data Define the new data of the texture
  84961. */
  84962. update(data: ArrayBufferView): void;
  84963. /**
  84964. * Creates a luminance texture from some data.
  84965. * @param data Define the texture data
  84966. * @param width Define the width of the texture
  84967. * @param height Define the height of the texture
  84968. * @param scene Define the scene the texture belongs to
  84969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84972. * @returns the luminance texture
  84973. */
  84974. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84975. /**
  84976. * Creates a luminance alpha texture from some data.
  84977. * @param data Define the texture data
  84978. * @param width Define the width of the texture
  84979. * @param height Define the height of the texture
  84980. * @param scene Define the scene the texture belongs to
  84981. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84984. * @returns the luminance alpha texture
  84985. */
  84986. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84987. /**
  84988. * Creates an alpha texture from some data.
  84989. * @param data Define the texture data
  84990. * @param width Define the width of the texture
  84991. * @param height Define the height of the texture
  84992. * @param scene Define the scene the texture belongs to
  84993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84996. * @returns the alpha texture
  84997. */
  84998. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84999. /**
  85000. * Creates a RGB texture from some data.
  85001. * @param data Define the texture data
  85002. * @param width Define the width of the texture
  85003. * @param height Define the height of the texture
  85004. * @param scene Define the scene the texture belongs to
  85005. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85006. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85007. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85008. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85009. * @returns the RGB alpha texture
  85010. */
  85011. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85012. /**
  85013. * Creates a RGBA texture from some data.
  85014. * @param data Define the texture data
  85015. * @param width Define the width of the texture
  85016. * @param height Define the height of the texture
  85017. * @param scene Define the scene the texture belongs to
  85018. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85019. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85020. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85021. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85022. * @returns the RGBA texture
  85023. */
  85024. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85025. /**
  85026. * Creates a R texture from some data.
  85027. * @param data Define the texture data
  85028. * @param width Define the width of the texture
  85029. * @param height Define the height of the texture
  85030. * @param scene Define the scene the texture belongs to
  85031. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85032. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85033. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85034. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85035. * @returns the R texture
  85036. */
  85037. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85038. }
  85039. }
  85040. declare module BABYLON {
  85041. interface AbstractScene {
  85042. /**
  85043. * The list of procedural textures added to the scene
  85044. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85045. */
  85046. proceduralTextures: Array<ProceduralTexture>;
  85047. }
  85048. /**
  85049. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85050. * in a given scene.
  85051. */
  85052. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85053. /**
  85054. * The component name helpfull to identify the component in the list of scene components.
  85055. */
  85056. readonly name: string;
  85057. /**
  85058. * The scene the component belongs to.
  85059. */
  85060. scene: Scene;
  85061. /**
  85062. * Creates a new instance of the component for the given scene
  85063. * @param scene Defines the scene to register the component in
  85064. */
  85065. constructor(scene: Scene);
  85066. /**
  85067. * Registers the component in a given scene
  85068. */
  85069. register(): void;
  85070. /**
  85071. * Rebuilds the elements related to this component in case of
  85072. * context lost for instance.
  85073. */
  85074. rebuild(): void;
  85075. /**
  85076. * Disposes the component and the associated ressources.
  85077. */
  85078. dispose(): void;
  85079. private _beforeClear;
  85080. }
  85081. }
  85082. declare module BABYLON {
  85083. interface ThinEngine {
  85084. /**
  85085. * Creates a new render target cube texture
  85086. * @param size defines the size of the texture
  85087. * @param options defines the options used to create the texture
  85088. * @returns a new render target cube texture stored in an InternalTexture
  85089. */
  85090. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85091. }
  85092. }
  85093. declare module BABYLON {
  85094. /** @hidden */
  85095. export var proceduralVertexShader: {
  85096. name: string;
  85097. shader: string;
  85098. };
  85099. }
  85100. declare module BABYLON {
  85101. /**
  85102. * 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.
  85103. * This is the base class of any Procedural texture and contains most of the shareable code.
  85104. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85105. */
  85106. export class ProceduralTexture extends Texture {
  85107. isCube: boolean;
  85108. /**
  85109. * Define if the texture is enabled or not (disabled texture will not render)
  85110. */
  85111. isEnabled: boolean;
  85112. /**
  85113. * Define if the texture must be cleared before rendering (default is true)
  85114. */
  85115. autoClear: boolean;
  85116. /**
  85117. * Callback called when the texture is generated
  85118. */
  85119. onGenerated: () => void;
  85120. /**
  85121. * Event raised when the texture is generated
  85122. */
  85123. onGeneratedObservable: Observable<ProceduralTexture>;
  85124. /** @hidden */
  85125. _generateMipMaps: boolean;
  85126. /** @hidden **/
  85127. _effect: Effect;
  85128. /** @hidden */
  85129. _textures: {
  85130. [key: string]: Texture;
  85131. };
  85132. /** @hidden */
  85133. protected _fallbackTexture: Nullable<Texture>;
  85134. private _size;
  85135. private _currentRefreshId;
  85136. private _frameId;
  85137. private _refreshRate;
  85138. private _vertexBuffers;
  85139. private _indexBuffer;
  85140. private _uniforms;
  85141. private _samplers;
  85142. private _fragment;
  85143. private _floats;
  85144. private _ints;
  85145. private _floatsArrays;
  85146. private _colors3;
  85147. private _colors4;
  85148. private _vectors2;
  85149. private _vectors3;
  85150. private _matrices;
  85151. private _fallbackTextureUsed;
  85152. private _engine;
  85153. private _cachedDefines;
  85154. private _contentUpdateId;
  85155. private _contentData;
  85156. /**
  85157. * Instantiates a new procedural texture.
  85158. * 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.
  85159. * This is the base class of any Procedural texture and contains most of the shareable code.
  85160. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85161. * @param name Define the name of the texture
  85162. * @param size Define the size of the texture to create
  85163. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85164. * @param scene Define the scene the texture belongs to
  85165. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85166. * @param generateMipMaps Define if the texture should creates mip maps or not
  85167. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85168. */
  85169. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85170. /**
  85171. * The effect that is created when initializing the post process.
  85172. * @returns The created effect corresponding the the postprocess.
  85173. */
  85174. getEffect(): Effect;
  85175. /**
  85176. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85177. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85178. */
  85179. getContent(): Nullable<ArrayBufferView>;
  85180. private _createIndexBuffer;
  85181. /** @hidden */
  85182. _rebuild(): void;
  85183. /**
  85184. * Resets the texture in order to recreate its associated resources.
  85185. * This can be called in case of context loss
  85186. */
  85187. reset(): void;
  85188. protected _getDefines(): string;
  85189. /**
  85190. * Is the texture ready to be used ? (rendered at least once)
  85191. * @returns true if ready, otherwise, false.
  85192. */
  85193. isReady(): boolean;
  85194. /**
  85195. * Resets the refresh counter of the texture and start bak from scratch.
  85196. * Could be useful to regenerate the texture if it is setup to render only once.
  85197. */
  85198. resetRefreshCounter(): void;
  85199. /**
  85200. * Set the fragment shader to use in order to render the texture.
  85201. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85202. */
  85203. setFragment(fragment: any): void;
  85204. /**
  85205. * Define the refresh rate of the texture or the rendering frequency.
  85206. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85207. */
  85208. get refreshRate(): number;
  85209. set refreshRate(value: number);
  85210. /** @hidden */
  85211. _shouldRender(): boolean;
  85212. /**
  85213. * Get the size the texture is rendering at.
  85214. * @returns the size (texture is always squared)
  85215. */
  85216. getRenderSize(): number;
  85217. /**
  85218. * Resize the texture to new value.
  85219. * @param size Define the new size the texture should have
  85220. * @param generateMipMaps Define whether the new texture should create mip maps
  85221. */
  85222. resize(size: number, generateMipMaps: boolean): void;
  85223. private _checkUniform;
  85224. /**
  85225. * Set a texture in the shader program used to render.
  85226. * @param name Define the name of the uniform samplers as defined in the shader
  85227. * @param texture Define the texture to bind to this sampler
  85228. * @return the texture itself allowing "fluent" like uniform updates
  85229. */
  85230. setTexture(name: string, texture: Texture): ProceduralTexture;
  85231. /**
  85232. * Set a float in the shader.
  85233. * @param name Define the name of the uniform as defined in the shader
  85234. * @param value Define the value to give to the uniform
  85235. * @return the texture itself allowing "fluent" like uniform updates
  85236. */
  85237. setFloat(name: string, value: number): ProceduralTexture;
  85238. /**
  85239. * Set a int in the shader.
  85240. * @param name Define the name of the uniform as defined in the shader
  85241. * @param value Define the value to give to the uniform
  85242. * @return the texture itself allowing "fluent" like uniform updates
  85243. */
  85244. setInt(name: string, value: number): ProceduralTexture;
  85245. /**
  85246. * Set an array of floats in the shader.
  85247. * @param name Define the name of the uniform as defined in the shader
  85248. * @param value Define the value to give to the uniform
  85249. * @return the texture itself allowing "fluent" like uniform updates
  85250. */
  85251. setFloats(name: string, value: number[]): ProceduralTexture;
  85252. /**
  85253. * Set a vec3 in the shader from a Color3.
  85254. * @param name Define the name of the uniform as defined in the shader
  85255. * @param value Define the value to give to the uniform
  85256. * @return the texture itself allowing "fluent" like uniform updates
  85257. */
  85258. setColor3(name: string, value: Color3): ProceduralTexture;
  85259. /**
  85260. * Set a vec4 in the shader from a Color4.
  85261. * @param name Define the name of the uniform as defined in the shader
  85262. * @param value Define the value to give to the uniform
  85263. * @return the texture itself allowing "fluent" like uniform updates
  85264. */
  85265. setColor4(name: string, value: Color4): ProceduralTexture;
  85266. /**
  85267. * Set a vec2 in the shader from a Vector2.
  85268. * @param name Define the name of the uniform as defined in the shader
  85269. * @param value Define the value to give to the uniform
  85270. * @return the texture itself allowing "fluent" like uniform updates
  85271. */
  85272. setVector2(name: string, value: Vector2): ProceduralTexture;
  85273. /**
  85274. * Set a vec3 in the shader from a Vector3.
  85275. * @param name Define the name of the uniform as defined in the shader
  85276. * @param value Define the value to give to the uniform
  85277. * @return the texture itself allowing "fluent" like uniform updates
  85278. */
  85279. setVector3(name: string, value: Vector3): ProceduralTexture;
  85280. /**
  85281. * Set a mat4 in the shader from a MAtrix.
  85282. * @param name Define the name of the uniform as defined in the shader
  85283. * @param value Define the value to give to the uniform
  85284. * @return the texture itself allowing "fluent" like uniform updates
  85285. */
  85286. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85287. /**
  85288. * Render the texture to its associated render target.
  85289. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85290. */
  85291. render(useCameraPostProcess?: boolean): void;
  85292. /**
  85293. * Clone the texture.
  85294. * @returns the cloned texture
  85295. */
  85296. clone(): ProceduralTexture;
  85297. /**
  85298. * Dispose the texture and release its asoociated resources.
  85299. */
  85300. dispose(): void;
  85301. }
  85302. }
  85303. declare module BABYLON {
  85304. /**
  85305. * This represents the base class for particle system in Babylon.
  85306. * 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.
  85307. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85308. * @example https://doc.babylonjs.com/babylon101/particles
  85309. */
  85310. export class BaseParticleSystem {
  85311. /**
  85312. * Source color is added to the destination color without alpha affecting the result
  85313. */
  85314. static BLENDMODE_ONEONE: number;
  85315. /**
  85316. * Blend current color and particle color using particle’s alpha
  85317. */
  85318. static BLENDMODE_STANDARD: number;
  85319. /**
  85320. * Add current color and particle color multiplied by particle’s alpha
  85321. */
  85322. static BLENDMODE_ADD: number;
  85323. /**
  85324. * Multiply current color with particle color
  85325. */
  85326. static BLENDMODE_MULTIPLY: number;
  85327. /**
  85328. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85329. */
  85330. static BLENDMODE_MULTIPLYADD: number;
  85331. /**
  85332. * List of animations used by the particle system.
  85333. */
  85334. animations: Animation[];
  85335. /**
  85336. * Gets or sets the unique id of the particle system
  85337. */
  85338. uniqueId: number;
  85339. /**
  85340. * The id of the Particle system.
  85341. */
  85342. id: string;
  85343. /**
  85344. * The friendly name of the Particle system.
  85345. */
  85346. name: string;
  85347. /**
  85348. * Snippet ID if the particle system was created from the snippet server
  85349. */
  85350. snippetId: string;
  85351. /**
  85352. * The rendering group used by the Particle system to chose when to render.
  85353. */
  85354. renderingGroupId: number;
  85355. /**
  85356. * The emitter represents the Mesh or position we are attaching the particle system to.
  85357. */
  85358. emitter: Nullable<AbstractMesh | Vector3>;
  85359. /**
  85360. * The maximum number of particles to emit per frame
  85361. */
  85362. emitRate: number;
  85363. /**
  85364. * If you want to launch only a few particles at once, that can be done, as well.
  85365. */
  85366. manualEmitCount: number;
  85367. /**
  85368. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85369. */
  85370. updateSpeed: number;
  85371. /**
  85372. * The amount of time the particle system is running (depends of the overall update speed).
  85373. */
  85374. targetStopDuration: number;
  85375. /**
  85376. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85377. */
  85378. disposeOnStop: boolean;
  85379. /**
  85380. * Minimum power of emitting particles.
  85381. */
  85382. minEmitPower: number;
  85383. /**
  85384. * Maximum power of emitting particles.
  85385. */
  85386. maxEmitPower: number;
  85387. /**
  85388. * Minimum life time of emitting particles.
  85389. */
  85390. minLifeTime: number;
  85391. /**
  85392. * Maximum life time of emitting particles.
  85393. */
  85394. maxLifeTime: number;
  85395. /**
  85396. * Minimum Size of emitting particles.
  85397. */
  85398. minSize: number;
  85399. /**
  85400. * Maximum Size of emitting particles.
  85401. */
  85402. maxSize: number;
  85403. /**
  85404. * Minimum scale of emitting particles on X axis.
  85405. */
  85406. minScaleX: number;
  85407. /**
  85408. * Maximum scale of emitting particles on X axis.
  85409. */
  85410. maxScaleX: number;
  85411. /**
  85412. * Minimum scale of emitting particles on Y axis.
  85413. */
  85414. minScaleY: number;
  85415. /**
  85416. * Maximum scale of emitting particles on Y axis.
  85417. */
  85418. maxScaleY: number;
  85419. /**
  85420. * Gets or sets the minimal initial rotation in radians.
  85421. */
  85422. minInitialRotation: number;
  85423. /**
  85424. * Gets or sets the maximal initial rotation in radians.
  85425. */
  85426. maxInitialRotation: number;
  85427. /**
  85428. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85429. */
  85430. minAngularSpeed: number;
  85431. /**
  85432. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85433. */
  85434. maxAngularSpeed: number;
  85435. /**
  85436. * The texture used to render each particle. (this can be a spritesheet)
  85437. */
  85438. particleTexture: Nullable<Texture>;
  85439. /**
  85440. * The layer mask we are rendering the particles through.
  85441. */
  85442. layerMask: number;
  85443. /**
  85444. * This can help using your own shader to render the particle system.
  85445. * The according effect will be created
  85446. */
  85447. customShader: any;
  85448. /**
  85449. * By default particle system starts as soon as they are created. This prevents the
  85450. * automatic start to happen and let you decide when to start emitting particles.
  85451. */
  85452. preventAutoStart: boolean;
  85453. private _noiseTexture;
  85454. /**
  85455. * Gets or sets a texture used to add random noise to particle positions
  85456. */
  85457. get noiseTexture(): Nullable<ProceduralTexture>;
  85458. set noiseTexture(value: Nullable<ProceduralTexture>);
  85459. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85460. noiseStrength: Vector3;
  85461. /**
  85462. * Callback triggered when the particle animation is ending.
  85463. */
  85464. onAnimationEnd: Nullable<() => void>;
  85465. /**
  85466. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85467. */
  85468. blendMode: number;
  85469. /**
  85470. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85471. * to override the particles.
  85472. */
  85473. forceDepthWrite: boolean;
  85474. /** 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 */
  85475. preWarmCycles: number;
  85476. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85477. preWarmStepOffset: number;
  85478. /**
  85479. * 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)
  85480. */
  85481. spriteCellChangeSpeed: number;
  85482. /**
  85483. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85484. */
  85485. startSpriteCellID: number;
  85486. /**
  85487. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85488. */
  85489. endSpriteCellID: number;
  85490. /**
  85491. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85492. */
  85493. spriteCellWidth: number;
  85494. /**
  85495. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85496. */
  85497. spriteCellHeight: number;
  85498. /**
  85499. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85500. */
  85501. spriteRandomStartCell: boolean;
  85502. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85503. translationPivot: Vector2;
  85504. /** @hidden */
  85505. protected _isAnimationSheetEnabled: boolean;
  85506. /**
  85507. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85508. */
  85509. beginAnimationOnStart: boolean;
  85510. /**
  85511. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85512. */
  85513. beginAnimationFrom: number;
  85514. /**
  85515. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85516. */
  85517. beginAnimationTo: number;
  85518. /**
  85519. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85520. */
  85521. beginAnimationLoop: boolean;
  85522. /**
  85523. * Gets or sets a world offset applied to all particles
  85524. */
  85525. worldOffset: Vector3;
  85526. /**
  85527. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85528. */
  85529. get isAnimationSheetEnabled(): boolean;
  85530. set isAnimationSheetEnabled(value: boolean);
  85531. /**
  85532. * Get hosting scene
  85533. * @returns the scene
  85534. */
  85535. getScene(): Scene;
  85536. /**
  85537. * You can use gravity if you want to give an orientation to your particles.
  85538. */
  85539. gravity: Vector3;
  85540. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85541. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85542. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85543. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85544. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85545. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85546. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85547. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85548. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85549. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85550. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85551. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85552. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85553. /**
  85554. * Defines the delay in milliseconds before starting the system (0 by default)
  85555. */
  85556. startDelay: number;
  85557. /**
  85558. * Gets the current list of drag gradients.
  85559. * You must use addDragGradient and removeDragGradient to udpate this list
  85560. * @returns the list of drag gradients
  85561. */
  85562. getDragGradients(): Nullable<Array<FactorGradient>>;
  85563. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85564. limitVelocityDamping: number;
  85565. /**
  85566. * Gets the current list of limit velocity gradients.
  85567. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85568. * @returns the list of limit velocity gradients
  85569. */
  85570. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85571. /**
  85572. * Gets the current list of color gradients.
  85573. * You must use addColorGradient and removeColorGradient to udpate this list
  85574. * @returns the list of color gradients
  85575. */
  85576. getColorGradients(): Nullable<Array<ColorGradient>>;
  85577. /**
  85578. * Gets the current list of size gradients.
  85579. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85580. * @returns the list of size gradients
  85581. */
  85582. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85583. /**
  85584. * Gets the current list of color remap gradients.
  85585. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85586. * @returns the list of color remap gradients
  85587. */
  85588. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85589. /**
  85590. * Gets the current list of alpha remap gradients.
  85591. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85592. * @returns the list of alpha remap gradients
  85593. */
  85594. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85595. /**
  85596. * Gets the current list of life time gradients.
  85597. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85598. * @returns the list of life time gradients
  85599. */
  85600. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85601. /**
  85602. * Gets the current list of angular speed gradients.
  85603. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85604. * @returns the list of angular speed gradients
  85605. */
  85606. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85607. /**
  85608. * Gets the current list of velocity gradients.
  85609. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85610. * @returns the list of velocity gradients
  85611. */
  85612. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85613. /**
  85614. * Gets the current list of start size gradients.
  85615. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85616. * @returns the list of start size gradients
  85617. */
  85618. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85619. /**
  85620. * Gets the current list of emit rate gradients.
  85621. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85622. * @returns the list of emit rate gradients
  85623. */
  85624. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85625. /**
  85626. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85627. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85628. */
  85629. get direction1(): Vector3;
  85630. set direction1(value: Vector3);
  85631. /**
  85632. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85633. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85634. */
  85635. get direction2(): Vector3;
  85636. set direction2(value: Vector3);
  85637. /**
  85638. * 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.
  85639. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85640. */
  85641. get minEmitBox(): Vector3;
  85642. set minEmitBox(value: Vector3);
  85643. /**
  85644. * 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.
  85645. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85646. */
  85647. get maxEmitBox(): Vector3;
  85648. set maxEmitBox(value: Vector3);
  85649. /**
  85650. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85651. */
  85652. color1: Color4;
  85653. /**
  85654. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85655. */
  85656. color2: Color4;
  85657. /**
  85658. * Color the particle will have at the end of its lifetime
  85659. */
  85660. colorDead: Color4;
  85661. /**
  85662. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85663. */
  85664. textureMask: Color4;
  85665. /**
  85666. * The particle emitter type defines the emitter used by the particle system.
  85667. * It can be for example box, sphere, or cone...
  85668. */
  85669. particleEmitterType: IParticleEmitterType;
  85670. /** @hidden */
  85671. _isSubEmitter: boolean;
  85672. /**
  85673. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85674. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85675. */
  85676. billboardMode: number;
  85677. protected _isBillboardBased: boolean;
  85678. /**
  85679. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85680. */
  85681. get isBillboardBased(): boolean;
  85682. set isBillboardBased(value: boolean);
  85683. /**
  85684. * The scene the particle system belongs to.
  85685. */
  85686. protected _scene: Scene;
  85687. /**
  85688. * Local cache of defines for image processing.
  85689. */
  85690. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85691. /**
  85692. * Default configuration related to image processing available in the standard Material.
  85693. */
  85694. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85695. /**
  85696. * Gets the image processing configuration used either in this material.
  85697. */
  85698. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85699. /**
  85700. * Sets the Default image processing configuration used either in the this material.
  85701. *
  85702. * If sets to null, the scene one is in use.
  85703. */
  85704. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85705. /**
  85706. * Attaches a new image processing configuration to the Standard Material.
  85707. * @param configuration
  85708. */
  85709. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85710. /** @hidden */
  85711. protected _reset(): void;
  85712. /** @hidden */
  85713. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85714. /**
  85715. * Instantiates a particle system.
  85716. * 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.
  85717. * @param name The name of the particle system
  85718. */
  85719. constructor(name: string);
  85720. /**
  85721. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85722. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85723. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85724. * @returns the emitter
  85725. */
  85726. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85727. /**
  85728. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85729. * @param radius The radius of the hemisphere to emit from
  85730. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85731. * @returns the emitter
  85732. */
  85733. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85734. /**
  85735. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85736. * @param radius The radius of the sphere to emit from
  85737. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85738. * @returns the emitter
  85739. */
  85740. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85741. /**
  85742. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85743. * @param radius The radius of the sphere to emit from
  85744. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85745. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85746. * @returns the emitter
  85747. */
  85748. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85749. /**
  85750. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85751. * @param radius The radius of the emission cylinder
  85752. * @param height The height of the emission cylinder
  85753. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85754. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85755. * @returns the emitter
  85756. */
  85757. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85758. /**
  85759. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85760. * @param radius The radius of the cylinder to emit from
  85761. * @param height The height of the emission cylinder
  85762. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85763. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85764. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85765. * @returns the emitter
  85766. */
  85767. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85768. /**
  85769. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85770. * @param radius The radius of the cone to emit from
  85771. * @param angle The base angle of the cone
  85772. * @returns the emitter
  85773. */
  85774. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85775. /**
  85776. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85777. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85778. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85779. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85780. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85781. * @returns the emitter
  85782. */
  85783. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85784. }
  85785. }
  85786. declare module BABYLON {
  85787. /**
  85788. * Type of sub emitter
  85789. */
  85790. export enum SubEmitterType {
  85791. /**
  85792. * Attached to the particle over it's lifetime
  85793. */
  85794. ATTACHED = 0,
  85795. /**
  85796. * Created when the particle dies
  85797. */
  85798. END = 1
  85799. }
  85800. /**
  85801. * Sub emitter class used to emit particles from an existing particle
  85802. */
  85803. export class SubEmitter {
  85804. /**
  85805. * the particle system to be used by the sub emitter
  85806. */
  85807. particleSystem: ParticleSystem;
  85808. /**
  85809. * Type of the submitter (Default: END)
  85810. */
  85811. type: SubEmitterType;
  85812. /**
  85813. * 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)
  85814. * Note: This only is supported when using an emitter of type Mesh
  85815. */
  85816. inheritDirection: boolean;
  85817. /**
  85818. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85819. */
  85820. inheritedVelocityAmount: number;
  85821. /**
  85822. * Creates a sub emitter
  85823. * @param particleSystem the particle system to be used by the sub emitter
  85824. */
  85825. constructor(
  85826. /**
  85827. * the particle system to be used by the sub emitter
  85828. */
  85829. particleSystem: ParticleSystem);
  85830. /**
  85831. * Clones the sub emitter
  85832. * @returns the cloned sub emitter
  85833. */
  85834. clone(): SubEmitter;
  85835. /**
  85836. * Serialize current object to a JSON object
  85837. * @returns the serialized object
  85838. */
  85839. serialize(): any;
  85840. /** @hidden */
  85841. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85842. /**
  85843. * Creates a new SubEmitter from a serialized JSON version
  85844. * @param serializationObject defines the JSON object to read from
  85845. * @param scene defines the hosting scene
  85846. * @param rootUrl defines the rootUrl for data loading
  85847. * @returns a new SubEmitter
  85848. */
  85849. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85850. /** Release associated resources */
  85851. dispose(): void;
  85852. }
  85853. }
  85854. declare module BABYLON {
  85855. /** @hidden */
  85856. export var imageProcessingDeclaration: {
  85857. name: string;
  85858. shader: string;
  85859. };
  85860. }
  85861. declare module BABYLON {
  85862. /** @hidden */
  85863. export var imageProcessingFunctions: {
  85864. name: string;
  85865. shader: string;
  85866. };
  85867. }
  85868. declare module BABYLON {
  85869. /** @hidden */
  85870. export var particlesPixelShader: {
  85871. name: string;
  85872. shader: string;
  85873. };
  85874. }
  85875. declare module BABYLON {
  85876. /** @hidden */
  85877. export var particlesVertexShader: {
  85878. name: string;
  85879. shader: string;
  85880. };
  85881. }
  85882. declare module BABYLON {
  85883. /**
  85884. * This represents a particle system in Babylon.
  85885. * 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.
  85886. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85887. * @example https://doc.babylonjs.com/babylon101/particles
  85888. */
  85889. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85890. /**
  85891. * Billboard mode will only apply to Y axis
  85892. */
  85893. static readonly BILLBOARDMODE_Y: number;
  85894. /**
  85895. * Billboard mode will apply to all axes
  85896. */
  85897. static readonly BILLBOARDMODE_ALL: number;
  85898. /**
  85899. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85900. */
  85901. static readonly BILLBOARDMODE_STRETCHED: number;
  85902. /**
  85903. * This function can be defined to provide custom update for active particles.
  85904. * This function will be called instead of regular update (age, position, color, etc.).
  85905. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85906. */
  85907. updateFunction: (particles: Particle[]) => void;
  85908. private _emitterWorldMatrix;
  85909. /**
  85910. * This function can be defined to specify initial direction for every new particle.
  85911. * It by default use the emitterType defined function
  85912. */
  85913. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85914. /**
  85915. * This function can be defined to specify initial position for every new particle.
  85916. * It by default use the emitterType defined function
  85917. */
  85918. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85919. /**
  85920. * @hidden
  85921. */
  85922. _inheritedVelocityOffset: Vector3;
  85923. /**
  85924. * An event triggered when the system is disposed
  85925. */
  85926. onDisposeObservable: Observable<ParticleSystem>;
  85927. private _onDisposeObserver;
  85928. /**
  85929. * Sets a callback that will be triggered when the system is disposed
  85930. */
  85931. set onDispose(callback: () => void);
  85932. private _particles;
  85933. private _epsilon;
  85934. private _capacity;
  85935. private _stockParticles;
  85936. private _newPartsExcess;
  85937. private _vertexData;
  85938. private _vertexBuffer;
  85939. private _vertexBuffers;
  85940. private _spriteBuffer;
  85941. private _indexBuffer;
  85942. private _effect;
  85943. private _customEffect;
  85944. private _cachedDefines;
  85945. private _scaledColorStep;
  85946. private _colorDiff;
  85947. private _scaledDirection;
  85948. private _scaledGravity;
  85949. private _currentRenderId;
  85950. private _alive;
  85951. private _useInstancing;
  85952. private _started;
  85953. private _stopped;
  85954. private _actualFrame;
  85955. private _scaledUpdateSpeed;
  85956. private _vertexBufferSize;
  85957. /** @hidden */
  85958. _currentEmitRateGradient: Nullable<FactorGradient>;
  85959. /** @hidden */
  85960. _currentEmitRate1: number;
  85961. /** @hidden */
  85962. _currentEmitRate2: number;
  85963. /** @hidden */
  85964. _currentStartSizeGradient: Nullable<FactorGradient>;
  85965. /** @hidden */
  85966. _currentStartSize1: number;
  85967. /** @hidden */
  85968. _currentStartSize2: number;
  85969. private readonly _rawTextureWidth;
  85970. private _rampGradientsTexture;
  85971. private _useRampGradients;
  85972. /** Gets or sets a boolean indicating that ramp gradients must be used
  85973. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85974. */
  85975. get useRampGradients(): boolean;
  85976. set useRampGradients(value: boolean);
  85977. /**
  85978. * 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.
  85979. * 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: [])
  85980. */
  85981. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85982. private _subEmitters;
  85983. /**
  85984. * @hidden
  85985. * If the particle systems emitter should be disposed when the particle system is disposed
  85986. */
  85987. _disposeEmitterOnDispose: boolean;
  85988. /**
  85989. * The current active Sub-systems, this property is used by the root particle system only.
  85990. */
  85991. activeSubSystems: Array<ParticleSystem>;
  85992. /**
  85993. * Specifies if the particles are updated in emitter local space or world space
  85994. */
  85995. isLocal: boolean;
  85996. private _rootParticleSystem;
  85997. /**
  85998. * Gets the current list of active particles
  85999. */
  86000. get particles(): Particle[];
  86001. /**
  86002. * Gets the number of particles active at the same time.
  86003. * @returns The number of active particles.
  86004. */
  86005. getActiveCount(): number;
  86006. /**
  86007. * Returns the string "ParticleSystem"
  86008. * @returns a string containing the class name
  86009. */
  86010. getClassName(): string;
  86011. /**
  86012. * Gets a boolean indicating that the system is stopping
  86013. * @returns true if the system is currently stopping
  86014. */
  86015. isStopping(): boolean;
  86016. /**
  86017. * Instantiates a particle system.
  86018. * 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.
  86019. * @param name The name of the particle system
  86020. * @param capacity The max number of particles alive at the same time
  86021. * @param scene The scene the particle system belongs to
  86022. * @param customEffect a custom effect used to change the way particles are rendered by default
  86023. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86024. * @param epsilon Offset used to render the particles
  86025. */
  86026. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86027. private _addFactorGradient;
  86028. private _removeFactorGradient;
  86029. /**
  86030. * Adds a new life time gradient
  86031. * @param gradient defines the gradient to use (between 0 and 1)
  86032. * @param factor defines the life time factor to affect to the specified gradient
  86033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86034. * @returns the current particle system
  86035. */
  86036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86037. /**
  86038. * Remove a specific life time gradient
  86039. * @param gradient defines the gradient to remove
  86040. * @returns the current particle system
  86041. */
  86042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86043. /**
  86044. * Adds a new size gradient
  86045. * @param gradient defines the gradient to use (between 0 and 1)
  86046. * @param factor defines the size factor to affect to the specified gradient
  86047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86048. * @returns the current particle system
  86049. */
  86050. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86051. /**
  86052. * Remove a specific size gradient
  86053. * @param gradient defines the gradient to remove
  86054. * @returns the current particle system
  86055. */
  86056. removeSizeGradient(gradient: number): IParticleSystem;
  86057. /**
  86058. * Adds a new color remap gradient
  86059. * @param gradient defines the gradient to use (between 0 and 1)
  86060. * @param min defines the color remap minimal range
  86061. * @param max defines the color remap maximal range
  86062. * @returns the current particle system
  86063. */
  86064. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86065. /**
  86066. * Remove a specific color remap gradient
  86067. * @param gradient defines the gradient to remove
  86068. * @returns the current particle system
  86069. */
  86070. removeColorRemapGradient(gradient: number): IParticleSystem;
  86071. /**
  86072. * Adds a new alpha remap gradient
  86073. * @param gradient defines the gradient to use (between 0 and 1)
  86074. * @param min defines the alpha remap minimal range
  86075. * @param max defines the alpha remap maximal range
  86076. * @returns the current particle system
  86077. */
  86078. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86079. /**
  86080. * Remove a specific alpha remap gradient
  86081. * @param gradient defines the gradient to remove
  86082. * @returns the current particle system
  86083. */
  86084. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86085. /**
  86086. * Adds a new angular speed gradient
  86087. * @param gradient defines the gradient to use (between 0 and 1)
  86088. * @param factor defines the angular speed to affect to the specified gradient
  86089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86090. * @returns the current particle system
  86091. */
  86092. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86093. /**
  86094. * Remove a specific angular speed gradient
  86095. * @param gradient defines the gradient to remove
  86096. * @returns the current particle system
  86097. */
  86098. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86099. /**
  86100. * Adds a new velocity gradient
  86101. * @param gradient defines the gradient to use (between 0 and 1)
  86102. * @param factor defines the velocity to affect to the specified gradient
  86103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86104. * @returns the current particle system
  86105. */
  86106. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86107. /**
  86108. * Remove a specific velocity gradient
  86109. * @param gradient defines the gradient to remove
  86110. * @returns the current particle system
  86111. */
  86112. removeVelocityGradient(gradient: number): IParticleSystem;
  86113. /**
  86114. * Adds a new limit velocity gradient
  86115. * @param gradient defines the gradient to use (between 0 and 1)
  86116. * @param factor defines the limit velocity value to affect to the specified gradient
  86117. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86118. * @returns the current particle system
  86119. */
  86120. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86121. /**
  86122. * Remove a specific limit velocity gradient
  86123. * @param gradient defines the gradient to remove
  86124. * @returns the current particle system
  86125. */
  86126. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86127. /**
  86128. * Adds a new drag gradient
  86129. * @param gradient defines the gradient to use (between 0 and 1)
  86130. * @param factor defines the drag value to affect to the specified gradient
  86131. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86132. * @returns the current particle system
  86133. */
  86134. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86135. /**
  86136. * Remove a specific drag gradient
  86137. * @param gradient defines the gradient to remove
  86138. * @returns the current particle system
  86139. */
  86140. removeDragGradient(gradient: number): IParticleSystem;
  86141. /**
  86142. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86143. * @param gradient defines the gradient to use (between 0 and 1)
  86144. * @param factor defines the emit rate value to affect to the specified gradient
  86145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86146. * @returns the current particle system
  86147. */
  86148. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86149. /**
  86150. * Remove a specific emit rate gradient
  86151. * @param gradient defines the gradient to remove
  86152. * @returns the current particle system
  86153. */
  86154. removeEmitRateGradient(gradient: number): IParticleSystem;
  86155. /**
  86156. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86157. * @param gradient defines the gradient to use (between 0 and 1)
  86158. * @param factor defines the start size value to affect to the specified gradient
  86159. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86160. * @returns the current particle system
  86161. */
  86162. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86163. /**
  86164. * Remove a specific start size gradient
  86165. * @param gradient defines the gradient to remove
  86166. * @returns the current particle system
  86167. */
  86168. removeStartSizeGradient(gradient: number): IParticleSystem;
  86169. private _createRampGradientTexture;
  86170. /**
  86171. * Gets the current list of ramp gradients.
  86172. * You must use addRampGradient and removeRampGradient to udpate this list
  86173. * @returns the list of ramp gradients
  86174. */
  86175. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86176. /** Force the system to rebuild all gradients that need to be resync */
  86177. forceRefreshGradients(): void;
  86178. private _syncRampGradientTexture;
  86179. /**
  86180. * Adds a new ramp gradient used to remap particle colors
  86181. * @param gradient defines the gradient to use (between 0 and 1)
  86182. * @param color defines the color to affect to the specified gradient
  86183. * @returns the current particle system
  86184. */
  86185. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86186. /**
  86187. * Remove a specific ramp gradient
  86188. * @param gradient defines the gradient to remove
  86189. * @returns the current particle system
  86190. */
  86191. removeRampGradient(gradient: number): ParticleSystem;
  86192. /**
  86193. * Adds a new color gradient
  86194. * @param gradient defines the gradient to use (between 0 and 1)
  86195. * @param color1 defines the color to affect to the specified gradient
  86196. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86197. * @returns this particle system
  86198. */
  86199. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86200. /**
  86201. * Remove a specific color gradient
  86202. * @param gradient defines the gradient to remove
  86203. * @returns this particle system
  86204. */
  86205. removeColorGradient(gradient: number): IParticleSystem;
  86206. private _fetchR;
  86207. protected _reset(): void;
  86208. private _resetEffect;
  86209. private _createVertexBuffers;
  86210. private _createIndexBuffer;
  86211. /**
  86212. * Gets the maximum number of particles active at the same time.
  86213. * @returns The max number of active particles.
  86214. */
  86215. getCapacity(): number;
  86216. /**
  86217. * Gets whether there are still active particles in the system.
  86218. * @returns True if it is alive, otherwise false.
  86219. */
  86220. isAlive(): boolean;
  86221. /**
  86222. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86223. * @returns True if it has been started, otherwise false.
  86224. */
  86225. isStarted(): boolean;
  86226. private _prepareSubEmitterInternalArray;
  86227. /**
  86228. * Starts the particle system and begins to emit
  86229. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86230. */
  86231. start(delay?: number): void;
  86232. /**
  86233. * Stops the particle system.
  86234. * @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.
  86235. */
  86236. stop(stopSubEmitters?: boolean): void;
  86237. /**
  86238. * Remove all active particles
  86239. */
  86240. reset(): void;
  86241. /**
  86242. * @hidden (for internal use only)
  86243. */
  86244. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86245. /**
  86246. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86247. * Its lifetime will start back at 0.
  86248. */
  86249. recycleParticle: (particle: Particle) => void;
  86250. private _stopSubEmitters;
  86251. private _createParticle;
  86252. private _removeFromRoot;
  86253. private _emitFromParticle;
  86254. private _update;
  86255. /** @hidden */
  86256. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86257. /** @hidden */
  86258. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86259. /** @hidden */
  86260. private _getEffect;
  86261. /**
  86262. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86263. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86264. */
  86265. animate(preWarmOnly?: boolean): void;
  86266. private _appendParticleVertices;
  86267. /**
  86268. * Rebuilds the particle system.
  86269. */
  86270. rebuild(): void;
  86271. /**
  86272. * Is this system ready to be used/rendered
  86273. * @return true if the system is ready
  86274. */
  86275. isReady(): boolean;
  86276. private _render;
  86277. /**
  86278. * Renders the particle system in its current state.
  86279. * @returns the current number of particles
  86280. */
  86281. render(): number;
  86282. /**
  86283. * Disposes the particle system and free the associated resources
  86284. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86285. */
  86286. dispose(disposeTexture?: boolean): void;
  86287. /**
  86288. * Clones the particle system.
  86289. * @param name The name of the cloned object
  86290. * @param newEmitter The new emitter to use
  86291. * @returns the cloned particle system
  86292. */
  86293. clone(name: string, newEmitter: any): ParticleSystem;
  86294. /**
  86295. * Serializes the particle system to a JSON object
  86296. * @param serializeTexture defines if the texture must be serialized as well
  86297. * @returns the JSON object
  86298. */
  86299. serialize(serializeTexture?: boolean): any;
  86300. /** @hidden */
  86301. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  86302. /** @hidden */
  86303. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86304. /**
  86305. * Parses a JSON object to create a particle system.
  86306. * @param parsedParticleSystem The JSON object to parse
  86307. * @param scene The scene to create the particle system in
  86308. * @param rootUrl The root url to use to load external dependencies like texture
  86309. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86310. * @returns the Parsed particle system
  86311. */
  86312. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86313. }
  86314. }
  86315. declare module BABYLON {
  86316. /**
  86317. * A particle represents one of the element emitted by a particle system.
  86318. * This is mainly define by its coordinates, direction, velocity and age.
  86319. */
  86320. export class Particle {
  86321. /**
  86322. * The particle system the particle belongs to.
  86323. */
  86324. particleSystem: ParticleSystem;
  86325. private static _Count;
  86326. /**
  86327. * Unique ID of the particle
  86328. */
  86329. id: number;
  86330. /**
  86331. * The world position of the particle in the scene.
  86332. */
  86333. position: Vector3;
  86334. /**
  86335. * The world direction of the particle in the scene.
  86336. */
  86337. direction: Vector3;
  86338. /**
  86339. * The color of the particle.
  86340. */
  86341. color: Color4;
  86342. /**
  86343. * The color change of the particle per step.
  86344. */
  86345. colorStep: Color4;
  86346. /**
  86347. * Defines how long will the life of the particle be.
  86348. */
  86349. lifeTime: number;
  86350. /**
  86351. * The current age of the particle.
  86352. */
  86353. age: number;
  86354. /**
  86355. * The current size of the particle.
  86356. */
  86357. size: number;
  86358. /**
  86359. * The current scale of the particle.
  86360. */
  86361. scale: Vector2;
  86362. /**
  86363. * The current angle of the particle.
  86364. */
  86365. angle: number;
  86366. /**
  86367. * Defines how fast is the angle changing.
  86368. */
  86369. angularSpeed: number;
  86370. /**
  86371. * Defines the cell index used by the particle to be rendered from a sprite.
  86372. */
  86373. cellIndex: number;
  86374. /**
  86375. * The information required to support color remapping
  86376. */
  86377. remapData: Vector4;
  86378. /** @hidden */
  86379. _randomCellOffset?: number;
  86380. /** @hidden */
  86381. _initialDirection: Nullable<Vector3>;
  86382. /** @hidden */
  86383. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86384. /** @hidden */
  86385. _initialStartSpriteCellID: number;
  86386. /** @hidden */
  86387. _initialEndSpriteCellID: number;
  86388. /** @hidden */
  86389. _currentColorGradient: Nullable<ColorGradient>;
  86390. /** @hidden */
  86391. _currentColor1: Color4;
  86392. /** @hidden */
  86393. _currentColor2: Color4;
  86394. /** @hidden */
  86395. _currentSizeGradient: Nullable<FactorGradient>;
  86396. /** @hidden */
  86397. _currentSize1: number;
  86398. /** @hidden */
  86399. _currentSize2: number;
  86400. /** @hidden */
  86401. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86402. /** @hidden */
  86403. _currentAngularSpeed1: number;
  86404. /** @hidden */
  86405. _currentAngularSpeed2: number;
  86406. /** @hidden */
  86407. _currentVelocityGradient: Nullable<FactorGradient>;
  86408. /** @hidden */
  86409. _currentVelocity1: number;
  86410. /** @hidden */
  86411. _currentVelocity2: number;
  86412. /** @hidden */
  86413. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86414. /** @hidden */
  86415. _currentLimitVelocity1: number;
  86416. /** @hidden */
  86417. _currentLimitVelocity2: number;
  86418. /** @hidden */
  86419. _currentDragGradient: Nullable<FactorGradient>;
  86420. /** @hidden */
  86421. _currentDrag1: number;
  86422. /** @hidden */
  86423. _currentDrag2: number;
  86424. /** @hidden */
  86425. _randomNoiseCoordinates1: Vector3;
  86426. /** @hidden */
  86427. _randomNoiseCoordinates2: Vector3;
  86428. /** @hidden */
  86429. _localPosition?: Vector3;
  86430. /**
  86431. * Creates a new instance Particle
  86432. * @param particleSystem the particle system the particle belongs to
  86433. */
  86434. constructor(
  86435. /**
  86436. * The particle system the particle belongs to.
  86437. */
  86438. particleSystem: ParticleSystem);
  86439. private updateCellInfoFromSystem;
  86440. /**
  86441. * Defines how the sprite cell index is updated for the particle
  86442. */
  86443. updateCellIndex(): void;
  86444. /** @hidden */
  86445. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86446. /** @hidden */
  86447. _inheritParticleInfoToSubEmitters(): void;
  86448. /** @hidden */
  86449. _reset(): void;
  86450. /**
  86451. * Copy the properties of particle to another one.
  86452. * @param other the particle to copy the information to.
  86453. */
  86454. copyTo(other: Particle): void;
  86455. }
  86456. }
  86457. declare module BABYLON {
  86458. /**
  86459. * Particle emitter represents a volume emitting particles.
  86460. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86461. */
  86462. export interface IParticleEmitterType {
  86463. /**
  86464. * Called by the particle System when the direction is computed for the created particle.
  86465. * @param worldMatrix is the world matrix of the particle system
  86466. * @param directionToUpdate is the direction vector to update with the result
  86467. * @param particle is the particle we are computed the direction for
  86468. * @param isLocal defines if the direction should be set in local space
  86469. */
  86470. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86471. /**
  86472. * Called by the particle System when the position is computed for the created particle.
  86473. * @param worldMatrix is the world matrix of the particle system
  86474. * @param positionToUpdate is the position vector to update with the result
  86475. * @param particle is the particle we are computed the position for
  86476. * @param isLocal defines if the position should be set in local space
  86477. */
  86478. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86479. /**
  86480. * Clones the current emitter and returns a copy of it
  86481. * @returns the new emitter
  86482. */
  86483. clone(): IParticleEmitterType;
  86484. /**
  86485. * Called by the GPUParticleSystem to setup the update shader
  86486. * @param effect defines the update shader
  86487. */
  86488. applyToShader(effect: Effect): void;
  86489. /**
  86490. * Returns a string to use to update the GPU particles update shader
  86491. * @returns the effect defines string
  86492. */
  86493. getEffectDefines(): string;
  86494. /**
  86495. * Returns a string representing the class name
  86496. * @returns a string containing the class name
  86497. */
  86498. getClassName(): string;
  86499. /**
  86500. * Serializes the particle system to a JSON object.
  86501. * @returns the JSON object
  86502. */
  86503. serialize(): any;
  86504. /**
  86505. * Parse properties from a JSON object
  86506. * @param serializationObject defines the JSON object
  86507. * @param scene defines the hosting scene
  86508. */
  86509. parse(serializationObject: any, scene: Scene): void;
  86510. }
  86511. }
  86512. declare module BABYLON {
  86513. /**
  86514. * Particle emitter emitting particles from the inside of a box.
  86515. * It emits the particles randomly between 2 given directions.
  86516. */
  86517. export class BoxParticleEmitter implements IParticleEmitterType {
  86518. /**
  86519. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86520. */
  86521. direction1: Vector3;
  86522. /**
  86523. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86524. */
  86525. direction2: Vector3;
  86526. /**
  86527. * 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.
  86528. */
  86529. minEmitBox: Vector3;
  86530. /**
  86531. * 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.
  86532. */
  86533. maxEmitBox: Vector3;
  86534. /**
  86535. * Creates a new instance BoxParticleEmitter
  86536. */
  86537. constructor();
  86538. /**
  86539. * Called by the particle System when the direction is computed for the created particle.
  86540. * @param worldMatrix is the world matrix of the particle system
  86541. * @param directionToUpdate is the direction vector to update with the result
  86542. * @param particle is the particle we are computed the direction for
  86543. * @param isLocal defines if the direction should be set in local space
  86544. */
  86545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86546. /**
  86547. * Called by the particle System when the position is computed for the created particle.
  86548. * @param worldMatrix is the world matrix of the particle system
  86549. * @param positionToUpdate is the position vector to update with the result
  86550. * @param particle is the particle we are computed the position for
  86551. * @param isLocal defines if the position should be set in local space
  86552. */
  86553. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86554. /**
  86555. * Clones the current emitter and returns a copy of it
  86556. * @returns the new emitter
  86557. */
  86558. clone(): BoxParticleEmitter;
  86559. /**
  86560. * Called by the GPUParticleSystem to setup the update shader
  86561. * @param effect defines the update shader
  86562. */
  86563. applyToShader(effect: Effect): void;
  86564. /**
  86565. * Returns a string to use to update the GPU particles update shader
  86566. * @returns a string containng the defines string
  86567. */
  86568. getEffectDefines(): string;
  86569. /**
  86570. * Returns the string "BoxParticleEmitter"
  86571. * @returns a string containing the class name
  86572. */
  86573. getClassName(): string;
  86574. /**
  86575. * Serializes the particle system to a JSON object.
  86576. * @returns the JSON object
  86577. */
  86578. serialize(): any;
  86579. /**
  86580. * Parse properties from a JSON object
  86581. * @param serializationObject defines the JSON object
  86582. */
  86583. parse(serializationObject: any): void;
  86584. }
  86585. }
  86586. declare module BABYLON {
  86587. /**
  86588. * Particle emitter emitting particles from the inside of a cone.
  86589. * It emits the particles alongside the cone volume from the base to the particle.
  86590. * The emission direction might be randomized.
  86591. */
  86592. export class ConeParticleEmitter implements IParticleEmitterType {
  86593. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86594. directionRandomizer: number;
  86595. private _radius;
  86596. private _angle;
  86597. private _height;
  86598. /**
  86599. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86600. */
  86601. radiusRange: number;
  86602. /**
  86603. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86604. */
  86605. heightRange: number;
  86606. /**
  86607. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86608. */
  86609. emitFromSpawnPointOnly: boolean;
  86610. /**
  86611. * Gets or sets the radius of the emission cone
  86612. */
  86613. get radius(): number;
  86614. set radius(value: number);
  86615. /**
  86616. * Gets or sets the angle of the emission cone
  86617. */
  86618. get angle(): number;
  86619. set angle(value: number);
  86620. private _buildHeight;
  86621. /**
  86622. * Creates a new instance ConeParticleEmitter
  86623. * @param radius the radius of the emission cone (1 by default)
  86624. * @param angle the cone base angle (PI by default)
  86625. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86626. */
  86627. constructor(radius?: number, angle?: number,
  86628. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86629. directionRandomizer?: number);
  86630. /**
  86631. * Called by the particle System when the direction is computed for the created particle.
  86632. * @param worldMatrix is the world matrix of the particle system
  86633. * @param directionToUpdate is the direction vector to update with the result
  86634. * @param particle is the particle we are computed the direction for
  86635. * @param isLocal defines if the direction should be set in local space
  86636. */
  86637. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86638. /**
  86639. * Called by the particle System when the position is computed for the created particle.
  86640. * @param worldMatrix is the world matrix of the particle system
  86641. * @param positionToUpdate is the position vector to update with the result
  86642. * @param particle is the particle we are computed the position for
  86643. * @param isLocal defines if the position should be set in local space
  86644. */
  86645. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86646. /**
  86647. * Clones the current emitter and returns a copy of it
  86648. * @returns the new emitter
  86649. */
  86650. clone(): ConeParticleEmitter;
  86651. /**
  86652. * Called by the GPUParticleSystem to setup the update shader
  86653. * @param effect defines the update shader
  86654. */
  86655. applyToShader(effect: Effect): void;
  86656. /**
  86657. * Returns a string to use to update the GPU particles update shader
  86658. * @returns a string containng the defines string
  86659. */
  86660. getEffectDefines(): string;
  86661. /**
  86662. * Returns the string "ConeParticleEmitter"
  86663. * @returns a string containing the class name
  86664. */
  86665. getClassName(): string;
  86666. /**
  86667. * Serializes the particle system to a JSON object.
  86668. * @returns the JSON object
  86669. */
  86670. serialize(): any;
  86671. /**
  86672. * Parse properties from a JSON object
  86673. * @param serializationObject defines the JSON object
  86674. */
  86675. parse(serializationObject: any): void;
  86676. }
  86677. }
  86678. declare module BABYLON {
  86679. /**
  86680. * Particle emitter emitting particles from the inside of a cylinder.
  86681. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86682. */
  86683. export class CylinderParticleEmitter implements IParticleEmitterType {
  86684. /**
  86685. * The radius of the emission cylinder.
  86686. */
  86687. radius: number;
  86688. /**
  86689. * The height of the emission cylinder.
  86690. */
  86691. height: number;
  86692. /**
  86693. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86694. */
  86695. radiusRange: number;
  86696. /**
  86697. * How much to randomize the particle direction [0-1].
  86698. */
  86699. directionRandomizer: number;
  86700. /**
  86701. * Creates a new instance CylinderParticleEmitter
  86702. * @param radius the radius of the emission cylinder (1 by default)
  86703. * @param height the height of the emission cylinder (1 by default)
  86704. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86705. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86706. */
  86707. constructor(
  86708. /**
  86709. * The radius of the emission cylinder.
  86710. */
  86711. radius?: number,
  86712. /**
  86713. * The height of the emission cylinder.
  86714. */
  86715. height?: number,
  86716. /**
  86717. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86718. */
  86719. radiusRange?: number,
  86720. /**
  86721. * How much to randomize the particle direction [0-1].
  86722. */
  86723. directionRandomizer?: number);
  86724. /**
  86725. * Called by the particle System when the direction is computed for the created particle.
  86726. * @param worldMatrix is the world matrix of the particle system
  86727. * @param directionToUpdate is the direction vector to update with the result
  86728. * @param particle is the particle we are computed the direction for
  86729. * @param isLocal defines if the direction should be set in local space
  86730. */
  86731. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86732. /**
  86733. * Called by the particle System when the position is computed for the created particle.
  86734. * @param worldMatrix is the world matrix of the particle system
  86735. * @param positionToUpdate is the position vector to update with the result
  86736. * @param particle is the particle we are computed the position for
  86737. * @param isLocal defines if the position should be set in local space
  86738. */
  86739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86740. /**
  86741. * Clones the current emitter and returns a copy of it
  86742. * @returns the new emitter
  86743. */
  86744. clone(): CylinderParticleEmitter;
  86745. /**
  86746. * Called by the GPUParticleSystem to setup the update shader
  86747. * @param effect defines the update shader
  86748. */
  86749. applyToShader(effect: Effect): void;
  86750. /**
  86751. * Returns a string to use to update the GPU particles update shader
  86752. * @returns a string containng the defines string
  86753. */
  86754. getEffectDefines(): string;
  86755. /**
  86756. * Returns the string "CylinderParticleEmitter"
  86757. * @returns a string containing the class name
  86758. */
  86759. getClassName(): string;
  86760. /**
  86761. * Serializes the particle system to a JSON object.
  86762. * @returns the JSON object
  86763. */
  86764. serialize(): any;
  86765. /**
  86766. * Parse properties from a JSON object
  86767. * @param serializationObject defines the JSON object
  86768. */
  86769. parse(serializationObject: any): void;
  86770. }
  86771. /**
  86772. * Particle emitter emitting particles from the inside of a cylinder.
  86773. * It emits the particles randomly between two vectors.
  86774. */
  86775. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86776. /**
  86777. * The min limit of the emission direction.
  86778. */
  86779. direction1: Vector3;
  86780. /**
  86781. * The max limit of the emission direction.
  86782. */
  86783. direction2: Vector3;
  86784. /**
  86785. * Creates a new instance CylinderDirectedParticleEmitter
  86786. * @param radius the radius of the emission cylinder (1 by default)
  86787. * @param height the height of the emission cylinder (1 by default)
  86788. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86789. * @param direction1 the min limit of the emission direction (up vector by default)
  86790. * @param direction2 the max limit of the emission direction (up vector by default)
  86791. */
  86792. constructor(radius?: number, height?: number, radiusRange?: number,
  86793. /**
  86794. * The min limit of the emission direction.
  86795. */
  86796. direction1?: Vector3,
  86797. /**
  86798. * The max limit of the emission direction.
  86799. */
  86800. direction2?: Vector3);
  86801. /**
  86802. * Called by the particle System when the direction is computed for the created particle.
  86803. * @param worldMatrix is the world matrix of the particle system
  86804. * @param directionToUpdate is the direction vector to update with the result
  86805. * @param particle is the particle we are computed the direction for
  86806. */
  86807. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86808. /**
  86809. * Clones the current emitter and returns a copy of it
  86810. * @returns the new emitter
  86811. */
  86812. clone(): CylinderDirectedParticleEmitter;
  86813. /**
  86814. * Called by the GPUParticleSystem to setup the update shader
  86815. * @param effect defines the update shader
  86816. */
  86817. applyToShader(effect: Effect): void;
  86818. /**
  86819. * Returns a string to use to update the GPU particles update shader
  86820. * @returns a string containng the defines string
  86821. */
  86822. getEffectDefines(): string;
  86823. /**
  86824. * Returns the string "CylinderDirectedParticleEmitter"
  86825. * @returns a string containing the class name
  86826. */
  86827. getClassName(): string;
  86828. /**
  86829. * Serializes the particle system to a JSON object.
  86830. * @returns the JSON object
  86831. */
  86832. serialize(): any;
  86833. /**
  86834. * Parse properties from a JSON object
  86835. * @param serializationObject defines the JSON object
  86836. */
  86837. parse(serializationObject: any): void;
  86838. }
  86839. }
  86840. declare module BABYLON {
  86841. /**
  86842. * Particle emitter emitting particles from the inside of a hemisphere.
  86843. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86844. */
  86845. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86846. /**
  86847. * The radius of the emission hemisphere.
  86848. */
  86849. radius: number;
  86850. /**
  86851. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86852. */
  86853. radiusRange: number;
  86854. /**
  86855. * How much to randomize the particle direction [0-1].
  86856. */
  86857. directionRandomizer: number;
  86858. /**
  86859. * Creates a new instance HemisphericParticleEmitter
  86860. * @param radius the radius of the emission hemisphere (1 by default)
  86861. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86862. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86863. */
  86864. constructor(
  86865. /**
  86866. * The radius of the emission hemisphere.
  86867. */
  86868. radius?: number,
  86869. /**
  86870. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86871. */
  86872. radiusRange?: number,
  86873. /**
  86874. * How much to randomize the particle direction [0-1].
  86875. */
  86876. directionRandomizer?: number);
  86877. /**
  86878. * Called by the particle System when the direction is computed for the created particle.
  86879. * @param worldMatrix is the world matrix of the particle system
  86880. * @param directionToUpdate is the direction vector to update with the result
  86881. * @param particle is the particle we are computed the direction for
  86882. * @param isLocal defines if the direction should be set in local space
  86883. */
  86884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86885. /**
  86886. * Called by the particle System when the position is computed for the created particle.
  86887. * @param worldMatrix is the world matrix of the particle system
  86888. * @param positionToUpdate is the position vector to update with the result
  86889. * @param particle is the particle we are computed the position for
  86890. * @param isLocal defines if the position should be set in local space
  86891. */
  86892. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86893. /**
  86894. * Clones the current emitter and returns a copy of it
  86895. * @returns the new emitter
  86896. */
  86897. clone(): HemisphericParticleEmitter;
  86898. /**
  86899. * Called by the GPUParticleSystem to setup the update shader
  86900. * @param effect defines the update shader
  86901. */
  86902. applyToShader(effect: Effect): void;
  86903. /**
  86904. * Returns a string to use to update the GPU particles update shader
  86905. * @returns a string containng the defines string
  86906. */
  86907. getEffectDefines(): string;
  86908. /**
  86909. * Returns the string "HemisphericParticleEmitter"
  86910. * @returns a string containing the class name
  86911. */
  86912. getClassName(): string;
  86913. /**
  86914. * Serializes the particle system to a JSON object.
  86915. * @returns the JSON object
  86916. */
  86917. serialize(): any;
  86918. /**
  86919. * Parse properties from a JSON object
  86920. * @param serializationObject defines the JSON object
  86921. */
  86922. parse(serializationObject: any): void;
  86923. }
  86924. }
  86925. declare module BABYLON {
  86926. /**
  86927. * Particle emitter emitting particles from a point.
  86928. * It emits the particles randomly between 2 given directions.
  86929. */
  86930. export class PointParticleEmitter implements IParticleEmitterType {
  86931. /**
  86932. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86933. */
  86934. direction1: Vector3;
  86935. /**
  86936. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86937. */
  86938. direction2: Vector3;
  86939. /**
  86940. * Creates a new instance PointParticleEmitter
  86941. */
  86942. constructor();
  86943. /**
  86944. * Called by the particle System when the direction is computed for the created particle.
  86945. * @param worldMatrix is the world matrix of the particle system
  86946. * @param directionToUpdate is the direction vector to update with the result
  86947. * @param particle is the particle we are computed the direction for
  86948. * @param isLocal defines if the direction should be set in local space
  86949. */
  86950. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86951. /**
  86952. * Called by the particle System when the position is computed for the created particle.
  86953. * @param worldMatrix is the world matrix of the particle system
  86954. * @param positionToUpdate is the position vector to update with the result
  86955. * @param particle is the particle we are computed the position for
  86956. * @param isLocal defines if the position should be set in local space
  86957. */
  86958. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86959. /**
  86960. * Clones the current emitter and returns a copy of it
  86961. * @returns the new emitter
  86962. */
  86963. clone(): PointParticleEmitter;
  86964. /**
  86965. * Called by the GPUParticleSystem to setup the update shader
  86966. * @param effect defines the update shader
  86967. */
  86968. applyToShader(effect: Effect): void;
  86969. /**
  86970. * Returns a string to use to update the GPU particles update shader
  86971. * @returns a string containng the defines string
  86972. */
  86973. getEffectDefines(): string;
  86974. /**
  86975. * Returns the string "PointParticleEmitter"
  86976. * @returns a string containing the class name
  86977. */
  86978. getClassName(): string;
  86979. /**
  86980. * Serializes the particle system to a JSON object.
  86981. * @returns the JSON object
  86982. */
  86983. serialize(): any;
  86984. /**
  86985. * Parse properties from a JSON object
  86986. * @param serializationObject defines the JSON object
  86987. */
  86988. parse(serializationObject: any): void;
  86989. }
  86990. }
  86991. declare module BABYLON {
  86992. /**
  86993. * Particle emitter emitting particles from the inside of a sphere.
  86994. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  86995. */
  86996. export class SphereParticleEmitter implements IParticleEmitterType {
  86997. /**
  86998. * The radius of the emission sphere.
  86999. */
  87000. radius: number;
  87001. /**
  87002. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87003. */
  87004. radiusRange: number;
  87005. /**
  87006. * How much to randomize the particle direction [0-1].
  87007. */
  87008. directionRandomizer: number;
  87009. /**
  87010. * Creates a new instance SphereParticleEmitter
  87011. * @param radius the radius of the emission sphere (1 by default)
  87012. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87013. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87014. */
  87015. constructor(
  87016. /**
  87017. * The radius of the emission sphere.
  87018. */
  87019. radius?: number,
  87020. /**
  87021. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87022. */
  87023. radiusRange?: number,
  87024. /**
  87025. * How much to randomize the particle direction [0-1].
  87026. */
  87027. directionRandomizer?: number);
  87028. /**
  87029. * Called by the particle System when the direction is computed for the created particle.
  87030. * @param worldMatrix is the world matrix of the particle system
  87031. * @param directionToUpdate is the direction vector to update with the result
  87032. * @param particle is the particle we are computed the direction for
  87033. * @param isLocal defines if the direction should be set in local space
  87034. */
  87035. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87036. /**
  87037. * Called by the particle System when the position is computed for the created particle.
  87038. * @param worldMatrix is the world matrix of the particle system
  87039. * @param positionToUpdate is the position vector to update with the result
  87040. * @param particle is the particle we are computed the position for
  87041. * @param isLocal defines if the position should be set in local space
  87042. */
  87043. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87044. /**
  87045. * Clones the current emitter and returns a copy of it
  87046. * @returns the new emitter
  87047. */
  87048. clone(): SphereParticleEmitter;
  87049. /**
  87050. * Called by the GPUParticleSystem to setup the update shader
  87051. * @param effect defines the update shader
  87052. */
  87053. applyToShader(effect: Effect): void;
  87054. /**
  87055. * Returns a string to use to update the GPU particles update shader
  87056. * @returns a string containng the defines string
  87057. */
  87058. getEffectDefines(): string;
  87059. /**
  87060. * Returns the string "SphereParticleEmitter"
  87061. * @returns a string containing the class name
  87062. */
  87063. getClassName(): string;
  87064. /**
  87065. * Serializes the particle system to a JSON object.
  87066. * @returns the JSON object
  87067. */
  87068. serialize(): any;
  87069. /**
  87070. * Parse properties from a JSON object
  87071. * @param serializationObject defines the JSON object
  87072. */
  87073. parse(serializationObject: any): void;
  87074. }
  87075. /**
  87076. * Particle emitter emitting particles from the inside of a sphere.
  87077. * It emits the particles randomly between two vectors.
  87078. */
  87079. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87080. /**
  87081. * The min limit of the emission direction.
  87082. */
  87083. direction1: Vector3;
  87084. /**
  87085. * The max limit of the emission direction.
  87086. */
  87087. direction2: Vector3;
  87088. /**
  87089. * Creates a new instance SphereDirectedParticleEmitter
  87090. * @param radius the radius of the emission sphere (1 by default)
  87091. * @param direction1 the min limit of the emission direction (up vector by default)
  87092. * @param direction2 the max limit of the emission direction (up vector by default)
  87093. */
  87094. constructor(radius?: number,
  87095. /**
  87096. * The min limit of the emission direction.
  87097. */
  87098. direction1?: Vector3,
  87099. /**
  87100. * The max limit of the emission direction.
  87101. */
  87102. direction2?: Vector3);
  87103. /**
  87104. * Called by the particle System when the direction is computed for the created particle.
  87105. * @param worldMatrix is the world matrix of the particle system
  87106. * @param directionToUpdate is the direction vector to update with the result
  87107. * @param particle is the particle we are computed the direction for
  87108. */
  87109. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87110. /**
  87111. * Clones the current emitter and returns a copy of it
  87112. * @returns the new emitter
  87113. */
  87114. clone(): SphereDirectedParticleEmitter;
  87115. /**
  87116. * Called by the GPUParticleSystem to setup the update shader
  87117. * @param effect defines the update shader
  87118. */
  87119. applyToShader(effect: Effect): void;
  87120. /**
  87121. * Returns a string to use to update the GPU particles update shader
  87122. * @returns a string containng the defines string
  87123. */
  87124. getEffectDefines(): string;
  87125. /**
  87126. * Returns the string "SphereDirectedParticleEmitter"
  87127. * @returns a string containing the class name
  87128. */
  87129. getClassName(): string;
  87130. /**
  87131. * Serializes the particle system to a JSON object.
  87132. * @returns the JSON object
  87133. */
  87134. serialize(): any;
  87135. /**
  87136. * Parse properties from a JSON object
  87137. * @param serializationObject defines the JSON object
  87138. */
  87139. parse(serializationObject: any): void;
  87140. }
  87141. }
  87142. declare module BABYLON {
  87143. /**
  87144. * Particle emitter emitting particles from a custom list of positions.
  87145. */
  87146. export class CustomParticleEmitter implements IParticleEmitterType {
  87147. /**
  87148. * Gets or sets the position generator that will create the inital position of each particle.
  87149. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87150. */
  87151. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  87152. /**
  87153. * Gets or sets the destination generator that will create the final destination of each particle.
  87154. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87155. */
  87156. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  87157. /**
  87158. * Creates a new instance CustomParticleEmitter
  87159. */
  87160. constructor();
  87161. /**
  87162. * Called by the particle System when the direction is computed for the created particle.
  87163. * @param worldMatrix is the world matrix of the particle system
  87164. * @param directionToUpdate is the direction vector to update with the result
  87165. * @param particle is the particle we are computed the direction for
  87166. * @param isLocal defines if the direction should be set in local space
  87167. */
  87168. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87169. /**
  87170. * Called by the particle System when the position is computed for the created particle.
  87171. * @param worldMatrix is the world matrix of the particle system
  87172. * @param positionToUpdate is the position vector to update with the result
  87173. * @param particle is the particle we are computed the position for
  87174. * @param isLocal defines if the position should be set in local space
  87175. */
  87176. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87177. /**
  87178. * Clones the current emitter and returns a copy of it
  87179. * @returns the new emitter
  87180. */
  87181. clone(): CustomParticleEmitter;
  87182. /**
  87183. * Called by the GPUParticleSystem to setup the update shader
  87184. * @param effect defines the update shader
  87185. */
  87186. applyToShader(effect: Effect): void;
  87187. /**
  87188. * Returns a string to use to update the GPU particles update shader
  87189. * @returns a string containng the defines string
  87190. */
  87191. getEffectDefines(): string;
  87192. /**
  87193. * Returns the string "PointParticleEmitter"
  87194. * @returns a string containing the class name
  87195. */
  87196. getClassName(): string;
  87197. /**
  87198. * Serializes the particle system to a JSON object.
  87199. * @returns the JSON object
  87200. */
  87201. serialize(): any;
  87202. /**
  87203. * Parse properties from a JSON object
  87204. * @param serializationObject defines the JSON object
  87205. */
  87206. parse(serializationObject: any): void;
  87207. }
  87208. }
  87209. declare module BABYLON {
  87210. /**
  87211. * Particle emitter emitting particles from the inside of a box.
  87212. * It emits the particles randomly between 2 given directions.
  87213. */
  87214. export class MeshParticleEmitter implements IParticleEmitterType {
  87215. private _indices;
  87216. private _positions;
  87217. private _normals;
  87218. private _storedNormal;
  87219. private _mesh;
  87220. /**
  87221. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87222. */
  87223. direction1: Vector3;
  87224. /**
  87225. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87226. */
  87227. direction2: Vector3;
  87228. /**
  87229. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  87230. */
  87231. useMeshNormalsForDirection: boolean;
  87232. /** Defines the mesh to use as source */
  87233. get mesh(): Nullable<AbstractMesh>;
  87234. set mesh(value: Nullable<AbstractMesh>);
  87235. /**
  87236. * Creates a new instance MeshParticleEmitter
  87237. * @param mesh defines the mesh to use as source
  87238. */
  87239. constructor(mesh?: Nullable<AbstractMesh>);
  87240. /**
  87241. * Called by the particle System when the direction is computed for the created particle.
  87242. * @param worldMatrix is the world matrix of the particle system
  87243. * @param directionToUpdate is the direction vector to update with the result
  87244. * @param particle is the particle we are computed the direction for
  87245. * @param isLocal defines if the direction should be set in local space
  87246. */
  87247. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87248. /**
  87249. * Called by the particle System when the position is computed for the created particle.
  87250. * @param worldMatrix is the world matrix of the particle system
  87251. * @param positionToUpdate is the position vector to update with the result
  87252. * @param particle is the particle we are computed the position for
  87253. * @param isLocal defines if the position should be set in local space
  87254. */
  87255. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87256. /**
  87257. * Clones the current emitter and returns a copy of it
  87258. * @returns the new emitter
  87259. */
  87260. clone(): MeshParticleEmitter;
  87261. /**
  87262. * Called by the GPUParticleSystem to setup the update shader
  87263. * @param effect defines the update shader
  87264. */
  87265. applyToShader(effect: Effect): void;
  87266. /**
  87267. * Returns a string to use to update the GPU particles update shader
  87268. * @returns a string containng the defines string
  87269. */
  87270. getEffectDefines(): string;
  87271. /**
  87272. * Returns the string "BoxParticleEmitter"
  87273. * @returns a string containing the class name
  87274. */
  87275. getClassName(): string;
  87276. /**
  87277. * Serializes the particle system to a JSON object.
  87278. * @returns the JSON object
  87279. */
  87280. serialize(): any;
  87281. /**
  87282. * Parse properties from a JSON object
  87283. * @param serializationObject defines the JSON object
  87284. * @param scene defines the hosting scene
  87285. */
  87286. parse(serializationObject: any, scene: Scene): void;
  87287. }
  87288. }
  87289. declare module BABYLON {
  87290. /**
  87291. * Interface representing a particle system in Babylon.js.
  87292. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87293. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87294. */
  87295. export interface IParticleSystem {
  87296. /**
  87297. * List of animations used by the particle system.
  87298. */
  87299. animations: Animation[];
  87300. /**
  87301. * The id of the Particle system.
  87302. */
  87303. id: string;
  87304. /**
  87305. * The name of the Particle system.
  87306. */
  87307. name: string;
  87308. /**
  87309. * The emitter represents the Mesh or position we are attaching the particle system to.
  87310. */
  87311. emitter: Nullable<AbstractMesh | Vector3>;
  87312. /**
  87313. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87314. */
  87315. isBillboardBased: boolean;
  87316. /**
  87317. * The rendering group used by the Particle system to chose when to render.
  87318. */
  87319. renderingGroupId: number;
  87320. /**
  87321. * The layer mask we are rendering the particles through.
  87322. */
  87323. layerMask: number;
  87324. /**
  87325. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87326. */
  87327. updateSpeed: number;
  87328. /**
  87329. * The amount of time the particle system is running (depends of the overall update speed).
  87330. */
  87331. targetStopDuration: number;
  87332. /**
  87333. * The texture used to render each particle. (this can be a spritesheet)
  87334. */
  87335. particleTexture: Nullable<Texture>;
  87336. /**
  87337. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87338. */
  87339. blendMode: number;
  87340. /**
  87341. * Minimum life time of emitting particles.
  87342. */
  87343. minLifeTime: number;
  87344. /**
  87345. * Maximum life time of emitting particles.
  87346. */
  87347. maxLifeTime: number;
  87348. /**
  87349. * Minimum Size of emitting particles.
  87350. */
  87351. minSize: number;
  87352. /**
  87353. * Maximum Size of emitting particles.
  87354. */
  87355. maxSize: number;
  87356. /**
  87357. * Minimum scale of emitting particles on X axis.
  87358. */
  87359. minScaleX: number;
  87360. /**
  87361. * Maximum scale of emitting particles on X axis.
  87362. */
  87363. maxScaleX: number;
  87364. /**
  87365. * Minimum scale of emitting particles on Y axis.
  87366. */
  87367. minScaleY: number;
  87368. /**
  87369. * Maximum scale of emitting particles on Y axis.
  87370. */
  87371. maxScaleY: number;
  87372. /**
  87373. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87374. */
  87375. color1: Color4;
  87376. /**
  87377. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87378. */
  87379. color2: Color4;
  87380. /**
  87381. * Color the particle will have at the end of its lifetime.
  87382. */
  87383. colorDead: Color4;
  87384. /**
  87385. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87386. */
  87387. emitRate: number;
  87388. /**
  87389. * You can use gravity if you want to give an orientation to your particles.
  87390. */
  87391. gravity: Vector3;
  87392. /**
  87393. * Minimum power of emitting particles.
  87394. */
  87395. minEmitPower: number;
  87396. /**
  87397. * Maximum power of emitting particles.
  87398. */
  87399. maxEmitPower: number;
  87400. /**
  87401. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87402. */
  87403. minAngularSpeed: number;
  87404. /**
  87405. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87406. */
  87407. maxAngularSpeed: number;
  87408. /**
  87409. * Gets or sets the minimal initial rotation in radians.
  87410. */
  87411. minInitialRotation: number;
  87412. /**
  87413. * Gets or sets the maximal initial rotation in radians.
  87414. */
  87415. maxInitialRotation: number;
  87416. /**
  87417. * The particle emitter type defines the emitter used by the particle system.
  87418. * It can be for example box, sphere, or cone...
  87419. */
  87420. particleEmitterType: Nullable<IParticleEmitterType>;
  87421. /**
  87422. * Defines the delay in milliseconds before starting the system (0 by default)
  87423. */
  87424. startDelay: number;
  87425. /**
  87426. * 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
  87427. */
  87428. preWarmCycles: number;
  87429. /**
  87430. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87431. */
  87432. preWarmStepOffset: number;
  87433. /**
  87434. * 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)
  87435. */
  87436. spriteCellChangeSpeed: number;
  87437. /**
  87438. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87439. */
  87440. startSpriteCellID: number;
  87441. /**
  87442. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87443. */
  87444. endSpriteCellID: number;
  87445. /**
  87446. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87447. */
  87448. spriteCellWidth: number;
  87449. /**
  87450. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87451. */
  87452. spriteCellHeight: number;
  87453. /**
  87454. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87455. */
  87456. spriteRandomStartCell: boolean;
  87457. /**
  87458. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87459. */
  87460. isAnimationSheetEnabled: boolean;
  87461. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87462. translationPivot: Vector2;
  87463. /**
  87464. * Gets or sets a texture used to add random noise to particle positions
  87465. */
  87466. noiseTexture: Nullable<BaseTexture>;
  87467. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87468. noiseStrength: Vector3;
  87469. /**
  87470. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87471. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87472. */
  87473. billboardMode: number;
  87474. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87475. limitVelocityDamping: number;
  87476. /**
  87477. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87478. */
  87479. beginAnimationOnStart: boolean;
  87480. /**
  87481. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87482. */
  87483. beginAnimationFrom: number;
  87484. /**
  87485. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87486. */
  87487. beginAnimationTo: number;
  87488. /**
  87489. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87490. */
  87491. beginAnimationLoop: boolean;
  87492. /**
  87493. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87494. */
  87495. disposeOnStop: boolean;
  87496. /**
  87497. * Specifies if the particles are updated in emitter local space or world space
  87498. */
  87499. isLocal: boolean;
  87500. /** Snippet ID if the particle system was created from the snippet server */
  87501. snippetId: string;
  87502. /**
  87503. * Gets the maximum number of particles active at the same time.
  87504. * @returns The max number of active particles.
  87505. */
  87506. getCapacity(): number;
  87507. /**
  87508. * Gets the number of particles active at the same time.
  87509. * @returns The number of active particles.
  87510. */
  87511. getActiveCount(): number;
  87512. /**
  87513. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87514. * @returns True if it has been started, otherwise false.
  87515. */
  87516. isStarted(): boolean;
  87517. /**
  87518. * Animates the particle system for this frame.
  87519. */
  87520. animate(): void;
  87521. /**
  87522. * Renders the particle system in its current state.
  87523. * @returns the current number of particles
  87524. */
  87525. render(): number;
  87526. /**
  87527. * Dispose the particle system and frees its associated resources.
  87528. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87529. */
  87530. dispose(disposeTexture?: boolean): void;
  87531. /**
  87532. * Clones the particle system.
  87533. * @param name The name of the cloned object
  87534. * @param newEmitter The new emitter to use
  87535. * @returns the cloned particle system
  87536. */
  87537. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87538. /**
  87539. * Serializes the particle system to a JSON object
  87540. * @param serializeTexture defines if the texture must be serialized as well
  87541. * @returns the JSON object
  87542. */
  87543. serialize(serializeTexture: boolean): any;
  87544. /**
  87545. * Rebuild the particle system
  87546. */
  87547. rebuild(): void;
  87548. /** Force the system to rebuild all gradients that need to be resync */
  87549. forceRefreshGradients(): void;
  87550. /**
  87551. * Starts the particle system and begins to emit
  87552. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87553. */
  87554. start(delay?: number): void;
  87555. /**
  87556. * Stops the particle system.
  87557. */
  87558. stop(): void;
  87559. /**
  87560. * Remove all active particles
  87561. */
  87562. reset(): void;
  87563. /**
  87564. * Gets a boolean indicating that the system is stopping
  87565. * @returns true if the system is currently stopping
  87566. */
  87567. isStopping(): boolean;
  87568. /**
  87569. * Is this system ready to be used/rendered
  87570. * @return true if the system is ready
  87571. */
  87572. isReady(): boolean;
  87573. /**
  87574. * Returns the string "ParticleSystem"
  87575. * @returns a string containing the class name
  87576. */
  87577. getClassName(): string;
  87578. /**
  87579. * Adds a new color gradient
  87580. * @param gradient defines the gradient to use (between 0 and 1)
  87581. * @param color1 defines the color to affect to the specified gradient
  87582. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87583. * @returns the current particle system
  87584. */
  87585. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87586. /**
  87587. * Remove a specific color gradient
  87588. * @param gradient defines the gradient to remove
  87589. * @returns the current particle system
  87590. */
  87591. removeColorGradient(gradient: number): IParticleSystem;
  87592. /**
  87593. * Adds a new size gradient
  87594. * @param gradient defines the gradient to use (between 0 and 1)
  87595. * @param factor defines the size factor to affect to the specified gradient
  87596. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87597. * @returns the current particle system
  87598. */
  87599. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87600. /**
  87601. * Remove a specific size gradient
  87602. * @param gradient defines the gradient to remove
  87603. * @returns the current particle system
  87604. */
  87605. removeSizeGradient(gradient: number): IParticleSystem;
  87606. /**
  87607. * Gets the current list of color gradients.
  87608. * You must use addColorGradient and removeColorGradient to udpate this list
  87609. * @returns the list of color gradients
  87610. */
  87611. getColorGradients(): Nullable<Array<ColorGradient>>;
  87612. /**
  87613. * Gets the current list of size gradients.
  87614. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87615. * @returns the list of size gradients
  87616. */
  87617. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87618. /**
  87619. * Gets the current list of angular speed gradients.
  87620. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87621. * @returns the list of angular speed gradients
  87622. */
  87623. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87624. /**
  87625. * Adds a new angular speed gradient
  87626. * @param gradient defines the gradient to use (between 0 and 1)
  87627. * @param factor defines the angular speed to affect to the specified gradient
  87628. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87629. * @returns the current particle system
  87630. */
  87631. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87632. /**
  87633. * Remove a specific angular speed gradient
  87634. * @param gradient defines the gradient to remove
  87635. * @returns the current particle system
  87636. */
  87637. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87638. /**
  87639. * Gets the current list of velocity gradients.
  87640. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87641. * @returns the list of velocity gradients
  87642. */
  87643. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87644. /**
  87645. * Adds a new velocity gradient
  87646. * @param gradient defines the gradient to use (between 0 and 1)
  87647. * @param factor defines the velocity to affect to the specified gradient
  87648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87649. * @returns the current particle system
  87650. */
  87651. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87652. /**
  87653. * Remove a specific velocity gradient
  87654. * @param gradient defines the gradient to remove
  87655. * @returns the current particle system
  87656. */
  87657. removeVelocityGradient(gradient: number): IParticleSystem;
  87658. /**
  87659. * Gets the current list of limit velocity gradients.
  87660. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87661. * @returns the list of limit velocity gradients
  87662. */
  87663. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87664. /**
  87665. * Adds a new limit velocity gradient
  87666. * @param gradient defines the gradient to use (between 0 and 1)
  87667. * @param factor defines the limit velocity to affect to the specified gradient
  87668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87669. * @returns the current particle system
  87670. */
  87671. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87672. /**
  87673. * Remove a specific limit velocity gradient
  87674. * @param gradient defines the gradient to remove
  87675. * @returns the current particle system
  87676. */
  87677. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87678. /**
  87679. * Adds a new drag gradient
  87680. * @param gradient defines the gradient to use (between 0 and 1)
  87681. * @param factor defines the drag to affect to the specified gradient
  87682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87683. * @returns the current particle system
  87684. */
  87685. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87686. /**
  87687. * Remove a specific drag gradient
  87688. * @param gradient defines the gradient to remove
  87689. * @returns the current particle system
  87690. */
  87691. removeDragGradient(gradient: number): IParticleSystem;
  87692. /**
  87693. * Gets the current list of drag gradients.
  87694. * You must use addDragGradient and removeDragGradient to udpate this list
  87695. * @returns the list of drag gradients
  87696. */
  87697. getDragGradients(): Nullable<Array<FactorGradient>>;
  87698. /**
  87699. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87700. * @param gradient defines the gradient to use (between 0 and 1)
  87701. * @param factor defines the emit rate to affect to the specified gradient
  87702. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87703. * @returns the current particle system
  87704. */
  87705. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87706. /**
  87707. * Remove a specific emit rate gradient
  87708. * @param gradient defines the gradient to remove
  87709. * @returns the current particle system
  87710. */
  87711. removeEmitRateGradient(gradient: number): IParticleSystem;
  87712. /**
  87713. * Gets the current list of emit rate gradients.
  87714. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87715. * @returns the list of emit rate gradients
  87716. */
  87717. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87718. /**
  87719. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87720. * @param gradient defines the gradient to use (between 0 and 1)
  87721. * @param factor defines the start size to affect to the specified gradient
  87722. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87723. * @returns the current particle system
  87724. */
  87725. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87726. /**
  87727. * Remove a specific start size gradient
  87728. * @param gradient defines the gradient to remove
  87729. * @returns the current particle system
  87730. */
  87731. removeStartSizeGradient(gradient: number): IParticleSystem;
  87732. /**
  87733. * Gets the current list of start size gradients.
  87734. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87735. * @returns the list of start size gradients
  87736. */
  87737. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87738. /**
  87739. * Adds a new life time gradient
  87740. * @param gradient defines the gradient to use (between 0 and 1)
  87741. * @param factor defines the life time factor to affect to the specified gradient
  87742. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87743. * @returns the current particle system
  87744. */
  87745. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87746. /**
  87747. * Remove a specific life time gradient
  87748. * @param gradient defines the gradient to remove
  87749. * @returns the current particle system
  87750. */
  87751. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87752. /**
  87753. * Gets the current list of life time gradients.
  87754. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87755. * @returns the list of life time gradients
  87756. */
  87757. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87758. /**
  87759. * Gets the current list of color gradients.
  87760. * You must use addColorGradient and removeColorGradient to udpate this list
  87761. * @returns the list of color gradients
  87762. */
  87763. getColorGradients(): Nullable<Array<ColorGradient>>;
  87764. /**
  87765. * Adds a new ramp gradient used to remap particle colors
  87766. * @param gradient defines the gradient to use (between 0 and 1)
  87767. * @param color defines the color to affect to the specified gradient
  87768. * @returns the current particle system
  87769. */
  87770. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87771. /**
  87772. * Gets the current list of ramp gradients.
  87773. * You must use addRampGradient and removeRampGradient to udpate this list
  87774. * @returns the list of ramp gradients
  87775. */
  87776. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87777. /** Gets or sets a boolean indicating that ramp gradients must be used
  87778. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87779. */
  87780. useRampGradients: boolean;
  87781. /**
  87782. * Adds a new color remap gradient
  87783. * @param gradient defines the gradient to use (between 0 and 1)
  87784. * @param min defines the color remap minimal range
  87785. * @param max defines the color remap maximal range
  87786. * @returns the current particle system
  87787. */
  87788. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87789. /**
  87790. * Gets the current list of color remap gradients.
  87791. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87792. * @returns the list of color remap gradients
  87793. */
  87794. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87795. /**
  87796. * Adds a new alpha remap gradient
  87797. * @param gradient defines the gradient to use (between 0 and 1)
  87798. * @param min defines the alpha remap minimal range
  87799. * @param max defines the alpha remap maximal range
  87800. * @returns the current particle system
  87801. */
  87802. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87803. /**
  87804. * Gets the current list of alpha remap gradients.
  87805. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87806. * @returns the list of alpha remap gradients
  87807. */
  87808. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87809. /**
  87810. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87811. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87812. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87813. * @returns the emitter
  87814. */
  87815. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87816. /**
  87817. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87818. * @param radius The radius of the hemisphere to emit from
  87819. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87820. * @returns the emitter
  87821. */
  87822. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87823. /**
  87824. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87825. * @param radius The radius of the sphere to emit from
  87826. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87827. * @returns the emitter
  87828. */
  87829. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87830. /**
  87831. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87832. * @param radius The radius of the sphere to emit from
  87833. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87834. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87835. * @returns the emitter
  87836. */
  87837. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87838. /**
  87839. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87840. * @param radius The radius of the emission cylinder
  87841. * @param height The height of the emission cylinder
  87842. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87843. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87844. * @returns the emitter
  87845. */
  87846. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87847. /**
  87848. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87849. * @param radius The radius of the cylinder to emit from
  87850. * @param height The height of the emission cylinder
  87851. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87852. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87853. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87854. * @returns the emitter
  87855. */
  87856. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87857. /**
  87858. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87859. * @param radius The radius of the cone to emit from
  87860. * @param angle The base angle of the cone
  87861. * @returns the emitter
  87862. */
  87863. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87864. /**
  87865. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87866. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87867. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87868. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87869. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87870. * @returns the emitter
  87871. */
  87872. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87873. /**
  87874. * Get hosting scene
  87875. * @returns the scene
  87876. */
  87877. getScene(): Scene;
  87878. }
  87879. }
  87880. declare module BABYLON {
  87881. /**
  87882. * 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.
  87883. * @see https://doc.babylonjs.com/how_to/transformnode
  87884. */
  87885. export class TransformNode extends Node {
  87886. /**
  87887. * Object will not rotate to face the camera
  87888. */
  87889. static BILLBOARDMODE_NONE: number;
  87890. /**
  87891. * Object will rotate to face the camera but only on the x axis
  87892. */
  87893. static BILLBOARDMODE_X: number;
  87894. /**
  87895. * Object will rotate to face the camera but only on the y axis
  87896. */
  87897. static BILLBOARDMODE_Y: number;
  87898. /**
  87899. * Object will rotate to face the camera but only on the z axis
  87900. */
  87901. static BILLBOARDMODE_Z: number;
  87902. /**
  87903. * Object will rotate to face the camera
  87904. */
  87905. static BILLBOARDMODE_ALL: number;
  87906. /**
  87907. * Object will rotate to face the camera's position instead of orientation
  87908. */
  87909. static BILLBOARDMODE_USE_POSITION: number;
  87910. private _forward;
  87911. private _forwardInverted;
  87912. private _up;
  87913. private _right;
  87914. private _rightInverted;
  87915. private _position;
  87916. private _rotation;
  87917. private _rotationQuaternion;
  87918. protected _scaling: Vector3;
  87919. protected _isDirty: boolean;
  87920. private _transformToBoneReferal;
  87921. private _isAbsoluteSynced;
  87922. private _billboardMode;
  87923. /**
  87924. * Gets or sets the billboard mode. Default is 0.
  87925. *
  87926. * | Value | Type | Description |
  87927. * | --- | --- | --- |
  87928. * | 0 | BILLBOARDMODE_NONE | |
  87929. * | 1 | BILLBOARDMODE_X | |
  87930. * | 2 | BILLBOARDMODE_Y | |
  87931. * | 4 | BILLBOARDMODE_Z | |
  87932. * | 7 | BILLBOARDMODE_ALL | |
  87933. *
  87934. */
  87935. get billboardMode(): number;
  87936. set billboardMode(value: number);
  87937. private _preserveParentRotationForBillboard;
  87938. /**
  87939. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87940. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87941. */
  87942. get preserveParentRotationForBillboard(): boolean;
  87943. set preserveParentRotationForBillboard(value: boolean);
  87944. /**
  87945. * 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
  87946. */
  87947. scalingDeterminant: number;
  87948. private _infiniteDistance;
  87949. /**
  87950. * Gets or sets the distance of the object to max, often used by skybox
  87951. */
  87952. get infiniteDistance(): boolean;
  87953. set infiniteDistance(value: boolean);
  87954. /**
  87955. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87956. * By default the system will update normals to compensate
  87957. */
  87958. ignoreNonUniformScaling: boolean;
  87959. /**
  87960. * 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
  87961. */
  87962. reIntegrateRotationIntoRotationQuaternion: boolean;
  87963. /** @hidden */
  87964. _poseMatrix: Nullable<Matrix>;
  87965. /** @hidden */
  87966. _localMatrix: Matrix;
  87967. private _usePivotMatrix;
  87968. private _absolutePosition;
  87969. private _absoluteScaling;
  87970. private _absoluteRotationQuaternion;
  87971. private _pivotMatrix;
  87972. private _pivotMatrixInverse;
  87973. protected _postMultiplyPivotMatrix: boolean;
  87974. protected _isWorldMatrixFrozen: boolean;
  87975. /** @hidden */
  87976. _indexInSceneTransformNodesArray: number;
  87977. /**
  87978. * An event triggered after the world matrix is updated
  87979. */
  87980. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87981. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87982. /**
  87983. * Gets a string identifying the name of the class
  87984. * @returns "TransformNode" string
  87985. */
  87986. getClassName(): string;
  87987. /**
  87988. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87989. */
  87990. get position(): Vector3;
  87991. set position(newPosition: Vector3);
  87992. /**
  87993. * 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)).
  87994. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  87995. */
  87996. get rotation(): Vector3;
  87997. set rotation(newRotation: Vector3);
  87998. /**
  87999. * 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)).
  88000. */
  88001. get scaling(): Vector3;
  88002. set scaling(newScaling: Vector3);
  88003. /**
  88004. * 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).
  88005. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  88006. */
  88007. get rotationQuaternion(): Nullable<Quaternion>;
  88008. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  88009. /**
  88010. * The forward direction of that transform in world space.
  88011. */
  88012. get forward(): Vector3;
  88013. /**
  88014. * The up direction of that transform in world space.
  88015. */
  88016. get up(): Vector3;
  88017. /**
  88018. * The right direction of that transform in world space.
  88019. */
  88020. get right(): Vector3;
  88021. /**
  88022. * Copies the parameter passed Matrix into the mesh Pose matrix.
  88023. * @param matrix the matrix to copy the pose from
  88024. * @returns this TransformNode.
  88025. */
  88026. updatePoseMatrix(matrix: Matrix): TransformNode;
  88027. /**
  88028. * Returns the mesh Pose matrix.
  88029. * @returns the pose matrix
  88030. */
  88031. getPoseMatrix(): Matrix;
  88032. /** @hidden */
  88033. _isSynchronized(): boolean;
  88034. /** @hidden */
  88035. _initCache(): void;
  88036. /**
  88037. * Flag the transform node as dirty (Forcing it to update everything)
  88038. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  88039. * @returns this transform node
  88040. */
  88041. markAsDirty(property: string): TransformNode;
  88042. /**
  88043. * Returns the current mesh absolute position.
  88044. * Returns a Vector3.
  88045. */
  88046. get absolutePosition(): Vector3;
  88047. /**
  88048. * Returns the current mesh absolute scaling.
  88049. * Returns a Vector3.
  88050. */
  88051. get absoluteScaling(): Vector3;
  88052. /**
  88053. * Returns the current mesh absolute rotation.
  88054. * Returns a Quaternion.
  88055. */
  88056. get absoluteRotationQuaternion(): Quaternion;
  88057. /**
  88058. * Sets a new matrix to apply before all other transformation
  88059. * @param matrix defines the transform matrix
  88060. * @returns the current TransformNode
  88061. */
  88062. setPreTransformMatrix(matrix: Matrix): TransformNode;
  88063. /**
  88064. * Sets a new pivot matrix to the current node
  88065. * @param matrix defines the new pivot matrix to use
  88066. * @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
  88067. * @returns the current TransformNode
  88068. */
  88069. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  88070. /**
  88071. * Returns the mesh pivot matrix.
  88072. * Default : Identity.
  88073. * @returns the matrix
  88074. */
  88075. getPivotMatrix(): Matrix;
  88076. /**
  88077. * Instantiate (when possible) or clone that node with its hierarchy
  88078. * @param newParent defines the new parent to use for the instance (or clone)
  88079. * @param options defines options to configure how copy is done
  88080. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  88081. * @returns an instance (or a clone) of the current node with its hiearchy
  88082. */
  88083. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  88084. doNotInstantiate: boolean;
  88085. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  88086. /**
  88087. * Prevents the World matrix to be computed any longer
  88088. * @param newWorldMatrix defines an optional matrix to use as world matrix
  88089. * @returns the TransformNode.
  88090. */
  88091. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  88092. /**
  88093. * Allows back the World matrix computation.
  88094. * @returns the TransformNode.
  88095. */
  88096. unfreezeWorldMatrix(): this;
  88097. /**
  88098. * True if the World matrix has been frozen.
  88099. */
  88100. get isWorldMatrixFrozen(): boolean;
  88101. /**
  88102. * Retuns the mesh absolute position in the World.
  88103. * @returns a Vector3.
  88104. */
  88105. getAbsolutePosition(): Vector3;
  88106. /**
  88107. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  88108. * @param absolutePosition the absolute position to set
  88109. * @returns the TransformNode.
  88110. */
  88111. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88112. /**
  88113. * Sets the mesh position in its local space.
  88114. * @param vector3 the position to set in localspace
  88115. * @returns the TransformNode.
  88116. */
  88117. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  88118. /**
  88119. * Returns the mesh position in the local space from the current World matrix values.
  88120. * @returns a new Vector3.
  88121. */
  88122. getPositionExpressedInLocalSpace(): Vector3;
  88123. /**
  88124. * Translates the mesh along the passed Vector3 in its local space.
  88125. * @param vector3 the distance to translate in localspace
  88126. * @returns the TransformNode.
  88127. */
  88128. locallyTranslate(vector3: Vector3): TransformNode;
  88129. private static _lookAtVectorCache;
  88130. /**
  88131. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  88132. * @param targetPoint the position (must be in same space as current mesh) to look at
  88133. * @param yawCor optional yaw (y-axis) correction in radians
  88134. * @param pitchCor optional pitch (x-axis) correction in radians
  88135. * @param rollCor optional roll (z-axis) correction in radians
  88136. * @param space the choosen space of the target
  88137. * @returns the TransformNode.
  88138. */
  88139. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  88140. /**
  88141. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88142. * This Vector3 is expressed in the World space.
  88143. * @param localAxis axis to rotate
  88144. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88145. */
  88146. getDirection(localAxis: Vector3): Vector3;
  88147. /**
  88148. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  88149. * localAxis is expressed in the mesh local space.
  88150. * result is computed in the Wordl space from the mesh World matrix.
  88151. * @param localAxis axis to rotate
  88152. * @param result the resulting transformnode
  88153. * @returns this TransformNode.
  88154. */
  88155. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  88156. /**
  88157. * Sets this transform node rotation to the given local axis.
  88158. * @param localAxis the axis in local space
  88159. * @param yawCor optional yaw (y-axis) correction in radians
  88160. * @param pitchCor optional pitch (x-axis) correction in radians
  88161. * @param rollCor optional roll (z-axis) correction in radians
  88162. * @returns this TransformNode
  88163. */
  88164. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  88165. /**
  88166. * Sets a new pivot point to the current node
  88167. * @param point defines the new pivot point to use
  88168. * @param space defines if the point is in world or local space (local by default)
  88169. * @returns the current TransformNode
  88170. */
  88171. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  88172. /**
  88173. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  88174. * @returns the pivot point
  88175. */
  88176. getPivotPoint(): Vector3;
  88177. /**
  88178. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  88179. * @param result the vector3 to store the result
  88180. * @returns this TransformNode.
  88181. */
  88182. getPivotPointToRef(result: Vector3): TransformNode;
  88183. /**
  88184. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  88185. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  88186. */
  88187. getAbsolutePivotPoint(): Vector3;
  88188. /**
  88189. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  88190. * @param result vector3 to store the result
  88191. * @returns this TransformNode.
  88192. */
  88193. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  88194. /**
  88195. * Defines the passed node as the parent of the current node.
  88196. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  88197. * @see https://doc.babylonjs.com/how_to/parenting
  88198. * @param node the node ot set as the parent
  88199. * @returns this TransformNode.
  88200. */
  88201. setParent(node: Nullable<Node>): TransformNode;
  88202. private _nonUniformScaling;
  88203. /**
  88204. * True if the scaling property of this object is non uniform eg. (1,2,1)
  88205. */
  88206. get nonUniformScaling(): boolean;
  88207. /** @hidden */
  88208. _updateNonUniformScalingState(value: boolean): boolean;
  88209. /**
  88210. * Attach the current TransformNode to another TransformNode associated with a bone
  88211. * @param bone Bone affecting the TransformNode
  88212. * @param affectedTransformNode TransformNode associated with the bone
  88213. * @returns this object
  88214. */
  88215. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  88216. /**
  88217. * Detach the transform node if its associated with a bone
  88218. * @returns this object
  88219. */
  88220. detachFromBone(): TransformNode;
  88221. private static _rotationAxisCache;
  88222. /**
  88223. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  88224. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88225. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88226. * The passed axis is also normalized.
  88227. * @param axis the axis to rotate around
  88228. * @param amount the amount to rotate in radians
  88229. * @param space Space to rotate in (Default: local)
  88230. * @returns the TransformNode.
  88231. */
  88232. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88233. /**
  88234. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  88235. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88236. * The passed axis is also normalized. .
  88237. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  88238. * @param point the point to rotate around
  88239. * @param axis the axis to rotate around
  88240. * @param amount the amount to rotate in radians
  88241. * @returns the TransformNode
  88242. */
  88243. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  88244. /**
  88245. * Translates the mesh along the axis vector for the passed distance in the given space.
  88246. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88247. * @param axis the axis to translate in
  88248. * @param distance the distance to translate
  88249. * @param space Space to rotate in (Default: local)
  88250. * @returns the TransformNode.
  88251. */
  88252. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88253. /**
  88254. * Adds a rotation step to the mesh current rotation.
  88255. * x, y, z are Euler angles expressed in radians.
  88256. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  88257. * This means this rotation is made in the mesh local space only.
  88258. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  88259. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  88260. * ```javascript
  88261. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  88262. * ```
  88263. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  88264. * 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.
  88265. * @param x Rotation to add
  88266. * @param y Rotation to add
  88267. * @param z Rotation to add
  88268. * @returns the TransformNode.
  88269. */
  88270. addRotation(x: number, y: number, z: number): TransformNode;
  88271. /**
  88272. * @hidden
  88273. */
  88274. protected _getEffectiveParent(): Nullable<Node>;
  88275. /**
  88276. * Computes the world matrix of the node
  88277. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88278. * @returns the world matrix
  88279. */
  88280. computeWorldMatrix(force?: boolean): Matrix;
  88281. /**
  88282. * Resets this nodeTransform's local matrix to Matrix.Identity().
  88283. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  88284. */
  88285. resetLocalMatrix(independentOfChildren?: boolean): void;
  88286. protected _afterComputeWorldMatrix(): void;
  88287. /**
  88288. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  88289. * @param func callback function to add
  88290. *
  88291. * @returns the TransformNode.
  88292. */
  88293. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88294. /**
  88295. * Removes a registered callback function.
  88296. * @param func callback function to remove
  88297. * @returns the TransformNode.
  88298. */
  88299. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88300. /**
  88301. * Gets the position of the current mesh in camera space
  88302. * @param camera defines the camera to use
  88303. * @returns a position
  88304. */
  88305. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  88306. /**
  88307. * Returns the distance from the mesh to the active camera
  88308. * @param camera defines the camera to use
  88309. * @returns the distance
  88310. */
  88311. getDistanceToCamera(camera?: Nullable<Camera>): number;
  88312. /**
  88313. * Clone the current transform node
  88314. * @param name Name of the new clone
  88315. * @param newParent New parent for the clone
  88316. * @param doNotCloneChildren Do not clone children hierarchy
  88317. * @returns the new transform node
  88318. */
  88319. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  88320. /**
  88321. * Serializes the objects information.
  88322. * @param currentSerializationObject defines the object to serialize in
  88323. * @returns the serialized object
  88324. */
  88325. serialize(currentSerializationObject?: any): any;
  88326. /**
  88327. * Returns a new TransformNode object parsed from the source provided.
  88328. * @param parsedTransformNode is the source.
  88329. * @param scene the scne the object belongs to
  88330. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  88331. * @returns a new TransformNode object parsed from the source provided.
  88332. */
  88333. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  88334. /**
  88335. * Get all child-transformNodes of this node
  88336. * @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
  88337. * @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
  88338. * @returns an array of TransformNode
  88339. */
  88340. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  88341. /**
  88342. * Releases resources associated with this transform node.
  88343. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88344. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88345. */
  88346. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88347. /**
  88348. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  88349. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  88350. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  88351. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  88352. * @returns the current mesh
  88353. */
  88354. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  88355. private _syncAbsoluteScalingAndRotation;
  88356. }
  88357. }
  88358. declare module BABYLON {
  88359. /**
  88360. * Class used to override all child animations of a given target
  88361. */
  88362. export class AnimationPropertiesOverride {
  88363. /**
  88364. * Gets or sets a value indicating if animation blending must be used
  88365. */
  88366. enableBlending: boolean;
  88367. /**
  88368. * Gets or sets the blending speed to use when enableBlending is true
  88369. */
  88370. blendingSpeed: number;
  88371. /**
  88372. * Gets or sets the default loop mode to use
  88373. */
  88374. loopMode: number;
  88375. }
  88376. }
  88377. declare module BABYLON {
  88378. /**
  88379. * Class used to store bone information
  88380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88381. */
  88382. export class Bone extends Node {
  88383. /**
  88384. * defines the bone name
  88385. */
  88386. name: string;
  88387. private static _tmpVecs;
  88388. private static _tmpQuat;
  88389. private static _tmpMats;
  88390. /**
  88391. * Gets the list of child bones
  88392. */
  88393. children: Bone[];
  88394. /** Gets the animations associated with this bone */
  88395. animations: Animation[];
  88396. /**
  88397. * Gets or sets bone length
  88398. */
  88399. length: number;
  88400. /**
  88401. * @hidden Internal only
  88402. * Set this value to map this bone to a different index in the transform matrices
  88403. * Set this value to -1 to exclude the bone from the transform matrices
  88404. */
  88405. _index: Nullable<number>;
  88406. private _skeleton;
  88407. private _localMatrix;
  88408. private _restPose;
  88409. private _baseMatrix;
  88410. private _absoluteTransform;
  88411. private _invertedAbsoluteTransform;
  88412. private _parent;
  88413. private _scalingDeterminant;
  88414. private _worldTransform;
  88415. private _localScaling;
  88416. private _localRotation;
  88417. private _localPosition;
  88418. private _needToDecompose;
  88419. private _needToCompose;
  88420. /** @hidden */
  88421. _linkedTransformNode: Nullable<TransformNode>;
  88422. /** @hidden */
  88423. _waitingTransformNodeId: Nullable<string>;
  88424. /** @hidden */
  88425. get _matrix(): Matrix;
  88426. /** @hidden */
  88427. set _matrix(value: Matrix);
  88428. /**
  88429. * Create a new bone
  88430. * @param name defines the bone name
  88431. * @param skeleton defines the parent skeleton
  88432. * @param parentBone defines the parent (can be null if the bone is the root)
  88433. * @param localMatrix defines the local matrix
  88434. * @param restPose defines the rest pose matrix
  88435. * @param baseMatrix defines the base matrix
  88436. * @param index defines index of the bone in the hiearchy
  88437. */
  88438. constructor(
  88439. /**
  88440. * defines the bone name
  88441. */
  88442. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  88443. /**
  88444. * Gets the current object class name.
  88445. * @return the class name
  88446. */
  88447. getClassName(): string;
  88448. /**
  88449. * Gets the parent skeleton
  88450. * @returns a skeleton
  88451. */
  88452. getSkeleton(): Skeleton;
  88453. /**
  88454. * Gets parent bone
  88455. * @returns a bone or null if the bone is the root of the bone hierarchy
  88456. */
  88457. getParent(): Nullable<Bone>;
  88458. /**
  88459. * Returns an array containing the root bones
  88460. * @returns an array containing the root bones
  88461. */
  88462. getChildren(): Array<Bone>;
  88463. /**
  88464. * Gets the node index in matrix array generated for rendering
  88465. * @returns the node index
  88466. */
  88467. getIndex(): number;
  88468. /**
  88469. * Sets the parent bone
  88470. * @param parent defines the parent (can be null if the bone is the root)
  88471. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88472. */
  88473. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  88474. /**
  88475. * Gets the local matrix
  88476. * @returns a matrix
  88477. */
  88478. getLocalMatrix(): Matrix;
  88479. /**
  88480. * Gets the base matrix (initial matrix which remains unchanged)
  88481. * @returns a matrix
  88482. */
  88483. getBaseMatrix(): Matrix;
  88484. /**
  88485. * Gets the rest pose matrix
  88486. * @returns a matrix
  88487. */
  88488. getRestPose(): Matrix;
  88489. /**
  88490. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  88491. */
  88492. getWorldMatrix(): Matrix;
  88493. /**
  88494. * Sets the local matrix to rest pose matrix
  88495. */
  88496. returnToRest(): void;
  88497. /**
  88498. * Gets the inverse of the absolute transform matrix.
  88499. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  88500. * @returns a matrix
  88501. */
  88502. getInvertedAbsoluteTransform(): Matrix;
  88503. /**
  88504. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  88505. * @returns a matrix
  88506. */
  88507. getAbsoluteTransform(): Matrix;
  88508. /**
  88509. * Links with the given transform node.
  88510. * The local matrix of this bone is copied from the transform node every frame.
  88511. * @param transformNode defines the transform node to link to
  88512. */
  88513. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  88514. /**
  88515. * Gets the node used to drive the bone's transformation
  88516. * @returns a transform node or null
  88517. */
  88518. getTransformNode(): Nullable<TransformNode>;
  88519. /** Gets or sets current position (in local space) */
  88520. get position(): Vector3;
  88521. set position(newPosition: Vector3);
  88522. /** Gets or sets current rotation (in local space) */
  88523. get rotation(): Vector3;
  88524. set rotation(newRotation: Vector3);
  88525. /** Gets or sets current rotation quaternion (in local space) */
  88526. get rotationQuaternion(): Quaternion;
  88527. set rotationQuaternion(newRotation: Quaternion);
  88528. /** Gets or sets current scaling (in local space) */
  88529. get scaling(): Vector3;
  88530. set scaling(newScaling: Vector3);
  88531. /**
  88532. * Gets the animation properties override
  88533. */
  88534. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88535. private _decompose;
  88536. private _compose;
  88537. /**
  88538. * Update the base and local matrices
  88539. * @param matrix defines the new base or local matrix
  88540. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88541. * @param updateLocalMatrix defines if the local matrix should be updated
  88542. */
  88543. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  88544. /** @hidden */
  88545. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  88546. /**
  88547. * Flag the bone as dirty (Forcing it to update everything)
  88548. */
  88549. markAsDirty(): void;
  88550. /** @hidden */
  88551. _markAsDirtyAndCompose(): void;
  88552. private _markAsDirtyAndDecompose;
  88553. /**
  88554. * Translate the bone in local or world space
  88555. * @param vec The amount to translate the bone
  88556. * @param space The space that the translation is in
  88557. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88558. */
  88559. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88560. /**
  88561. * Set the postion of the bone in local or world space
  88562. * @param position The position to set the bone
  88563. * @param space The space that the position is in
  88564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88565. */
  88566. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88567. /**
  88568. * Set the absolute position of the bone (world space)
  88569. * @param position The position to set the bone
  88570. * @param mesh The mesh that this bone is attached to
  88571. */
  88572. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  88573. /**
  88574. * Scale the bone on the x, y and z axes (in local space)
  88575. * @param x The amount to scale the bone on the x axis
  88576. * @param y The amount to scale the bone on the y axis
  88577. * @param z The amount to scale the bone on the z axis
  88578. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  88579. */
  88580. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  88581. /**
  88582. * Set the bone scaling in local space
  88583. * @param scale defines the scaling vector
  88584. */
  88585. setScale(scale: Vector3): void;
  88586. /**
  88587. * Gets the current scaling in local space
  88588. * @returns the current scaling vector
  88589. */
  88590. getScale(): Vector3;
  88591. /**
  88592. * Gets the current scaling in local space and stores it in a target vector
  88593. * @param result defines the target vector
  88594. */
  88595. getScaleToRef(result: Vector3): void;
  88596. /**
  88597. * Set the yaw, pitch, and roll of the bone in local or world space
  88598. * @param yaw The rotation of the bone on the y axis
  88599. * @param pitch The rotation of the bone on the x axis
  88600. * @param roll The rotation of the bone on the z axis
  88601. * @param space The space that the axes of rotation are in
  88602. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88603. */
  88604. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  88605. /**
  88606. * Add a rotation to the bone on an axis in local or world space
  88607. * @param axis The axis to rotate the bone on
  88608. * @param amount The amount to rotate the bone
  88609. * @param space The space that the axis is in
  88610. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88611. */
  88612. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  88613. /**
  88614. * Set the rotation of the bone to a particular axis angle in local or world space
  88615. * @param axis The axis to rotate the bone on
  88616. * @param angle The angle that the bone should be rotated to
  88617. * @param space The space that the axis is in
  88618. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88619. */
  88620. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  88621. /**
  88622. * Set the euler rotation of the bone in local of world space
  88623. * @param rotation The euler rotation that the bone should be set to
  88624. * @param space The space that the rotation is in
  88625. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88626. */
  88627. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88628. /**
  88629. * Set the quaternion rotation of the bone in local of world space
  88630. * @param quat The quaternion rotation that the bone should be set to
  88631. * @param space The space that the rotation is in
  88632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88633. */
  88634. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  88635. /**
  88636. * Set the rotation matrix of the bone in local of world space
  88637. * @param rotMat The rotation matrix that the bone should be set to
  88638. * @param space The space that the rotation is in
  88639. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88640. */
  88641. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  88642. private _rotateWithMatrix;
  88643. private _getNegativeRotationToRef;
  88644. /**
  88645. * Get the position of the bone in local or world space
  88646. * @param space The space that the returned position is in
  88647. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88648. * @returns The position of the bone
  88649. */
  88650. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88651. /**
  88652. * Copy the position of the bone to a vector3 in local or world space
  88653. * @param space The space that the returned position is in
  88654. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88655. * @param result The vector3 to copy the position to
  88656. */
  88657. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  88658. /**
  88659. * Get the absolute position of the bone (world space)
  88660. * @param mesh The mesh that this bone is attached to
  88661. * @returns The absolute position of the bone
  88662. */
  88663. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  88664. /**
  88665. * Copy the absolute position of the bone (world space) to the result param
  88666. * @param mesh The mesh that this bone is attached to
  88667. * @param result The vector3 to copy the absolute position to
  88668. */
  88669. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  88670. /**
  88671. * Compute the absolute transforms of this bone and its children
  88672. */
  88673. computeAbsoluteTransforms(): void;
  88674. /**
  88675. * Get the world direction from an axis that is in the local space of the bone
  88676. * @param localAxis The local direction that is used to compute the world direction
  88677. * @param mesh The mesh that this bone is attached to
  88678. * @returns The world direction
  88679. */
  88680. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88681. /**
  88682. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  88683. * @param localAxis The local direction that is used to compute the world direction
  88684. * @param mesh The mesh that this bone is attached to
  88685. * @param result The vector3 that the world direction will be copied to
  88686. */
  88687. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88688. /**
  88689. * Get the euler rotation of the bone in local or world space
  88690. * @param space The space that the rotation should be in
  88691. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88692. * @returns The euler rotation
  88693. */
  88694. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88695. /**
  88696. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88697. * @param space The space that the rotation should be in
  88698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88699. * @param result The vector3 that the rotation should be copied to
  88700. */
  88701. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88702. /**
  88703. * Get the quaternion rotation of the bone in either local or world space
  88704. * @param space The space that the rotation should be in
  88705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88706. * @returns The quaternion rotation
  88707. */
  88708. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  88709. /**
  88710. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  88711. * @param space The space that the rotation should be in
  88712. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88713. * @param result The quaternion that the rotation should be copied to
  88714. */
  88715. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  88716. /**
  88717. * Get the rotation matrix of the bone in local or world space
  88718. * @param space The space that the rotation should be in
  88719. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88720. * @returns The rotation matrix
  88721. */
  88722. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  88723. /**
  88724. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  88725. * @param space The space that the rotation should be in
  88726. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88727. * @param result The quaternion that the rotation should be copied to
  88728. */
  88729. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  88730. /**
  88731. * Get the world position of a point that is in the local space of the bone
  88732. * @param position The local position
  88733. * @param mesh The mesh that this bone is attached to
  88734. * @returns The world position
  88735. */
  88736. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88737. /**
  88738. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  88739. * @param position The local position
  88740. * @param mesh The mesh that this bone is attached to
  88741. * @param result The vector3 that the world position should be copied to
  88742. */
  88743. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88744. /**
  88745. * Get the local position of a point that is in world space
  88746. * @param position The world position
  88747. * @param mesh The mesh that this bone is attached to
  88748. * @returns The local position
  88749. */
  88750. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88751. /**
  88752. * Get the local position of a point that is in world space and copy it to the result param
  88753. * @param position The world position
  88754. * @param mesh The mesh that this bone is attached to
  88755. * @param result The vector3 that the local position should be copied to
  88756. */
  88757. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88758. }
  88759. }
  88760. declare module BABYLON {
  88761. /**
  88762. * Defines a runtime animation
  88763. */
  88764. export class RuntimeAnimation {
  88765. private _events;
  88766. /**
  88767. * The current frame of the runtime animation
  88768. */
  88769. private _currentFrame;
  88770. /**
  88771. * The animation used by the runtime animation
  88772. */
  88773. private _animation;
  88774. /**
  88775. * The target of the runtime animation
  88776. */
  88777. private _target;
  88778. /**
  88779. * The initiating animatable
  88780. */
  88781. private _host;
  88782. /**
  88783. * The original value of the runtime animation
  88784. */
  88785. private _originalValue;
  88786. /**
  88787. * The original blend value of the runtime animation
  88788. */
  88789. private _originalBlendValue;
  88790. /**
  88791. * The offsets cache of the runtime animation
  88792. */
  88793. private _offsetsCache;
  88794. /**
  88795. * The high limits cache of the runtime animation
  88796. */
  88797. private _highLimitsCache;
  88798. /**
  88799. * Specifies if the runtime animation has been stopped
  88800. */
  88801. private _stopped;
  88802. /**
  88803. * The blending factor of the runtime animation
  88804. */
  88805. private _blendingFactor;
  88806. /**
  88807. * The BabylonJS scene
  88808. */
  88809. private _scene;
  88810. /**
  88811. * The current value of the runtime animation
  88812. */
  88813. private _currentValue;
  88814. /** @hidden */
  88815. _animationState: _IAnimationState;
  88816. /**
  88817. * The active target of the runtime animation
  88818. */
  88819. private _activeTargets;
  88820. private _currentActiveTarget;
  88821. private _directTarget;
  88822. /**
  88823. * The target path of the runtime animation
  88824. */
  88825. private _targetPath;
  88826. /**
  88827. * The weight of the runtime animation
  88828. */
  88829. private _weight;
  88830. /**
  88831. * The ratio offset of the runtime animation
  88832. */
  88833. private _ratioOffset;
  88834. /**
  88835. * The previous delay of the runtime animation
  88836. */
  88837. private _previousDelay;
  88838. /**
  88839. * The previous ratio of the runtime animation
  88840. */
  88841. private _previousRatio;
  88842. private _enableBlending;
  88843. private _keys;
  88844. private _minFrame;
  88845. private _maxFrame;
  88846. private _minValue;
  88847. private _maxValue;
  88848. private _targetIsArray;
  88849. /**
  88850. * Gets the current frame of the runtime animation
  88851. */
  88852. get currentFrame(): number;
  88853. /**
  88854. * Gets the weight of the runtime animation
  88855. */
  88856. get weight(): number;
  88857. /**
  88858. * Gets the current value of the runtime animation
  88859. */
  88860. get currentValue(): any;
  88861. /**
  88862. * Gets the target path of the runtime animation
  88863. */
  88864. get targetPath(): string;
  88865. /**
  88866. * Gets the actual target of the runtime animation
  88867. */
  88868. get target(): any;
  88869. /**
  88870. * Gets the additive state of the runtime animation
  88871. */
  88872. get isAdditive(): boolean;
  88873. /** @hidden */
  88874. _onLoop: () => void;
  88875. /**
  88876. * Create a new RuntimeAnimation object
  88877. * @param target defines the target of the animation
  88878. * @param animation defines the source animation object
  88879. * @param scene defines the hosting scene
  88880. * @param host defines the initiating Animatable
  88881. */
  88882. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88883. private _preparePath;
  88884. /**
  88885. * Gets the animation from the runtime animation
  88886. */
  88887. get animation(): Animation;
  88888. /**
  88889. * Resets the runtime animation to the beginning
  88890. * @param restoreOriginal defines whether to restore the target property to the original value
  88891. */
  88892. reset(restoreOriginal?: boolean): void;
  88893. /**
  88894. * Specifies if the runtime animation is stopped
  88895. * @returns Boolean specifying if the runtime animation is stopped
  88896. */
  88897. isStopped(): boolean;
  88898. /**
  88899. * Disposes of the runtime animation
  88900. */
  88901. dispose(): void;
  88902. /**
  88903. * Apply the interpolated value to the target
  88904. * @param currentValue defines the value computed by the animation
  88905. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88906. */
  88907. setValue(currentValue: any, weight: number): void;
  88908. private _getOriginalValues;
  88909. private _setValue;
  88910. /**
  88911. * Gets the loop pmode of the runtime animation
  88912. * @returns Loop Mode
  88913. */
  88914. private _getCorrectLoopMode;
  88915. /**
  88916. * Move the current animation to a given frame
  88917. * @param frame defines the frame to move to
  88918. */
  88919. goToFrame(frame: number): void;
  88920. /**
  88921. * @hidden Internal use only
  88922. */
  88923. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88924. /**
  88925. * Execute the current animation
  88926. * @param delay defines the delay to add to the current frame
  88927. * @param from defines the lower bound of the animation range
  88928. * @param to defines the upper bound of the animation range
  88929. * @param loop defines if the current animation must loop
  88930. * @param speedRatio defines the current speed ratio
  88931. * @param weight defines the weight of the animation (default is -1 so no weight)
  88932. * @param onLoop optional callback called when animation loops
  88933. * @returns a boolean indicating if the animation is running
  88934. */
  88935. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88936. }
  88937. }
  88938. declare module BABYLON {
  88939. /**
  88940. * Class used to store an actual running animation
  88941. */
  88942. export class Animatable {
  88943. /** defines the target object */
  88944. target: any;
  88945. /** defines the starting frame number (default is 0) */
  88946. fromFrame: number;
  88947. /** defines the ending frame number (default is 100) */
  88948. toFrame: number;
  88949. /** defines if the animation must loop (default is false) */
  88950. loopAnimation: boolean;
  88951. /** defines a callback to call when animation ends if it is not looping */
  88952. onAnimationEnd?: (() => void) | null | undefined;
  88953. /** defines a callback to call when animation loops */
  88954. onAnimationLoop?: (() => void) | null | undefined;
  88955. /** defines whether the animation should be evaluated additively */
  88956. isAdditive: boolean;
  88957. private _localDelayOffset;
  88958. private _pausedDelay;
  88959. private _runtimeAnimations;
  88960. private _paused;
  88961. private _scene;
  88962. private _speedRatio;
  88963. private _weight;
  88964. private _syncRoot;
  88965. /**
  88966. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88967. * This will only apply for non looping animation (default is true)
  88968. */
  88969. disposeOnEnd: boolean;
  88970. /**
  88971. * Gets a boolean indicating if the animation has started
  88972. */
  88973. animationStarted: boolean;
  88974. /**
  88975. * Observer raised when the animation ends
  88976. */
  88977. onAnimationEndObservable: Observable<Animatable>;
  88978. /**
  88979. * Observer raised when the animation loops
  88980. */
  88981. onAnimationLoopObservable: Observable<Animatable>;
  88982. /**
  88983. * Gets the root Animatable used to synchronize and normalize animations
  88984. */
  88985. get syncRoot(): Nullable<Animatable>;
  88986. /**
  88987. * Gets the current frame of the first RuntimeAnimation
  88988. * Used to synchronize Animatables
  88989. */
  88990. get masterFrame(): number;
  88991. /**
  88992. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  88993. */
  88994. get weight(): number;
  88995. set weight(value: number);
  88996. /**
  88997. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  88998. */
  88999. get speedRatio(): number;
  89000. set speedRatio(value: number);
  89001. /**
  89002. * Creates a new Animatable
  89003. * @param scene defines the hosting scene
  89004. * @param target defines the target object
  89005. * @param fromFrame defines the starting frame number (default is 0)
  89006. * @param toFrame defines the ending frame number (default is 100)
  89007. * @param loopAnimation defines if the animation must loop (default is false)
  89008. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  89009. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  89010. * @param animations defines a group of animation to add to the new Animatable
  89011. * @param onAnimationLoop defines a callback to call when animation loops
  89012. * @param isAdditive defines whether the animation should be evaluated additively
  89013. */
  89014. constructor(scene: Scene,
  89015. /** defines the target object */
  89016. target: any,
  89017. /** defines the starting frame number (default is 0) */
  89018. fromFrame?: number,
  89019. /** defines the ending frame number (default is 100) */
  89020. toFrame?: number,
  89021. /** defines if the animation must loop (default is false) */
  89022. loopAnimation?: boolean, speedRatio?: number,
  89023. /** defines a callback to call when animation ends if it is not looping */
  89024. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  89025. /** defines a callback to call when animation loops */
  89026. onAnimationLoop?: (() => void) | null | undefined,
  89027. /** defines whether the animation should be evaluated additively */
  89028. isAdditive?: boolean);
  89029. /**
  89030. * Synchronize and normalize current Animatable with a source Animatable
  89031. * This is useful when using animation weights and when animations are not of the same length
  89032. * @param root defines the root Animatable to synchronize with
  89033. * @returns the current Animatable
  89034. */
  89035. syncWith(root: Animatable): Animatable;
  89036. /**
  89037. * Gets the list of runtime animations
  89038. * @returns an array of RuntimeAnimation
  89039. */
  89040. getAnimations(): RuntimeAnimation[];
  89041. /**
  89042. * Adds more animations to the current animatable
  89043. * @param target defines the target of the animations
  89044. * @param animations defines the new animations to add
  89045. */
  89046. appendAnimations(target: any, animations: Animation[]): void;
  89047. /**
  89048. * Gets the source animation for a specific property
  89049. * @param property defines the propertyu to look for
  89050. * @returns null or the source animation for the given property
  89051. */
  89052. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  89053. /**
  89054. * Gets the runtime animation for a specific property
  89055. * @param property defines the propertyu to look for
  89056. * @returns null or the runtime animation for the given property
  89057. */
  89058. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  89059. /**
  89060. * Resets the animatable to its original state
  89061. */
  89062. reset(): void;
  89063. /**
  89064. * Allows the animatable to blend with current running animations
  89065. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89066. * @param blendingSpeed defines the blending speed to use
  89067. */
  89068. enableBlending(blendingSpeed: number): void;
  89069. /**
  89070. * Disable animation blending
  89071. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89072. */
  89073. disableBlending(): void;
  89074. /**
  89075. * Jump directly to a given frame
  89076. * @param frame defines the frame to jump to
  89077. */
  89078. goToFrame(frame: number): void;
  89079. /**
  89080. * Pause the animation
  89081. */
  89082. pause(): void;
  89083. /**
  89084. * Restart the animation
  89085. */
  89086. restart(): void;
  89087. private _raiseOnAnimationEnd;
  89088. /**
  89089. * Stop and delete the current animation
  89090. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  89091. * @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)
  89092. */
  89093. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  89094. /**
  89095. * Wait asynchronously for the animation to end
  89096. * @returns a promise which will be fullfilled when the animation ends
  89097. */
  89098. waitAsync(): Promise<Animatable>;
  89099. /** @hidden */
  89100. _animate(delay: number): boolean;
  89101. }
  89102. interface Scene {
  89103. /** @hidden */
  89104. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  89105. /** @hidden */
  89106. _processLateAnimationBindingsForMatrices(holder: {
  89107. totalWeight: number;
  89108. totalAdditiveWeight: number;
  89109. animations: RuntimeAnimation[];
  89110. additiveAnimations: RuntimeAnimation[];
  89111. originalValue: Matrix;
  89112. }): any;
  89113. /** @hidden */
  89114. _processLateAnimationBindingsForQuaternions(holder: {
  89115. totalWeight: number;
  89116. totalAdditiveWeight: number;
  89117. animations: RuntimeAnimation[];
  89118. additiveAnimations: RuntimeAnimation[];
  89119. originalValue: Quaternion;
  89120. }, refQuaternion: Quaternion): Quaternion;
  89121. /** @hidden */
  89122. _processLateAnimationBindings(): void;
  89123. /**
  89124. * Will start the animation sequence of a given target
  89125. * @param target defines the target
  89126. * @param from defines from which frame should animation start
  89127. * @param to defines until which frame should animation run.
  89128. * @param weight defines the weight to apply to the animation (1.0 by default)
  89129. * @param loop defines if the animation loops
  89130. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89131. * @param onAnimationEnd defines the function to be executed when the animation ends
  89132. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89133. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89134. * @param onAnimationLoop defines the callback to call when an animation loops
  89135. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89136. * @returns the animatable object created for this animation
  89137. */
  89138. 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;
  89139. /**
  89140. * Will start the animation sequence of a given target
  89141. * @param target defines the target
  89142. * @param from defines from which frame should animation start
  89143. * @param to defines until which frame should animation run.
  89144. * @param loop defines if the animation loops
  89145. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89146. * @param onAnimationEnd defines the function to be executed when the animation ends
  89147. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89148. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89149. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  89150. * @param onAnimationLoop defines the callback to call when an animation loops
  89151. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89152. * @returns the animatable object created for this animation
  89153. */
  89154. 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;
  89155. /**
  89156. * Will start the animation sequence of a given target and its hierarchy
  89157. * @param target defines the target
  89158. * @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.
  89159. * @param from defines from which frame should animation start
  89160. * @param to defines until which frame should animation run.
  89161. * @param loop defines if the animation loops
  89162. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89163. * @param onAnimationEnd defines the function to be executed when the animation ends
  89164. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89165. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89166. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89167. * @param onAnimationLoop defines the callback to call when an animation loops
  89168. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89169. * @returns the list of created animatables
  89170. */
  89171. 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[];
  89172. /**
  89173. * Begin a new animation on a given node
  89174. * @param target defines the target where the animation will take place
  89175. * @param animations defines the list of animations to start
  89176. * @param from defines the initial value
  89177. * @param to defines the final value
  89178. * @param loop defines if you want animation to loop (off by default)
  89179. * @param speedRatio defines the speed ratio to apply to all animations
  89180. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89181. * @param onAnimationLoop defines the callback to call when an animation loops
  89182. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89183. * @returns the list of created animatables
  89184. */
  89185. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89186. /**
  89187. * Begin a new animation on a given node and its hierarchy
  89188. * @param target defines the root node where the animation will take place
  89189. * @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.
  89190. * @param animations defines the list of animations to start
  89191. * @param from defines the initial value
  89192. * @param to defines the final value
  89193. * @param loop defines if you want animation to loop (off by default)
  89194. * @param speedRatio defines the speed ratio to apply to all animations
  89195. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89196. * @param onAnimationLoop defines the callback to call when an animation loops
  89197. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89198. * @returns the list of animatables created for all nodes
  89199. */
  89200. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  89201. /**
  89202. * Gets the animatable associated with a specific target
  89203. * @param target defines the target of the animatable
  89204. * @returns the required animatable if found
  89205. */
  89206. getAnimatableByTarget(target: any): Nullable<Animatable>;
  89207. /**
  89208. * Gets all animatables associated with a given target
  89209. * @param target defines the target to look animatables for
  89210. * @returns an array of Animatables
  89211. */
  89212. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  89213. /**
  89214. * Stops and removes all animations that have been applied to the scene
  89215. */
  89216. stopAllAnimations(): void;
  89217. /**
  89218. * Gets the current delta time used by animation engine
  89219. */
  89220. deltaTime: number;
  89221. }
  89222. interface Bone {
  89223. /**
  89224. * Copy an animation range from another bone
  89225. * @param source defines the source bone
  89226. * @param rangeName defines the range name to copy
  89227. * @param frameOffset defines the frame offset
  89228. * @param rescaleAsRequired defines if rescaling must be applied if required
  89229. * @param skelDimensionsRatio defines the scaling ratio
  89230. * @returns true if operation was successful
  89231. */
  89232. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  89233. }
  89234. }
  89235. declare module BABYLON {
  89236. /**
  89237. * Class used to handle skinning animations
  89238. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89239. */
  89240. export class Skeleton implements IAnimatable {
  89241. /** defines the skeleton name */
  89242. name: string;
  89243. /** defines the skeleton Id */
  89244. id: string;
  89245. /**
  89246. * Defines the list of child bones
  89247. */
  89248. bones: Bone[];
  89249. /**
  89250. * Defines an estimate of the dimension of the skeleton at rest
  89251. */
  89252. dimensionsAtRest: Vector3;
  89253. /**
  89254. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  89255. */
  89256. needInitialSkinMatrix: boolean;
  89257. /**
  89258. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  89259. */
  89260. overrideMesh: Nullable<AbstractMesh>;
  89261. /**
  89262. * Gets the list of animations attached to this skeleton
  89263. */
  89264. animations: Array<Animation>;
  89265. private _scene;
  89266. private _isDirty;
  89267. private _transformMatrices;
  89268. private _transformMatrixTexture;
  89269. private _meshesWithPoseMatrix;
  89270. private _animatables;
  89271. private _identity;
  89272. private _synchronizedWithMesh;
  89273. private _ranges;
  89274. private _lastAbsoluteTransformsUpdateId;
  89275. private _canUseTextureForBones;
  89276. private _uniqueId;
  89277. /** @hidden */
  89278. _numBonesWithLinkedTransformNode: number;
  89279. /** @hidden */
  89280. _hasWaitingData: Nullable<boolean>;
  89281. /**
  89282. * Specifies if the skeleton should be serialized
  89283. */
  89284. doNotSerialize: boolean;
  89285. private _useTextureToStoreBoneMatrices;
  89286. /**
  89287. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  89288. * Please note that this option is not available if the hardware does not support it
  89289. */
  89290. get useTextureToStoreBoneMatrices(): boolean;
  89291. set useTextureToStoreBoneMatrices(value: boolean);
  89292. private _animationPropertiesOverride;
  89293. /**
  89294. * Gets or sets the animation properties override
  89295. */
  89296. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89297. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  89298. /**
  89299. * List of inspectable custom properties (used by the Inspector)
  89300. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89301. */
  89302. inspectableCustomProperties: IInspectable[];
  89303. /**
  89304. * An observable triggered before computing the skeleton's matrices
  89305. */
  89306. onBeforeComputeObservable: Observable<Skeleton>;
  89307. /**
  89308. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  89309. */
  89310. get isUsingTextureForMatrices(): boolean;
  89311. /**
  89312. * Gets the unique ID of this skeleton
  89313. */
  89314. get uniqueId(): number;
  89315. /**
  89316. * Creates a new skeleton
  89317. * @param name defines the skeleton name
  89318. * @param id defines the skeleton Id
  89319. * @param scene defines the hosting scene
  89320. */
  89321. constructor(
  89322. /** defines the skeleton name */
  89323. name: string,
  89324. /** defines the skeleton Id */
  89325. id: string, scene: Scene);
  89326. /**
  89327. * Gets the current object class name.
  89328. * @return the class name
  89329. */
  89330. getClassName(): string;
  89331. /**
  89332. * Returns an array containing the root bones
  89333. * @returns an array containing the root bones
  89334. */
  89335. getChildren(): Array<Bone>;
  89336. /**
  89337. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  89338. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89339. * @returns a Float32Array containing matrices data
  89340. */
  89341. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  89342. /**
  89343. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  89344. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89345. * @returns a raw texture containing the data
  89346. */
  89347. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  89348. /**
  89349. * Gets the current hosting scene
  89350. * @returns a scene object
  89351. */
  89352. getScene(): Scene;
  89353. /**
  89354. * Gets a string representing the current skeleton data
  89355. * @param fullDetails defines a boolean indicating if we want a verbose version
  89356. * @returns a string representing the current skeleton data
  89357. */
  89358. toString(fullDetails?: boolean): string;
  89359. /**
  89360. * Get bone's index searching by name
  89361. * @param name defines bone's name to search for
  89362. * @return the indice of the bone. Returns -1 if not found
  89363. */
  89364. getBoneIndexByName(name: string): number;
  89365. /**
  89366. * Creater a new animation range
  89367. * @param name defines the name of the range
  89368. * @param from defines the start key
  89369. * @param to defines the end key
  89370. */
  89371. createAnimationRange(name: string, from: number, to: number): void;
  89372. /**
  89373. * Delete a specific animation range
  89374. * @param name defines the name of the range
  89375. * @param deleteFrames defines if frames must be removed as well
  89376. */
  89377. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89378. /**
  89379. * Gets a specific animation range
  89380. * @param name defines the name of the range to look for
  89381. * @returns the requested animation range or null if not found
  89382. */
  89383. getAnimationRange(name: string): Nullable<AnimationRange>;
  89384. /**
  89385. * Gets the list of all animation ranges defined on this skeleton
  89386. * @returns an array
  89387. */
  89388. getAnimationRanges(): Nullable<AnimationRange>[];
  89389. /**
  89390. * Copy animation range from a source skeleton.
  89391. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  89392. * @param source defines the source skeleton
  89393. * @param name defines the name of the range to copy
  89394. * @param rescaleAsRequired defines if rescaling must be applied if required
  89395. * @returns true if operation was successful
  89396. */
  89397. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  89398. /**
  89399. * Forces the skeleton to go to rest pose
  89400. */
  89401. returnToRest(): void;
  89402. private _getHighestAnimationFrame;
  89403. /**
  89404. * Begin a specific animation range
  89405. * @param name defines the name of the range to start
  89406. * @param loop defines if looping must be turned on (false by default)
  89407. * @param speedRatio defines the speed ratio to apply (1 by default)
  89408. * @param onAnimationEnd defines a callback which will be called when animation will end
  89409. * @returns a new animatable
  89410. */
  89411. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89412. /**
  89413. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  89414. * @param skeleton defines the Skeleton containing the animation range to convert
  89415. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  89416. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  89417. * @returns the original skeleton
  89418. */
  89419. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  89420. /** @hidden */
  89421. _markAsDirty(): void;
  89422. /** @hidden */
  89423. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89424. /** @hidden */
  89425. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89426. private _computeTransformMatrices;
  89427. /**
  89428. * Build all resources required to render a skeleton
  89429. */
  89430. prepare(): void;
  89431. /**
  89432. * Gets the list of animatables currently running for this skeleton
  89433. * @returns an array of animatables
  89434. */
  89435. getAnimatables(): IAnimatable[];
  89436. /**
  89437. * Clone the current skeleton
  89438. * @param name defines the name of the new skeleton
  89439. * @param id defines the id of the new skeleton
  89440. * @returns the new skeleton
  89441. */
  89442. clone(name: string, id?: string): Skeleton;
  89443. /**
  89444. * Enable animation blending for this skeleton
  89445. * @param blendingSpeed defines the blending speed to apply
  89446. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89447. */
  89448. enableBlending(blendingSpeed?: number): void;
  89449. /**
  89450. * Releases all resources associated with the current skeleton
  89451. */
  89452. dispose(): void;
  89453. /**
  89454. * Serialize the skeleton in a JSON object
  89455. * @returns a JSON object
  89456. */
  89457. serialize(): any;
  89458. /**
  89459. * Creates a new skeleton from serialized data
  89460. * @param parsedSkeleton defines the serialized data
  89461. * @param scene defines the hosting scene
  89462. * @returns a new skeleton
  89463. */
  89464. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  89465. /**
  89466. * Compute all node absolute transforms
  89467. * @param forceUpdate defines if computation must be done even if cache is up to date
  89468. */
  89469. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  89470. /**
  89471. * Gets the root pose matrix
  89472. * @returns a matrix
  89473. */
  89474. getPoseMatrix(): Nullable<Matrix>;
  89475. /**
  89476. * Sorts bones per internal index
  89477. */
  89478. sortBones(): void;
  89479. private _sortBones;
  89480. }
  89481. }
  89482. declare module BABYLON {
  89483. /**
  89484. * Creates an instance based on a source mesh.
  89485. */
  89486. export class InstancedMesh extends AbstractMesh {
  89487. private _sourceMesh;
  89488. private _currentLOD;
  89489. /** @hidden */
  89490. _indexInSourceMeshInstanceArray: number;
  89491. constructor(name: string, source: Mesh);
  89492. /**
  89493. * Returns the string "InstancedMesh".
  89494. */
  89495. getClassName(): string;
  89496. /** Gets the list of lights affecting that mesh */
  89497. get lightSources(): Light[];
  89498. _resyncLightSources(): void;
  89499. _resyncLightSource(light: Light): void;
  89500. _removeLightSource(light: Light, dispose: boolean): void;
  89501. /**
  89502. * If the source mesh receives shadows
  89503. */
  89504. get receiveShadows(): boolean;
  89505. /**
  89506. * The material of the source mesh
  89507. */
  89508. get material(): Nullable<Material>;
  89509. /**
  89510. * Visibility of the source mesh
  89511. */
  89512. get visibility(): number;
  89513. /**
  89514. * Skeleton of the source mesh
  89515. */
  89516. get skeleton(): Nullable<Skeleton>;
  89517. /**
  89518. * Rendering ground id of the source mesh
  89519. */
  89520. get renderingGroupId(): number;
  89521. set renderingGroupId(value: number);
  89522. /**
  89523. * Returns the total number of vertices (integer).
  89524. */
  89525. getTotalVertices(): number;
  89526. /**
  89527. * Returns a positive integer : the total number of indices in this mesh geometry.
  89528. * @returns the numner of indices or zero if the mesh has no geometry.
  89529. */
  89530. getTotalIndices(): number;
  89531. /**
  89532. * The source mesh of the instance
  89533. */
  89534. get sourceMesh(): Mesh;
  89535. /**
  89536. * Is this node ready to be used/rendered
  89537. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89538. * @return {boolean} is it ready
  89539. */
  89540. isReady(completeCheck?: boolean): boolean;
  89541. /**
  89542. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89543. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89544. * @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.
  89545. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89546. */
  89547. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89548. /**
  89549. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89550. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89551. * The `data` are either a numeric array either a Float32Array.
  89552. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89553. * 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).
  89554. * Note that a new underlying VertexBuffer object is created each call.
  89555. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89556. *
  89557. * Possible `kind` values :
  89558. * - VertexBuffer.PositionKind
  89559. * - VertexBuffer.UVKind
  89560. * - VertexBuffer.UV2Kind
  89561. * - VertexBuffer.UV3Kind
  89562. * - VertexBuffer.UV4Kind
  89563. * - VertexBuffer.UV5Kind
  89564. * - VertexBuffer.UV6Kind
  89565. * - VertexBuffer.ColorKind
  89566. * - VertexBuffer.MatricesIndicesKind
  89567. * - VertexBuffer.MatricesIndicesExtraKind
  89568. * - VertexBuffer.MatricesWeightsKind
  89569. * - VertexBuffer.MatricesWeightsExtraKind
  89570. *
  89571. * Returns the Mesh.
  89572. */
  89573. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89574. /**
  89575. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89576. * If the mesh has no geometry, it is simply returned as it is.
  89577. * The `data` are either a numeric array either a Float32Array.
  89578. * No new underlying VertexBuffer object is created.
  89579. * 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.
  89580. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89581. *
  89582. * Possible `kind` values :
  89583. * - VertexBuffer.PositionKind
  89584. * - VertexBuffer.UVKind
  89585. * - VertexBuffer.UV2Kind
  89586. * - VertexBuffer.UV3Kind
  89587. * - VertexBuffer.UV4Kind
  89588. * - VertexBuffer.UV5Kind
  89589. * - VertexBuffer.UV6Kind
  89590. * - VertexBuffer.ColorKind
  89591. * - VertexBuffer.MatricesIndicesKind
  89592. * - VertexBuffer.MatricesIndicesExtraKind
  89593. * - VertexBuffer.MatricesWeightsKind
  89594. * - VertexBuffer.MatricesWeightsExtraKind
  89595. *
  89596. * Returns the Mesh.
  89597. */
  89598. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89599. /**
  89600. * Sets the mesh indices.
  89601. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89602. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89603. * This method creates a new index buffer each call.
  89604. * Returns the Mesh.
  89605. */
  89606. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89607. /**
  89608. * Boolean : True if the mesh owns the requested kind of data.
  89609. */
  89610. isVerticesDataPresent(kind: string): boolean;
  89611. /**
  89612. * Returns an array of indices (IndicesArray).
  89613. */
  89614. getIndices(): Nullable<IndicesArray>;
  89615. get _positions(): Nullable<Vector3[]>;
  89616. /**
  89617. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89618. * This means the mesh underlying bounding box and sphere are recomputed.
  89619. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89620. * @returns the current mesh
  89621. */
  89622. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89623. /** @hidden */
  89624. _preActivate(): InstancedMesh;
  89625. /** @hidden */
  89626. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89627. /** @hidden */
  89628. _postActivate(): void;
  89629. getWorldMatrix(): Matrix;
  89630. get isAnInstance(): boolean;
  89631. /**
  89632. * Returns the current associated LOD AbstractMesh.
  89633. */
  89634. getLOD(camera: Camera): AbstractMesh;
  89635. /** @hidden */
  89636. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89637. /** @hidden */
  89638. _syncSubMeshes(): InstancedMesh;
  89639. /** @hidden */
  89640. _generatePointsArray(): boolean;
  89641. /**
  89642. * Creates a new InstancedMesh from the current mesh.
  89643. * - name (string) : the cloned mesh name
  89644. * - newParent (optional Node) : the optional Node to parent the clone to.
  89645. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89646. *
  89647. * Returns the clone.
  89648. */
  89649. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  89650. /**
  89651. * Disposes the InstancedMesh.
  89652. * Returns nothing.
  89653. */
  89654. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89655. }
  89656. interface Mesh {
  89657. /**
  89658. * Register a custom buffer that will be instanced
  89659. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89660. * @param kind defines the buffer kind
  89661. * @param stride defines the stride in floats
  89662. */
  89663. registerInstancedBuffer(kind: string, stride: number): void;
  89664. /** @hidden */
  89665. _userInstancedBuffersStorage: {
  89666. data: {
  89667. [key: string]: Float32Array;
  89668. };
  89669. sizes: {
  89670. [key: string]: number;
  89671. };
  89672. vertexBuffers: {
  89673. [key: string]: Nullable<VertexBuffer>;
  89674. };
  89675. strides: {
  89676. [key: string]: number;
  89677. };
  89678. };
  89679. }
  89680. interface AbstractMesh {
  89681. /**
  89682. * Object used to store instanced buffers defined by user
  89683. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89684. */
  89685. instancedBuffers: {
  89686. [key: string]: any;
  89687. };
  89688. }
  89689. }
  89690. declare module BABYLON {
  89691. /**
  89692. * Defines the options associated with the creation of a shader material.
  89693. */
  89694. export interface IShaderMaterialOptions {
  89695. /**
  89696. * Does the material work in alpha blend mode
  89697. */
  89698. needAlphaBlending: boolean;
  89699. /**
  89700. * Does the material work in alpha test mode
  89701. */
  89702. needAlphaTesting: boolean;
  89703. /**
  89704. * The list of attribute names used in the shader
  89705. */
  89706. attributes: string[];
  89707. /**
  89708. * The list of unifrom names used in the shader
  89709. */
  89710. uniforms: string[];
  89711. /**
  89712. * The list of UBO names used in the shader
  89713. */
  89714. uniformBuffers: string[];
  89715. /**
  89716. * The list of sampler names used in the shader
  89717. */
  89718. samplers: string[];
  89719. /**
  89720. * The list of defines used in the shader
  89721. */
  89722. defines: string[];
  89723. }
  89724. /**
  89725. * 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.
  89726. *
  89727. * This returned material effects how the mesh will look based on the code in the shaders.
  89728. *
  89729. * @see http://doc.babylonjs.com/how_to/shader_material
  89730. */
  89731. export class ShaderMaterial extends Material {
  89732. private _shaderPath;
  89733. private _options;
  89734. private _textures;
  89735. private _textureArrays;
  89736. private _floats;
  89737. private _ints;
  89738. private _floatsArrays;
  89739. private _colors3;
  89740. private _colors3Arrays;
  89741. private _colors4;
  89742. private _colors4Arrays;
  89743. private _vectors2;
  89744. private _vectors3;
  89745. private _vectors4;
  89746. private _matrices;
  89747. private _matrixArrays;
  89748. private _matrices3x3;
  89749. private _matrices2x2;
  89750. private _vectors2Arrays;
  89751. private _vectors3Arrays;
  89752. private _vectors4Arrays;
  89753. private _cachedWorldViewMatrix;
  89754. private _cachedWorldViewProjectionMatrix;
  89755. private _renderId;
  89756. private _multiview;
  89757. /**
  89758. * Instantiate a new shader material.
  89759. * 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.
  89760. * This returned material effects how the mesh will look based on the code in the shaders.
  89761. * @see http://doc.babylonjs.com/how_to/shader_material
  89762. * @param name Define the name of the material in the scene
  89763. * @param scene Define the scene the material belongs to
  89764. * @param shaderPath Defines the route to the shader code in one of three ways:
  89765. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89766. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89767. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89768. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89769. * @param options Define the options used to create the shader
  89770. */
  89771. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89772. /**
  89773. * Gets the shader path used to define the shader code
  89774. * It can be modified to trigger a new compilation
  89775. */
  89776. get shaderPath(): any;
  89777. /**
  89778. * Sets the shader path used to define the shader code
  89779. * It can be modified to trigger a new compilation
  89780. */
  89781. set shaderPath(shaderPath: any);
  89782. /**
  89783. * Gets the options used to compile the shader.
  89784. * They can be modified to trigger a new compilation
  89785. */
  89786. get options(): IShaderMaterialOptions;
  89787. /**
  89788. * Gets the current class name of the material e.g. "ShaderMaterial"
  89789. * Mainly use in serialization.
  89790. * @returns the class name
  89791. */
  89792. getClassName(): string;
  89793. /**
  89794. * Specifies if the material will require alpha blending
  89795. * @returns a boolean specifying if alpha blending is needed
  89796. */
  89797. needAlphaBlending(): boolean;
  89798. /**
  89799. * Specifies if this material should be rendered in alpha test mode
  89800. * @returns a boolean specifying if an alpha test is needed.
  89801. */
  89802. needAlphaTesting(): boolean;
  89803. private _checkUniform;
  89804. /**
  89805. * Set a texture in the shader.
  89806. * @param name Define the name of the uniform samplers as defined in the shader
  89807. * @param texture Define the texture to bind to this sampler
  89808. * @return the material itself allowing "fluent" like uniform updates
  89809. */
  89810. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  89811. /**
  89812. * Set a texture array in the shader.
  89813. * @param name Define the name of the uniform sampler array as defined in the shader
  89814. * @param textures Define the list of textures to bind to this sampler
  89815. * @return the material itself allowing "fluent" like uniform updates
  89816. */
  89817. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  89818. /**
  89819. * Set a float in the shader.
  89820. * @param name Define the name of the uniform as defined in the shader
  89821. * @param value Define the value to give to the uniform
  89822. * @return the material itself allowing "fluent" like uniform updates
  89823. */
  89824. setFloat(name: string, value: number): ShaderMaterial;
  89825. /**
  89826. * Set a int in the shader.
  89827. * @param name Define the name of the uniform as defined in the shader
  89828. * @param value Define the value to give to the uniform
  89829. * @return the material itself allowing "fluent" like uniform updates
  89830. */
  89831. setInt(name: string, value: number): ShaderMaterial;
  89832. /**
  89833. * Set an array of floats in the shader.
  89834. * @param name Define the name of the uniform as defined in the shader
  89835. * @param value Define the value to give to the uniform
  89836. * @return the material itself allowing "fluent" like uniform updates
  89837. */
  89838. setFloats(name: string, value: number[]): ShaderMaterial;
  89839. /**
  89840. * Set a vec3 in the shader from a Color3.
  89841. * @param name Define the name of the uniform as defined in the shader
  89842. * @param value Define the value to give to the uniform
  89843. * @return the material itself allowing "fluent" like uniform updates
  89844. */
  89845. setColor3(name: string, value: Color3): ShaderMaterial;
  89846. /**
  89847. * Set a vec3 array in the shader from a Color3 array.
  89848. * @param name Define the name of the uniform as defined in the shader
  89849. * @param value Define the value to give to the uniform
  89850. * @return the material itself allowing "fluent" like uniform updates
  89851. */
  89852. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89853. /**
  89854. * Set a vec4 in the shader from a Color4.
  89855. * @param name Define the name of the uniform as defined in the shader
  89856. * @param value Define the value to give to the uniform
  89857. * @return the material itself allowing "fluent" like uniform updates
  89858. */
  89859. setColor4(name: string, value: Color4): ShaderMaterial;
  89860. /**
  89861. * Set a vec4 array in the shader from a Color4 array.
  89862. * @param name Define the name of the uniform as defined in the shader
  89863. * @param value Define the value to give to the uniform
  89864. * @return the material itself allowing "fluent" like uniform updates
  89865. */
  89866. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89867. /**
  89868. * Set a vec2 in the shader from a Vector2.
  89869. * @param name Define the name of the uniform as defined in the shader
  89870. * @param value Define the value to give to the uniform
  89871. * @return the material itself allowing "fluent" like uniform updates
  89872. */
  89873. setVector2(name: string, value: Vector2): ShaderMaterial;
  89874. /**
  89875. * Set a vec3 in the shader from a Vector3.
  89876. * @param name Define the name of the uniform as defined in the shader
  89877. * @param value Define the value to give to the uniform
  89878. * @return the material itself allowing "fluent" like uniform updates
  89879. */
  89880. setVector3(name: string, value: Vector3): ShaderMaterial;
  89881. /**
  89882. * Set a vec4 in the shader from a Vector4.
  89883. * @param name Define the name of the uniform as defined in the shader
  89884. * @param value Define the value to give to the uniform
  89885. * @return the material itself allowing "fluent" like uniform updates
  89886. */
  89887. setVector4(name: string, value: Vector4): ShaderMaterial;
  89888. /**
  89889. * Set a mat4 in the shader from a Matrix.
  89890. * @param name Define the name of the uniform as defined in the shader
  89891. * @param value Define the value to give to the uniform
  89892. * @return the material itself allowing "fluent" like uniform updates
  89893. */
  89894. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89895. /**
  89896. * Set a float32Array in the shader from a matrix array.
  89897. * @param name Define the name of the uniform as defined in the shader
  89898. * @param value Define the value to give to the uniform
  89899. * @return the material itself allowing "fluent" like uniform updates
  89900. */
  89901. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89902. /**
  89903. * Set a mat3 in the shader from a Float32Array.
  89904. * @param name Define the name of the uniform as defined in the shader
  89905. * @param value Define the value to give to the uniform
  89906. * @return the material itself allowing "fluent" like uniform updates
  89907. */
  89908. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89909. /**
  89910. * Set a mat2 in the shader from a Float32Array.
  89911. * @param name Define the name of the uniform as defined in the shader
  89912. * @param value Define the value to give to the uniform
  89913. * @return the material itself allowing "fluent" like uniform updates
  89914. */
  89915. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89916. /**
  89917. * Set a vec2 array in the shader from a number array.
  89918. * @param name Define the name of the uniform as defined in the shader
  89919. * @param value Define the value to give to the uniform
  89920. * @return the material itself allowing "fluent" like uniform updates
  89921. */
  89922. setArray2(name: string, value: number[]): ShaderMaterial;
  89923. /**
  89924. * Set a vec3 array in the shader from a number array.
  89925. * @param name Define the name of the uniform as defined in the shader
  89926. * @param value Define the value to give to the uniform
  89927. * @return the material itself allowing "fluent" like uniform updates
  89928. */
  89929. setArray3(name: string, value: number[]): ShaderMaterial;
  89930. /**
  89931. * Set a vec4 array in the shader from a number array.
  89932. * @param name Define the name of the uniform as defined in the shader
  89933. * @param value Define the value to give to the uniform
  89934. * @return the material itself allowing "fluent" like uniform updates
  89935. */
  89936. setArray4(name: string, value: number[]): ShaderMaterial;
  89937. private _checkCache;
  89938. /**
  89939. * Specifies that the submesh is ready to be used
  89940. * @param mesh defines the mesh to check
  89941. * @param subMesh defines which submesh to check
  89942. * @param useInstances specifies that instances should be used
  89943. * @returns a boolean indicating that the submesh is ready or not
  89944. */
  89945. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89946. /**
  89947. * Checks if the material is ready to render the requested mesh
  89948. * @param mesh Define the mesh to render
  89949. * @param useInstances Define whether or not the material is used with instances
  89950. * @returns true if ready, otherwise false
  89951. */
  89952. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89953. /**
  89954. * Binds the world matrix to the material
  89955. * @param world defines the world transformation matrix
  89956. */
  89957. bindOnlyWorldMatrix(world: Matrix): void;
  89958. /**
  89959. * Binds the material to the mesh
  89960. * @param world defines the world transformation matrix
  89961. * @param mesh defines the mesh to bind the material to
  89962. */
  89963. bind(world: Matrix, mesh?: Mesh): void;
  89964. /**
  89965. * Gets the active textures from the material
  89966. * @returns an array of textures
  89967. */
  89968. getActiveTextures(): BaseTexture[];
  89969. /**
  89970. * Specifies if the material uses a texture
  89971. * @param texture defines the texture to check against the material
  89972. * @returns a boolean specifying if the material uses the texture
  89973. */
  89974. hasTexture(texture: BaseTexture): boolean;
  89975. /**
  89976. * Makes a duplicate of the material, and gives it a new name
  89977. * @param name defines the new name for the duplicated material
  89978. * @returns the cloned material
  89979. */
  89980. clone(name: string): ShaderMaterial;
  89981. /**
  89982. * Disposes the material
  89983. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89984. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89985. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89986. */
  89987. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89988. /**
  89989. * Serializes this material in a JSON representation
  89990. * @returns the serialized material object
  89991. */
  89992. serialize(): any;
  89993. /**
  89994. * Creates a shader material from parsed shader material data
  89995. * @param source defines the JSON represnetation of the material
  89996. * @param scene defines the hosting scene
  89997. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89998. * @returns a new material
  89999. */
  90000. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90001. }
  90002. }
  90003. declare module BABYLON {
  90004. /** @hidden */
  90005. export var colorPixelShader: {
  90006. name: string;
  90007. shader: string;
  90008. };
  90009. }
  90010. declare module BABYLON {
  90011. /** @hidden */
  90012. export var colorVertexShader: {
  90013. name: string;
  90014. shader: string;
  90015. };
  90016. }
  90017. declare module BABYLON {
  90018. /**
  90019. * Line mesh
  90020. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90021. */
  90022. export class LinesMesh extends Mesh {
  90023. /**
  90024. * If vertex color should be applied to the mesh
  90025. */
  90026. readonly useVertexColor?: boolean | undefined;
  90027. /**
  90028. * If vertex alpha should be applied to the mesh
  90029. */
  90030. readonly useVertexAlpha?: boolean | undefined;
  90031. /**
  90032. * Color of the line (Default: White)
  90033. */
  90034. color: Color3;
  90035. /**
  90036. * Alpha of the line (Default: 1)
  90037. */
  90038. alpha: number;
  90039. /**
  90040. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90041. * This margin is expressed in world space coordinates, so its value may vary.
  90042. * Default value is 0.1
  90043. */
  90044. intersectionThreshold: number;
  90045. private _colorShader;
  90046. private color4;
  90047. /**
  90048. * Creates a new LinesMesh
  90049. * @param name defines the name
  90050. * @param scene defines the hosting scene
  90051. * @param parent defines the parent mesh if any
  90052. * @param source defines the optional source LinesMesh used to clone data from
  90053. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90054. * When false, achieved by calling a clone(), also passing False.
  90055. * This will make creation of children, recursive.
  90056. * @param useVertexColor defines if this LinesMesh supports vertex color
  90057. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90058. */
  90059. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90060. /**
  90061. * If vertex color should be applied to the mesh
  90062. */
  90063. useVertexColor?: boolean | undefined,
  90064. /**
  90065. * If vertex alpha should be applied to the mesh
  90066. */
  90067. useVertexAlpha?: boolean | undefined);
  90068. private _addClipPlaneDefine;
  90069. private _removeClipPlaneDefine;
  90070. isReady(): boolean;
  90071. /**
  90072. * Returns the string "LineMesh"
  90073. */
  90074. getClassName(): string;
  90075. /**
  90076. * @hidden
  90077. */
  90078. get material(): Material;
  90079. /**
  90080. * @hidden
  90081. */
  90082. set material(value: Material);
  90083. /**
  90084. * @hidden
  90085. */
  90086. get checkCollisions(): boolean;
  90087. /** @hidden */
  90088. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90089. /** @hidden */
  90090. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90091. /**
  90092. * Disposes of the line mesh
  90093. * @param doNotRecurse If children should be disposed
  90094. */
  90095. dispose(doNotRecurse?: boolean): void;
  90096. /**
  90097. * Returns a new LineMesh object cloned from the current one.
  90098. */
  90099. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  90100. /**
  90101. * Creates a new InstancedLinesMesh object from the mesh model.
  90102. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90103. * @param name defines the name of the new instance
  90104. * @returns a new InstancedLinesMesh
  90105. */
  90106. createInstance(name: string): InstancedLinesMesh;
  90107. }
  90108. /**
  90109. * Creates an instance based on a source LinesMesh
  90110. */
  90111. export class InstancedLinesMesh extends InstancedMesh {
  90112. /**
  90113. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90114. * This margin is expressed in world space coordinates, so its value may vary.
  90115. * Initilized with the intersectionThreshold value of the source LinesMesh
  90116. */
  90117. intersectionThreshold: number;
  90118. constructor(name: string, source: LinesMesh);
  90119. /**
  90120. * Returns the string "InstancedLinesMesh".
  90121. */
  90122. getClassName(): string;
  90123. }
  90124. }
  90125. declare module BABYLON {
  90126. /** @hidden */
  90127. export var linePixelShader: {
  90128. name: string;
  90129. shader: string;
  90130. };
  90131. }
  90132. declare module BABYLON {
  90133. /** @hidden */
  90134. export var lineVertexShader: {
  90135. name: string;
  90136. shader: string;
  90137. };
  90138. }
  90139. declare module BABYLON {
  90140. interface AbstractMesh {
  90141. /**
  90142. * Gets the edgesRenderer associated with the mesh
  90143. */
  90144. edgesRenderer: Nullable<EdgesRenderer>;
  90145. }
  90146. interface LinesMesh {
  90147. /**
  90148. * Enables the edge rendering mode on the mesh.
  90149. * This mode makes the mesh edges visible
  90150. * @param epsilon defines the maximal distance between two angles to detect a face
  90151. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90152. * @returns the currentAbstractMesh
  90153. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90154. */
  90155. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90156. }
  90157. interface InstancedLinesMesh {
  90158. /**
  90159. * Enables the edge rendering mode on the mesh.
  90160. * This mode makes the mesh edges visible
  90161. * @param epsilon defines the maximal distance between two angles to detect a face
  90162. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90163. * @returns the current InstancedLinesMesh
  90164. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90165. */
  90166. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90167. }
  90168. /**
  90169. * Defines the minimum contract an Edges renderer should follow.
  90170. */
  90171. export interface IEdgesRenderer extends IDisposable {
  90172. /**
  90173. * Gets or sets a boolean indicating if the edgesRenderer is active
  90174. */
  90175. isEnabled: boolean;
  90176. /**
  90177. * Renders the edges of the attached mesh,
  90178. */
  90179. render(): void;
  90180. /**
  90181. * Checks wether or not the edges renderer is ready to render.
  90182. * @return true if ready, otherwise false.
  90183. */
  90184. isReady(): boolean;
  90185. }
  90186. /**
  90187. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90188. */
  90189. export class EdgesRenderer implements IEdgesRenderer {
  90190. /**
  90191. * Define the size of the edges with an orthographic camera
  90192. */
  90193. edgesWidthScalerForOrthographic: number;
  90194. /**
  90195. * Define the size of the edges with a perspective camera
  90196. */
  90197. edgesWidthScalerForPerspective: number;
  90198. protected _source: AbstractMesh;
  90199. protected _linesPositions: number[];
  90200. protected _linesNormals: number[];
  90201. protected _linesIndices: number[];
  90202. protected _epsilon: number;
  90203. protected _indicesCount: number;
  90204. protected _lineShader: ShaderMaterial;
  90205. protected _ib: DataBuffer;
  90206. protected _buffers: {
  90207. [key: string]: Nullable<VertexBuffer>;
  90208. };
  90209. protected _checkVerticesInsteadOfIndices: boolean;
  90210. private _meshRebuildObserver;
  90211. private _meshDisposeObserver;
  90212. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90213. isEnabled: boolean;
  90214. /**
  90215. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90216. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90217. * @param source Mesh used to create edges
  90218. * @param epsilon sum of angles in adjacency to check for edge
  90219. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90220. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90221. */
  90222. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90223. protected _prepareRessources(): void;
  90224. /** @hidden */
  90225. _rebuild(): void;
  90226. /**
  90227. * Releases the required resources for the edges renderer
  90228. */
  90229. dispose(): void;
  90230. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90231. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90232. /**
  90233. * Checks if the pair of p0 and p1 is en edge
  90234. * @param faceIndex
  90235. * @param edge
  90236. * @param faceNormals
  90237. * @param p0
  90238. * @param p1
  90239. * @private
  90240. */
  90241. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90242. /**
  90243. * push line into the position, normal and index buffer
  90244. * @protected
  90245. */
  90246. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90247. /**
  90248. * Generates lines edges from adjacencjes
  90249. * @private
  90250. */
  90251. _generateEdgesLines(): void;
  90252. /**
  90253. * Checks wether or not the edges renderer is ready to render.
  90254. * @return true if ready, otherwise false.
  90255. */
  90256. isReady(): boolean;
  90257. /**
  90258. * Renders the edges of the attached mesh,
  90259. */
  90260. render(): void;
  90261. }
  90262. /**
  90263. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90264. */
  90265. export class LineEdgesRenderer extends EdgesRenderer {
  90266. /**
  90267. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90268. * @param source LineMesh used to generate edges
  90269. * @param epsilon not important (specified angle for edge detection)
  90270. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90271. */
  90272. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90273. /**
  90274. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90275. */
  90276. _generateEdgesLines(): void;
  90277. }
  90278. }
  90279. declare module BABYLON {
  90280. /**
  90281. * This represents the object necessary to create a rendering group.
  90282. * This is exclusively used and created by the rendering manager.
  90283. * To modify the behavior, you use the available helpers in your scene or meshes.
  90284. * @hidden
  90285. */
  90286. export class RenderingGroup {
  90287. index: number;
  90288. private static _zeroVector;
  90289. private _scene;
  90290. private _opaqueSubMeshes;
  90291. private _transparentSubMeshes;
  90292. private _alphaTestSubMeshes;
  90293. private _depthOnlySubMeshes;
  90294. private _particleSystems;
  90295. private _spriteManagers;
  90296. private _opaqueSortCompareFn;
  90297. private _alphaTestSortCompareFn;
  90298. private _transparentSortCompareFn;
  90299. private _renderOpaque;
  90300. private _renderAlphaTest;
  90301. private _renderTransparent;
  90302. /** @hidden */
  90303. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90304. onBeforeTransparentRendering: () => void;
  90305. /**
  90306. * Set the opaque sort comparison function.
  90307. * If null the sub meshes will be render in the order they were created
  90308. */
  90309. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90310. /**
  90311. * Set the alpha test sort comparison function.
  90312. * If null the sub meshes will be render in the order they were created
  90313. */
  90314. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90315. /**
  90316. * Set the transparent sort comparison function.
  90317. * If null the sub meshes will be render in the order they were created
  90318. */
  90319. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90320. /**
  90321. * Creates a new rendering group.
  90322. * @param index The rendering group index
  90323. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90324. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90325. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90326. */
  90327. 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>);
  90328. /**
  90329. * Render all the sub meshes contained in the group.
  90330. * @param customRenderFunction Used to override the default render behaviour of the group.
  90331. * @returns true if rendered some submeshes.
  90332. */
  90333. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90334. /**
  90335. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90336. * @param subMeshes The submeshes to render
  90337. */
  90338. private renderOpaqueSorted;
  90339. /**
  90340. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90341. * @param subMeshes The submeshes to render
  90342. */
  90343. private renderAlphaTestSorted;
  90344. /**
  90345. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90346. * @param subMeshes The submeshes to render
  90347. */
  90348. private renderTransparentSorted;
  90349. /**
  90350. * Renders the submeshes in a specified order.
  90351. * @param subMeshes The submeshes to sort before render
  90352. * @param sortCompareFn The comparison function use to sort
  90353. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90354. * @param transparent Specifies to activate blending if true
  90355. */
  90356. private static renderSorted;
  90357. /**
  90358. * Renders the submeshes in the order they were dispatched (no sort applied).
  90359. * @param subMeshes The submeshes to render
  90360. */
  90361. private static renderUnsorted;
  90362. /**
  90363. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90364. * are rendered back to front if in the same alpha index.
  90365. *
  90366. * @param a The first submesh
  90367. * @param b The second submesh
  90368. * @returns The result of the comparison
  90369. */
  90370. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90371. /**
  90372. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90373. * are rendered back to front.
  90374. *
  90375. * @param a The first submesh
  90376. * @param b The second submesh
  90377. * @returns The result of the comparison
  90378. */
  90379. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90380. /**
  90381. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90382. * are rendered front to back (prevent overdraw).
  90383. *
  90384. * @param a The first submesh
  90385. * @param b The second submesh
  90386. * @returns The result of the comparison
  90387. */
  90388. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90389. /**
  90390. * Resets the different lists of submeshes to prepare a new frame.
  90391. */
  90392. prepare(): void;
  90393. dispose(): void;
  90394. /**
  90395. * Inserts the submesh in its correct queue depending on its material.
  90396. * @param subMesh The submesh to dispatch
  90397. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90398. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90399. */
  90400. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90401. dispatchSprites(spriteManager: ISpriteManager): void;
  90402. dispatchParticles(particleSystem: IParticleSystem): void;
  90403. private _renderParticles;
  90404. private _renderSprites;
  90405. }
  90406. }
  90407. declare module BABYLON {
  90408. /**
  90409. * Interface describing the different options available in the rendering manager
  90410. * regarding Auto Clear between groups.
  90411. */
  90412. export interface IRenderingManagerAutoClearSetup {
  90413. /**
  90414. * Defines whether or not autoclear is enable.
  90415. */
  90416. autoClear: boolean;
  90417. /**
  90418. * Defines whether or not to autoclear the depth buffer.
  90419. */
  90420. depth: boolean;
  90421. /**
  90422. * Defines whether or not to autoclear the stencil buffer.
  90423. */
  90424. stencil: boolean;
  90425. }
  90426. /**
  90427. * This class is used by the onRenderingGroupObservable
  90428. */
  90429. export class RenderingGroupInfo {
  90430. /**
  90431. * The Scene that being rendered
  90432. */
  90433. scene: Scene;
  90434. /**
  90435. * The camera currently used for the rendering pass
  90436. */
  90437. camera: Nullable<Camera>;
  90438. /**
  90439. * The ID of the renderingGroup being processed
  90440. */
  90441. renderingGroupId: number;
  90442. }
  90443. /**
  90444. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90445. * It is enable to manage the different groups as well as the different necessary sort functions.
  90446. * This should not be used directly aside of the few static configurations
  90447. */
  90448. export class RenderingManager {
  90449. /**
  90450. * The max id used for rendering groups (not included)
  90451. */
  90452. static MAX_RENDERINGGROUPS: number;
  90453. /**
  90454. * The min id used for rendering groups (included)
  90455. */
  90456. static MIN_RENDERINGGROUPS: number;
  90457. /**
  90458. * Used to globally prevent autoclearing scenes.
  90459. */
  90460. static AUTOCLEAR: boolean;
  90461. /**
  90462. * @hidden
  90463. */
  90464. _useSceneAutoClearSetup: boolean;
  90465. private _scene;
  90466. private _renderingGroups;
  90467. private _depthStencilBufferAlreadyCleaned;
  90468. private _autoClearDepthStencil;
  90469. private _customOpaqueSortCompareFn;
  90470. private _customAlphaTestSortCompareFn;
  90471. private _customTransparentSortCompareFn;
  90472. private _renderingGroupInfo;
  90473. /**
  90474. * Instantiates a new rendering group for a particular scene
  90475. * @param scene Defines the scene the groups belongs to
  90476. */
  90477. constructor(scene: Scene);
  90478. private _clearDepthStencilBuffer;
  90479. /**
  90480. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90481. * @hidden
  90482. */
  90483. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90484. /**
  90485. * Resets the different information of the group to prepare a new frame
  90486. * @hidden
  90487. */
  90488. reset(): void;
  90489. /**
  90490. * Dispose and release the group and its associated resources.
  90491. * @hidden
  90492. */
  90493. dispose(): void;
  90494. /**
  90495. * Clear the info related to rendering groups preventing retention points during dispose.
  90496. */
  90497. freeRenderingGroups(): void;
  90498. private _prepareRenderingGroup;
  90499. /**
  90500. * Add a sprite manager to the rendering manager in order to render it this frame.
  90501. * @param spriteManager Define the sprite manager to render
  90502. */
  90503. dispatchSprites(spriteManager: ISpriteManager): void;
  90504. /**
  90505. * Add a particle system to the rendering manager in order to render it this frame.
  90506. * @param particleSystem Define the particle system to render
  90507. */
  90508. dispatchParticles(particleSystem: IParticleSystem): void;
  90509. /**
  90510. * Add a submesh to the manager in order to render it this frame
  90511. * @param subMesh The submesh to dispatch
  90512. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90513. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90514. */
  90515. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90516. /**
  90517. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90518. * This allowed control for front to back rendering or reversly depending of the special needs.
  90519. *
  90520. * @param renderingGroupId The rendering group id corresponding to its index
  90521. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90522. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90523. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90524. */
  90525. 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;
  90526. /**
  90527. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90528. *
  90529. * @param renderingGroupId The rendering group id corresponding to its index
  90530. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90531. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90532. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90533. */
  90534. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90535. /**
  90536. * Gets the current auto clear configuration for one rendering group of the rendering
  90537. * manager.
  90538. * @param index the rendering group index to get the information for
  90539. * @returns The auto clear setup for the requested rendering group
  90540. */
  90541. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90542. }
  90543. }
  90544. declare module BABYLON {
  90545. /**
  90546. * Defines the options associated with the creation of a custom shader for a shadow generator.
  90547. */
  90548. export interface ICustomShaderOptions {
  90549. /**
  90550. * Gets or sets the custom shader name to use
  90551. */
  90552. shaderName: string;
  90553. /**
  90554. * The list of attribute names used in the shader
  90555. */
  90556. attributes?: string[];
  90557. /**
  90558. * The list of unifrom names used in the shader
  90559. */
  90560. uniforms?: string[];
  90561. /**
  90562. * The list of sampler names used in the shader
  90563. */
  90564. samplers?: string[];
  90565. /**
  90566. * The list of defines used in the shader
  90567. */
  90568. defines?: string[];
  90569. }
  90570. /**
  90571. * Interface to implement to create a shadow generator compatible with BJS.
  90572. */
  90573. export interface IShadowGenerator {
  90574. /**
  90575. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90576. * @returns The render target texture if present otherwise, null
  90577. */
  90578. getShadowMap(): Nullable<RenderTargetTexture>;
  90579. /**
  90580. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90581. * @param subMesh The submesh we want to render in the shadow map
  90582. * @param useInstances Defines wether will draw in the map using instances
  90583. * @returns true if ready otherwise, false
  90584. */
  90585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90586. /**
  90587. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90588. * @param defines Defines of the material we want to update
  90589. * @param lightIndex Index of the light in the enabled light list of the material
  90590. */
  90591. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  90592. /**
  90593. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90594. * defined in the generator but impacting the effect).
  90595. * It implies the unifroms available on the materials are the standard BJS ones.
  90596. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90597. * @param effect The effect we are binfing the information for
  90598. */
  90599. bindShadowLight(lightIndex: string, effect: Effect): void;
  90600. /**
  90601. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90602. * (eq to shadow prjection matrix * light transform matrix)
  90603. * @returns The transform matrix used to create the shadow map
  90604. */
  90605. getTransformMatrix(): Matrix;
  90606. /**
  90607. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90608. * Cube and 2D textures for instance.
  90609. */
  90610. recreateShadowMap(): void;
  90611. /**
  90612. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90613. * @param onCompiled Callback triggered at the and of the effects compilation
  90614. * @param options Sets of optional options forcing the compilation with different modes
  90615. */
  90616. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90617. useInstances: boolean;
  90618. }>): void;
  90619. /**
  90620. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90621. * @param options Sets of optional options forcing the compilation with different modes
  90622. * @returns A promise that resolves when the compilation completes
  90623. */
  90624. forceCompilationAsync(options?: Partial<{
  90625. useInstances: boolean;
  90626. }>): Promise<void>;
  90627. /**
  90628. * Serializes the shadow generator setup to a json object.
  90629. * @returns The serialized JSON object
  90630. */
  90631. serialize(): any;
  90632. /**
  90633. * Disposes the Shadow map and related Textures and effects.
  90634. */
  90635. dispose(): void;
  90636. }
  90637. /**
  90638. * Default implementation IShadowGenerator.
  90639. * This is the main object responsible of generating shadows in the framework.
  90640. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  90641. */
  90642. export class ShadowGenerator implements IShadowGenerator {
  90643. /**
  90644. * Name of the shadow generator class
  90645. */
  90646. static CLASSNAME: string;
  90647. /**
  90648. * Shadow generator mode None: no filtering applied.
  90649. */
  90650. static readonly FILTER_NONE: number;
  90651. /**
  90652. * Shadow generator mode ESM: Exponential Shadow Mapping.
  90653. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90654. */
  90655. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  90656. /**
  90657. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  90658. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  90659. */
  90660. static readonly FILTER_POISSONSAMPLING: number;
  90661. /**
  90662. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  90663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90664. */
  90665. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  90666. /**
  90667. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  90668. * edge artifacts on steep falloff.
  90669. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90670. */
  90671. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  90672. /**
  90673. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  90674. * edge artifacts on steep falloff.
  90675. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90676. */
  90677. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  90678. /**
  90679. * Shadow generator mode PCF: Percentage Closer Filtering
  90680. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90681. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  90682. */
  90683. static readonly FILTER_PCF: number;
  90684. /**
  90685. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  90686. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90687. * Contact Hardening
  90688. */
  90689. static readonly FILTER_PCSS: number;
  90690. /**
  90691. * Reserved for PCF and PCSS
  90692. * Highest Quality.
  90693. *
  90694. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  90695. *
  90696. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  90697. */
  90698. static readonly QUALITY_HIGH: number;
  90699. /**
  90700. * Reserved for PCF and PCSS
  90701. * Good tradeoff for quality/perf cross devices
  90702. *
  90703. * Execute PCF on a 3*3 kernel.
  90704. *
  90705. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  90706. */
  90707. static readonly QUALITY_MEDIUM: number;
  90708. /**
  90709. * Reserved for PCF and PCSS
  90710. * The lowest quality but the fastest.
  90711. *
  90712. * Execute PCF on a 1*1 kernel.
  90713. *
  90714. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  90715. */
  90716. static readonly QUALITY_LOW: number;
  90717. /** Gets or sets the custom shader name to use */
  90718. customShaderOptions: ICustomShaderOptions;
  90719. /**
  90720. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  90721. */
  90722. onBeforeShadowMapRenderObservable: Observable<Effect>;
  90723. /**
  90724. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  90725. */
  90726. onAfterShadowMapRenderObservable: Observable<Effect>;
  90727. /**
  90728. * Observable triggered before a mesh is rendered in the shadow map.
  90729. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  90730. */
  90731. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  90732. /**
  90733. * Observable triggered after a mesh is rendered in the shadow map.
  90734. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  90735. */
  90736. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  90737. protected _bias: number;
  90738. /**
  90739. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  90740. */
  90741. get bias(): number;
  90742. /**
  90743. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  90744. */
  90745. set bias(bias: number);
  90746. protected _normalBias: number;
  90747. /**
  90748. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90749. */
  90750. get normalBias(): number;
  90751. /**
  90752. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90753. */
  90754. set normalBias(normalBias: number);
  90755. protected _blurBoxOffset: number;
  90756. /**
  90757. * Gets the blur box offset: offset applied during the blur pass.
  90758. * Only useful if useKernelBlur = false
  90759. */
  90760. get blurBoxOffset(): number;
  90761. /**
  90762. * Sets the blur box offset: offset applied during the blur pass.
  90763. * Only useful if useKernelBlur = false
  90764. */
  90765. set blurBoxOffset(value: number);
  90766. protected _blurScale: number;
  90767. /**
  90768. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  90769. * 2 means half of the size.
  90770. */
  90771. get blurScale(): number;
  90772. /**
  90773. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  90774. * 2 means half of the size.
  90775. */
  90776. set blurScale(value: number);
  90777. protected _blurKernel: number;
  90778. /**
  90779. * Gets the blur kernel: kernel size of the blur pass.
  90780. * Only useful if useKernelBlur = true
  90781. */
  90782. get blurKernel(): number;
  90783. /**
  90784. * Sets the blur kernel: kernel size of the blur pass.
  90785. * Only useful if useKernelBlur = true
  90786. */
  90787. set blurKernel(value: number);
  90788. protected _useKernelBlur: boolean;
  90789. /**
  90790. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  90791. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90792. */
  90793. get useKernelBlur(): boolean;
  90794. /**
  90795. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  90796. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90797. */
  90798. set useKernelBlur(value: boolean);
  90799. protected _depthScale: number;
  90800. /**
  90801. * Gets the depth scale used in ESM mode.
  90802. */
  90803. get depthScale(): number;
  90804. /**
  90805. * Sets the depth scale used in ESM mode.
  90806. * This can override the scale stored on the light.
  90807. */
  90808. set depthScale(value: number);
  90809. protected _validateFilter(filter: number): number;
  90810. protected _filter: number;
  90811. /**
  90812. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  90813. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90814. */
  90815. get filter(): number;
  90816. /**
  90817. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  90818. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90819. */
  90820. set filter(value: number);
  90821. /**
  90822. * Gets if the current filter is set to Poisson Sampling.
  90823. */
  90824. get usePoissonSampling(): boolean;
  90825. /**
  90826. * Sets the current filter to Poisson Sampling.
  90827. */
  90828. set usePoissonSampling(value: boolean);
  90829. /**
  90830. * Gets if the current filter is set to ESM.
  90831. */
  90832. get useExponentialShadowMap(): boolean;
  90833. /**
  90834. * Sets the current filter is to ESM.
  90835. */
  90836. set useExponentialShadowMap(value: boolean);
  90837. /**
  90838. * Gets if the current filter is set to filtered ESM.
  90839. */
  90840. get useBlurExponentialShadowMap(): boolean;
  90841. /**
  90842. * Gets if the current filter is set to filtered ESM.
  90843. */
  90844. set useBlurExponentialShadowMap(value: boolean);
  90845. /**
  90846. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90847. * exponential to prevent steep falloff artifacts).
  90848. */
  90849. get useCloseExponentialShadowMap(): boolean;
  90850. /**
  90851. * Sets the current filter to "close ESM" (using the inverse of the
  90852. * exponential to prevent steep falloff artifacts).
  90853. */
  90854. set useCloseExponentialShadowMap(value: boolean);
  90855. /**
  90856. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90857. * exponential to prevent steep falloff artifacts).
  90858. */
  90859. get useBlurCloseExponentialShadowMap(): boolean;
  90860. /**
  90861. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90862. * exponential to prevent steep falloff artifacts).
  90863. */
  90864. set useBlurCloseExponentialShadowMap(value: boolean);
  90865. /**
  90866. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90867. */
  90868. get usePercentageCloserFiltering(): boolean;
  90869. /**
  90870. * Sets the current filter to "PCF" (percentage closer filtering).
  90871. */
  90872. set usePercentageCloserFiltering(value: boolean);
  90873. protected _filteringQuality: number;
  90874. /**
  90875. * Gets the PCF or PCSS Quality.
  90876. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90877. */
  90878. get filteringQuality(): number;
  90879. /**
  90880. * Sets the PCF or PCSS Quality.
  90881. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90882. */
  90883. set filteringQuality(filteringQuality: number);
  90884. /**
  90885. * Gets if the current filter is set to "PCSS" (contact hardening).
  90886. */
  90887. get useContactHardeningShadow(): boolean;
  90888. /**
  90889. * Sets the current filter to "PCSS" (contact hardening).
  90890. */
  90891. set useContactHardeningShadow(value: boolean);
  90892. protected _contactHardeningLightSizeUVRatio: number;
  90893. /**
  90894. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90895. * Using a ratio helps keeping shape stability independently of the map size.
  90896. *
  90897. * It does not account for the light projection as it was having too much
  90898. * instability during the light setup or during light position changes.
  90899. *
  90900. * Only valid if useContactHardeningShadow is true.
  90901. */
  90902. get contactHardeningLightSizeUVRatio(): number;
  90903. /**
  90904. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90905. * Using a ratio helps keeping shape stability independently of the map size.
  90906. *
  90907. * It does not account for the light projection as it was having too much
  90908. * instability during the light setup or during light position changes.
  90909. *
  90910. * Only valid if useContactHardeningShadow is true.
  90911. */
  90912. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90913. protected _darkness: number;
  90914. /** Gets or sets the actual darkness of a shadow */
  90915. get darkness(): number;
  90916. set darkness(value: number);
  90917. /**
  90918. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90919. * 0 means strongest and 1 would means no shadow.
  90920. * @returns the darkness.
  90921. */
  90922. getDarkness(): number;
  90923. /**
  90924. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90925. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90926. * @returns the shadow generator allowing fluent coding.
  90927. */
  90928. setDarkness(darkness: number): ShadowGenerator;
  90929. protected _transparencyShadow: boolean;
  90930. /** Gets or sets the ability to have transparent shadow */
  90931. get transparencyShadow(): boolean;
  90932. set transparencyShadow(value: boolean);
  90933. /**
  90934. * Sets the ability to have transparent shadow (boolean).
  90935. * @param transparent True if transparent else False
  90936. * @returns the shadow generator allowing fluent coding
  90937. */
  90938. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90939. protected _shadowMap: Nullable<RenderTargetTexture>;
  90940. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90941. /**
  90942. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90943. * @returns The render target texture if present otherwise, null
  90944. */
  90945. getShadowMap(): Nullable<RenderTargetTexture>;
  90946. /**
  90947. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90948. * @returns The render target texture if the shadow map is present otherwise, null
  90949. */
  90950. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90951. /**
  90952. * Gets the class name of that object
  90953. * @returns "ShadowGenerator"
  90954. */
  90955. getClassName(): string;
  90956. /**
  90957. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90958. * @param mesh Mesh to add
  90959. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90960. * @returns the Shadow Generator itself
  90961. */
  90962. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90963. /**
  90964. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90965. * @param mesh Mesh to remove
  90966. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90967. * @returns the Shadow Generator itself
  90968. */
  90969. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90970. /**
  90971. * Controls the extent to which the shadows fade out at the edge of the frustum
  90972. */
  90973. frustumEdgeFalloff: number;
  90974. protected _light: IShadowLight;
  90975. /**
  90976. * Returns the associated light object.
  90977. * @returns the light generating the shadow
  90978. */
  90979. getLight(): IShadowLight;
  90980. /**
  90981. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90982. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90983. * It might on the other hand introduce peter panning.
  90984. */
  90985. forceBackFacesOnly: boolean;
  90986. protected _scene: Scene;
  90987. protected _lightDirection: Vector3;
  90988. protected _effect: Effect;
  90989. protected _viewMatrix: Matrix;
  90990. protected _projectionMatrix: Matrix;
  90991. protected _transformMatrix: Matrix;
  90992. protected _cachedPosition: Vector3;
  90993. protected _cachedDirection: Vector3;
  90994. protected _cachedDefines: string;
  90995. protected _currentRenderID: number;
  90996. protected _boxBlurPostprocess: Nullable<PostProcess>;
  90997. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  90998. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  90999. protected _blurPostProcesses: PostProcess[];
  91000. protected _mapSize: number;
  91001. protected _currentFaceIndex: number;
  91002. protected _currentFaceIndexCache: number;
  91003. protected _textureType: number;
  91004. protected _defaultTextureMatrix: Matrix;
  91005. protected _storedUniqueId: Nullable<number>;
  91006. /** @hidden */
  91007. static _SceneComponentInitialization: (scene: Scene) => void;
  91008. /**
  91009. * Creates a ShadowGenerator object.
  91010. * A ShadowGenerator is the required tool to use the shadows.
  91011. * Each light casting shadows needs to use its own ShadowGenerator.
  91012. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  91013. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  91014. * @param light The light object generating the shadows.
  91015. * @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.
  91016. */
  91017. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  91018. protected _initializeGenerator(): void;
  91019. protected _createTargetRenderTexture(): void;
  91020. protected _initializeShadowMap(): void;
  91021. protected _initializeBlurRTTAndPostProcesses(): void;
  91022. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  91023. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  91024. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  91025. protected _applyFilterValues(): void;
  91026. /**
  91027. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91028. * @param onCompiled Callback triggered at the and of the effects compilation
  91029. * @param options Sets of optional options forcing the compilation with different modes
  91030. */
  91031. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  91032. useInstances: boolean;
  91033. }>): void;
  91034. /**
  91035. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91036. * @param options Sets of optional options forcing the compilation with different modes
  91037. * @returns A promise that resolves when the compilation completes
  91038. */
  91039. forceCompilationAsync(options?: Partial<{
  91040. useInstances: boolean;
  91041. }>): Promise<void>;
  91042. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  91043. /**
  91044. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  91045. * @param subMesh The submesh we want to render in the shadow map
  91046. * @param useInstances Defines wether will draw in the map using instances
  91047. * @returns true if ready otherwise, false
  91048. */
  91049. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  91050. /**
  91051. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  91052. * @param defines Defines of the material we want to update
  91053. * @param lightIndex Index of the light in the enabled light list of the material
  91054. */
  91055. prepareDefines(defines: any, lightIndex: number): void;
  91056. /**
  91057. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  91058. * defined in the generator but impacting the effect).
  91059. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  91060. * @param effect The effect we are binfing the information for
  91061. */
  91062. bindShadowLight(lightIndex: string, effect: Effect): void;
  91063. /**
  91064. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  91065. * (eq to shadow prjection matrix * light transform matrix)
  91066. * @returns The transform matrix used to create the shadow map
  91067. */
  91068. getTransformMatrix(): Matrix;
  91069. /**
  91070. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  91071. * Cube and 2D textures for instance.
  91072. */
  91073. recreateShadowMap(): void;
  91074. protected _disposeBlurPostProcesses(): void;
  91075. protected _disposeRTTandPostProcesses(): void;
  91076. /**
  91077. * Disposes the ShadowGenerator.
  91078. * Returns nothing.
  91079. */
  91080. dispose(): void;
  91081. /**
  91082. * Serializes the shadow generator setup to a json object.
  91083. * @returns The serialized JSON object
  91084. */
  91085. serialize(): any;
  91086. /**
  91087. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  91088. * @param parsedShadowGenerator The JSON object to parse
  91089. * @param scene The scene to create the shadow map for
  91090. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  91091. * @returns The parsed shadow generator
  91092. */
  91093. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  91094. }
  91095. }
  91096. declare module BABYLON {
  91097. /**
  91098. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  91099. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  91100. * 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.
  91101. */
  91102. export abstract class Light extends Node {
  91103. /**
  91104. * Falloff Default: light is falling off following the material specification:
  91105. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  91106. */
  91107. static readonly FALLOFF_DEFAULT: number;
  91108. /**
  91109. * Falloff Physical: light is falling off following the inverse squared distance law.
  91110. */
  91111. static readonly FALLOFF_PHYSICAL: number;
  91112. /**
  91113. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  91114. * to enhance interoperability with other engines.
  91115. */
  91116. static readonly FALLOFF_GLTF: number;
  91117. /**
  91118. * Falloff Standard: light is falling off like in the standard material
  91119. * to enhance interoperability with other materials.
  91120. */
  91121. static readonly FALLOFF_STANDARD: number;
  91122. /**
  91123. * If every light affecting the material is in this lightmapMode,
  91124. * material.lightmapTexture adds or multiplies
  91125. * (depends on material.useLightmapAsShadowmap)
  91126. * after every other light calculations.
  91127. */
  91128. static readonly LIGHTMAP_DEFAULT: number;
  91129. /**
  91130. * material.lightmapTexture as only diffuse lighting from this light
  91131. * adds only specular lighting from this light
  91132. * adds dynamic shadows
  91133. */
  91134. static readonly LIGHTMAP_SPECULAR: number;
  91135. /**
  91136. * material.lightmapTexture as only lighting
  91137. * no light calculation from this light
  91138. * only adds dynamic shadows from this light
  91139. */
  91140. static readonly LIGHTMAP_SHADOWSONLY: number;
  91141. /**
  91142. * Each light type uses the default quantity according to its type:
  91143. * point/spot lights use luminous intensity
  91144. * directional lights use illuminance
  91145. */
  91146. static readonly INTENSITYMODE_AUTOMATIC: number;
  91147. /**
  91148. * lumen (lm)
  91149. */
  91150. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  91151. /**
  91152. * candela (lm/sr)
  91153. */
  91154. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  91155. /**
  91156. * lux (lm/m^2)
  91157. */
  91158. static readonly INTENSITYMODE_ILLUMINANCE: number;
  91159. /**
  91160. * nit (cd/m^2)
  91161. */
  91162. static readonly INTENSITYMODE_LUMINANCE: number;
  91163. /**
  91164. * Light type const id of the point light.
  91165. */
  91166. static readonly LIGHTTYPEID_POINTLIGHT: number;
  91167. /**
  91168. * Light type const id of the directional light.
  91169. */
  91170. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  91171. /**
  91172. * Light type const id of the spot light.
  91173. */
  91174. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  91175. /**
  91176. * Light type const id of the hemispheric light.
  91177. */
  91178. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  91179. /**
  91180. * Diffuse gives the basic color to an object.
  91181. */
  91182. diffuse: Color3;
  91183. /**
  91184. * Specular produces a highlight color on an object.
  91185. * Note: This is note affecting PBR materials.
  91186. */
  91187. specular: Color3;
  91188. /**
  91189. * Defines the falloff type for this light. This lets overrriding how punctual light are
  91190. * falling off base on range or angle.
  91191. * This can be set to any values in Light.FALLOFF_x.
  91192. *
  91193. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  91194. * other types of materials.
  91195. */
  91196. falloffType: number;
  91197. /**
  91198. * Strength of the light.
  91199. * Note: By default it is define in the framework own unit.
  91200. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  91201. */
  91202. intensity: number;
  91203. private _range;
  91204. protected _inverseSquaredRange: number;
  91205. /**
  91206. * Defines how far from the source the light is impacting in scene units.
  91207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91208. */
  91209. get range(): number;
  91210. /**
  91211. * Defines how far from the source the light is impacting in scene units.
  91212. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91213. */
  91214. set range(value: number);
  91215. /**
  91216. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  91217. * of light.
  91218. */
  91219. private _photometricScale;
  91220. private _intensityMode;
  91221. /**
  91222. * Gets the photometric scale used to interpret the intensity.
  91223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91224. */
  91225. get intensityMode(): number;
  91226. /**
  91227. * Sets the photometric scale used to interpret the intensity.
  91228. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91229. */
  91230. set intensityMode(value: number);
  91231. private _radius;
  91232. /**
  91233. * Gets the light radius used by PBR Materials to simulate soft area lights.
  91234. */
  91235. get radius(): number;
  91236. /**
  91237. * sets the light radius used by PBR Materials to simulate soft area lights.
  91238. */
  91239. set radius(value: number);
  91240. private _renderPriority;
  91241. /**
  91242. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  91243. * exceeding the number allowed of the materials.
  91244. */
  91245. renderPriority: number;
  91246. private _shadowEnabled;
  91247. /**
  91248. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91249. * the current shadow generator.
  91250. */
  91251. get shadowEnabled(): boolean;
  91252. /**
  91253. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91254. * the current shadow generator.
  91255. */
  91256. set shadowEnabled(value: boolean);
  91257. private _includedOnlyMeshes;
  91258. /**
  91259. * Gets the only meshes impacted by this light.
  91260. */
  91261. get includedOnlyMeshes(): AbstractMesh[];
  91262. /**
  91263. * Sets the only meshes impacted by this light.
  91264. */
  91265. set includedOnlyMeshes(value: AbstractMesh[]);
  91266. private _excludedMeshes;
  91267. /**
  91268. * Gets the meshes not impacted by this light.
  91269. */
  91270. get excludedMeshes(): AbstractMesh[];
  91271. /**
  91272. * Sets the meshes not impacted by this light.
  91273. */
  91274. set excludedMeshes(value: AbstractMesh[]);
  91275. private _excludeWithLayerMask;
  91276. /**
  91277. * Gets the layer id use to find what meshes are not impacted by the light.
  91278. * Inactive if 0
  91279. */
  91280. get excludeWithLayerMask(): number;
  91281. /**
  91282. * Sets the layer id use to find what meshes are not impacted by the light.
  91283. * Inactive if 0
  91284. */
  91285. set excludeWithLayerMask(value: number);
  91286. private _includeOnlyWithLayerMask;
  91287. /**
  91288. * Gets the layer id use to find what meshes are impacted by the light.
  91289. * Inactive if 0
  91290. */
  91291. get includeOnlyWithLayerMask(): number;
  91292. /**
  91293. * Sets the layer id use to find what meshes are impacted by the light.
  91294. * Inactive if 0
  91295. */
  91296. set includeOnlyWithLayerMask(value: number);
  91297. private _lightmapMode;
  91298. /**
  91299. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91300. */
  91301. get lightmapMode(): number;
  91302. /**
  91303. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91304. */
  91305. set lightmapMode(value: number);
  91306. /**
  91307. * Shadow generator associted to the light.
  91308. * @hidden Internal use only.
  91309. */
  91310. _shadowGenerator: Nullable<IShadowGenerator>;
  91311. /**
  91312. * @hidden Internal use only.
  91313. */
  91314. _excludedMeshesIds: string[];
  91315. /**
  91316. * @hidden Internal use only.
  91317. */
  91318. _includedOnlyMeshesIds: string[];
  91319. /**
  91320. * The current light unifom buffer.
  91321. * @hidden Internal use only.
  91322. */
  91323. _uniformBuffer: UniformBuffer;
  91324. /** @hidden */
  91325. _renderId: number;
  91326. /**
  91327. * Creates a Light object in the scene.
  91328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  91329. * @param name The firendly name of the light
  91330. * @param scene The scene the light belongs too
  91331. */
  91332. constructor(name: string, scene: Scene);
  91333. protected abstract _buildUniformLayout(): void;
  91334. /**
  91335. * Sets the passed Effect "effect" with the Light information.
  91336. * @param effect The effect to update
  91337. * @param lightIndex The index of the light in the effect to update
  91338. * @returns The light
  91339. */
  91340. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  91341. /**
  91342. * Sets the passed Effect "effect" with the Light textures.
  91343. * @param effect The effect to update
  91344. * @param lightIndex The index of the light in the effect to update
  91345. * @returns The light
  91346. */
  91347. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  91348. /**
  91349. * Binds the lights information from the scene to the effect for the given mesh.
  91350. * @param lightIndex Light index
  91351. * @param scene The scene where the light belongs to
  91352. * @param effect The effect we are binding the data to
  91353. * @param useSpecular Defines if specular is supported
  91354. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  91355. */
  91356. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  91357. /**
  91358. * Sets the passed Effect "effect" with the Light information.
  91359. * @param effect The effect to update
  91360. * @param lightDataUniformName The uniform used to store light data (position or direction)
  91361. * @returns The light
  91362. */
  91363. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  91364. /**
  91365. * Returns the string "Light".
  91366. * @returns the class name
  91367. */
  91368. getClassName(): string;
  91369. /** @hidden */
  91370. readonly _isLight: boolean;
  91371. /**
  91372. * Converts the light information to a readable string for debug purpose.
  91373. * @param fullDetails Supports for multiple levels of logging within scene loading
  91374. * @returns the human readable light info
  91375. */
  91376. toString(fullDetails?: boolean): string;
  91377. /** @hidden */
  91378. protected _syncParentEnabledState(): void;
  91379. /**
  91380. * Set the enabled state of this node.
  91381. * @param value - the new enabled state
  91382. */
  91383. setEnabled(value: boolean): void;
  91384. /**
  91385. * Returns the Light associated shadow generator if any.
  91386. * @return the associated shadow generator.
  91387. */
  91388. getShadowGenerator(): Nullable<IShadowGenerator>;
  91389. /**
  91390. * Returns a Vector3, the absolute light position in the World.
  91391. * @returns the world space position of the light
  91392. */
  91393. getAbsolutePosition(): Vector3;
  91394. /**
  91395. * Specifies if the light will affect the passed mesh.
  91396. * @param mesh The mesh to test against the light
  91397. * @return true the mesh is affected otherwise, false.
  91398. */
  91399. canAffectMesh(mesh: AbstractMesh): boolean;
  91400. /**
  91401. * Sort function to order lights for rendering.
  91402. * @param a First Light object to compare to second.
  91403. * @param b Second Light object to compare first.
  91404. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  91405. */
  91406. static CompareLightsPriority(a: Light, b: Light): number;
  91407. /**
  91408. * Releases resources associated with this node.
  91409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91411. */
  91412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91413. /**
  91414. * Returns the light type ID (integer).
  91415. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  91416. */
  91417. getTypeID(): number;
  91418. /**
  91419. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  91420. * @returns the scaled intensity in intensity mode unit
  91421. */
  91422. getScaledIntensity(): number;
  91423. /**
  91424. * Returns a new Light object, named "name", from the current one.
  91425. * @param name The name of the cloned light
  91426. * @returns the new created light
  91427. */
  91428. clone(name: string): Nullable<Light>;
  91429. /**
  91430. * Serializes the current light into a Serialization object.
  91431. * @returns the serialized object.
  91432. */
  91433. serialize(): any;
  91434. /**
  91435. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  91436. * This new light is named "name" and added to the passed scene.
  91437. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  91438. * @param name The friendly name of the light
  91439. * @param scene The scene the new light will belong to
  91440. * @returns the constructor function
  91441. */
  91442. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  91443. /**
  91444. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  91445. * @param parsedLight The JSON representation of the light
  91446. * @param scene The scene to create the parsed light in
  91447. * @returns the created light after parsing
  91448. */
  91449. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  91450. private _hookArrayForExcluded;
  91451. private _hookArrayForIncludedOnly;
  91452. private _resyncMeshes;
  91453. /**
  91454. * Forces the meshes to update their light related information in their rendering used effects
  91455. * @hidden Internal Use Only
  91456. */
  91457. _markMeshesAsLightDirty(): void;
  91458. /**
  91459. * Recomputes the cached photometric scale if needed.
  91460. */
  91461. private _computePhotometricScale;
  91462. /**
  91463. * Returns the Photometric Scale according to the light type and intensity mode.
  91464. */
  91465. private _getPhotometricScale;
  91466. /**
  91467. * Reorder the light in the scene according to their defined priority.
  91468. * @hidden Internal Use Only
  91469. */
  91470. _reorderLightsInScene(): void;
  91471. /**
  91472. * Prepares the list of defines specific to the light type.
  91473. * @param defines the list of defines
  91474. * @param lightIndex defines the index of the light for the effect
  91475. */
  91476. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  91477. }
  91478. }
  91479. declare module BABYLON {
  91480. /**
  91481. * Interface used to define Action
  91482. */
  91483. export interface IAction {
  91484. /**
  91485. * Trigger for the action
  91486. */
  91487. trigger: number;
  91488. /** Options of the trigger */
  91489. triggerOptions: any;
  91490. /**
  91491. * Gets the trigger parameters
  91492. * @returns the trigger parameters
  91493. */
  91494. getTriggerParameter(): any;
  91495. /**
  91496. * Internal only - executes current action event
  91497. * @hidden
  91498. */
  91499. _executeCurrent(evt?: ActionEvent): void;
  91500. /**
  91501. * Serialize placeholder for child classes
  91502. * @param parent of child
  91503. * @returns the serialized object
  91504. */
  91505. serialize(parent: any): any;
  91506. /**
  91507. * Internal only
  91508. * @hidden
  91509. */
  91510. _prepare(): void;
  91511. /**
  91512. * Internal only - manager for action
  91513. * @hidden
  91514. */
  91515. _actionManager: AbstractActionManager;
  91516. /**
  91517. * Adds action to chain of actions, may be a DoNothingAction
  91518. * @param action defines the next action to execute
  91519. * @returns The action passed in
  91520. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91521. */
  91522. then(action: IAction): IAction;
  91523. }
  91524. /**
  91525. * The action to be carried out following a trigger
  91526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91527. */
  91528. export class Action implements IAction {
  91529. /** the trigger, with or without parameters, for the action */
  91530. triggerOptions: any;
  91531. /**
  91532. * Trigger for the action
  91533. */
  91534. trigger: number;
  91535. /**
  91536. * Internal only - manager for action
  91537. * @hidden
  91538. */
  91539. _actionManager: ActionManager;
  91540. private _nextActiveAction;
  91541. private _child;
  91542. private _condition?;
  91543. private _triggerParameter;
  91544. /**
  91545. * An event triggered prior to action being executed.
  91546. */
  91547. onBeforeExecuteObservable: Observable<Action>;
  91548. /**
  91549. * Creates a new Action
  91550. * @param triggerOptions the trigger, with or without parameters, for the action
  91551. * @param condition an optional determinant of action
  91552. */
  91553. constructor(
  91554. /** the trigger, with or without parameters, for the action */
  91555. triggerOptions: any, condition?: Condition);
  91556. /**
  91557. * Internal only
  91558. * @hidden
  91559. */
  91560. _prepare(): void;
  91561. /**
  91562. * Gets the trigger parameters
  91563. * @returns the trigger parameters
  91564. */
  91565. getTriggerParameter(): any;
  91566. /**
  91567. * Internal only - executes current action event
  91568. * @hidden
  91569. */
  91570. _executeCurrent(evt?: ActionEvent): void;
  91571. /**
  91572. * Execute placeholder for child classes
  91573. * @param evt optional action event
  91574. */
  91575. execute(evt?: ActionEvent): void;
  91576. /**
  91577. * Skips to next active action
  91578. */
  91579. skipToNextActiveAction(): void;
  91580. /**
  91581. * Adds action to chain of actions, may be a DoNothingAction
  91582. * @param action defines the next action to execute
  91583. * @returns The action passed in
  91584. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91585. */
  91586. then(action: Action): Action;
  91587. /**
  91588. * Internal only
  91589. * @hidden
  91590. */
  91591. _getProperty(propertyPath: string): string;
  91592. /**
  91593. * Internal only
  91594. * @hidden
  91595. */
  91596. _getEffectiveTarget(target: any, propertyPath: string): any;
  91597. /**
  91598. * Serialize placeholder for child classes
  91599. * @param parent of child
  91600. * @returns the serialized object
  91601. */
  91602. serialize(parent: any): any;
  91603. /**
  91604. * Internal only called by serialize
  91605. * @hidden
  91606. */
  91607. protected _serialize(serializedAction: any, parent?: any): any;
  91608. /**
  91609. * Internal only
  91610. * @hidden
  91611. */
  91612. static _SerializeValueAsString: (value: any) => string;
  91613. /**
  91614. * Internal only
  91615. * @hidden
  91616. */
  91617. static _GetTargetProperty: (target: Node | Scene) => {
  91618. name: string;
  91619. targetType: string;
  91620. value: string;
  91621. };
  91622. }
  91623. }
  91624. declare module BABYLON {
  91625. /**
  91626. * A Condition applied to an Action
  91627. */
  91628. export class Condition {
  91629. /**
  91630. * Internal only - manager for action
  91631. * @hidden
  91632. */
  91633. _actionManager: ActionManager;
  91634. /**
  91635. * Internal only
  91636. * @hidden
  91637. */
  91638. _evaluationId: number;
  91639. /**
  91640. * Internal only
  91641. * @hidden
  91642. */
  91643. _currentResult: boolean;
  91644. /**
  91645. * Creates a new Condition
  91646. * @param actionManager the manager of the action the condition is applied to
  91647. */
  91648. constructor(actionManager: ActionManager);
  91649. /**
  91650. * Check if the current condition is valid
  91651. * @returns a boolean
  91652. */
  91653. isValid(): boolean;
  91654. /**
  91655. * Internal only
  91656. * @hidden
  91657. */
  91658. _getProperty(propertyPath: string): string;
  91659. /**
  91660. * Internal only
  91661. * @hidden
  91662. */
  91663. _getEffectiveTarget(target: any, propertyPath: string): any;
  91664. /**
  91665. * Serialize placeholder for child classes
  91666. * @returns the serialized object
  91667. */
  91668. serialize(): any;
  91669. /**
  91670. * Internal only
  91671. * @hidden
  91672. */
  91673. protected _serialize(serializedCondition: any): any;
  91674. }
  91675. /**
  91676. * Defines specific conditional operators as extensions of Condition
  91677. */
  91678. export class ValueCondition extends Condition {
  91679. /** path to specify the property of the target the conditional operator uses */
  91680. propertyPath: string;
  91681. /** the value compared by the conditional operator against the current value of the property */
  91682. value: any;
  91683. /** the conditional operator, default ValueCondition.IsEqual */
  91684. operator: number;
  91685. /**
  91686. * Internal only
  91687. * @hidden
  91688. */
  91689. private static _IsEqual;
  91690. /**
  91691. * Internal only
  91692. * @hidden
  91693. */
  91694. private static _IsDifferent;
  91695. /**
  91696. * Internal only
  91697. * @hidden
  91698. */
  91699. private static _IsGreater;
  91700. /**
  91701. * Internal only
  91702. * @hidden
  91703. */
  91704. private static _IsLesser;
  91705. /**
  91706. * returns the number for IsEqual
  91707. */
  91708. static get IsEqual(): number;
  91709. /**
  91710. * Returns the number for IsDifferent
  91711. */
  91712. static get IsDifferent(): number;
  91713. /**
  91714. * Returns the number for IsGreater
  91715. */
  91716. static get IsGreater(): number;
  91717. /**
  91718. * Returns the number for IsLesser
  91719. */
  91720. static get IsLesser(): number;
  91721. /**
  91722. * Internal only The action manager for the condition
  91723. * @hidden
  91724. */
  91725. _actionManager: ActionManager;
  91726. /**
  91727. * Internal only
  91728. * @hidden
  91729. */
  91730. private _target;
  91731. /**
  91732. * Internal only
  91733. * @hidden
  91734. */
  91735. private _effectiveTarget;
  91736. /**
  91737. * Internal only
  91738. * @hidden
  91739. */
  91740. private _property;
  91741. /**
  91742. * Creates a new ValueCondition
  91743. * @param actionManager manager for the action the condition applies to
  91744. * @param target for the action
  91745. * @param propertyPath path to specify the property of the target the conditional operator uses
  91746. * @param value the value compared by the conditional operator against the current value of the property
  91747. * @param operator the conditional operator, default ValueCondition.IsEqual
  91748. */
  91749. constructor(actionManager: ActionManager, target: any,
  91750. /** path to specify the property of the target the conditional operator uses */
  91751. propertyPath: string,
  91752. /** the value compared by the conditional operator against the current value of the property */
  91753. value: any,
  91754. /** the conditional operator, default ValueCondition.IsEqual */
  91755. operator?: number);
  91756. /**
  91757. * Compares the given value with the property value for the specified conditional operator
  91758. * @returns the result of the comparison
  91759. */
  91760. isValid(): boolean;
  91761. /**
  91762. * Serialize the ValueCondition into a JSON compatible object
  91763. * @returns serialization object
  91764. */
  91765. serialize(): any;
  91766. /**
  91767. * Gets the name of the conditional operator for the ValueCondition
  91768. * @param operator the conditional operator
  91769. * @returns the name
  91770. */
  91771. static GetOperatorName(operator: number): string;
  91772. }
  91773. /**
  91774. * Defines a predicate condition as an extension of Condition
  91775. */
  91776. export class PredicateCondition extends Condition {
  91777. /** defines the predicate function used to validate the condition */
  91778. predicate: () => boolean;
  91779. /**
  91780. * Internal only - manager for action
  91781. * @hidden
  91782. */
  91783. _actionManager: ActionManager;
  91784. /**
  91785. * Creates a new PredicateCondition
  91786. * @param actionManager manager for the action the condition applies to
  91787. * @param predicate defines the predicate function used to validate the condition
  91788. */
  91789. constructor(actionManager: ActionManager,
  91790. /** defines the predicate function used to validate the condition */
  91791. predicate: () => boolean);
  91792. /**
  91793. * @returns the validity of the predicate condition
  91794. */
  91795. isValid(): boolean;
  91796. }
  91797. /**
  91798. * Defines a state condition as an extension of Condition
  91799. */
  91800. export class StateCondition extends Condition {
  91801. /** Value to compare with target state */
  91802. value: string;
  91803. /**
  91804. * Internal only - manager for action
  91805. * @hidden
  91806. */
  91807. _actionManager: ActionManager;
  91808. /**
  91809. * Internal only
  91810. * @hidden
  91811. */
  91812. private _target;
  91813. /**
  91814. * Creates a new StateCondition
  91815. * @param actionManager manager for the action the condition applies to
  91816. * @param target of the condition
  91817. * @param value to compare with target state
  91818. */
  91819. constructor(actionManager: ActionManager, target: any,
  91820. /** Value to compare with target state */
  91821. value: string);
  91822. /**
  91823. * Gets a boolean indicating if the current condition is met
  91824. * @returns the validity of the state
  91825. */
  91826. isValid(): boolean;
  91827. /**
  91828. * Serialize the StateCondition into a JSON compatible object
  91829. * @returns serialization object
  91830. */
  91831. serialize(): any;
  91832. }
  91833. }
  91834. declare module BABYLON {
  91835. /**
  91836. * This defines an action responsible to toggle a boolean once triggered.
  91837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91838. */
  91839. export class SwitchBooleanAction extends Action {
  91840. /**
  91841. * The path to the boolean property in the target object
  91842. */
  91843. propertyPath: string;
  91844. private _target;
  91845. private _effectiveTarget;
  91846. private _property;
  91847. /**
  91848. * Instantiate the action
  91849. * @param triggerOptions defines the trigger options
  91850. * @param target defines the object containing the boolean
  91851. * @param propertyPath defines the path to the boolean property in the target object
  91852. * @param condition defines the trigger related conditions
  91853. */
  91854. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91855. /** @hidden */
  91856. _prepare(): void;
  91857. /**
  91858. * Execute the action toggle the boolean value.
  91859. */
  91860. execute(): void;
  91861. /**
  91862. * Serializes the actions and its related information.
  91863. * @param parent defines the object to serialize in
  91864. * @returns the serialized object
  91865. */
  91866. serialize(parent: any): any;
  91867. }
  91868. /**
  91869. * This defines an action responsible to set a the state field of the target
  91870. * to a desired value once triggered.
  91871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91872. */
  91873. export class SetStateAction extends Action {
  91874. /**
  91875. * The value to store in the state field.
  91876. */
  91877. value: string;
  91878. private _target;
  91879. /**
  91880. * Instantiate the action
  91881. * @param triggerOptions defines the trigger options
  91882. * @param target defines the object containing the state property
  91883. * @param value defines the value to store in the state field
  91884. * @param condition defines the trigger related conditions
  91885. */
  91886. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91887. /**
  91888. * Execute the action and store the value on the target state property.
  91889. */
  91890. execute(): void;
  91891. /**
  91892. * Serializes the actions and its related information.
  91893. * @param parent defines the object to serialize in
  91894. * @returns the serialized object
  91895. */
  91896. serialize(parent: any): any;
  91897. }
  91898. /**
  91899. * This defines an action responsible to set a property of the target
  91900. * to a desired value once triggered.
  91901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91902. */
  91903. export class SetValueAction extends Action {
  91904. /**
  91905. * The path of the property to set in the target.
  91906. */
  91907. propertyPath: string;
  91908. /**
  91909. * The value to set in the property
  91910. */
  91911. value: any;
  91912. private _target;
  91913. private _effectiveTarget;
  91914. private _property;
  91915. /**
  91916. * Instantiate the action
  91917. * @param triggerOptions defines the trigger options
  91918. * @param target defines the object containing the property
  91919. * @param propertyPath defines the path of the property to set in the target
  91920. * @param value defines the value to set in the property
  91921. * @param condition defines the trigger related conditions
  91922. */
  91923. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91924. /** @hidden */
  91925. _prepare(): void;
  91926. /**
  91927. * Execute the action and set the targetted property to the desired value.
  91928. */
  91929. execute(): void;
  91930. /**
  91931. * Serializes the actions and its related information.
  91932. * @param parent defines the object to serialize in
  91933. * @returns the serialized object
  91934. */
  91935. serialize(parent: any): any;
  91936. }
  91937. /**
  91938. * This defines an action responsible to increment the target value
  91939. * to a desired value once triggered.
  91940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91941. */
  91942. export class IncrementValueAction extends Action {
  91943. /**
  91944. * The path of the property to increment in the target.
  91945. */
  91946. propertyPath: string;
  91947. /**
  91948. * The value we should increment the property by.
  91949. */
  91950. value: any;
  91951. private _target;
  91952. private _effectiveTarget;
  91953. private _property;
  91954. /**
  91955. * Instantiate the action
  91956. * @param triggerOptions defines the trigger options
  91957. * @param target defines the object containing the property
  91958. * @param propertyPath defines the path of the property to increment in the target
  91959. * @param value defines the value value we should increment the property by
  91960. * @param condition defines the trigger related conditions
  91961. */
  91962. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91963. /** @hidden */
  91964. _prepare(): void;
  91965. /**
  91966. * Execute the action and increment the target of the value amount.
  91967. */
  91968. execute(): void;
  91969. /**
  91970. * Serializes the actions and its related information.
  91971. * @param parent defines the object to serialize in
  91972. * @returns the serialized object
  91973. */
  91974. serialize(parent: any): any;
  91975. }
  91976. /**
  91977. * This defines an action responsible to start an animation once triggered.
  91978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91979. */
  91980. export class PlayAnimationAction extends Action {
  91981. /**
  91982. * Where the animation should start (animation frame)
  91983. */
  91984. from: number;
  91985. /**
  91986. * Where the animation should stop (animation frame)
  91987. */
  91988. to: number;
  91989. /**
  91990. * Define if the animation should loop or stop after the first play.
  91991. */
  91992. loop?: boolean;
  91993. private _target;
  91994. /**
  91995. * Instantiate the action
  91996. * @param triggerOptions defines the trigger options
  91997. * @param target defines the target animation or animation name
  91998. * @param from defines from where the animation should start (animation frame)
  91999. * @param end defines where the animation should stop (animation frame)
  92000. * @param loop defines if the animation should loop or stop after the first play
  92001. * @param condition defines the trigger related conditions
  92002. */
  92003. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  92004. /** @hidden */
  92005. _prepare(): void;
  92006. /**
  92007. * Execute the action and play the animation.
  92008. */
  92009. execute(): void;
  92010. /**
  92011. * Serializes the actions and its related information.
  92012. * @param parent defines the object to serialize in
  92013. * @returns the serialized object
  92014. */
  92015. serialize(parent: any): any;
  92016. }
  92017. /**
  92018. * This defines an action responsible to stop an animation once triggered.
  92019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92020. */
  92021. export class StopAnimationAction extends Action {
  92022. private _target;
  92023. /**
  92024. * Instantiate the action
  92025. * @param triggerOptions defines the trigger options
  92026. * @param target defines the target animation or animation name
  92027. * @param condition defines the trigger related conditions
  92028. */
  92029. constructor(triggerOptions: any, target: any, condition?: Condition);
  92030. /** @hidden */
  92031. _prepare(): void;
  92032. /**
  92033. * Execute the action and stop the animation.
  92034. */
  92035. execute(): void;
  92036. /**
  92037. * Serializes the actions and its related information.
  92038. * @param parent defines the object to serialize in
  92039. * @returns the serialized object
  92040. */
  92041. serialize(parent: any): any;
  92042. }
  92043. /**
  92044. * This defines an action responsible that does nothing once triggered.
  92045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92046. */
  92047. export class DoNothingAction extends Action {
  92048. /**
  92049. * Instantiate the action
  92050. * @param triggerOptions defines the trigger options
  92051. * @param condition defines the trigger related conditions
  92052. */
  92053. constructor(triggerOptions?: any, condition?: Condition);
  92054. /**
  92055. * Execute the action and do nothing.
  92056. */
  92057. execute(): void;
  92058. /**
  92059. * Serializes the actions and its related information.
  92060. * @param parent defines the object to serialize in
  92061. * @returns the serialized object
  92062. */
  92063. serialize(parent: any): any;
  92064. }
  92065. /**
  92066. * This defines an action responsible to trigger several actions once triggered.
  92067. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92068. */
  92069. export class CombineAction extends Action {
  92070. /**
  92071. * The list of aggregated animations to run.
  92072. */
  92073. children: Action[];
  92074. /**
  92075. * Instantiate the action
  92076. * @param triggerOptions defines the trigger options
  92077. * @param children defines the list of aggregated animations to run
  92078. * @param condition defines the trigger related conditions
  92079. */
  92080. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  92081. /** @hidden */
  92082. _prepare(): void;
  92083. /**
  92084. * Execute the action and executes all the aggregated actions.
  92085. */
  92086. execute(evt: ActionEvent): void;
  92087. /**
  92088. * Serializes the actions and its related information.
  92089. * @param parent defines the object to serialize in
  92090. * @returns the serialized object
  92091. */
  92092. serialize(parent: any): any;
  92093. }
  92094. /**
  92095. * This defines an action responsible to run code (external event) once triggered.
  92096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92097. */
  92098. export class ExecuteCodeAction extends Action {
  92099. /**
  92100. * The callback function to run.
  92101. */
  92102. func: (evt: ActionEvent) => void;
  92103. /**
  92104. * Instantiate the action
  92105. * @param triggerOptions defines the trigger options
  92106. * @param func defines the callback function to run
  92107. * @param condition defines the trigger related conditions
  92108. */
  92109. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  92110. /**
  92111. * Execute the action and run the attached code.
  92112. */
  92113. execute(evt: ActionEvent): void;
  92114. }
  92115. /**
  92116. * This defines an action responsible to set the parent property of the target once triggered.
  92117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92118. */
  92119. export class SetParentAction extends Action {
  92120. private _parent;
  92121. private _target;
  92122. /**
  92123. * Instantiate the action
  92124. * @param triggerOptions defines the trigger options
  92125. * @param target defines the target containing the parent property
  92126. * @param parent defines from where the animation should start (animation frame)
  92127. * @param condition defines the trigger related conditions
  92128. */
  92129. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  92130. /** @hidden */
  92131. _prepare(): void;
  92132. /**
  92133. * Execute the action and set the parent property.
  92134. */
  92135. execute(): void;
  92136. /**
  92137. * Serializes the actions and its related information.
  92138. * @param parent defines the object to serialize in
  92139. * @returns the serialized object
  92140. */
  92141. serialize(parent: any): any;
  92142. }
  92143. }
  92144. declare module BABYLON {
  92145. /**
  92146. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  92147. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  92148. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92149. */
  92150. export class ActionManager extends AbstractActionManager {
  92151. /**
  92152. * Nothing
  92153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92154. */
  92155. static readonly NothingTrigger: number;
  92156. /**
  92157. * On pick
  92158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92159. */
  92160. static readonly OnPickTrigger: number;
  92161. /**
  92162. * On left pick
  92163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92164. */
  92165. static readonly OnLeftPickTrigger: number;
  92166. /**
  92167. * On right pick
  92168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92169. */
  92170. static readonly OnRightPickTrigger: number;
  92171. /**
  92172. * On center pick
  92173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92174. */
  92175. static readonly OnCenterPickTrigger: number;
  92176. /**
  92177. * On pick down
  92178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92179. */
  92180. static readonly OnPickDownTrigger: number;
  92181. /**
  92182. * On double pick
  92183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92184. */
  92185. static readonly OnDoublePickTrigger: number;
  92186. /**
  92187. * On pick up
  92188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92189. */
  92190. static readonly OnPickUpTrigger: number;
  92191. /**
  92192. * On pick out.
  92193. * This trigger will only be raised if you also declared a OnPickDown
  92194. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92195. */
  92196. static readonly OnPickOutTrigger: number;
  92197. /**
  92198. * On long press
  92199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92200. */
  92201. static readonly OnLongPressTrigger: number;
  92202. /**
  92203. * On pointer over
  92204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92205. */
  92206. static readonly OnPointerOverTrigger: number;
  92207. /**
  92208. * On pointer out
  92209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92210. */
  92211. static readonly OnPointerOutTrigger: number;
  92212. /**
  92213. * On every frame
  92214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92215. */
  92216. static readonly OnEveryFrameTrigger: number;
  92217. /**
  92218. * On intersection enter
  92219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92220. */
  92221. static readonly OnIntersectionEnterTrigger: number;
  92222. /**
  92223. * On intersection exit
  92224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92225. */
  92226. static readonly OnIntersectionExitTrigger: number;
  92227. /**
  92228. * On key down
  92229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92230. */
  92231. static readonly OnKeyDownTrigger: number;
  92232. /**
  92233. * On key up
  92234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92235. */
  92236. static readonly OnKeyUpTrigger: number;
  92237. private _scene;
  92238. /**
  92239. * Creates a new action manager
  92240. * @param scene defines the hosting scene
  92241. */
  92242. constructor(scene: Scene);
  92243. /**
  92244. * Releases all associated resources
  92245. */
  92246. dispose(): void;
  92247. /**
  92248. * Gets hosting scene
  92249. * @returns the hosting scene
  92250. */
  92251. getScene(): Scene;
  92252. /**
  92253. * Does this action manager handles actions of any of the given triggers
  92254. * @param triggers defines the triggers to be tested
  92255. * @return a boolean indicating whether one (or more) of the triggers is handled
  92256. */
  92257. hasSpecificTriggers(triggers: number[]): boolean;
  92258. /**
  92259. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92260. * speed.
  92261. * @param triggerA defines the trigger to be tested
  92262. * @param triggerB defines the trigger to be tested
  92263. * @return a boolean indicating whether one (or more) of the triggers is handled
  92264. */
  92265. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92266. /**
  92267. * Does this action manager handles actions of a given trigger
  92268. * @param trigger defines the trigger to be tested
  92269. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92270. * @return whether the trigger is handled
  92271. */
  92272. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92273. /**
  92274. * Does this action manager has pointer triggers
  92275. */
  92276. get hasPointerTriggers(): boolean;
  92277. /**
  92278. * Does this action manager has pick triggers
  92279. */
  92280. get hasPickTriggers(): boolean;
  92281. /**
  92282. * Registers an action to this action manager
  92283. * @param action defines the action to be registered
  92284. * @return the action amended (prepared) after registration
  92285. */
  92286. registerAction(action: IAction): Nullable<IAction>;
  92287. /**
  92288. * Unregisters an action to this action manager
  92289. * @param action defines the action to be unregistered
  92290. * @return a boolean indicating whether the action has been unregistered
  92291. */
  92292. unregisterAction(action: IAction): Boolean;
  92293. /**
  92294. * Process a specific trigger
  92295. * @param trigger defines the trigger to process
  92296. * @param evt defines the event details to be processed
  92297. */
  92298. processTrigger(trigger: number, evt?: IActionEvent): void;
  92299. /** @hidden */
  92300. _getEffectiveTarget(target: any, propertyPath: string): any;
  92301. /** @hidden */
  92302. _getProperty(propertyPath: string): string;
  92303. /**
  92304. * Serialize this manager to a JSON object
  92305. * @param name defines the property name to store this manager
  92306. * @returns a JSON representation of this manager
  92307. */
  92308. serialize(name: string): any;
  92309. /**
  92310. * Creates a new ActionManager from a JSON data
  92311. * @param parsedActions defines the JSON data to read from
  92312. * @param object defines the hosting mesh
  92313. * @param scene defines the hosting scene
  92314. */
  92315. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  92316. /**
  92317. * Get a trigger name by index
  92318. * @param trigger defines the trigger index
  92319. * @returns a trigger name
  92320. */
  92321. static GetTriggerName(trigger: number): string;
  92322. }
  92323. }
  92324. declare module BABYLON {
  92325. /**
  92326. * Class used to represent a sprite
  92327. * @see http://doc.babylonjs.com/babylon101/sprites
  92328. */
  92329. export class Sprite {
  92330. /** defines the name */
  92331. name: string;
  92332. /** Gets or sets the current world position */
  92333. position: Vector3;
  92334. /** Gets or sets the main color */
  92335. color: Color4;
  92336. /** Gets or sets the width */
  92337. width: number;
  92338. /** Gets or sets the height */
  92339. height: number;
  92340. /** Gets or sets rotation angle */
  92341. angle: number;
  92342. /** Gets or sets the cell index in the sprite sheet */
  92343. cellIndex: number;
  92344. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  92345. cellRef: string;
  92346. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  92347. invertU: number;
  92348. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  92349. invertV: number;
  92350. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  92351. disposeWhenFinishedAnimating: boolean;
  92352. /** Gets the list of attached animations */
  92353. animations: Animation[];
  92354. /** Gets or sets a boolean indicating if the sprite can be picked */
  92355. isPickable: boolean;
  92356. /**
  92357. * Gets or sets the associated action manager
  92358. */
  92359. actionManager: Nullable<ActionManager>;
  92360. private _animationStarted;
  92361. private _loopAnimation;
  92362. private _fromIndex;
  92363. private _toIndex;
  92364. private _delay;
  92365. private _direction;
  92366. private _manager;
  92367. private _time;
  92368. private _onAnimationEnd;
  92369. /**
  92370. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  92371. */
  92372. isVisible: boolean;
  92373. /**
  92374. * Gets or sets the sprite size
  92375. */
  92376. get size(): number;
  92377. set size(value: number);
  92378. /**
  92379. * Creates a new Sprite
  92380. * @param name defines the name
  92381. * @param manager defines the manager
  92382. */
  92383. constructor(
  92384. /** defines the name */
  92385. name: string, manager: ISpriteManager);
  92386. /**
  92387. * Starts an animation
  92388. * @param from defines the initial key
  92389. * @param to defines the end key
  92390. * @param loop defines if the animation must loop
  92391. * @param delay defines the start delay (in ms)
  92392. * @param onAnimationEnd defines a callback to call when animation ends
  92393. */
  92394. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  92395. /** Stops current animation (if any) */
  92396. stopAnimation(): void;
  92397. /** @hidden */
  92398. _animate(deltaTime: number): void;
  92399. /** Release associated resources */
  92400. dispose(): void;
  92401. }
  92402. }
  92403. declare module BABYLON {
  92404. /**
  92405. * Information about the result of picking within a scene
  92406. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  92407. */
  92408. export class PickingInfo {
  92409. /** @hidden */
  92410. _pickingUnavailable: boolean;
  92411. /**
  92412. * If the pick collided with an object
  92413. */
  92414. hit: boolean;
  92415. /**
  92416. * Distance away where the pick collided
  92417. */
  92418. distance: number;
  92419. /**
  92420. * The location of pick collision
  92421. */
  92422. pickedPoint: Nullable<Vector3>;
  92423. /**
  92424. * The mesh corresponding the the pick collision
  92425. */
  92426. pickedMesh: Nullable<AbstractMesh>;
  92427. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  92428. bu: number;
  92429. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  92430. bv: number;
  92431. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  92432. faceId: number;
  92433. /** Id of the the submesh that was picked */
  92434. subMeshId: number;
  92435. /** If a sprite was picked, this will be the sprite the pick collided with */
  92436. pickedSprite: Nullable<Sprite>;
  92437. /**
  92438. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  92439. */
  92440. originMesh: Nullable<AbstractMesh>;
  92441. /**
  92442. * The ray that was used to perform the picking.
  92443. */
  92444. ray: Nullable<Ray>;
  92445. /**
  92446. * Gets the normal correspodning to the face the pick collided with
  92447. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  92448. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  92449. * @returns The normal correspodning to the face the pick collided with
  92450. */
  92451. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  92452. /**
  92453. * Gets the texture coordinates of where the pick occured
  92454. * @returns the vector containing the coordnates of the texture
  92455. */
  92456. getTextureCoordinates(): Nullable<Vector2>;
  92457. }
  92458. }
  92459. declare module BABYLON {
  92460. /**
  92461. * Gather the list of pointer event types as constants.
  92462. */
  92463. export class PointerEventTypes {
  92464. /**
  92465. * 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.
  92466. */
  92467. static readonly POINTERDOWN: number;
  92468. /**
  92469. * The pointerup event is fired when a pointer is no longer active.
  92470. */
  92471. static readonly POINTERUP: number;
  92472. /**
  92473. * The pointermove event is fired when a pointer changes coordinates.
  92474. */
  92475. static readonly POINTERMOVE: number;
  92476. /**
  92477. * The pointerwheel event is fired when a mouse wheel has been rotated.
  92478. */
  92479. static readonly POINTERWHEEL: number;
  92480. /**
  92481. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  92482. */
  92483. static readonly POINTERPICK: number;
  92484. /**
  92485. * The pointertap event is fired when a the object has been touched and released without drag.
  92486. */
  92487. static readonly POINTERTAP: number;
  92488. /**
  92489. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  92490. */
  92491. static readonly POINTERDOUBLETAP: number;
  92492. }
  92493. /**
  92494. * Base class of pointer info types.
  92495. */
  92496. export class PointerInfoBase {
  92497. /**
  92498. * Defines the type of event (PointerEventTypes)
  92499. */
  92500. type: number;
  92501. /**
  92502. * Defines the related dom event
  92503. */
  92504. event: PointerEvent | MouseWheelEvent;
  92505. /**
  92506. * Instantiates the base class of pointers info.
  92507. * @param type Defines the type of event (PointerEventTypes)
  92508. * @param event Defines the related dom event
  92509. */
  92510. constructor(
  92511. /**
  92512. * Defines the type of event (PointerEventTypes)
  92513. */
  92514. type: number,
  92515. /**
  92516. * Defines the related dom event
  92517. */
  92518. event: PointerEvent | MouseWheelEvent);
  92519. }
  92520. /**
  92521. * This class is used to store pointer related info for the onPrePointerObservable event.
  92522. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  92523. */
  92524. export class PointerInfoPre extends PointerInfoBase {
  92525. /**
  92526. * Ray from a pointer if availible (eg. 6dof controller)
  92527. */
  92528. ray: Nullable<Ray>;
  92529. /**
  92530. * Defines the local position of the pointer on the canvas.
  92531. */
  92532. localPosition: Vector2;
  92533. /**
  92534. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  92535. */
  92536. skipOnPointerObservable: boolean;
  92537. /**
  92538. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  92539. * @param type Defines the type of event (PointerEventTypes)
  92540. * @param event Defines the related dom event
  92541. * @param localX Defines the local x coordinates of the pointer when the event occured
  92542. * @param localY Defines the local y coordinates of the pointer when the event occured
  92543. */
  92544. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  92545. }
  92546. /**
  92547. * This type contains all the data related to a pointer event in Babylon.js.
  92548. * 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.
  92549. */
  92550. export class PointerInfo extends PointerInfoBase {
  92551. /**
  92552. * Defines the picking info associated to the info (if any)\
  92553. */
  92554. pickInfo: Nullable<PickingInfo>;
  92555. /**
  92556. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  92557. * @param type Defines the type of event (PointerEventTypes)
  92558. * @param event Defines the related dom event
  92559. * @param pickInfo Defines the picking info associated to the info (if any)\
  92560. */
  92561. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  92562. /**
  92563. * Defines the picking info associated to the info (if any)\
  92564. */
  92565. pickInfo: Nullable<PickingInfo>);
  92566. }
  92567. /**
  92568. * Data relating to a touch event on the screen.
  92569. */
  92570. export interface PointerTouch {
  92571. /**
  92572. * X coordinate of touch.
  92573. */
  92574. x: number;
  92575. /**
  92576. * Y coordinate of touch.
  92577. */
  92578. y: number;
  92579. /**
  92580. * Id of touch. Unique for each finger.
  92581. */
  92582. pointerId: number;
  92583. /**
  92584. * Event type passed from DOM.
  92585. */
  92586. type: any;
  92587. }
  92588. }
  92589. declare module BABYLON {
  92590. /**
  92591. * Manage the mouse inputs to control the movement of a free camera.
  92592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92593. */
  92594. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  92595. /**
  92596. * Define if touch is enabled in the mouse input
  92597. */
  92598. touchEnabled: boolean;
  92599. /**
  92600. * Defines the camera the input is attached to.
  92601. */
  92602. camera: FreeCamera;
  92603. /**
  92604. * Defines the buttons associated with the input to handle camera move.
  92605. */
  92606. buttons: number[];
  92607. /**
  92608. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  92609. */
  92610. angularSensibility: number;
  92611. private _pointerInput;
  92612. private _onMouseMove;
  92613. private _observer;
  92614. private previousPosition;
  92615. /**
  92616. * Observable for when a pointer move event occurs containing the move offset
  92617. */
  92618. onPointerMovedObservable: Observable<{
  92619. offsetX: number;
  92620. offsetY: number;
  92621. }>;
  92622. /**
  92623. * @hidden
  92624. * If the camera should be rotated automatically based on pointer movement
  92625. */
  92626. _allowCameraRotation: boolean;
  92627. /**
  92628. * Manage the mouse inputs to control the movement of a free camera.
  92629. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92630. * @param touchEnabled Defines if touch is enabled or not
  92631. */
  92632. constructor(
  92633. /**
  92634. * Define if touch is enabled in the mouse input
  92635. */
  92636. touchEnabled?: boolean);
  92637. /**
  92638. * Attach the input controls to a specific dom element to get the input from.
  92639. * @param element Defines the element the controls should be listened from
  92640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92641. */
  92642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92643. /**
  92644. * Called on JS contextmenu event.
  92645. * Override this method to provide functionality.
  92646. */
  92647. protected onContextMenu(evt: PointerEvent): void;
  92648. /**
  92649. * Detach the current controls from the specified dom element.
  92650. * @param element Defines the element to stop listening the inputs from
  92651. */
  92652. detachControl(element: Nullable<HTMLElement>): void;
  92653. /**
  92654. * Gets the class name of the current intput.
  92655. * @returns the class name
  92656. */
  92657. getClassName(): string;
  92658. /**
  92659. * Get the friendly name associated with the input class.
  92660. * @returns the input friendly name
  92661. */
  92662. getSimpleName(): string;
  92663. }
  92664. }
  92665. declare module BABYLON {
  92666. /**
  92667. * Manage the touch inputs to control the movement of a free camera.
  92668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92669. */
  92670. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  92671. /**
  92672. * Defines the camera the input is attached to.
  92673. */
  92674. camera: FreeCamera;
  92675. /**
  92676. * Defines the touch sensibility for rotation.
  92677. * The higher the faster.
  92678. */
  92679. touchAngularSensibility: number;
  92680. /**
  92681. * Defines the touch sensibility for move.
  92682. * The higher the faster.
  92683. */
  92684. touchMoveSensibility: number;
  92685. private _offsetX;
  92686. private _offsetY;
  92687. private _pointerPressed;
  92688. private _pointerInput;
  92689. private _observer;
  92690. private _onLostFocus;
  92691. /**
  92692. * Attach the input controls to a specific dom element to get the input from.
  92693. * @param element Defines the element the controls should be listened from
  92694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92695. */
  92696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92697. /**
  92698. * Detach the current controls from the specified dom element.
  92699. * @param element Defines the element to stop listening the inputs from
  92700. */
  92701. detachControl(element: Nullable<HTMLElement>): void;
  92702. /**
  92703. * Update the current camera state depending on the inputs that have been used this frame.
  92704. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92705. */
  92706. checkInputs(): void;
  92707. /**
  92708. * Gets the class name of the current intput.
  92709. * @returns the class name
  92710. */
  92711. getClassName(): string;
  92712. /**
  92713. * Get the friendly name associated with the input class.
  92714. * @returns the input friendly name
  92715. */
  92716. getSimpleName(): string;
  92717. }
  92718. }
  92719. declare module BABYLON {
  92720. /**
  92721. * Default Inputs manager for the FreeCamera.
  92722. * It groups all the default supported inputs for ease of use.
  92723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92724. */
  92725. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  92726. /**
  92727. * @hidden
  92728. */
  92729. _mouseInput: Nullable<FreeCameraMouseInput>;
  92730. /**
  92731. * Instantiates a new FreeCameraInputsManager.
  92732. * @param camera Defines the camera the inputs belong to
  92733. */
  92734. constructor(camera: FreeCamera);
  92735. /**
  92736. * Add keyboard input support to the input manager.
  92737. * @returns the current input manager
  92738. */
  92739. addKeyboard(): FreeCameraInputsManager;
  92740. /**
  92741. * Add mouse input support to the input manager.
  92742. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  92743. * @returns the current input manager
  92744. */
  92745. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  92746. /**
  92747. * Removes the mouse input support from the manager
  92748. * @returns the current input manager
  92749. */
  92750. removeMouse(): FreeCameraInputsManager;
  92751. /**
  92752. * Add touch input support to the input manager.
  92753. * @returns the current input manager
  92754. */
  92755. addTouch(): FreeCameraInputsManager;
  92756. /**
  92757. * Remove all attached input methods from a camera
  92758. */
  92759. clear(): void;
  92760. }
  92761. }
  92762. declare module BABYLON {
  92763. /**
  92764. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92765. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  92766. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92767. */
  92768. export class FreeCamera extends TargetCamera {
  92769. /**
  92770. * Define the collision ellipsoid of the camera.
  92771. * This is helpful to simulate a camera body like the player body around the camera
  92772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92773. */
  92774. ellipsoid: Vector3;
  92775. /**
  92776. * Define an offset for the position of the ellipsoid around the camera.
  92777. * This can be helpful to determine the center of the body near the gravity center of the body
  92778. * instead of its head.
  92779. */
  92780. ellipsoidOffset: Vector3;
  92781. /**
  92782. * Enable or disable collisions of the camera with the rest of the scene objects.
  92783. */
  92784. checkCollisions: boolean;
  92785. /**
  92786. * Enable or disable gravity on the camera.
  92787. */
  92788. applyGravity: boolean;
  92789. /**
  92790. * Define the input manager associated to the camera.
  92791. */
  92792. inputs: FreeCameraInputsManager;
  92793. /**
  92794. * Gets the input sensibility for a mouse input. (default is 2000.0)
  92795. * Higher values reduce sensitivity.
  92796. */
  92797. get angularSensibility(): number;
  92798. /**
  92799. * Sets the input sensibility for a mouse input. (default is 2000.0)
  92800. * Higher values reduce sensitivity.
  92801. */
  92802. set angularSensibility(value: number);
  92803. /**
  92804. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  92805. */
  92806. get keysUp(): number[];
  92807. set keysUp(value: number[]);
  92808. /**
  92809. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  92810. */
  92811. get keysUpward(): number[];
  92812. set keysUpward(value: number[]);
  92813. /**
  92814. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  92815. */
  92816. get keysDown(): number[];
  92817. set keysDown(value: number[]);
  92818. /**
  92819. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92820. */
  92821. get keysDownward(): number[];
  92822. set keysDownward(value: number[]);
  92823. /**
  92824. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92825. */
  92826. get keysLeft(): number[];
  92827. set keysLeft(value: number[]);
  92828. /**
  92829. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92830. */
  92831. get keysRight(): number[];
  92832. set keysRight(value: number[]);
  92833. /**
  92834. * Event raised when the camera collide with a mesh in the scene.
  92835. */
  92836. onCollide: (collidedMesh: AbstractMesh) => void;
  92837. private _collider;
  92838. private _needMoveForGravity;
  92839. private _oldPosition;
  92840. private _diffPosition;
  92841. private _newPosition;
  92842. /** @hidden */
  92843. _localDirection: Vector3;
  92844. /** @hidden */
  92845. _transformedDirection: Vector3;
  92846. /**
  92847. * Instantiates a Free Camera.
  92848. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92849. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92850. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92851. * @param name Define the name of the camera in the scene
  92852. * @param position Define the start position of the camera in the scene
  92853. * @param scene Define the scene the camera belongs to
  92854. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92855. */
  92856. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92857. /**
  92858. * Attached controls to the current camera.
  92859. * @param element Defines the element the controls should be listened from
  92860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92861. */
  92862. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92863. /**
  92864. * Detach the current controls from the camera.
  92865. * The camera will stop reacting to inputs.
  92866. * @param element Defines the element to stop listening the inputs from
  92867. */
  92868. detachControl(element: HTMLElement): void;
  92869. private _collisionMask;
  92870. /**
  92871. * Define a collision mask to limit the list of object the camera can collide with
  92872. */
  92873. get collisionMask(): number;
  92874. set collisionMask(mask: number);
  92875. /** @hidden */
  92876. _collideWithWorld(displacement: Vector3): void;
  92877. private _onCollisionPositionChange;
  92878. /** @hidden */
  92879. _checkInputs(): void;
  92880. /** @hidden */
  92881. _decideIfNeedsToMove(): boolean;
  92882. /** @hidden */
  92883. _updatePosition(): void;
  92884. /**
  92885. * Destroy the camera and release the current resources hold by it.
  92886. */
  92887. dispose(): void;
  92888. /**
  92889. * Gets the current object class name.
  92890. * @return the class name
  92891. */
  92892. getClassName(): string;
  92893. }
  92894. }
  92895. declare module BABYLON {
  92896. /**
  92897. * Represents a gamepad control stick position
  92898. */
  92899. export class StickValues {
  92900. /**
  92901. * The x component of the control stick
  92902. */
  92903. x: number;
  92904. /**
  92905. * The y component of the control stick
  92906. */
  92907. y: number;
  92908. /**
  92909. * Initializes the gamepad x and y control stick values
  92910. * @param x The x component of the gamepad control stick value
  92911. * @param y The y component of the gamepad control stick value
  92912. */
  92913. constructor(
  92914. /**
  92915. * The x component of the control stick
  92916. */
  92917. x: number,
  92918. /**
  92919. * The y component of the control stick
  92920. */
  92921. y: number);
  92922. }
  92923. /**
  92924. * An interface which manages callbacks for gamepad button changes
  92925. */
  92926. export interface GamepadButtonChanges {
  92927. /**
  92928. * Called when a gamepad has been changed
  92929. */
  92930. changed: boolean;
  92931. /**
  92932. * Called when a gamepad press event has been triggered
  92933. */
  92934. pressChanged: boolean;
  92935. /**
  92936. * Called when a touch event has been triggered
  92937. */
  92938. touchChanged: boolean;
  92939. /**
  92940. * Called when a value has changed
  92941. */
  92942. valueChanged: boolean;
  92943. }
  92944. /**
  92945. * Represents a gamepad
  92946. */
  92947. export class Gamepad {
  92948. /**
  92949. * The id of the gamepad
  92950. */
  92951. id: string;
  92952. /**
  92953. * The index of the gamepad
  92954. */
  92955. index: number;
  92956. /**
  92957. * The browser gamepad
  92958. */
  92959. browserGamepad: any;
  92960. /**
  92961. * Specifies what type of gamepad this represents
  92962. */
  92963. type: number;
  92964. private _leftStick;
  92965. private _rightStick;
  92966. /** @hidden */
  92967. _isConnected: boolean;
  92968. private _leftStickAxisX;
  92969. private _leftStickAxisY;
  92970. private _rightStickAxisX;
  92971. private _rightStickAxisY;
  92972. /**
  92973. * Triggered when the left control stick has been changed
  92974. */
  92975. private _onleftstickchanged;
  92976. /**
  92977. * Triggered when the right control stick has been changed
  92978. */
  92979. private _onrightstickchanged;
  92980. /**
  92981. * Represents a gamepad controller
  92982. */
  92983. static GAMEPAD: number;
  92984. /**
  92985. * Represents a generic controller
  92986. */
  92987. static GENERIC: number;
  92988. /**
  92989. * Represents an XBox controller
  92990. */
  92991. static XBOX: number;
  92992. /**
  92993. * Represents a pose-enabled controller
  92994. */
  92995. static POSE_ENABLED: number;
  92996. /**
  92997. * Represents an Dual Shock controller
  92998. */
  92999. static DUALSHOCK: number;
  93000. /**
  93001. * Specifies whether the left control stick should be Y-inverted
  93002. */
  93003. protected _invertLeftStickY: boolean;
  93004. /**
  93005. * Specifies if the gamepad has been connected
  93006. */
  93007. get isConnected(): boolean;
  93008. /**
  93009. * Initializes the gamepad
  93010. * @param id The id of the gamepad
  93011. * @param index The index of the gamepad
  93012. * @param browserGamepad The browser gamepad
  93013. * @param leftStickX The x component of the left joystick
  93014. * @param leftStickY The y component of the left joystick
  93015. * @param rightStickX The x component of the right joystick
  93016. * @param rightStickY The y component of the right joystick
  93017. */
  93018. constructor(
  93019. /**
  93020. * The id of the gamepad
  93021. */
  93022. id: string,
  93023. /**
  93024. * The index of the gamepad
  93025. */
  93026. index: number,
  93027. /**
  93028. * The browser gamepad
  93029. */
  93030. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  93031. /**
  93032. * Callback triggered when the left joystick has changed
  93033. * @param callback
  93034. */
  93035. onleftstickchanged(callback: (values: StickValues) => void): void;
  93036. /**
  93037. * Callback triggered when the right joystick has changed
  93038. * @param callback
  93039. */
  93040. onrightstickchanged(callback: (values: StickValues) => void): void;
  93041. /**
  93042. * Gets the left joystick
  93043. */
  93044. get leftStick(): StickValues;
  93045. /**
  93046. * Sets the left joystick values
  93047. */
  93048. set leftStick(newValues: StickValues);
  93049. /**
  93050. * Gets the right joystick
  93051. */
  93052. get rightStick(): StickValues;
  93053. /**
  93054. * Sets the right joystick value
  93055. */
  93056. set rightStick(newValues: StickValues);
  93057. /**
  93058. * Updates the gamepad joystick positions
  93059. */
  93060. update(): void;
  93061. /**
  93062. * Disposes the gamepad
  93063. */
  93064. dispose(): void;
  93065. }
  93066. /**
  93067. * Represents a generic gamepad
  93068. */
  93069. export class GenericPad extends Gamepad {
  93070. private _buttons;
  93071. private _onbuttondown;
  93072. private _onbuttonup;
  93073. /**
  93074. * Observable triggered when a button has been pressed
  93075. */
  93076. onButtonDownObservable: Observable<number>;
  93077. /**
  93078. * Observable triggered when a button has been released
  93079. */
  93080. onButtonUpObservable: Observable<number>;
  93081. /**
  93082. * Callback triggered when a button has been pressed
  93083. * @param callback Called when a button has been pressed
  93084. */
  93085. onbuttondown(callback: (buttonPressed: number) => void): void;
  93086. /**
  93087. * Callback triggered when a button has been released
  93088. * @param callback Called when a button has been released
  93089. */
  93090. onbuttonup(callback: (buttonReleased: number) => void): void;
  93091. /**
  93092. * Initializes the generic gamepad
  93093. * @param id The id of the generic gamepad
  93094. * @param index The index of the generic gamepad
  93095. * @param browserGamepad The browser gamepad
  93096. */
  93097. constructor(id: string, index: number, browserGamepad: any);
  93098. private _setButtonValue;
  93099. /**
  93100. * Updates the generic gamepad
  93101. */
  93102. update(): void;
  93103. /**
  93104. * Disposes the generic gamepad
  93105. */
  93106. dispose(): void;
  93107. }
  93108. }
  93109. declare module BABYLON {
  93110. /**
  93111. * Defines the types of pose enabled controllers that are supported
  93112. */
  93113. export enum PoseEnabledControllerType {
  93114. /**
  93115. * HTC Vive
  93116. */
  93117. VIVE = 0,
  93118. /**
  93119. * Oculus Rift
  93120. */
  93121. OCULUS = 1,
  93122. /**
  93123. * Windows mixed reality
  93124. */
  93125. WINDOWS = 2,
  93126. /**
  93127. * Samsung gear VR
  93128. */
  93129. GEAR_VR = 3,
  93130. /**
  93131. * Google Daydream
  93132. */
  93133. DAYDREAM = 4,
  93134. /**
  93135. * Generic
  93136. */
  93137. GENERIC = 5
  93138. }
  93139. /**
  93140. * Defines the MutableGamepadButton interface for the state of a gamepad button
  93141. */
  93142. export interface MutableGamepadButton {
  93143. /**
  93144. * Value of the button/trigger
  93145. */
  93146. value: number;
  93147. /**
  93148. * If the button/trigger is currently touched
  93149. */
  93150. touched: boolean;
  93151. /**
  93152. * If the button/trigger is currently pressed
  93153. */
  93154. pressed: boolean;
  93155. }
  93156. /**
  93157. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  93158. * @hidden
  93159. */
  93160. export interface ExtendedGamepadButton extends GamepadButton {
  93161. /**
  93162. * If the button/trigger is currently pressed
  93163. */
  93164. readonly pressed: boolean;
  93165. /**
  93166. * If the button/trigger is currently touched
  93167. */
  93168. readonly touched: boolean;
  93169. /**
  93170. * Value of the button/trigger
  93171. */
  93172. readonly value: number;
  93173. }
  93174. /** @hidden */
  93175. export interface _GamePadFactory {
  93176. /**
  93177. * Returns whether or not the current gamepad can be created for this type of controller.
  93178. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93179. * @returns true if it can be created, otherwise false
  93180. */
  93181. canCreate(gamepadInfo: any): boolean;
  93182. /**
  93183. * Creates a new instance of the Gamepad.
  93184. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93185. * @returns the new gamepad instance
  93186. */
  93187. create(gamepadInfo: any): Gamepad;
  93188. }
  93189. /**
  93190. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93191. */
  93192. export class PoseEnabledControllerHelper {
  93193. /** @hidden */
  93194. static _ControllerFactories: _GamePadFactory[];
  93195. /** @hidden */
  93196. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  93197. /**
  93198. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93199. * @param vrGamepad the gamepad to initialized
  93200. * @returns a vr controller of the type the gamepad identified as
  93201. */
  93202. static InitiateController(vrGamepad: any): Gamepad;
  93203. }
  93204. /**
  93205. * Defines the PoseEnabledController object that contains state of a vr capable controller
  93206. */
  93207. export class PoseEnabledController extends Gamepad implements PoseControlled {
  93208. /**
  93209. * If the controller is used in a webXR session
  93210. */
  93211. isXR: boolean;
  93212. private _deviceRoomPosition;
  93213. private _deviceRoomRotationQuaternion;
  93214. /**
  93215. * The device position in babylon space
  93216. */
  93217. devicePosition: Vector3;
  93218. /**
  93219. * The device rotation in babylon space
  93220. */
  93221. deviceRotationQuaternion: Quaternion;
  93222. /**
  93223. * The scale factor of the device in babylon space
  93224. */
  93225. deviceScaleFactor: number;
  93226. /**
  93227. * (Likely devicePosition should be used instead) The device position in its room space
  93228. */
  93229. position: Vector3;
  93230. /**
  93231. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  93232. */
  93233. rotationQuaternion: Quaternion;
  93234. /**
  93235. * The type of controller (Eg. Windows mixed reality)
  93236. */
  93237. controllerType: PoseEnabledControllerType;
  93238. protected _calculatedPosition: Vector3;
  93239. private _calculatedRotation;
  93240. /**
  93241. * The raw pose from the device
  93242. */
  93243. rawPose: DevicePose;
  93244. private _trackPosition;
  93245. private _maxRotationDistFromHeadset;
  93246. private _draggedRoomRotation;
  93247. /**
  93248. * @hidden
  93249. */
  93250. _disableTrackPosition(fixedPosition: Vector3): void;
  93251. /**
  93252. * Internal, the mesh attached to the controller
  93253. * @hidden
  93254. */
  93255. _mesh: Nullable<AbstractMesh>;
  93256. private _poseControlledCamera;
  93257. private _leftHandSystemQuaternion;
  93258. /**
  93259. * Internal, matrix used to convert room space to babylon space
  93260. * @hidden
  93261. */
  93262. _deviceToWorld: Matrix;
  93263. /**
  93264. * Node to be used when casting a ray from the controller
  93265. * @hidden
  93266. */
  93267. _pointingPoseNode: Nullable<TransformNode>;
  93268. /**
  93269. * Name of the child mesh that can be used to cast a ray from the controller
  93270. */
  93271. static readonly POINTING_POSE: string;
  93272. /**
  93273. * Creates a new PoseEnabledController from a gamepad
  93274. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  93275. */
  93276. constructor(browserGamepad: any);
  93277. private _workingMatrix;
  93278. /**
  93279. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  93280. */
  93281. update(): void;
  93282. /**
  93283. * Updates only the pose device and mesh without doing any button event checking
  93284. */
  93285. protected _updatePoseAndMesh(): void;
  93286. /**
  93287. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  93288. * @param poseData raw pose fromthe device
  93289. */
  93290. updateFromDevice(poseData: DevicePose): void;
  93291. /**
  93292. * @hidden
  93293. */
  93294. _meshAttachedObservable: Observable<AbstractMesh>;
  93295. /**
  93296. * Attaches a mesh to the controller
  93297. * @param mesh the mesh to be attached
  93298. */
  93299. attachToMesh(mesh: AbstractMesh): void;
  93300. /**
  93301. * Attaches the controllers mesh to a camera
  93302. * @param camera the camera the mesh should be attached to
  93303. */
  93304. attachToPoseControlledCamera(camera: TargetCamera): void;
  93305. /**
  93306. * Disposes of the controller
  93307. */
  93308. dispose(): void;
  93309. /**
  93310. * The mesh that is attached to the controller
  93311. */
  93312. get mesh(): Nullable<AbstractMesh>;
  93313. /**
  93314. * Gets the ray of the controller in the direction the controller is pointing
  93315. * @param length the length the resulting ray should be
  93316. * @returns a ray in the direction the controller is pointing
  93317. */
  93318. getForwardRay(length?: number): Ray;
  93319. }
  93320. }
  93321. declare module BABYLON {
  93322. /**
  93323. * Defines the WebVRController object that represents controllers tracked in 3D space
  93324. */
  93325. export abstract class WebVRController extends PoseEnabledController {
  93326. /**
  93327. * Internal, the default controller model for the controller
  93328. */
  93329. protected _defaultModel: Nullable<AbstractMesh>;
  93330. /**
  93331. * Fired when the trigger state has changed
  93332. */
  93333. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  93334. /**
  93335. * Fired when the main button state has changed
  93336. */
  93337. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93338. /**
  93339. * Fired when the secondary button state has changed
  93340. */
  93341. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93342. /**
  93343. * Fired when the pad state has changed
  93344. */
  93345. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  93346. /**
  93347. * Fired when controllers stick values have changed
  93348. */
  93349. onPadValuesChangedObservable: Observable<StickValues>;
  93350. /**
  93351. * Array of button availible on the controller
  93352. */
  93353. protected _buttons: Array<MutableGamepadButton>;
  93354. private _onButtonStateChange;
  93355. /**
  93356. * Fired when a controller button's state has changed
  93357. * @param callback the callback containing the button that was modified
  93358. */
  93359. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  93360. /**
  93361. * X and Y axis corresponding to the controllers joystick
  93362. */
  93363. pad: StickValues;
  93364. /**
  93365. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  93366. */
  93367. hand: string;
  93368. /**
  93369. * The default controller model for the controller
  93370. */
  93371. get defaultModel(): Nullable<AbstractMesh>;
  93372. /**
  93373. * Creates a new WebVRController from a gamepad
  93374. * @param vrGamepad the gamepad that the WebVRController should be created from
  93375. */
  93376. constructor(vrGamepad: any);
  93377. /**
  93378. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  93379. */
  93380. update(): void;
  93381. /**
  93382. * Function to be called when a button is modified
  93383. */
  93384. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  93385. /**
  93386. * Loads a mesh and attaches it to the controller
  93387. * @param scene the scene the mesh should be added to
  93388. * @param meshLoaded callback for when the mesh has been loaded
  93389. */
  93390. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  93391. private _setButtonValue;
  93392. private _changes;
  93393. private _checkChanges;
  93394. /**
  93395. * Disposes of th webVRCOntroller
  93396. */
  93397. dispose(): void;
  93398. }
  93399. }
  93400. declare module BABYLON {
  93401. /**
  93402. * The HemisphericLight simulates the ambient environment light,
  93403. * so the passed direction is the light reflection direction, not the incoming direction.
  93404. */
  93405. export class HemisphericLight extends Light {
  93406. /**
  93407. * The groundColor is the light in the opposite direction to the one specified during creation.
  93408. * 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.
  93409. */
  93410. groundColor: Color3;
  93411. /**
  93412. * The light reflection direction, not the incoming direction.
  93413. */
  93414. direction: Vector3;
  93415. /**
  93416. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  93417. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  93418. * The HemisphericLight can't cast shadows.
  93419. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93420. * @param name The friendly name of the light
  93421. * @param direction The direction of the light reflection
  93422. * @param scene The scene the light belongs to
  93423. */
  93424. constructor(name: string, direction: Vector3, scene: Scene);
  93425. protected _buildUniformLayout(): void;
  93426. /**
  93427. * Returns the string "HemisphericLight".
  93428. * @return The class name
  93429. */
  93430. getClassName(): string;
  93431. /**
  93432. * Sets the HemisphericLight direction towards the passed target (Vector3).
  93433. * Returns the updated direction.
  93434. * @param target The target the direction should point to
  93435. * @return The computed direction
  93436. */
  93437. setDirectionToTarget(target: Vector3): Vector3;
  93438. /**
  93439. * Returns the shadow generator associated to the light.
  93440. * @returns Always null for hemispheric lights because it does not support shadows.
  93441. */
  93442. getShadowGenerator(): Nullable<IShadowGenerator>;
  93443. /**
  93444. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  93445. * @param effect The effect to update
  93446. * @param lightIndex The index of the light in the effect to update
  93447. * @returns The hemispheric light
  93448. */
  93449. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  93450. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  93451. /**
  93452. * Computes the world matrix of the node
  93453. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93454. * @param useWasUpdatedFlag defines a reserved property
  93455. * @returns the world matrix
  93456. */
  93457. computeWorldMatrix(): Matrix;
  93458. /**
  93459. * Returns the integer 3.
  93460. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93461. */
  93462. getTypeID(): number;
  93463. /**
  93464. * Prepares the list of defines specific to the light type.
  93465. * @param defines the list of defines
  93466. * @param lightIndex defines the index of the light for the effect
  93467. */
  93468. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93469. }
  93470. }
  93471. declare module BABYLON {
  93472. /** @hidden */
  93473. export var vrMultiviewToSingleviewPixelShader: {
  93474. name: string;
  93475. shader: string;
  93476. };
  93477. }
  93478. declare module BABYLON {
  93479. /**
  93480. * Renders to multiple views with a single draw call
  93481. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  93482. */
  93483. export class MultiviewRenderTarget extends RenderTargetTexture {
  93484. /**
  93485. * Creates a multiview render target
  93486. * @param scene scene used with the render target
  93487. * @param size the size of the render target (used for each view)
  93488. */
  93489. constructor(scene: Scene, size?: number | {
  93490. width: number;
  93491. height: number;
  93492. } | {
  93493. ratio: number;
  93494. });
  93495. /**
  93496. * @hidden
  93497. * @param faceIndex the face index, if its a cube texture
  93498. */
  93499. _bindFrameBuffer(faceIndex?: number): void;
  93500. /**
  93501. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93502. * @returns the view count
  93503. */
  93504. getViewCount(): number;
  93505. }
  93506. }
  93507. declare module BABYLON {
  93508. /**
  93509. * Represents a camera frustum
  93510. */
  93511. export class Frustum {
  93512. /**
  93513. * Gets the planes representing the frustum
  93514. * @param transform matrix to be applied to the returned planes
  93515. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93516. */
  93517. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93518. /**
  93519. * Gets the near frustum plane transformed by the transform matrix
  93520. * @param transform transformation matrix to be applied to the resulting frustum plane
  93521. * @param frustumPlane the resuling frustum plane
  93522. */
  93523. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93524. /**
  93525. * Gets the far frustum plane transformed by the transform matrix
  93526. * @param transform transformation matrix to be applied to the resulting frustum plane
  93527. * @param frustumPlane the resuling frustum plane
  93528. */
  93529. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93530. /**
  93531. * Gets the left frustum plane transformed by the transform matrix
  93532. * @param transform transformation matrix to be applied to the resulting frustum plane
  93533. * @param frustumPlane the resuling frustum plane
  93534. */
  93535. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93536. /**
  93537. * Gets the right frustum plane transformed by the transform matrix
  93538. * @param transform transformation matrix to be applied to the resulting frustum plane
  93539. * @param frustumPlane the resuling frustum plane
  93540. */
  93541. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93542. /**
  93543. * Gets the top frustum plane transformed by the transform matrix
  93544. * @param transform transformation matrix to be applied to the resulting frustum plane
  93545. * @param frustumPlane the resuling frustum plane
  93546. */
  93547. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93548. /**
  93549. * Gets the bottom frustum plane transformed by the transform matrix
  93550. * @param transform transformation matrix to be applied to the resulting frustum plane
  93551. * @param frustumPlane the resuling frustum plane
  93552. */
  93553. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93554. /**
  93555. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93556. * @param transform transformation matrix to be applied to the resulting frustum planes
  93557. * @param frustumPlanes the resuling frustum planes
  93558. */
  93559. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93560. }
  93561. }
  93562. declare module BABYLON {
  93563. interface Engine {
  93564. /**
  93565. * Creates a new multiview render target
  93566. * @param width defines the width of the texture
  93567. * @param height defines the height of the texture
  93568. * @returns the created multiview texture
  93569. */
  93570. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  93571. /**
  93572. * Binds a multiview framebuffer to be drawn to
  93573. * @param multiviewTexture texture to bind
  93574. */
  93575. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  93576. }
  93577. interface Camera {
  93578. /**
  93579. * @hidden
  93580. * 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)
  93581. */
  93582. _useMultiviewToSingleView: boolean;
  93583. /**
  93584. * @hidden
  93585. * 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)
  93586. */
  93587. _multiviewTexture: Nullable<RenderTargetTexture>;
  93588. /**
  93589. * @hidden
  93590. * ensures the multiview texture of the camera exists and has the specified width/height
  93591. * @param width height to set on the multiview texture
  93592. * @param height width to set on the multiview texture
  93593. */
  93594. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  93595. }
  93596. interface Scene {
  93597. /** @hidden */
  93598. _transformMatrixR: Matrix;
  93599. /** @hidden */
  93600. _multiviewSceneUbo: Nullable<UniformBuffer>;
  93601. /** @hidden */
  93602. _createMultiviewUbo(): void;
  93603. /** @hidden */
  93604. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  93605. /** @hidden */
  93606. _renderMultiviewToSingleView(camera: Camera): void;
  93607. }
  93608. }
  93609. declare module BABYLON {
  93610. /**
  93611. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  93612. * This will not be used for webXR as it supports displaying texture arrays directly
  93613. */
  93614. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  93615. /**
  93616. * Initializes a VRMultiviewToSingleview
  93617. * @param name name of the post process
  93618. * @param camera camera to be applied to
  93619. * @param scaleFactor scaling factor to the size of the output texture
  93620. */
  93621. constructor(name: string, camera: Camera, scaleFactor: number);
  93622. }
  93623. }
  93624. declare module BABYLON {
  93625. /**
  93626. * Interface used to define additional presentation attributes
  93627. */
  93628. export interface IVRPresentationAttributes {
  93629. /**
  93630. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  93631. */
  93632. highRefreshRate: boolean;
  93633. /**
  93634. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  93635. */
  93636. foveationLevel: number;
  93637. }
  93638. interface Engine {
  93639. /** @hidden */
  93640. _vrDisplay: any;
  93641. /** @hidden */
  93642. _vrSupported: boolean;
  93643. /** @hidden */
  93644. _oldSize: Size;
  93645. /** @hidden */
  93646. _oldHardwareScaleFactor: number;
  93647. /** @hidden */
  93648. _vrExclusivePointerMode: boolean;
  93649. /** @hidden */
  93650. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  93651. /** @hidden */
  93652. _onVRDisplayPointerRestricted: () => void;
  93653. /** @hidden */
  93654. _onVRDisplayPointerUnrestricted: () => void;
  93655. /** @hidden */
  93656. _onVrDisplayConnect: Nullable<(display: any) => void>;
  93657. /** @hidden */
  93658. _onVrDisplayDisconnect: Nullable<() => void>;
  93659. /** @hidden */
  93660. _onVrDisplayPresentChange: Nullable<() => void>;
  93661. /**
  93662. * Observable signaled when VR display mode changes
  93663. */
  93664. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  93665. /**
  93666. * Observable signaled when VR request present is complete
  93667. */
  93668. onVRRequestPresentComplete: Observable<boolean>;
  93669. /**
  93670. * Observable signaled when VR request present starts
  93671. */
  93672. onVRRequestPresentStart: Observable<Engine>;
  93673. /**
  93674. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  93675. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  93676. */
  93677. isInVRExclusivePointerMode: boolean;
  93678. /**
  93679. * Gets a boolean indicating if a webVR device was detected
  93680. * @returns true if a webVR device was detected
  93681. */
  93682. isVRDevicePresent(): boolean;
  93683. /**
  93684. * Gets the current webVR device
  93685. * @returns the current webVR device (or null)
  93686. */
  93687. getVRDevice(): any;
  93688. /**
  93689. * Initializes a webVR display and starts listening to display change events
  93690. * The onVRDisplayChangedObservable will be notified upon these changes
  93691. * @returns A promise containing a VRDisplay and if vr is supported
  93692. */
  93693. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  93694. /** @hidden */
  93695. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  93696. /**
  93697. * Gets or sets the presentation attributes used to configure VR rendering
  93698. */
  93699. vrPresentationAttributes?: IVRPresentationAttributes;
  93700. /**
  93701. * Call this function to switch to webVR mode
  93702. * Will do nothing if webVR is not supported or if there is no webVR device
  93703. * @param options the webvr options provided to the camera. mainly used for multiview
  93704. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93705. */
  93706. enableVR(options: WebVROptions): void;
  93707. /** @hidden */
  93708. _onVRFullScreenTriggered(): void;
  93709. }
  93710. }
  93711. declare module BABYLON {
  93712. /**
  93713. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  93714. * IMPORTANT!! The data is right-hand data.
  93715. * @export
  93716. * @interface DevicePose
  93717. */
  93718. export interface DevicePose {
  93719. /**
  93720. * The position of the device, values in array are [x,y,z].
  93721. */
  93722. readonly position: Nullable<Float32Array>;
  93723. /**
  93724. * The linearVelocity of the device, values in array are [x,y,z].
  93725. */
  93726. readonly linearVelocity: Nullable<Float32Array>;
  93727. /**
  93728. * The linearAcceleration of the device, values in array are [x,y,z].
  93729. */
  93730. readonly linearAcceleration: Nullable<Float32Array>;
  93731. /**
  93732. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  93733. */
  93734. readonly orientation: Nullable<Float32Array>;
  93735. /**
  93736. * The angularVelocity of the device, values in array are [x,y,z].
  93737. */
  93738. readonly angularVelocity: Nullable<Float32Array>;
  93739. /**
  93740. * The angularAcceleration of the device, values in array are [x,y,z].
  93741. */
  93742. readonly angularAcceleration: Nullable<Float32Array>;
  93743. }
  93744. /**
  93745. * Interface representing a pose controlled object in Babylon.
  93746. * A pose controlled object has both regular pose values as well as pose values
  93747. * from an external device such as a VR head mounted display
  93748. */
  93749. export interface PoseControlled {
  93750. /**
  93751. * The position of the object in babylon space.
  93752. */
  93753. position: Vector3;
  93754. /**
  93755. * The rotation quaternion of the object in babylon space.
  93756. */
  93757. rotationQuaternion: Quaternion;
  93758. /**
  93759. * The position of the device in babylon space.
  93760. */
  93761. devicePosition?: Vector3;
  93762. /**
  93763. * The rotation quaternion of the device in babylon space.
  93764. */
  93765. deviceRotationQuaternion: Quaternion;
  93766. /**
  93767. * The raw pose coming from the device.
  93768. */
  93769. rawPose: Nullable<DevicePose>;
  93770. /**
  93771. * The scale of the device to be used when translating from device space to babylon space.
  93772. */
  93773. deviceScaleFactor: number;
  93774. /**
  93775. * Updates the poseControlled values based on the input device pose.
  93776. * @param poseData the pose data to update the object with
  93777. */
  93778. updateFromDevice(poseData: DevicePose): void;
  93779. }
  93780. /**
  93781. * Set of options to customize the webVRCamera
  93782. */
  93783. export interface WebVROptions {
  93784. /**
  93785. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  93786. */
  93787. trackPosition?: boolean;
  93788. /**
  93789. * Sets the scale of the vrDevice in babylon space. (default: 1)
  93790. */
  93791. positionScale?: number;
  93792. /**
  93793. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  93794. */
  93795. displayName?: string;
  93796. /**
  93797. * Should the native controller meshes be initialized. (default: true)
  93798. */
  93799. controllerMeshes?: boolean;
  93800. /**
  93801. * Creating a default HemiLight only on controllers. (default: true)
  93802. */
  93803. defaultLightingOnControllers?: boolean;
  93804. /**
  93805. * If you don't want to use the default VR button of the helper. (default: false)
  93806. */
  93807. useCustomVRButton?: boolean;
  93808. /**
  93809. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  93810. */
  93811. customVRButton?: HTMLButtonElement;
  93812. /**
  93813. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  93814. */
  93815. rayLength?: number;
  93816. /**
  93817. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  93818. */
  93819. defaultHeight?: number;
  93820. /**
  93821. * If multiview should be used if availible (default: false)
  93822. */
  93823. useMultiview?: boolean;
  93824. }
  93825. /**
  93826. * This represents a WebVR camera.
  93827. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93828. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93829. */
  93830. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93831. private webVROptions;
  93832. /**
  93833. * @hidden
  93834. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93835. */
  93836. _vrDevice: any;
  93837. /**
  93838. * The rawPose of the vrDevice.
  93839. */
  93840. rawPose: Nullable<DevicePose>;
  93841. private _onVREnabled;
  93842. private _specsVersion;
  93843. private _attached;
  93844. private _frameData;
  93845. protected _descendants: Array<Node>;
  93846. private _deviceRoomPosition;
  93847. /** @hidden */
  93848. _deviceRoomRotationQuaternion: Quaternion;
  93849. private _standingMatrix;
  93850. /**
  93851. * Represents device position in babylon space.
  93852. */
  93853. devicePosition: Vector3;
  93854. /**
  93855. * Represents device rotation in babylon space.
  93856. */
  93857. deviceRotationQuaternion: Quaternion;
  93858. /**
  93859. * The scale of the device to be used when translating from device space to babylon space.
  93860. */
  93861. deviceScaleFactor: number;
  93862. private _deviceToWorld;
  93863. private _worldToDevice;
  93864. /**
  93865. * References to the webVR controllers for the vrDevice.
  93866. */
  93867. controllers: Array<WebVRController>;
  93868. /**
  93869. * Emits an event when a controller is attached.
  93870. */
  93871. onControllersAttachedObservable: Observable<WebVRController[]>;
  93872. /**
  93873. * Emits an event when a controller's mesh has been loaded;
  93874. */
  93875. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93876. /**
  93877. * Emits an event when the HMD's pose has been updated.
  93878. */
  93879. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93880. private _poseSet;
  93881. /**
  93882. * If the rig cameras be used as parent instead of this camera.
  93883. */
  93884. rigParenting: boolean;
  93885. private _lightOnControllers;
  93886. private _defaultHeight?;
  93887. /**
  93888. * Instantiates a WebVRFreeCamera.
  93889. * @param name The name of the WebVRFreeCamera
  93890. * @param position The starting anchor position for the camera
  93891. * @param scene The scene the camera belongs to
  93892. * @param webVROptions a set of customizable options for the webVRCamera
  93893. */
  93894. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93895. /**
  93896. * Gets the device distance from the ground in meters.
  93897. * @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.
  93898. */
  93899. deviceDistanceToRoomGround(): number;
  93900. /**
  93901. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93902. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93903. */
  93904. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93905. /**
  93906. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93907. * @returns A promise with a boolean set to if the standing matrix is supported.
  93908. */
  93909. useStandingMatrixAsync(): Promise<boolean>;
  93910. /**
  93911. * Disposes the camera
  93912. */
  93913. dispose(): void;
  93914. /**
  93915. * Gets a vrController by name.
  93916. * @param name The name of the controller to retreive
  93917. * @returns the controller matching the name specified or null if not found
  93918. */
  93919. getControllerByName(name: string): Nullable<WebVRController>;
  93920. private _leftController;
  93921. /**
  93922. * The controller corresponding to the users left hand.
  93923. */
  93924. get leftController(): Nullable<WebVRController>;
  93925. private _rightController;
  93926. /**
  93927. * The controller corresponding to the users right hand.
  93928. */
  93929. get rightController(): Nullable<WebVRController>;
  93930. /**
  93931. * Casts a ray forward from the vrCamera's gaze.
  93932. * @param length Length of the ray (default: 100)
  93933. * @returns the ray corresponding to the gaze
  93934. */
  93935. getForwardRay(length?: number): Ray;
  93936. /**
  93937. * @hidden
  93938. * Updates the camera based on device's frame data
  93939. */
  93940. _checkInputs(): void;
  93941. /**
  93942. * Updates the poseControlled values based on the input device pose.
  93943. * @param poseData Pose coming from the device
  93944. */
  93945. updateFromDevice(poseData: DevicePose): void;
  93946. private _htmlElementAttached;
  93947. private _detachIfAttached;
  93948. /**
  93949. * WebVR's attach control will start broadcasting frames to the device.
  93950. * Note that in certain browsers (chrome for example) this function must be called
  93951. * within a user-interaction callback. Example:
  93952. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93953. *
  93954. * @param element html element to attach the vrDevice to
  93955. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93956. */
  93957. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93958. /**
  93959. * Detaches the camera from the html element and disables VR
  93960. *
  93961. * @param element html element to detach from
  93962. */
  93963. detachControl(element: HTMLElement): void;
  93964. /**
  93965. * @returns the name of this class
  93966. */
  93967. getClassName(): string;
  93968. /**
  93969. * Calls resetPose on the vrDisplay
  93970. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93971. */
  93972. resetToCurrentRotation(): void;
  93973. /**
  93974. * @hidden
  93975. * Updates the rig cameras (left and right eye)
  93976. */
  93977. _updateRigCameras(): void;
  93978. private _workingVector;
  93979. private _oneVector;
  93980. private _workingMatrix;
  93981. private updateCacheCalled;
  93982. private _correctPositionIfNotTrackPosition;
  93983. /**
  93984. * @hidden
  93985. * Updates the cached values of the camera
  93986. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93987. */
  93988. _updateCache(ignoreParentClass?: boolean): void;
  93989. /**
  93990. * @hidden
  93991. * Get current device position in babylon world
  93992. */
  93993. _computeDevicePosition(): void;
  93994. /**
  93995. * Updates the current device position and rotation in the babylon world
  93996. */
  93997. update(): void;
  93998. /**
  93999. * @hidden
  94000. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  94001. * @returns an identity matrix
  94002. */
  94003. _getViewMatrix(): Matrix;
  94004. private _tmpMatrix;
  94005. /**
  94006. * This function is called by the two RIG cameras.
  94007. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  94008. * @hidden
  94009. */
  94010. _getWebVRViewMatrix(): Matrix;
  94011. /** @hidden */
  94012. _getWebVRProjectionMatrix(): Matrix;
  94013. private _onGamepadConnectedObserver;
  94014. private _onGamepadDisconnectedObserver;
  94015. private _updateCacheWhenTrackingDisabledObserver;
  94016. /**
  94017. * Initializes the controllers and their meshes
  94018. */
  94019. initControllers(): void;
  94020. }
  94021. }
  94022. declare module BABYLON {
  94023. /**
  94024. * Size options for a post process
  94025. */
  94026. export type PostProcessOptions = {
  94027. width: number;
  94028. height: number;
  94029. };
  94030. /**
  94031. * PostProcess can be used to apply a shader to a texture after it has been rendered
  94032. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94033. */
  94034. export class PostProcess {
  94035. /** Name of the PostProcess. */
  94036. name: string;
  94037. /**
  94038. * Gets or sets the unique id of the post process
  94039. */
  94040. uniqueId: number;
  94041. /**
  94042. * Width of the texture to apply the post process on
  94043. */
  94044. width: number;
  94045. /**
  94046. * Height of the texture to apply the post process on
  94047. */
  94048. height: number;
  94049. /**
  94050. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  94051. * @hidden
  94052. */
  94053. _outputTexture: Nullable<InternalTexture>;
  94054. /**
  94055. * Sampling mode used by the shader
  94056. * See https://doc.babylonjs.com/classes/3.1/texture
  94057. */
  94058. renderTargetSamplingMode: number;
  94059. /**
  94060. * Clear color to use when screen clearing
  94061. */
  94062. clearColor: Color4;
  94063. /**
  94064. * If the buffer needs to be cleared before applying the post process. (default: true)
  94065. * Should be set to false if shader will overwrite all previous pixels.
  94066. */
  94067. autoClear: boolean;
  94068. /**
  94069. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  94070. */
  94071. alphaMode: number;
  94072. /**
  94073. * Sets the setAlphaBlendConstants of the babylon engine
  94074. */
  94075. alphaConstants: Color4;
  94076. /**
  94077. * Animations to be used for the post processing
  94078. */
  94079. animations: Animation[];
  94080. /**
  94081. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  94082. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  94083. */
  94084. enablePixelPerfectMode: boolean;
  94085. /**
  94086. * Force the postprocess to be applied without taking in account viewport
  94087. */
  94088. forceFullscreenViewport: boolean;
  94089. /**
  94090. * List of inspectable custom properties (used by the Inspector)
  94091. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94092. */
  94093. inspectableCustomProperties: IInspectable[];
  94094. /**
  94095. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  94096. *
  94097. * | Value | Type | Description |
  94098. * | ----- | ----------------------------------- | ----------- |
  94099. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  94100. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  94101. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  94102. *
  94103. */
  94104. scaleMode: number;
  94105. /**
  94106. * Force textures to be a power of two (default: false)
  94107. */
  94108. alwaysForcePOT: boolean;
  94109. private _samples;
  94110. /**
  94111. * Number of sample textures (default: 1)
  94112. */
  94113. get samples(): number;
  94114. set samples(n: number);
  94115. /**
  94116. * Modify the scale of the post process to be the same as the viewport (default: false)
  94117. */
  94118. adaptScaleToCurrentViewport: boolean;
  94119. private _camera;
  94120. private _scene;
  94121. private _engine;
  94122. private _options;
  94123. private _reusable;
  94124. private _textureType;
  94125. private _textureFormat;
  94126. /**
  94127. * Smart array of input and output textures for the post process.
  94128. * @hidden
  94129. */
  94130. _textures: SmartArray<InternalTexture>;
  94131. /**
  94132. * The index in _textures that corresponds to the output texture.
  94133. * @hidden
  94134. */
  94135. _currentRenderTextureInd: number;
  94136. private _effect;
  94137. private _samplers;
  94138. private _fragmentUrl;
  94139. private _vertexUrl;
  94140. private _parameters;
  94141. private _scaleRatio;
  94142. protected _indexParameters: any;
  94143. private _shareOutputWithPostProcess;
  94144. private _texelSize;
  94145. private _forcedOutputTexture;
  94146. /**
  94147. * Returns the fragment url or shader name used in the post process.
  94148. * @returns the fragment url or name in the shader store.
  94149. */
  94150. getEffectName(): string;
  94151. /**
  94152. * An event triggered when the postprocess is activated.
  94153. */
  94154. onActivateObservable: Observable<Camera>;
  94155. private _onActivateObserver;
  94156. /**
  94157. * A function that is added to the onActivateObservable
  94158. */
  94159. set onActivate(callback: Nullable<(camera: Camera) => void>);
  94160. /**
  94161. * An event triggered when the postprocess changes its size.
  94162. */
  94163. onSizeChangedObservable: Observable<PostProcess>;
  94164. private _onSizeChangedObserver;
  94165. /**
  94166. * A function that is added to the onSizeChangedObservable
  94167. */
  94168. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  94169. /**
  94170. * An event triggered when the postprocess applies its effect.
  94171. */
  94172. onApplyObservable: Observable<Effect>;
  94173. private _onApplyObserver;
  94174. /**
  94175. * A function that is added to the onApplyObservable
  94176. */
  94177. set onApply(callback: (effect: Effect) => void);
  94178. /**
  94179. * An event triggered before rendering the postprocess
  94180. */
  94181. onBeforeRenderObservable: Observable<Effect>;
  94182. private _onBeforeRenderObserver;
  94183. /**
  94184. * A function that is added to the onBeforeRenderObservable
  94185. */
  94186. set onBeforeRender(callback: (effect: Effect) => void);
  94187. /**
  94188. * An event triggered after rendering the postprocess
  94189. */
  94190. onAfterRenderObservable: Observable<Effect>;
  94191. private _onAfterRenderObserver;
  94192. /**
  94193. * A function that is added to the onAfterRenderObservable
  94194. */
  94195. set onAfterRender(callback: (efect: Effect) => void);
  94196. /**
  94197. * 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
  94198. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  94199. */
  94200. get inputTexture(): InternalTexture;
  94201. set inputTexture(value: InternalTexture);
  94202. /**
  94203. * Gets the camera which post process is applied to.
  94204. * @returns The camera the post process is applied to.
  94205. */
  94206. getCamera(): Camera;
  94207. /**
  94208. * Gets the texel size of the postprocess.
  94209. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  94210. */
  94211. get texelSize(): Vector2;
  94212. /**
  94213. * Creates a new instance PostProcess
  94214. * @param name The name of the PostProcess.
  94215. * @param fragmentUrl The url of the fragment shader to be used.
  94216. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  94217. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  94218. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94219. * @param camera The camera to apply the render pass to.
  94220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94221. * @param engine The engine which the post process will be applied. (default: current engine)
  94222. * @param reusable If the post process can be reused on the same frame. (default: false)
  94223. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  94224. * @param textureType Type of textures used when performing the post process. (default: 0)
  94225. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  94226. * @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
  94227. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  94228. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  94229. */
  94230. constructor(
  94231. /** Name of the PostProcess. */
  94232. 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);
  94233. /**
  94234. * Gets a string idenfifying the name of the class
  94235. * @returns "PostProcess" string
  94236. */
  94237. getClassName(): string;
  94238. /**
  94239. * Gets the engine which this post process belongs to.
  94240. * @returns The engine the post process was enabled with.
  94241. */
  94242. getEngine(): Engine;
  94243. /**
  94244. * The effect that is created when initializing the post process.
  94245. * @returns The created effect corresponding the the postprocess.
  94246. */
  94247. getEffect(): Effect;
  94248. /**
  94249. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  94250. * @param postProcess The post process to share the output with.
  94251. * @returns This post process.
  94252. */
  94253. shareOutputWith(postProcess: PostProcess): PostProcess;
  94254. /**
  94255. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  94256. * This should be called if the post process that shares output with this post process is disabled/disposed.
  94257. */
  94258. useOwnOutput(): void;
  94259. /**
  94260. * Updates the effect with the current post process compile time values and recompiles the shader.
  94261. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94262. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94263. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94264. * @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
  94265. * @param onCompiled Called when the shader has been compiled.
  94266. * @param onError Called if there is an error when compiling a shader.
  94267. */
  94268. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94269. /**
  94270. * The post process is reusable if it can be used multiple times within one frame.
  94271. * @returns If the post process is reusable
  94272. */
  94273. isReusable(): boolean;
  94274. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  94275. markTextureDirty(): void;
  94276. /**
  94277. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  94278. * 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.
  94279. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  94280. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  94281. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  94282. * @returns The target texture that was bound to be written to.
  94283. */
  94284. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  94285. /**
  94286. * If the post process is supported.
  94287. */
  94288. get isSupported(): boolean;
  94289. /**
  94290. * The aspect ratio of the output texture.
  94291. */
  94292. get aspectRatio(): number;
  94293. /**
  94294. * Get a value indicating if the post-process is ready to be used
  94295. * @returns true if the post-process is ready (shader is compiled)
  94296. */
  94297. isReady(): boolean;
  94298. /**
  94299. * Binds all textures and uniforms to the shader, this will be run on every pass.
  94300. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  94301. */
  94302. apply(): Nullable<Effect>;
  94303. private _disposeTextures;
  94304. /**
  94305. * Disposes the post process.
  94306. * @param camera The camera to dispose the post process on.
  94307. */
  94308. dispose(camera?: Camera): void;
  94309. }
  94310. }
  94311. declare module BABYLON {
  94312. /** @hidden */
  94313. export var kernelBlurVaryingDeclaration: {
  94314. name: string;
  94315. shader: string;
  94316. };
  94317. }
  94318. declare module BABYLON {
  94319. /** @hidden */
  94320. export var kernelBlurFragment: {
  94321. name: string;
  94322. shader: string;
  94323. };
  94324. }
  94325. declare module BABYLON {
  94326. /** @hidden */
  94327. export var kernelBlurFragment2: {
  94328. name: string;
  94329. shader: string;
  94330. };
  94331. }
  94332. declare module BABYLON {
  94333. /** @hidden */
  94334. export var kernelBlurPixelShader: {
  94335. name: string;
  94336. shader: string;
  94337. };
  94338. }
  94339. declare module BABYLON {
  94340. /** @hidden */
  94341. export var kernelBlurVertex: {
  94342. name: string;
  94343. shader: string;
  94344. };
  94345. }
  94346. declare module BABYLON {
  94347. /** @hidden */
  94348. export var kernelBlurVertexShader: {
  94349. name: string;
  94350. shader: string;
  94351. };
  94352. }
  94353. declare module BABYLON {
  94354. /**
  94355. * The Blur Post Process which blurs an image based on a kernel and direction.
  94356. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  94357. */
  94358. export class BlurPostProcess extends PostProcess {
  94359. /** The direction in which to blur the image. */
  94360. direction: Vector2;
  94361. private blockCompilation;
  94362. protected _kernel: number;
  94363. protected _idealKernel: number;
  94364. protected _packedFloat: boolean;
  94365. private _staticDefines;
  94366. /**
  94367. * Sets the length in pixels of the blur sample region
  94368. */
  94369. set kernel(v: number);
  94370. /**
  94371. * Gets the length in pixels of the blur sample region
  94372. */
  94373. get kernel(): number;
  94374. /**
  94375. * Sets wether or not the blur needs to unpack/repack floats
  94376. */
  94377. set packedFloat(v: boolean);
  94378. /**
  94379. * Gets wether or not the blur is unpacking/repacking floats
  94380. */
  94381. get packedFloat(): boolean;
  94382. /**
  94383. * Creates a new instance BlurPostProcess
  94384. * @param name The name of the effect.
  94385. * @param direction The direction in which to blur the image.
  94386. * @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.
  94387. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94388. * @param camera The camera to apply the render pass to.
  94389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94390. * @param engine The engine which the post process will be applied. (default: current engine)
  94391. * @param reusable If the post process can be reused on the same frame. (default: false)
  94392. * @param textureType Type of textures used when performing the post process. (default: 0)
  94393. * @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)
  94394. */
  94395. constructor(name: string,
  94396. /** The direction in which to blur the image. */
  94397. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  94398. /**
  94399. * Updates the effect with the current post process compile time values and recompiles the shader.
  94400. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94401. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94402. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94403. * @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
  94404. * @param onCompiled Called when the shader has been compiled.
  94405. * @param onError Called if there is an error when compiling a shader.
  94406. */
  94407. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94408. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94409. /**
  94410. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  94411. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  94412. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  94413. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  94414. * The gaps between physical kernels are compensated for in the weighting of the samples
  94415. * @param idealKernel Ideal blur kernel.
  94416. * @return Nearest best kernel.
  94417. */
  94418. protected _nearestBestKernel(idealKernel: number): number;
  94419. /**
  94420. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  94421. * @param x The point on the Gaussian distribution to sample.
  94422. * @return the value of the Gaussian function at x.
  94423. */
  94424. protected _gaussianWeight(x: number): number;
  94425. /**
  94426. * Generates a string that can be used as a floating point number in GLSL.
  94427. * @param x Value to print.
  94428. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  94429. * @return GLSL float string.
  94430. */
  94431. protected _glslFloat(x: number, decimalFigures?: number): string;
  94432. }
  94433. }
  94434. declare module BABYLON {
  94435. /**
  94436. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94437. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94438. * You can then easily use it as a reflectionTexture on a flat surface.
  94439. * In case the surface is not a plane, please consider relying on reflection probes.
  94440. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94441. */
  94442. export class MirrorTexture extends RenderTargetTexture {
  94443. private scene;
  94444. /**
  94445. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  94446. * 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.
  94447. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94448. */
  94449. mirrorPlane: Plane;
  94450. /**
  94451. * Define the blur ratio used to blur the reflection if needed.
  94452. */
  94453. set blurRatio(value: number);
  94454. get blurRatio(): number;
  94455. /**
  94456. * Define the adaptive blur kernel used to blur the reflection if needed.
  94457. * This will autocompute the closest best match for the `blurKernel`
  94458. */
  94459. set adaptiveBlurKernel(value: number);
  94460. /**
  94461. * Define the blur kernel used to blur the reflection if needed.
  94462. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94463. */
  94464. set blurKernel(value: number);
  94465. /**
  94466. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  94467. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94468. */
  94469. set blurKernelX(value: number);
  94470. get blurKernelX(): number;
  94471. /**
  94472. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  94473. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94474. */
  94475. set blurKernelY(value: number);
  94476. get blurKernelY(): number;
  94477. private _autoComputeBlurKernel;
  94478. protected _onRatioRescale(): void;
  94479. private _updateGammaSpace;
  94480. private _imageProcessingConfigChangeObserver;
  94481. private _transformMatrix;
  94482. private _mirrorMatrix;
  94483. private _savedViewMatrix;
  94484. private _blurX;
  94485. private _blurY;
  94486. private _adaptiveBlurKernel;
  94487. private _blurKernelX;
  94488. private _blurKernelY;
  94489. private _blurRatio;
  94490. /**
  94491. * Instantiates a Mirror Texture.
  94492. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94493. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94494. * You can then easily use it as a reflectionTexture on a flat surface.
  94495. * In case the surface is not a plane, please consider relying on reflection probes.
  94496. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94497. * @param name
  94498. * @param size
  94499. * @param scene
  94500. * @param generateMipMaps
  94501. * @param type
  94502. * @param samplingMode
  94503. * @param generateDepthBuffer
  94504. */
  94505. constructor(name: string, size: number | {
  94506. width: number;
  94507. height: number;
  94508. } | {
  94509. ratio: number;
  94510. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  94511. private _preparePostProcesses;
  94512. /**
  94513. * Clone the mirror texture.
  94514. * @returns the cloned texture
  94515. */
  94516. clone(): MirrorTexture;
  94517. /**
  94518. * Serialize the texture to a JSON representation you could use in Parse later on
  94519. * @returns the serialized JSON representation
  94520. */
  94521. serialize(): any;
  94522. /**
  94523. * Dispose the texture and release its associated resources.
  94524. */
  94525. dispose(): void;
  94526. }
  94527. }
  94528. declare module BABYLON {
  94529. /**
  94530. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94531. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94532. */
  94533. export class Texture extends BaseTexture {
  94534. /**
  94535. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  94536. */
  94537. static SerializeBuffers: boolean;
  94538. /** @hidden */
  94539. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  94540. /** @hidden */
  94541. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  94542. /** @hidden */
  94543. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  94544. /** nearest is mag = nearest and min = nearest and mip = linear */
  94545. static readonly NEAREST_SAMPLINGMODE: number;
  94546. /** nearest is mag = nearest and min = nearest and mip = linear */
  94547. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  94548. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94549. static readonly BILINEAR_SAMPLINGMODE: number;
  94550. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94551. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  94552. /** Trilinear is mag = linear and min = linear and mip = linear */
  94553. static readonly TRILINEAR_SAMPLINGMODE: number;
  94554. /** Trilinear is mag = linear and min = linear and mip = linear */
  94555. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  94556. /** mag = nearest and min = nearest and mip = nearest */
  94557. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  94558. /** mag = nearest and min = linear and mip = nearest */
  94559. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  94560. /** mag = nearest and min = linear and mip = linear */
  94561. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  94562. /** mag = nearest and min = linear and mip = none */
  94563. static readonly NEAREST_LINEAR: number;
  94564. /** mag = nearest and min = nearest and mip = none */
  94565. static readonly NEAREST_NEAREST: number;
  94566. /** mag = linear and min = nearest and mip = nearest */
  94567. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  94568. /** mag = linear and min = nearest and mip = linear */
  94569. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  94570. /** mag = linear and min = linear and mip = none */
  94571. static readonly LINEAR_LINEAR: number;
  94572. /** mag = linear and min = nearest and mip = none */
  94573. static readonly LINEAR_NEAREST: number;
  94574. /** Explicit coordinates mode */
  94575. static readonly EXPLICIT_MODE: number;
  94576. /** Spherical coordinates mode */
  94577. static readonly SPHERICAL_MODE: number;
  94578. /** Planar coordinates mode */
  94579. static readonly PLANAR_MODE: number;
  94580. /** Cubic coordinates mode */
  94581. static readonly CUBIC_MODE: number;
  94582. /** Projection coordinates mode */
  94583. static readonly PROJECTION_MODE: number;
  94584. /** Inverse Cubic coordinates mode */
  94585. static readonly SKYBOX_MODE: number;
  94586. /** Inverse Cubic coordinates mode */
  94587. static readonly INVCUBIC_MODE: number;
  94588. /** Equirectangular coordinates mode */
  94589. static readonly EQUIRECTANGULAR_MODE: number;
  94590. /** Equirectangular Fixed coordinates mode */
  94591. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  94592. /** Equirectangular Fixed Mirrored coordinates mode */
  94593. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94594. /** Texture is not repeating outside of 0..1 UVs */
  94595. static readonly CLAMP_ADDRESSMODE: number;
  94596. /** Texture is repeating outside of 0..1 UVs */
  94597. static readonly WRAP_ADDRESSMODE: number;
  94598. /** Texture is repeating and mirrored */
  94599. static readonly MIRROR_ADDRESSMODE: number;
  94600. /**
  94601. * 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
  94602. */
  94603. static UseSerializedUrlIfAny: boolean;
  94604. /**
  94605. * Define the url of the texture.
  94606. */
  94607. url: Nullable<string>;
  94608. /**
  94609. * Define an offset on the texture to offset the u coordinates of the UVs
  94610. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94611. */
  94612. uOffset: number;
  94613. /**
  94614. * Define an offset on the texture to offset the v coordinates of the UVs
  94615. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94616. */
  94617. vOffset: number;
  94618. /**
  94619. * Define an offset on the texture to scale the u coordinates of the UVs
  94620. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94621. */
  94622. uScale: number;
  94623. /**
  94624. * Define an offset on the texture to scale the v coordinates of the UVs
  94625. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94626. */
  94627. vScale: number;
  94628. /**
  94629. * Define an offset on the texture to rotate around the u coordinates of the UVs
  94630. * @see http://doc.babylonjs.com/how_to/more_materials
  94631. */
  94632. uAng: number;
  94633. /**
  94634. * Define an offset on the texture to rotate around the v coordinates of the UVs
  94635. * @see http://doc.babylonjs.com/how_to/more_materials
  94636. */
  94637. vAng: number;
  94638. /**
  94639. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  94640. * @see http://doc.babylonjs.com/how_to/more_materials
  94641. */
  94642. wAng: number;
  94643. /**
  94644. * Defines the center of rotation (U)
  94645. */
  94646. uRotationCenter: number;
  94647. /**
  94648. * Defines the center of rotation (V)
  94649. */
  94650. vRotationCenter: number;
  94651. /**
  94652. * Defines the center of rotation (W)
  94653. */
  94654. wRotationCenter: number;
  94655. /**
  94656. * Are mip maps generated for this texture or not.
  94657. */
  94658. get noMipmap(): boolean;
  94659. /**
  94660. * List of inspectable custom properties (used by the Inspector)
  94661. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94662. */
  94663. inspectableCustomProperties: Nullable<IInspectable[]>;
  94664. private _noMipmap;
  94665. /** @hidden */
  94666. _invertY: boolean;
  94667. private _rowGenerationMatrix;
  94668. private _cachedTextureMatrix;
  94669. private _projectionModeMatrix;
  94670. private _t0;
  94671. private _t1;
  94672. private _t2;
  94673. private _cachedUOffset;
  94674. private _cachedVOffset;
  94675. private _cachedUScale;
  94676. private _cachedVScale;
  94677. private _cachedUAng;
  94678. private _cachedVAng;
  94679. private _cachedWAng;
  94680. private _cachedProjectionMatrixId;
  94681. private _cachedCoordinatesMode;
  94682. /** @hidden */
  94683. protected _initialSamplingMode: number;
  94684. /** @hidden */
  94685. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  94686. private _deleteBuffer;
  94687. protected _format: Nullable<number>;
  94688. private _delayedOnLoad;
  94689. private _delayedOnError;
  94690. private _mimeType?;
  94691. /**
  94692. * Observable triggered once the texture has been loaded.
  94693. */
  94694. onLoadObservable: Observable<Texture>;
  94695. protected _isBlocking: boolean;
  94696. /**
  94697. * Is the texture preventing material to render while loading.
  94698. * If false, a default texture will be used instead of the loading one during the preparation step.
  94699. */
  94700. set isBlocking(value: boolean);
  94701. get isBlocking(): boolean;
  94702. /**
  94703. * Get the current sampling mode associated with the texture.
  94704. */
  94705. get samplingMode(): number;
  94706. /**
  94707. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  94708. */
  94709. get invertY(): boolean;
  94710. /**
  94711. * Instantiates a new texture.
  94712. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94713. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94714. * @param url defines the url of the picture to load as a texture
  94715. * @param scene defines the scene or engine the texture will belong to
  94716. * @param noMipmap defines if the texture will require mip maps or not
  94717. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  94718. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94719. * @param onLoad defines a callback triggered when the texture has been loaded
  94720. * @param onError defines a callback triggered when an error occurred during the loading session
  94721. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  94722. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  94723. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94724. * @param mimeType defines an optional mime type information
  94725. */
  94726. 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);
  94727. /**
  94728. * Update the url (and optional buffer) of this texture if url was null during construction.
  94729. * @param url the url of the texture
  94730. * @param buffer the buffer of the texture (defaults to null)
  94731. * @param onLoad callback called when the texture is loaded (defaults to null)
  94732. */
  94733. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  94734. /**
  94735. * Finish the loading sequence of a texture flagged as delayed load.
  94736. * @hidden
  94737. */
  94738. delayLoad(): void;
  94739. private _prepareRowForTextureGeneration;
  94740. /**
  94741. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  94742. * @returns the transform matrix of the texture.
  94743. */
  94744. getTextureMatrix(uBase?: number): Matrix;
  94745. /**
  94746. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  94747. * @returns The reflection texture transform
  94748. */
  94749. getReflectionTextureMatrix(): Matrix;
  94750. /**
  94751. * Clones the texture.
  94752. * @returns the cloned texture
  94753. */
  94754. clone(): Texture;
  94755. /**
  94756. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94757. * @returns The JSON representation of the texture
  94758. */
  94759. serialize(): any;
  94760. /**
  94761. * Get the current class name of the texture useful for serialization or dynamic coding.
  94762. * @returns "Texture"
  94763. */
  94764. getClassName(): string;
  94765. /**
  94766. * Dispose the texture and release its associated resources.
  94767. */
  94768. dispose(): void;
  94769. /**
  94770. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  94771. * @param parsedTexture Define the JSON representation of the texture
  94772. * @param scene Define the scene the parsed texture should be instantiated in
  94773. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  94774. * @returns The parsed texture if successful
  94775. */
  94776. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  94777. /**
  94778. * Creates a texture from its base 64 representation.
  94779. * @param data Define the base64 payload without the data: prefix
  94780. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94781. * @param scene Define the scene the texture should belong to
  94782. * @param noMipmap Forces the texture to not create mip map information if true
  94783. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94784. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94785. * @param onLoad define a callback triggered when the texture has been loaded
  94786. * @param onError define a callback triggered when an error occurred during the loading session
  94787. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94788. * @returns the created texture
  94789. */
  94790. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  94791. /**
  94792. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  94793. * @param data Define the base64 payload without the data: prefix
  94794. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94795. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  94796. * @param scene Define the scene the texture should belong to
  94797. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  94798. * @param noMipmap Forces the texture to not create mip map information if true
  94799. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94800. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94801. * @param onLoad define a callback triggered when the texture has been loaded
  94802. * @param onError define a callback triggered when an error occurred during the loading session
  94803. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94804. * @returns the created texture
  94805. */
  94806. 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;
  94807. }
  94808. }
  94809. declare module BABYLON {
  94810. /**
  94811. * PostProcessManager is used to manage one or more post processes or post process pipelines
  94812. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94813. */
  94814. export class PostProcessManager {
  94815. private _scene;
  94816. private _indexBuffer;
  94817. private _vertexBuffers;
  94818. /**
  94819. * Creates a new instance PostProcess
  94820. * @param scene The scene that the post process is associated with.
  94821. */
  94822. constructor(scene: Scene);
  94823. private _prepareBuffers;
  94824. private _buildIndexBuffer;
  94825. /**
  94826. * Rebuilds the vertex buffers of the manager.
  94827. * @hidden
  94828. */
  94829. _rebuild(): void;
  94830. /**
  94831. * Prepares a frame to be run through a post process.
  94832. * @param sourceTexture The input texture to the post procesess. (default: null)
  94833. * @param postProcesses An array of post processes to be run. (default: null)
  94834. * @returns True if the post processes were able to be run.
  94835. * @hidden
  94836. */
  94837. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94838. /**
  94839. * Manually render a set of post processes to a texture.
  94840. * @param postProcesses An array of post processes to be run.
  94841. * @param targetTexture The target texture to render to.
  94842. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94843. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94844. * @param lodLevel defines which lod of the texture to render to
  94845. */
  94846. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94847. /**
  94848. * Finalize the result of the output of the postprocesses.
  94849. * @param doNotPresent If true the result will not be displayed to the screen.
  94850. * @param targetTexture The target texture to render to.
  94851. * @param faceIndex The index of the face to bind the target texture to.
  94852. * @param postProcesses The array of post processes to render.
  94853. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94854. * @hidden
  94855. */
  94856. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94857. /**
  94858. * Disposes of the post process manager.
  94859. */
  94860. dispose(): void;
  94861. }
  94862. }
  94863. declare module BABYLON {
  94864. /**
  94865. * This Helps creating a texture that will be created from a camera in your scene.
  94866. * It is basically a dynamic texture that could be used to create special effects for instance.
  94867. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94868. */
  94869. export class RenderTargetTexture extends Texture {
  94870. isCube: boolean;
  94871. /**
  94872. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94873. */
  94874. static readonly REFRESHRATE_RENDER_ONCE: number;
  94875. /**
  94876. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94877. */
  94878. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94879. /**
  94880. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94881. * the central point of your effect and can save a lot of performances.
  94882. */
  94883. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94884. /**
  94885. * Use this predicate to dynamically define the list of mesh you want to render.
  94886. * If set, the renderList property will be overwritten.
  94887. */
  94888. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94889. private _renderList;
  94890. /**
  94891. * Use this list to define the list of mesh you want to render.
  94892. */
  94893. get renderList(): Nullable<Array<AbstractMesh>>;
  94894. set renderList(value: Nullable<Array<AbstractMesh>>);
  94895. /**
  94896. * Use this function to overload the renderList array at rendering time.
  94897. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94898. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94899. * the cube (if the RTT is a cube, else layerOrFace=0).
  94900. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94901. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94902. * hold dummy elements!
  94903. */
  94904. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94905. private _hookArray;
  94906. /**
  94907. * Define if particles should be rendered in your texture.
  94908. */
  94909. renderParticles: boolean;
  94910. /**
  94911. * Define if sprites should be rendered in your texture.
  94912. */
  94913. renderSprites: boolean;
  94914. /**
  94915. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94916. */
  94917. coordinatesMode: number;
  94918. /**
  94919. * Define the camera used to render the texture.
  94920. */
  94921. activeCamera: Nullable<Camera>;
  94922. /**
  94923. * Override the mesh isReady function with your own one.
  94924. */
  94925. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  94926. /**
  94927. * Override the render function of the texture with your own one.
  94928. */
  94929. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94930. /**
  94931. * Define if camera post processes should be use while rendering the texture.
  94932. */
  94933. useCameraPostProcesses: boolean;
  94934. /**
  94935. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94936. */
  94937. ignoreCameraViewport: boolean;
  94938. private _postProcessManager;
  94939. private _postProcesses;
  94940. private _resizeObserver;
  94941. /**
  94942. * An event triggered when the texture is unbind.
  94943. */
  94944. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94945. /**
  94946. * An event triggered when the texture is unbind.
  94947. */
  94948. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94949. private _onAfterUnbindObserver;
  94950. /**
  94951. * Set a after unbind callback in the texture.
  94952. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94953. */
  94954. set onAfterUnbind(callback: () => void);
  94955. /**
  94956. * An event triggered before rendering the texture
  94957. */
  94958. onBeforeRenderObservable: Observable<number>;
  94959. private _onBeforeRenderObserver;
  94960. /**
  94961. * Set a before render callback in the texture.
  94962. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94963. */
  94964. set onBeforeRender(callback: (faceIndex: number) => void);
  94965. /**
  94966. * An event triggered after rendering the texture
  94967. */
  94968. onAfterRenderObservable: Observable<number>;
  94969. private _onAfterRenderObserver;
  94970. /**
  94971. * Set a after render callback in the texture.
  94972. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94973. */
  94974. set onAfterRender(callback: (faceIndex: number) => void);
  94975. /**
  94976. * An event triggered after the texture clear
  94977. */
  94978. onClearObservable: Observable<Engine>;
  94979. private _onClearObserver;
  94980. /**
  94981. * Set a clear callback in the texture.
  94982. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94983. */
  94984. set onClear(callback: (Engine: Engine) => void);
  94985. /**
  94986. * An event triggered when the texture is resized.
  94987. */
  94988. onResizeObservable: Observable<RenderTargetTexture>;
  94989. /**
  94990. * Define the clear color of the Render Target if it should be different from the scene.
  94991. */
  94992. clearColor: Color4;
  94993. protected _size: number | {
  94994. width: number;
  94995. height: number;
  94996. layers?: number;
  94997. };
  94998. protected _initialSizeParameter: number | {
  94999. width: number;
  95000. height: number;
  95001. } | {
  95002. ratio: number;
  95003. };
  95004. protected _sizeRatio: Nullable<number>;
  95005. /** @hidden */
  95006. _generateMipMaps: boolean;
  95007. protected _renderingManager: RenderingManager;
  95008. /** @hidden */
  95009. _waitingRenderList: string[];
  95010. protected _doNotChangeAspectRatio: boolean;
  95011. protected _currentRefreshId: number;
  95012. protected _refreshRate: number;
  95013. protected _textureMatrix: Matrix;
  95014. protected _samples: number;
  95015. protected _renderTargetOptions: RenderTargetCreationOptions;
  95016. /**
  95017. * Gets render target creation options that were used.
  95018. */
  95019. get renderTargetOptions(): RenderTargetCreationOptions;
  95020. protected _engine: Engine;
  95021. protected _onRatioRescale(): void;
  95022. /**
  95023. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  95024. * It must define where the camera used to render the texture is set
  95025. */
  95026. boundingBoxPosition: Vector3;
  95027. private _boundingBoxSize;
  95028. /**
  95029. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  95030. * When defined, the cubemap will switch to local mode
  95031. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95032. * @example https://www.babylonjs-playground.com/#RNASML
  95033. */
  95034. set boundingBoxSize(value: Vector3);
  95035. get boundingBoxSize(): Vector3;
  95036. /**
  95037. * In case the RTT has been created with a depth texture, get the associated
  95038. * depth texture.
  95039. * Otherwise, return null.
  95040. */
  95041. get depthStencilTexture(): Nullable<InternalTexture>;
  95042. /**
  95043. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  95044. * or used a shadow, depth texture...
  95045. * @param name The friendly name of the texture
  95046. * @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)
  95047. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  95048. * @param generateMipMaps True if mip maps need to be generated after render.
  95049. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  95050. * @param type The type of the buffer in the RTT (int, half float, float...)
  95051. * @param isCube True if a cube texture needs to be created
  95052. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  95053. * @param generateDepthBuffer True to generate a depth buffer
  95054. * @param generateStencilBuffer True to generate a stencil buffer
  95055. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  95056. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  95057. * @param delayAllocation if the texture allocation should be delayed (default: false)
  95058. */
  95059. constructor(name: string, size: number | {
  95060. width: number;
  95061. height: number;
  95062. layers?: number;
  95063. } | {
  95064. ratio: number;
  95065. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  95066. /**
  95067. * Creates a depth stencil texture.
  95068. * This is only available in WebGL 2 or with the depth texture extension available.
  95069. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  95070. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  95071. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  95072. */
  95073. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  95074. private _processSizeParameter;
  95075. /**
  95076. * Define the number of samples to use in case of MSAA.
  95077. * It defaults to one meaning no MSAA has been enabled.
  95078. */
  95079. get samples(): number;
  95080. set samples(value: number);
  95081. /**
  95082. * Resets the refresh counter of the texture and start bak from scratch.
  95083. * Could be useful to regenerate the texture if it is setup to render only once.
  95084. */
  95085. resetRefreshCounter(): void;
  95086. /**
  95087. * Define the refresh rate of the texture or the rendering frequency.
  95088. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95089. */
  95090. get refreshRate(): number;
  95091. set refreshRate(value: number);
  95092. /**
  95093. * Adds a post process to the render target rendering passes.
  95094. * @param postProcess define the post process to add
  95095. */
  95096. addPostProcess(postProcess: PostProcess): void;
  95097. /**
  95098. * Clear all the post processes attached to the render target
  95099. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  95100. */
  95101. clearPostProcesses(dispose?: boolean): void;
  95102. /**
  95103. * Remove one of the post process from the list of attached post processes to the texture
  95104. * @param postProcess define the post process to remove from the list
  95105. */
  95106. removePostProcess(postProcess: PostProcess): void;
  95107. /** @hidden */
  95108. _shouldRender(): boolean;
  95109. /**
  95110. * Gets the actual render size of the texture.
  95111. * @returns the width of the render size
  95112. */
  95113. getRenderSize(): number;
  95114. /**
  95115. * Gets the actual render width of the texture.
  95116. * @returns the width of the render size
  95117. */
  95118. getRenderWidth(): number;
  95119. /**
  95120. * Gets the actual render height of the texture.
  95121. * @returns the height of the render size
  95122. */
  95123. getRenderHeight(): number;
  95124. /**
  95125. * Gets the actual number of layers of the texture.
  95126. * @returns the number of layers
  95127. */
  95128. getRenderLayers(): number;
  95129. /**
  95130. * Get if the texture can be rescaled or not.
  95131. */
  95132. get canRescale(): boolean;
  95133. /**
  95134. * Resize the texture using a ratio.
  95135. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  95136. */
  95137. scale(ratio: number): void;
  95138. /**
  95139. * Get the texture reflection matrix used to rotate/transform the reflection.
  95140. * @returns the reflection matrix
  95141. */
  95142. getReflectionTextureMatrix(): Matrix;
  95143. /**
  95144. * Resize the texture to a new desired size.
  95145. * Be carrefull as it will recreate all the data in the new texture.
  95146. * @param size Define the new size. It can be:
  95147. * - a number for squared texture,
  95148. * - an object containing { width: number, height: number }
  95149. * - or an object containing a ratio { ratio: number }
  95150. */
  95151. resize(size: number | {
  95152. width: number;
  95153. height: number;
  95154. } | {
  95155. ratio: number;
  95156. }): void;
  95157. private _defaultRenderListPrepared;
  95158. /**
  95159. * Renders all the objects from the render list into the texture.
  95160. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  95161. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  95162. */
  95163. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  95164. private _bestReflectionRenderTargetDimension;
  95165. private _prepareRenderingManager;
  95166. /**
  95167. * @hidden
  95168. * @param faceIndex face index to bind to if this is a cubetexture
  95169. * @param layer defines the index of the texture to bind in the array
  95170. */
  95171. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  95172. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  95173. private renderToTarget;
  95174. /**
  95175. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95176. * This allowed control for front to back rendering or reversly depending of the special needs.
  95177. *
  95178. * @param renderingGroupId The rendering group id corresponding to its index
  95179. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95180. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95181. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95182. */
  95183. 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;
  95184. /**
  95185. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95186. *
  95187. * @param renderingGroupId The rendering group id corresponding to its index
  95188. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95189. */
  95190. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  95191. /**
  95192. * Clones the texture.
  95193. * @returns the cloned texture
  95194. */
  95195. clone(): RenderTargetTexture;
  95196. /**
  95197. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95198. * @returns The JSON representation of the texture
  95199. */
  95200. serialize(): any;
  95201. /**
  95202. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  95203. */
  95204. disposeFramebufferObjects(): void;
  95205. /**
  95206. * Dispose the texture and release its associated resources.
  95207. */
  95208. dispose(): void;
  95209. /** @hidden */
  95210. _rebuild(): void;
  95211. /**
  95212. * Clear the info related to rendering groups preventing retention point in material dispose.
  95213. */
  95214. freeRenderingGroups(): void;
  95215. /**
  95216. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95217. * @returns the view count
  95218. */
  95219. getViewCount(): number;
  95220. }
  95221. }
  95222. declare module BABYLON {
  95223. /**
  95224. * Options for compiling materials.
  95225. */
  95226. export interface IMaterialCompilationOptions {
  95227. /**
  95228. * Defines whether clip planes are enabled.
  95229. */
  95230. clipPlane: boolean;
  95231. /**
  95232. * Defines whether instances are enabled.
  95233. */
  95234. useInstances: boolean;
  95235. }
  95236. /**
  95237. * Base class for the main features of a material in Babylon.js
  95238. */
  95239. export class Material implements IAnimatable {
  95240. /**
  95241. * Returns the triangle fill mode
  95242. */
  95243. static readonly TriangleFillMode: number;
  95244. /**
  95245. * Returns the wireframe mode
  95246. */
  95247. static readonly WireFrameFillMode: number;
  95248. /**
  95249. * Returns the point fill mode
  95250. */
  95251. static readonly PointFillMode: number;
  95252. /**
  95253. * Returns the point list draw mode
  95254. */
  95255. static readonly PointListDrawMode: number;
  95256. /**
  95257. * Returns the line list draw mode
  95258. */
  95259. static readonly LineListDrawMode: number;
  95260. /**
  95261. * Returns the line loop draw mode
  95262. */
  95263. static readonly LineLoopDrawMode: number;
  95264. /**
  95265. * Returns the line strip draw mode
  95266. */
  95267. static readonly LineStripDrawMode: number;
  95268. /**
  95269. * Returns the triangle strip draw mode
  95270. */
  95271. static readonly TriangleStripDrawMode: number;
  95272. /**
  95273. * Returns the triangle fan draw mode
  95274. */
  95275. static readonly TriangleFanDrawMode: number;
  95276. /**
  95277. * Stores the clock-wise side orientation
  95278. */
  95279. static readonly ClockWiseSideOrientation: number;
  95280. /**
  95281. * Stores the counter clock-wise side orientation
  95282. */
  95283. static readonly CounterClockWiseSideOrientation: number;
  95284. /**
  95285. * The dirty texture flag value
  95286. */
  95287. static readonly TextureDirtyFlag: number;
  95288. /**
  95289. * The dirty light flag value
  95290. */
  95291. static readonly LightDirtyFlag: number;
  95292. /**
  95293. * The dirty fresnel flag value
  95294. */
  95295. static readonly FresnelDirtyFlag: number;
  95296. /**
  95297. * The dirty attribute flag value
  95298. */
  95299. static readonly AttributesDirtyFlag: number;
  95300. /**
  95301. * The dirty misc flag value
  95302. */
  95303. static readonly MiscDirtyFlag: number;
  95304. /**
  95305. * The all dirty flag value
  95306. */
  95307. static readonly AllDirtyFlag: number;
  95308. /**
  95309. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  95310. */
  95311. static readonly MATERIAL_OPAQUE: number;
  95312. /**
  95313. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  95314. */
  95315. static readonly MATERIAL_ALPHATEST: number;
  95316. /**
  95317. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95318. */
  95319. static readonly MATERIAL_ALPHABLEND: number;
  95320. /**
  95321. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95322. * They are also discarded below the alpha cutoff threshold to improve performances.
  95323. */
  95324. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  95325. /**
  95326. * The ID of the material
  95327. */
  95328. id: string;
  95329. /**
  95330. * Gets or sets the unique id of the material
  95331. */
  95332. uniqueId: number;
  95333. /**
  95334. * The name of the material
  95335. */
  95336. name: string;
  95337. /**
  95338. * Gets or sets user defined metadata
  95339. */
  95340. metadata: any;
  95341. /**
  95342. * For internal use only. Please do not use.
  95343. */
  95344. reservedDataStore: any;
  95345. /**
  95346. * Specifies if the ready state should be checked on each call
  95347. */
  95348. checkReadyOnEveryCall: boolean;
  95349. /**
  95350. * Specifies if the ready state should be checked once
  95351. */
  95352. checkReadyOnlyOnce: boolean;
  95353. /**
  95354. * The state of the material
  95355. */
  95356. state: string;
  95357. /**
  95358. * The alpha value of the material
  95359. */
  95360. protected _alpha: number;
  95361. /**
  95362. * List of inspectable custom properties (used by the Inspector)
  95363. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95364. */
  95365. inspectableCustomProperties: IInspectable[];
  95366. /**
  95367. * Sets the alpha value of the material
  95368. */
  95369. set alpha(value: number);
  95370. /**
  95371. * Gets the alpha value of the material
  95372. */
  95373. get alpha(): number;
  95374. /**
  95375. * Specifies if back face culling is enabled
  95376. */
  95377. protected _backFaceCulling: boolean;
  95378. /**
  95379. * Sets the back-face culling state
  95380. */
  95381. set backFaceCulling(value: boolean);
  95382. /**
  95383. * Gets the back-face culling state
  95384. */
  95385. get backFaceCulling(): boolean;
  95386. /**
  95387. * Stores the value for side orientation
  95388. */
  95389. sideOrientation: number;
  95390. /**
  95391. * Callback triggered when the material is compiled
  95392. */
  95393. onCompiled: Nullable<(effect: Effect) => void>;
  95394. /**
  95395. * Callback triggered when an error occurs
  95396. */
  95397. onError: Nullable<(effect: Effect, errors: string) => void>;
  95398. /**
  95399. * Callback triggered to get the render target textures
  95400. */
  95401. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  95402. /**
  95403. * Gets a boolean indicating that current material needs to register RTT
  95404. */
  95405. get hasRenderTargetTextures(): boolean;
  95406. /**
  95407. * Specifies if the material should be serialized
  95408. */
  95409. doNotSerialize: boolean;
  95410. /**
  95411. * @hidden
  95412. */
  95413. _storeEffectOnSubMeshes: boolean;
  95414. /**
  95415. * Stores the animations for the material
  95416. */
  95417. animations: Nullable<Array<Animation>>;
  95418. /**
  95419. * An event triggered when the material is disposed
  95420. */
  95421. onDisposeObservable: Observable<Material>;
  95422. /**
  95423. * An observer which watches for dispose events
  95424. */
  95425. private _onDisposeObserver;
  95426. private _onUnBindObservable;
  95427. /**
  95428. * Called during a dispose event
  95429. */
  95430. set onDispose(callback: () => void);
  95431. private _onBindObservable;
  95432. /**
  95433. * An event triggered when the material is bound
  95434. */
  95435. get onBindObservable(): Observable<AbstractMesh>;
  95436. /**
  95437. * An observer which watches for bind events
  95438. */
  95439. private _onBindObserver;
  95440. /**
  95441. * Called during a bind event
  95442. */
  95443. set onBind(callback: (Mesh: AbstractMesh) => void);
  95444. /**
  95445. * An event triggered when the material is unbound
  95446. */
  95447. get onUnBindObservable(): Observable<Material>;
  95448. /**
  95449. * Stores the value of the alpha mode
  95450. */
  95451. private _alphaMode;
  95452. /**
  95453. * Sets the value of the alpha mode.
  95454. *
  95455. * | Value | Type | Description |
  95456. * | --- | --- | --- |
  95457. * | 0 | ALPHA_DISABLE | |
  95458. * | 1 | ALPHA_ADD | |
  95459. * | 2 | ALPHA_COMBINE | |
  95460. * | 3 | ALPHA_SUBTRACT | |
  95461. * | 4 | ALPHA_MULTIPLY | |
  95462. * | 5 | ALPHA_MAXIMIZED | |
  95463. * | 6 | ALPHA_ONEONE | |
  95464. * | 7 | ALPHA_PREMULTIPLIED | |
  95465. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  95466. * | 9 | ALPHA_INTERPOLATE | |
  95467. * | 10 | ALPHA_SCREENMODE | |
  95468. *
  95469. */
  95470. set alphaMode(value: number);
  95471. /**
  95472. * Gets the value of the alpha mode
  95473. */
  95474. get alphaMode(): number;
  95475. /**
  95476. * Stores the state of the need depth pre-pass value
  95477. */
  95478. private _needDepthPrePass;
  95479. /**
  95480. * Sets the need depth pre-pass value
  95481. */
  95482. set needDepthPrePass(value: boolean);
  95483. /**
  95484. * Gets the depth pre-pass value
  95485. */
  95486. get needDepthPrePass(): boolean;
  95487. /**
  95488. * Specifies if depth writing should be disabled
  95489. */
  95490. disableDepthWrite: boolean;
  95491. /**
  95492. * Specifies if depth writing should be forced
  95493. */
  95494. forceDepthWrite: boolean;
  95495. /**
  95496. * Specifies the depth function that should be used. 0 means the default engine function
  95497. */
  95498. depthFunction: number;
  95499. /**
  95500. * Specifies if there should be a separate pass for culling
  95501. */
  95502. separateCullingPass: boolean;
  95503. /**
  95504. * Stores the state specifing if fog should be enabled
  95505. */
  95506. private _fogEnabled;
  95507. /**
  95508. * Sets the state for enabling fog
  95509. */
  95510. set fogEnabled(value: boolean);
  95511. /**
  95512. * Gets the value of the fog enabled state
  95513. */
  95514. get fogEnabled(): boolean;
  95515. /**
  95516. * Stores the size of points
  95517. */
  95518. pointSize: number;
  95519. /**
  95520. * Stores the z offset value
  95521. */
  95522. zOffset: number;
  95523. /**
  95524. * Gets a value specifying if wireframe mode is enabled
  95525. */
  95526. get wireframe(): boolean;
  95527. /**
  95528. * Sets the state of wireframe mode
  95529. */
  95530. set wireframe(value: boolean);
  95531. /**
  95532. * Gets the value specifying if point clouds are enabled
  95533. */
  95534. get pointsCloud(): boolean;
  95535. /**
  95536. * Sets the state of point cloud mode
  95537. */
  95538. set pointsCloud(value: boolean);
  95539. /**
  95540. * Gets the material fill mode
  95541. */
  95542. get fillMode(): number;
  95543. /**
  95544. * Sets the material fill mode
  95545. */
  95546. set fillMode(value: number);
  95547. /**
  95548. * @hidden
  95549. * Stores the effects for the material
  95550. */
  95551. _effect: Nullable<Effect>;
  95552. /**
  95553. * Specifies if uniform buffers should be used
  95554. */
  95555. private _useUBO;
  95556. /**
  95557. * Stores a reference to the scene
  95558. */
  95559. private _scene;
  95560. /**
  95561. * Stores the fill mode state
  95562. */
  95563. private _fillMode;
  95564. /**
  95565. * Specifies if the depth write state should be cached
  95566. */
  95567. private _cachedDepthWriteState;
  95568. /**
  95569. * Specifies if the depth function state should be cached
  95570. */
  95571. private _cachedDepthFunctionState;
  95572. /**
  95573. * Stores the uniform buffer
  95574. */
  95575. protected _uniformBuffer: UniformBuffer;
  95576. /** @hidden */
  95577. _indexInSceneMaterialArray: number;
  95578. /** @hidden */
  95579. meshMap: Nullable<{
  95580. [id: string]: AbstractMesh | undefined;
  95581. }>;
  95582. /**
  95583. * Creates a material instance
  95584. * @param name defines the name of the material
  95585. * @param scene defines the scene to reference
  95586. * @param doNotAdd specifies if the material should be added to the scene
  95587. */
  95588. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  95589. /**
  95590. * Returns a string representation of the current material
  95591. * @param fullDetails defines a boolean indicating which levels of logging is desired
  95592. * @returns a string with material information
  95593. */
  95594. toString(fullDetails?: boolean): string;
  95595. /**
  95596. * Gets the class name of the material
  95597. * @returns a string with the class name of the material
  95598. */
  95599. getClassName(): string;
  95600. /**
  95601. * Specifies if updates for the material been locked
  95602. */
  95603. get isFrozen(): boolean;
  95604. /**
  95605. * Locks updates for the material
  95606. */
  95607. freeze(): void;
  95608. /**
  95609. * Unlocks updates for the material
  95610. */
  95611. unfreeze(): void;
  95612. /**
  95613. * Specifies if the material is ready to be used
  95614. * @param mesh defines the mesh to check
  95615. * @param useInstances specifies if instances should be used
  95616. * @returns a boolean indicating if the material is ready to be used
  95617. */
  95618. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95619. /**
  95620. * Specifies that the submesh is ready to be used
  95621. * @param mesh defines the mesh to check
  95622. * @param subMesh defines which submesh to check
  95623. * @param useInstances specifies that instances should be used
  95624. * @returns a boolean indicating that the submesh is ready or not
  95625. */
  95626. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95627. /**
  95628. * Returns the material effect
  95629. * @returns the effect associated with the material
  95630. */
  95631. getEffect(): Nullable<Effect>;
  95632. /**
  95633. * Returns the current scene
  95634. * @returns a Scene
  95635. */
  95636. getScene(): Scene;
  95637. /**
  95638. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  95639. */
  95640. protected _forceAlphaTest: boolean;
  95641. /**
  95642. * The transparency mode of the material.
  95643. */
  95644. protected _transparencyMode: Nullable<number>;
  95645. /**
  95646. * Gets the current transparency mode.
  95647. */
  95648. get transparencyMode(): Nullable<number>;
  95649. /**
  95650. * Sets the transparency mode of the material.
  95651. *
  95652. * | Value | Type | Description |
  95653. * | ----- | ----------------------------------- | ----------- |
  95654. * | 0 | OPAQUE | |
  95655. * | 1 | ALPHATEST | |
  95656. * | 2 | ALPHABLEND | |
  95657. * | 3 | ALPHATESTANDBLEND | |
  95658. *
  95659. */
  95660. set transparencyMode(value: Nullable<number>);
  95661. /**
  95662. * Returns true if alpha blending should be disabled.
  95663. */
  95664. protected get _disableAlphaBlending(): boolean;
  95665. /**
  95666. * Specifies whether or not this material should be rendered in alpha blend mode.
  95667. * @returns a boolean specifying if alpha blending is needed
  95668. */
  95669. needAlphaBlending(): boolean;
  95670. /**
  95671. * Specifies if the mesh will require alpha blending
  95672. * @param mesh defines the mesh to check
  95673. * @returns a boolean specifying if alpha blending is needed for the mesh
  95674. */
  95675. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  95676. /**
  95677. * Specifies whether or not this material should be rendered in alpha test mode.
  95678. * @returns a boolean specifying if an alpha test is needed.
  95679. */
  95680. needAlphaTesting(): boolean;
  95681. /**
  95682. * Specifies if material alpha testing should be turned on for the mesh
  95683. * @param mesh defines the mesh to check
  95684. */
  95685. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  95686. /**
  95687. * Gets the texture used for the alpha test
  95688. * @returns the texture to use for alpha testing
  95689. */
  95690. getAlphaTestTexture(): Nullable<BaseTexture>;
  95691. /**
  95692. * Marks the material to indicate that it needs to be re-calculated
  95693. */
  95694. markDirty(): void;
  95695. /** @hidden */
  95696. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  95697. /**
  95698. * Binds the material to the mesh
  95699. * @param world defines the world transformation matrix
  95700. * @param mesh defines the mesh to bind the material to
  95701. */
  95702. bind(world: Matrix, mesh?: Mesh): void;
  95703. /**
  95704. * Binds the submesh to the material
  95705. * @param world defines the world transformation matrix
  95706. * @param mesh defines the mesh containing the submesh
  95707. * @param subMesh defines the submesh to bind the material to
  95708. */
  95709. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95710. /**
  95711. * Binds the world matrix to the material
  95712. * @param world defines the world transformation matrix
  95713. */
  95714. bindOnlyWorldMatrix(world: Matrix): void;
  95715. /**
  95716. * Binds the scene's uniform buffer to the effect.
  95717. * @param effect defines the effect to bind to the scene uniform buffer
  95718. * @param sceneUbo defines the uniform buffer storing scene data
  95719. */
  95720. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  95721. /**
  95722. * Binds the view matrix to the effect
  95723. * @param effect defines the effect to bind the view matrix to
  95724. */
  95725. bindView(effect: Effect): void;
  95726. /**
  95727. * Binds the view projection matrix to the effect
  95728. * @param effect defines the effect to bind the view projection matrix to
  95729. */
  95730. bindViewProjection(effect: Effect): void;
  95731. /**
  95732. * Processes to execute after binding the material to a mesh
  95733. * @param mesh defines the rendered mesh
  95734. */
  95735. protected _afterBind(mesh?: Mesh): void;
  95736. /**
  95737. * Unbinds the material from the mesh
  95738. */
  95739. unbind(): void;
  95740. /**
  95741. * Gets the active textures from the material
  95742. * @returns an array of textures
  95743. */
  95744. getActiveTextures(): BaseTexture[];
  95745. /**
  95746. * Specifies if the material uses a texture
  95747. * @param texture defines the texture to check against the material
  95748. * @returns a boolean specifying if the material uses the texture
  95749. */
  95750. hasTexture(texture: BaseTexture): boolean;
  95751. /**
  95752. * Makes a duplicate of the material, and gives it a new name
  95753. * @param name defines the new name for the duplicated material
  95754. * @returns the cloned material
  95755. */
  95756. clone(name: string): Nullable<Material>;
  95757. /**
  95758. * Gets the meshes bound to the material
  95759. * @returns an array of meshes bound to the material
  95760. */
  95761. getBindedMeshes(): AbstractMesh[];
  95762. /**
  95763. * Force shader compilation
  95764. * @param mesh defines the mesh associated with this material
  95765. * @param onCompiled defines a function to execute once the material is compiled
  95766. * @param options defines the options to configure the compilation
  95767. * @param onError defines a function to execute if the material fails compiling
  95768. */
  95769. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  95770. /**
  95771. * Force shader compilation
  95772. * @param mesh defines the mesh that will use this material
  95773. * @param options defines additional options for compiling the shaders
  95774. * @returns a promise that resolves when the compilation completes
  95775. */
  95776. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  95777. private static readonly _AllDirtyCallBack;
  95778. private static readonly _ImageProcessingDirtyCallBack;
  95779. private static readonly _TextureDirtyCallBack;
  95780. private static readonly _FresnelDirtyCallBack;
  95781. private static readonly _MiscDirtyCallBack;
  95782. private static readonly _LightsDirtyCallBack;
  95783. private static readonly _AttributeDirtyCallBack;
  95784. private static _FresnelAndMiscDirtyCallBack;
  95785. private static _TextureAndMiscDirtyCallBack;
  95786. private static readonly _DirtyCallbackArray;
  95787. private static readonly _RunDirtyCallBacks;
  95788. /**
  95789. * Marks a define in the material to indicate that it needs to be re-computed
  95790. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  95791. */
  95792. markAsDirty(flag: number): void;
  95793. /**
  95794. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  95795. * @param func defines a function which checks material defines against the submeshes
  95796. */
  95797. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  95798. /**
  95799. * Indicates that we need to re-calculated for all submeshes
  95800. */
  95801. protected _markAllSubMeshesAsAllDirty(): void;
  95802. /**
  95803. * Indicates that image processing needs to be re-calculated for all submeshes
  95804. */
  95805. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  95806. /**
  95807. * Indicates that textures need to be re-calculated for all submeshes
  95808. */
  95809. protected _markAllSubMeshesAsTexturesDirty(): void;
  95810. /**
  95811. * Indicates that fresnel needs to be re-calculated for all submeshes
  95812. */
  95813. protected _markAllSubMeshesAsFresnelDirty(): void;
  95814. /**
  95815. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  95816. */
  95817. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  95818. /**
  95819. * Indicates that lights need to be re-calculated for all submeshes
  95820. */
  95821. protected _markAllSubMeshesAsLightsDirty(): void;
  95822. /**
  95823. * Indicates that attributes need to be re-calculated for all submeshes
  95824. */
  95825. protected _markAllSubMeshesAsAttributesDirty(): void;
  95826. /**
  95827. * Indicates that misc needs to be re-calculated for all submeshes
  95828. */
  95829. protected _markAllSubMeshesAsMiscDirty(): void;
  95830. /**
  95831. * Indicates that textures and misc need to be re-calculated for all submeshes
  95832. */
  95833. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95834. /**
  95835. * Disposes the material
  95836. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95837. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95838. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95839. */
  95840. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95841. /** @hidden */
  95842. private releaseVertexArrayObject;
  95843. /**
  95844. * Serializes this material
  95845. * @returns the serialized material object
  95846. */
  95847. serialize(): any;
  95848. /**
  95849. * Creates a material from parsed material data
  95850. * @param parsedMaterial defines parsed material data
  95851. * @param scene defines the hosting scene
  95852. * @param rootUrl defines the root URL to use to load textures
  95853. * @returns a new material
  95854. */
  95855. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95856. }
  95857. }
  95858. declare module BABYLON {
  95859. /**
  95860. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95861. * separate meshes. This can be use to improve performances.
  95862. * @see http://doc.babylonjs.com/how_to/multi_materials
  95863. */
  95864. export class MultiMaterial extends Material {
  95865. private _subMaterials;
  95866. /**
  95867. * Gets or Sets the list of Materials used within the multi material.
  95868. * They need to be ordered according to the submeshes order in the associated mesh
  95869. */
  95870. get subMaterials(): Nullable<Material>[];
  95871. set subMaterials(value: Nullable<Material>[]);
  95872. /**
  95873. * Function used to align with Node.getChildren()
  95874. * @returns the list of Materials used within the multi material
  95875. */
  95876. getChildren(): Nullable<Material>[];
  95877. /**
  95878. * Instantiates a new Multi Material
  95879. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95880. * separate meshes. This can be use to improve performances.
  95881. * @see http://doc.babylonjs.com/how_to/multi_materials
  95882. * @param name Define the name in the scene
  95883. * @param scene Define the scene the material belongs to
  95884. */
  95885. constructor(name: string, scene: Scene);
  95886. private _hookArray;
  95887. /**
  95888. * Get one of the submaterial by its index in the submaterials array
  95889. * @param index The index to look the sub material at
  95890. * @returns The Material if the index has been defined
  95891. */
  95892. getSubMaterial(index: number): Nullable<Material>;
  95893. /**
  95894. * Get the list of active textures for the whole sub materials list.
  95895. * @returns All the textures that will be used during the rendering
  95896. */
  95897. getActiveTextures(): BaseTexture[];
  95898. /**
  95899. * Gets the current class name of the material e.g. "MultiMaterial"
  95900. * Mainly use in serialization.
  95901. * @returns the class name
  95902. */
  95903. getClassName(): string;
  95904. /**
  95905. * Checks if the material is ready to render the requested sub mesh
  95906. * @param mesh Define the mesh the submesh belongs to
  95907. * @param subMesh Define the sub mesh to look readyness for
  95908. * @param useInstances Define whether or not the material is used with instances
  95909. * @returns true if ready, otherwise false
  95910. */
  95911. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95912. /**
  95913. * Clones the current material and its related sub materials
  95914. * @param name Define the name of the newly cloned material
  95915. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95916. * @returns the cloned material
  95917. */
  95918. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95919. /**
  95920. * Serializes the materials into a JSON representation.
  95921. * @returns the JSON representation
  95922. */
  95923. serialize(): any;
  95924. /**
  95925. * Dispose the material and release its associated resources
  95926. * @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)
  95927. * @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)
  95928. * @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)
  95929. */
  95930. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95931. /**
  95932. * Creates a MultiMaterial from parsed MultiMaterial data.
  95933. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95934. * @param scene defines the hosting scene
  95935. * @returns a new MultiMaterial
  95936. */
  95937. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95938. }
  95939. }
  95940. declare module BABYLON {
  95941. /**
  95942. * Base class for submeshes
  95943. */
  95944. export class BaseSubMesh {
  95945. /** @hidden */
  95946. _materialDefines: Nullable<MaterialDefines>;
  95947. /** @hidden */
  95948. _materialEffect: Nullable<Effect>;
  95949. /**
  95950. * Gets material defines used by the effect associated to the sub mesh
  95951. */
  95952. get materialDefines(): Nullable<MaterialDefines>;
  95953. /**
  95954. * Sets material defines used by the effect associated to the sub mesh
  95955. */
  95956. set materialDefines(defines: Nullable<MaterialDefines>);
  95957. /**
  95958. * Gets associated effect
  95959. */
  95960. get effect(): Nullable<Effect>;
  95961. /**
  95962. * Sets associated effect (effect used to render this submesh)
  95963. * @param effect defines the effect to associate with
  95964. * @param defines defines the set of defines used to compile this effect
  95965. */
  95966. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95967. }
  95968. /**
  95969. * Defines a subdivision inside a mesh
  95970. */
  95971. export class SubMesh extends BaseSubMesh implements ICullable {
  95972. /** the material index to use */
  95973. materialIndex: number;
  95974. /** vertex index start */
  95975. verticesStart: number;
  95976. /** vertices count */
  95977. verticesCount: number;
  95978. /** index start */
  95979. indexStart: number;
  95980. /** indices count */
  95981. indexCount: number;
  95982. /** @hidden */
  95983. _linesIndexCount: number;
  95984. private _mesh;
  95985. private _renderingMesh;
  95986. private _boundingInfo;
  95987. private _linesIndexBuffer;
  95988. /** @hidden */
  95989. _lastColliderWorldVertices: Nullable<Vector3[]>;
  95990. /** @hidden */
  95991. _trianglePlanes: Plane[];
  95992. /** @hidden */
  95993. _lastColliderTransformMatrix: Nullable<Matrix>;
  95994. /** @hidden */
  95995. _renderId: number;
  95996. /** @hidden */
  95997. _alphaIndex: number;
  95998. /** @hidden */
  95999. _distanceToCamera: number;
  96000. /** @hidden */
  96001. _id: number;
  96002. private _currentMaterial;
  96003. /**
  96004. * Add a new submesh to a mesh
  96005. * @param materialIndex defines the material index to use
  96006. * @param verticesStart defines vertex index start
  96007. * @param verticesCount defines vertices count
  96008. * @param indexStart defines index start
  96009. * @param indexCount defines indices count
  96010. * @param mesh defines the parent mesh
  96011. * @param renderingMesh defines an optional rendering mesh
  96012. * @param createBoundingBox defines if bounding box should be created for this submesh
  96013. * @returns the new submesh
  96014. */
  96015. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  96016. /**
  96017. * Creates a new submesh
  96018. * @param materialIndex defines the material index to use
  96019. * @param verticesStart defines vertex index start
  96020. * @param verticesCount defines vertices count
  96021. * @param indexStart defines index start
  96022. * @param indexCount defines indices count
  96023. * @param mesh defines the parent mesh
  96024. * @param renderingMesh defines an optional rendering mesh
  96025. * @param createBoundingBox defines if bounding box should be created for this submesh
  96026. */
  96027. constructor(
  96028. /** the material index to use */
  96029. materialIndex: number,
  96030. /** vertex index start */
  96031. verticesStart: number,
  96032. /** vertices count */
  96033. verticesCount: number,
  96034. /** index start */
  96035. indexStart: number,
  96036. /** indices count */
  96037. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  96038. /**
  96039. * Returns true if this submesh covers the entire parent mesh
  96040. * @ignorenaming
  96041. */
  96042. get IsGlobal(): boolean;
  96043. /**
  96044. * Returns the submesh BoudingInfo object
  96045. * @returns current bounding info (or mesh's one if the submesh is global)
  96046. */
  96047. getBoundingInfo(): BoundingInfo;
  96048. /**
  96049. * Sets the submesh BoundingInfo
  96050. * @param boundingInfo defines the new bounding info to use
  96051. * @returns the SubMesh
  96052. */
  96053. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  96054. /**
  96055. * Returns the mesh of the current submesh
  96056. * @return the parent mesh
  96057. */
  96058. getMesh(): AbstractMesh;
  96059. /**
  96060. * Returns the rendering mesh of the submesh
  96061. * @returns the rendering mesh (could be different from parent mesh)
  96062. */
  96063. getRenderingMesh(): Mesh;
  96064. /**
  96065. * Returns the submesh material
  96066. * @returns null or the current material
  96067. */
  96068. getMaterial(): Nullable<Material>;
  96069. /**
  96070. * Sets a new updated BoundingInfo object to the submesh
  96071. * @param data defines an optional position array to use to determine the bounding info
  96072. * @returns the SubMesh
  96073. */
  96074. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  96075. /** @hidden */
  96076. _checkCollision(collider: Collider): boolean;
  96077. /**
  96078. * Updates the submesh BoundingInfo
  96079. * @param world defines the world matrix to use to update the bounding info
  96080. * @returns the submesh
  96081. */
  96082. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  96083. /**
  96084. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  96085. * @param frustumPlanes defines the frustum planes
  96086. * @returns true if the submesh is intersecting with the frustum
  96087. */
  96088. isInFrustum(frustumPlanes: Plane[]): boolean;
  96089. /**
  96090. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  96091. * @param frustumPlanes defines the frustum planes
  96092. * @returns true if the submesh is inside the frustum
  96093. */
  96094. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96095. /**
  96096. * Renders the submesh
  96097. * @param enableAlphaMode defines if alpha needs to be used
  96098. * @returns the submesh
  96099. */
  96100. render(enableAlphaMode: boolean): SubMesh;
  96101. /**
  96102. * @hidden
  96103. */
  96104. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  96105. /**
  96106. * Checks if the submesh intersects with a ray
  96107. * @param ray defines the ray to test
  96108. * @returns true is the passed ray intersects the submesh bounding box
  96109. */
  96110. canIntersects(ray: Ray): boolean;
  96111. /**
  96112. * Intersects current submesh with a ray
  96113. * @param ray defines the ray to test
  96114. * @param positions defines mesh's positions array
  96115. * @param indices defines mesh's indices array
  96116. * @param fastCheck defines if only bounding info should be used
  96117. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96118. * @returns intersection info or null if no intersection
  96119. */
  96120. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  96121. /** @hidden */
  96122. private _intersectLines;
  96123. /** @hidden */
  96124. private _intersectUnIndexedLines;
  96125. /** @hidden */
  96126. private _intersectTriangles;
  96127. /** @hidden */
  96128. private _intersectUnIndexedTriangles;
  96129. /** @hidden */
  96130. _rebuild(): void;
  96131. /**
  96132. * Creates a new submesh from the passed mesh
  96133. * @param newMesh defines the new hosting mesh
  96134. * @param newRenderingMesh defines an optional rendering mesh
  96135. * @returns the new submesh
  96136. */
  96137. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  96138. /**
  96139. * Release associated resources
  96140. */
  96141. dispose(): void;
  96142. /**
  96143. * Gets the class name
  96144. * @returns the string "SubMesh".
  96145. */
  96146. getClassName(): string;
  96147. /**
  96148. * Creates a new submesh from indices data
  96149. * @param materialIndex the index of the main mesh material
  96150. * @param startIndex the index where to start the copy in the mesh indices array
  96151. * @param indexCount the number of indices to copy then from the startIndex
  96152. * @param mesh the main mesh to create the submesh from
  96153. * @param renderingMesh the optional rendering mesh
  96154. * @returns a new submesh
  96155. */
  96156. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  96157. }
  96158. }
  96159. declare module BABYLON {
  96160. /**
  96161. * Class used to represent data loading progression
  96162. */
  96163. export class SceneLoaderFlags {
  96164. private static _ForceFullSceneLoadingForIncremental;
  96165. private static _ShowLoadingScreen;
  96166. private static _CleanBoneMatrixWeights;
  96167. private static _loggingLevel;
  96168. /**
  96169. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96170. */
  96171. static get ForceFullSceneLoadingForIncremental(): boolean;
  96172. static set ForceFullSceneLoadingForIncremental(value: boolean);
  96173. /**
  96174. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96175. */
  96176. static get ShowLoadingScreen(): boolean;
  96177. static set ShowLoadingScreen(value: boolean);
  96178. /**
  96179. * Defines the current logging level (while loading the scene)
  96180. * @ignorenaming
  96181. */
  96182. static get loggingLevel(): number;
  96183. static set loggingLevel(value: number);
  96184. /**
  96185. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96186. */
  96187. static get CleanBoneMatrixWeights(): boolean;
  96188. static set CleanBoneMatrixWeights(value: boolean);
  96189. }
  96190. }
  96191. declare module BABYLON {
  96192. /**
  96193. * Class used to store geometry data (vertex buffers + index buffer)
  96194. */
  96195. export class Geometry implements IGetSetVerticesData {
  96196. /**
  96197. * Gets or sets the ID of the geometry
  96198. */
  96199. id: string;
  96200. /**
  96201. * Gets or sets the unique ID of the geometry
  96202. */
  96203. uniqueId: number;
  96204. /**
  96205. * Gets the delay loading state of the geometry (none by default which means not delayed)
  96206. */
  96207. delayLoadState: number;
  96208. /**
  96209. * Gets the file containing the data to load when running in delay load state
  96210. */
  96211. delayLoadingFile: Nullable<string>;
  96212. /**
  96213. * Callback called when the geometry is updated
  96214. */
  96215. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  96216. private _scene;
  96217. private _engine;
  96218. private _meshes;
  96219. private _totalVertices;
  96220. /** @hidden */
  96221. _indices: IndicesArray;
  96222. /** @hidden */
  96223. _vertexBuffers: {
  96224. [key: string]: VertexBuffer;
  96225. };
  96226. private _isDisposed;
  96227. private _extend;
  96228. private _boundingBias;
  96229. /** @hidden */
  96230. _delayInfo: Array<string>;
  96231. private _indexBuffer;
  96232. private _indexBufferIsUpdatable;
  96233. /** @hidden */
  96234. _boundingInfo: Nullable<BoundingInfo>;
  96235. /** @hidden */
  96236. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  96237. /** @hidden */
  96238. _softwareSkinningFrameId: number;
  96239. private _vertexArrayObjects;
  96240. private _updatable;
  96241. /** @hidden */
  96242. _positions: Nullable<Vector3[]>;
  96243. /**
  96244. * 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
  96245. */
  96246. get boundingBias(): Vector2;
  96247. /**
  96248. * 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
  96249. */
  96250. set boundingBias(value: Vector2);
  96251. /**
  96252. * Static function used to attach a new empty geometry to a mesh
  96253. * @param mesh defines the mesh to attach the geometry to
  96254. * @returns the new Geometry
  96255. */
  96256. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  96257. /** Get the list of meshes using this geometry */
  96258. get meshes(): Mesh[];
  96259. /**
  96260. * Creates a new geometry
  96261. * @param id defines the unique ID
  96262. * @param scene defines the hosting scene
  96263. * @param vertexData defines the VertexData used to get geometry data
  96264. * @param updatable defines if geometry must be updatable (false by default)
  96265. * @param mesh defines the mesh that will be associated with the geometry
  96266. */
  96267. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  96268. /**
  96269. * Gets the current extend of the geometry
  96270. */
  96271. get extend(): {
  96272. minimum: Vector3;
  96273. maximum: Vector3;
  96274. };
  96275. /**
  96276. * Gets the hosting scene
  96277. * @returns the hosting Scene
  96278. */
  96279. getScene(): Scene;
  96280. /**
  96281. * Gets the hosting engine
  96282. * @returns the hosting Engine
  96283. */
  96284. getEngine(): Engine;
  96285. /**
  96286. * Defines if the geometry is ready to use
  96287. * @returns true if the geometry is ready to be used
  96288. */
  96289. isReady(): boolean;
  96290. /**
  96291. * Gets a value indicating that the geometry should not be serialized
  96292. */
  96293. get doNotSerialize(): boolean;
  96294. /** @hidden */
  96295. _rebuild(): void;
  96296. /**
  96297. * Affects all geometry data in one call
  96298. * @param vertexData defines the geometry data
  96299. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96300. */
  96301. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  96302. /**
  96303. * Set specific vertex data
  96304. * @param kind defines the data kind (Position, normal, etc...)
  96305. * @param data defines the vertex data to use
  96306. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96307. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96308. */
  96309. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  96310. /**
  96311. * Removes a specific vertex data
  96312. * @param kind defines the data kind (Position, normal, etc...)
  96313. */
  96314. removeVerticesData(kind: string): void;
  96315. /**
  96316. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96317. * @param buffer defines the vertex buffer to use
  96318. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96319. */
  96320. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  96321. /**
  96322. * Update a specific vertex buffer
  96323. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96324. * It will do nothing if the buffer is not updatable
  96325. * @param kind defines the data kind (Position, normal, etc...)
  96326. * @param data defines the data to use
  96327. * @param offset defines the offset in the target buffer where to store the data
  96328. * @param useBytes set to true if the offset is in bytes
  96329. */
  96330. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  96331. /**
  96332. * Update a specific vertex buffer
  96333. * This function will create a new buffer if the current one is not updatable
  96334. * @param kind defines the data kind (Position, normal, etc...)
  96335. * @param data defines the data to use
  96336. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96337. */
  96338. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  96339. private _updateBoundingInfo;
  96340. /** @hidden */
  96341. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  96342. /**
  96343. * Gets total number of vertices
  96344. * @returns the total number of vertices
  96345. */
  96346. getTotalVertices(): number;
  96347. /**
  96348. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96349. * @param kind defines the data kind (Position, normal, etc...)
  96350. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96351. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96352. * @returns a float array containing vertex data
  96353. */
  96354. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96355. /**
  96356. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96357. * @param kind defines the data kind (Position, normal, etc...)
  96358. * @returns true if the vertex buffer with the specified kind is updatable
  96359. */
  96360. isVertexBufferUpdatable(kind: string): boolean;
  96361. /**
  96362. * Gets a specific vertex buffer
  96363. * @param kind defines the data kind (Position, normal, etc...)
  96364. * @returns a VertexBuffer
  96365. */
  96366. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96367. /**
  96368. * Returns all vertex buffers
  96369. * @return an object holding all vertex buffers indexed by kind
  96370. */
  96371. getVertexBuffers(): Nullable<{
  96372. [key: string]: VertexBuffer;
  96373. }>;
  96374. /**
  96375. * Gets a boolean indicating if specific vertex buffer is present
  96376. * @param kind defines the data kind (Position, normal, etc...)
  96377. * @returns true if data is present
  96378. */
  96379. isVerticesDataPresent(kind: string): boolean;
  96380. /**
  96381. * Gets a list of all attached data kinds (Position, normal, etc...)
  96382. * @returns a list of string containing all kinds
  96383. */
  96384. getVerticesDataKinds(): string[];
  96385. /**
  96386. * Update index buffer
  96387. * @param indices defines the indices to store in the index buffer
  96388. * @param offset defines the offset in the target buffer where to store the data
  96389. * @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)
  96390. */
  96391. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  96392. /**
  96393. * Creates a new index buffer
  96394. * @param indices defines the indices to store in the index buffer
  96395. * @param totalVertices defines the total number of vertices (could be null)
  96396. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96397. */
  96398. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  96399. /**
  96400. * Return the total number of indices
  96401. * @returns the total number of indices
  96402. */
  96403. getTotalIndices(): number;
  96404. /**
  96405. * Gets the index buffer array
  96406. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96407. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96408. * @returns the index buffer array
  96409. */
  96410. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96411. /**
  96412. * Gets the index buffer
  96413. * @return the index buffer
  96414. */
  96415. getIndexBuffer(): Nullable<DataBuffer>;
  96416. /** @hidden */
  96417. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  96418. /**
  96419. * Release the associated resources for a specific mesh
  96420. * @param mesh defines the source mesh
  96421. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96422. */
  96423. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  96424. /**
  96425. * Apply current geometry to a given mesh
  96426. * @param mesh defines the mesh to apply geometry to
  96427. */
  96428. applyToMesh(mesh: Mesh): void;
  96429. private _updateExtend;
  96430. private _applyToMesh;
  96431. private notifyUpdate;
  96432. /**
  96433. * Load the geometry if it was flagged as delay loaded
  96434. * @param scene defines the hosting scene
  96435. * @param onLoaded defines a callback called when the geometry is loaded
  96436. */
  96437. load(scene: Scene, onLoaded?: () => void): void;
  96438. private _queueLoad;
  96439. /**
  96440. * Invert the geometry to move from a right handed system to a left handed one.
  96441. */
  96442. toLeftHanded(): void;
  96443. /** @hidden */
  96444. _resetPointsArrayCache(): void;
  96445. /** @hidden */
  96446. _generatePointsArray(): boolean;
  96447. /**
  96448. * Gets a value indicating if the geometry is disposed
  96449. * @returns true if the geometry was disposed
  96450. */
  96451. isDisposed(): boolean;
  96452. private _disposeVertexArrayObjects;
  96453. /**
  96454. * Free all associated resources
  96455. */
  96456. dispose(): void;
  96457. /**
  96458. * Clone the current geometry into a new geometry
  96459. * @param id defines the unique ID of the new geometry
  96460. * @returns a new geometry object
  96461. */
  96462. copy(id: string): Geometry;
  96463. /**
  96464. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96465. * @return a JSON representation of the current geometry data (without the vertices data)
  96466. */
  96467. serialize(): any;
  96468. private toNumberArray;
  96469. /**
  96470. * Serialize all vertices data into a JSON oject
  96471. * @returns a JSON representation of the current geometry data
  96472. */
  96473. serializeVerticeData(): any;
  96474. /**
  96475. * Extracts a clone of a mesh geometry
  96476. * @param mesh defines the source mesh
  96477. * @param id defines the unique ID of the new geometry object
  96478. * @returns the new geometry object
  96479. */
  96480. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  96481. /**
  96482. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96483. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96484. * Be aware Math.random() could cause collisions, but:
  96485. * "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"
  96486. * @returns a string containing a new GUID
  96487. */
  96488. static RandomId(): string;
  96489. /** @hidden */
  96490. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  96491. private static _CleanMatricesWeights;
  96492. /**
  96493. * Create a new geometry from persisted data (Using .babylon file format)
  96494. * @param parsedVertexData defines the persisted data
  96495. * @param scene defines the hosting scene
  96496. * @param rootUrl defines the root url to use to load assets (like delayed data)
  96497. * @returns the new geometry object
  96498. */
  96499. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  96500. }
  96501. }
  96502. declare module BABYLON {
  96503. /**
  96504. * Define an interface for all classes that will get and set the data on vertices
  96505. */
  96506. export interface IGetSetVerticesData {
  96507. /**
  96508. * Gets a boolean indicating if specific vertex data is present
  96509. * @param kind defines the vertex data kind to use
  96510. * @returns true is data kind is present
  96511. */
  96512. isVerticesDataPresent(kind: string): boolean;
  96513. /**
  96514. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96515. * @param kind defines the data kind (Position, normal, etc...)
  96516. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96517. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96518. * @returns a float array containing vertex data
  96519. */
  96520. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96521. /**
  96522. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96523. * @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.
  96524. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96525. * @returns the indices array or an empty array if the mesh has no geometry
  96526. */
  96527. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96528. /**
  96529. * Set specific vertex data
  96530. * @param kind defines the data kind (Position, normal, etc...)
  96531. * @param data defines the vertex data to use
  96532. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96533. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96534. */
  96535. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  96536. /**
  96537. * Update a specific associated vertex buffer
  96538. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96539. * - VertexBuffer.PositionKind
  96540. * - VertexBuffer.UVKind
  96541. * - VertexBuffer.UV2Kind
  96542. * - VertexBuffer.UV3Kind
  96543. * - VertexBuffer.UV4Kind
  96544. * - VertexBuffer.UV5Kind
  96545. * - VertexBuffer.UV6Kind
  96546. * - VertexBuffer.ColorKind
  96547. * - VertexBuffer.MatricesIndicesKind
  96548. * - VertexBuffer.MatricesIndicesExtraKind
  96549. * - VertexBuffer.MatricesWeightsKind
  96550. * - VertexBuffer.MatricesWeightsExtraKind
  96551. * @param data defines the data source
  96552. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  96553. * @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)
  96554. */
  96555. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  96556. /**
  96557. * Creates a new index buffer
  96558. * @param indices defines the indices to store in the index buffer
  96559. * @param totalVertices defines the total number of vertices (could be null)
  96560. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96561. */
  96562. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  96563. }
  96564. /**
  96565. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  96566. */
  96567. export class VertexData {
  96568. /**
  96569. * Mesh side orientation : usually the external or front surface
  96570. */
  96571. static readonly FRONTSIDE: number;
  96572. /**
  96573. * Mesh side orientation : usually the internal or back surface
  96574. */
  96575. static readonly BACKSIDE: number;
  96576. /**
  96577. * Mesh side orientation : both internal and external or front and back surfaces
  96578. */
  96579. static readonly DOUBLESIDE: number;
  96580. /**
  96581. * Mesh side orientation : by default, `FRONTSIDE`
  96582. */
  96583. static readonly DEFAULTSIDE: number;
  96584. /**
  96585. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  96586. */
  96587. positions: Nullable<FloatArray>;
  96588. /**
  96589. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  96590. */
  96591. normals: Nullable<FloatArray>;
  96592. /**
  96593. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  96594. */
  96595. tangents: Nullable<FloatArray>;
  96596. /**
  96597. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96598. */
  96599. uvs: Nullable<FloatArray>;
  96600. /**
  96601. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96602. */
  96603. uvs2: Nullable<FloatArray>;
  96604. /**
  96605. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96606. */
  96607. uvs3: Nullable<FloatArray>;
  96608. /**
  96609. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96610. */
  96611. uvs4: Nullable<FloatArray>;
  96612. /**
  96613. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96614. */
  96615. uvs5: Nullable<FloatArray>;
  96616. /**
  96617. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96618. */
  96619. uvs6: Nullable<FloatArray>;
  96620. /**
  96621. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  96622. */
  96623. colors: Nullable<FloatArray>;
  96624. /**
  96625. * 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).
  96626. */
  96627. matricesIndices: Nullable<FloatArray>;
  96628. /**
  96629. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  96630. */
  96631. matricesWeights: Nullable<FloatArray>;
  96632. /**
  96633. * An array extending the number of possible indices
  96634. */
  96635. matricesIndicesExtra: Nullable<FloatArray>;
  96636. /**
  96637. * An array extending the number of possible weights when the number of indices is extended
  96638. */
  96639. matricesWeightsExtra: Nullable<FloatArray>;
  96640. /**
  96641. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  96642. */
  96643. indices: Nullable<IndicesArray>;
  96644. /**
  96645. * Uses the passed data array to set the set the values for the specified kind of data
  96646. * @param data a linear array of floating numbers
  96647. * @param kind the type of data that is being set, eg positions, colors etc
  96648. */
  96649. set(data: FloatArray, kind: string): void;
  96650. /**
  96651. * Associates the vertexData to the passed Mesh.
  96652. * Sets it as updatable or not (default `false`)
  96653. * @param mesh the mesh the vertexData is applied to
  96654. * @param updatable when used and having the value true allows new data to update the vertexData
  96655. * @returns the VertexData
  96656. */
  96657. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  96658. /**
  96659. * Associates the vertexData to the passed Geometry.
  96660. * Sets it as updatable or not (default `false`)
  96661. * @param geometry the geometry the vertexData is applied to
  96662. * @param updatable when used and having the value true allows new data to update the vertexData
  96663. * @returns VertexData
  96664. */
  96665. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  96666. /**
  96667. * Updates the associated mesh
  96668. * @param mesh the mesh to be updated
  96669. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96670. * @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
  96671. * @returns VertexData
  96672. */
  96673. updateMesh(mesh: Mesh): VertexData;
  96674. /**
  96675. * Updates the associated geometry
  96676. * @param geometry the geometry to be updated
  96677. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96678. * @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
  96679. * @returns VertexData.
  96680. */
  96681. updateGeometry(geometry: Geometry): VertexData;
  96682. private _applyTo;
  96683. private _update;
  96684. /**
  96685. * Transforms each position and each normal of the vertexData according to the passed Matrix
  96686. * @param matrix the transforming matrix
  96687. * @returns the VertexData
  96688. */
  96689. transform(matrix: Matrix): VertexData;
  96690. /**
  96691. * Merges the passed VertexData into the current one
  96692. * @param other the VertexData to be merged into the current one
  96693. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  96694. * @returns the modified VertexData
  96695. */
  96696. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  96697. private _mergeElement;
  96698. private _validate;
  96699. /**
  96700. * Serializes the VertexData
  96701. * @returns a serialized object
  96702. */
  96703. serialize(): any;
  96704. /**
  96705. * Extracts the vertexData from a mesh
  96706. * @param mesh the mesh from which to extract the VertexData
  96707. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  96708. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96709. * @returns the object VertexData associated to the passed mesh
  96710. */
  96711. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96712. /**
  96713. * Extracts the vertexData from the geometry
  96714. * @param geometry the geometry from which to extract the VertexData
  96715. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  96716. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96717. * @returns the object VertexData associated to the passed mesh
  96718. */
  96719. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96720. private static _ExtractFrom;
  96721. /**
  96722. * Creates the VertexData for a Ribbon
  96723. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  96724. * * pathArray array of paths, each of which an array of successive Vector3
  96725. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  96726. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  96727. * * 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
  96728. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96729. * * 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)
  96730. * * 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)
  96731. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  96732. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  96733. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  96734. * @returns the VertexData of the ribbon
  96735. */
  96736. static CreateRibbon(options: {
  96737. pathArray: Vector3[][];
  96738. closeArray?: boolean;
  96739. closePath?: boolean;
  96740. offset?: number;
  96741. sideOrientation?: number;
  96742. frontUVs?: Vector4;
  96743. backUVs?: Vector4;
  96744. invertUV?: boolean;
  96745. uvs?: Vector2[];
  96746. colors?: Color4[];
  96747. }): VertexData;
  96748. /**
  96749. * Creates the VertexData for a box
  96750. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96751. * * size sets the width, height and depth of the box to the value of size, optional default 1
  96752. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  96753. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  96754. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  96755. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96756. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96758. * * 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)
  96759. * * 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)
  96760. * @returns the VertexData of the box
  96761. */
  96762. static CreateBox(options: {
  96763. size?: number;
  96764. width?: number;
  96765. height?: number;
  96766. depth?: number;
  96767. faceUV?: Vector4[];
  96768. faceColors?: Color4[];
  96769. sideOrientation?: number;
  96770. frontUVs?: Vector4;
  96771. backUVs?: Vector4;
  96772. }): VertexData;
  96773. /**
  96774. * Creates the VertexData for a tiled box
  96775. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96776. * * faceTiles sets the pattern, tile size and number of tiles for a face
  96777. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96778. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96779. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96780. * @returns the VertexData of the box
  96781. */
  96782. static CreateTiledBox(options: {
  96783. pattern?: number;
  96784. width?: number;
  96785. height?: number;
  96786. depth?: number;
  96787. tileSize?: number;
  96788. tileWidth?: number;
  96789. tileHeight?: number;
  96790. alignHorizontal?: number;
  96791. alignVertical?: number;
  96792. faceUV?: Vector4[];
  96793. faceColors?: Color4[];
  96794. sideOrientation?: number;
  96795. }): VertexData;
  96796. /**
  96797. * Creates the VertexData for a tiled plane
  96798. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96799. * * pattern a limited pattern arrangement depending on the number
  96800. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  96801. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  96802. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  96803. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96804. * * 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)
  96805. * * 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)
  96806. * @returns the VertexData of the tiled plane
  96807. */
  96808. static CreateTiledPlane(options: {
  96809. pattern?: number;
  96810. tileSize?: number;
  96811. tileWidth?: number;
  96812. tileHeight?: number;
  96813. size?: number;
  96814. width?: number;
  96815. height?: number;
  96816. alignHorizontal?: number;
  96817. alignVertical?: number;
  96818. sideOrientation?: number;
  96819. frontUVs?: Vector4;
  96820. backUVs?: Vector4;
  96821. }): VertexData;
  96822. /**
  96823. * Creates the VertexData for an ellipsoid, defaults to a sphere
  96824. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96825. * * segments sets the number of horizontal strips optional, default 32
  96826. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96827. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96828. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96829. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96830. * * 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
  96831. * * 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
  96832. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96833. * * 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)
  96834. * * 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)
  96835. * @returns the VertexData of the ellipsoid
  96836. */
  96837. static CreateSphere(options: {
  96838. segments?: number;
  96839. diameter?: number;
  96840. diameterX?: number;
  96841. diameterY?: number;
  96842. diameterZ?: number;
  96843. arc?: number;
  96844. slice?: number;
  96845. sideOrientation?: number;
  96846. frontUVs?: Vector4;
  96847. backUVs?: Vector4;
  96848. }): VertexData;
  96849. /**
  96850. * Creates the VertexData for a cylinder, cone or prism
  96851. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96852. * * height sets the height (y direction) of the cylinder, optional, default 2
  96853. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96854. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96855. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96856. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96857. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96858. * * 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
  96859. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96860. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96861. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96862. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96864. * * 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)
  96865. * * 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)
  96866. * @returns the VertexData of the cylinder, cone or prism
  96867. */
  96868. static CreateCylinder(options: {
  96869. height?: number;
  96870. diameterTop?: number;
  96871. diameterBottom?: number;
  96872. diameter?: number;
  96873. tessellation?: number;
  96874. subdivisions?: number;
  96875. arc?: number;
  96876. faceColors?: Color4[];
  96877. faceUV?: Vector4[];
  96878. hasRings?: boolean;
  96879. enclose?: boolean;
  96880. sideOrientation?: number;
  96881. frontUVs?: Vector4;
  96882. backUVs?: Vector4;
  96883. }): VertexData;
  96884. /**
  96885. * Creates the VertexData for a torus
  96886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96887. * * diameter the diameter of the torus, optional default 1
  96888. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96889. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96890. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96891. * * 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)
  96892. * * 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)
  96893. * @returns the VertexData of the torus
  96894. */
  96895. static CreateTorus(options: {
  96896. diameter?: number;
  96897. thickness?: number;
  96898. tessellation?: number;
  96899. sideOrientation?: number;
  96900. frontUVs?: Vector4;
  96901. backUVs?: Vector4;
  96902. }): VertexData;
  96903. /**
  96904. * Creates the VertexData of the LineSystem
  96905. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96906. * - lines an array of lines, each line being an array of successive Vector3
  96907. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96908. * @returns the VertexData of the LineSystem
  96909. */
  96910. static CreateLineSystem(options: {
  96911. lines: Vector3[][];
  96912. colors?: Nullable<Color4[][]>;
  96913. }): VertexData;
  96914. /**
  96915. * Create the VertexData for a DashedLines
  96916. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96917. * - points an array successive Vector3
  96918. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96919. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96920. * - dashNb the intended total number of dashes, optional, default 200
  96921. * @returns the VertexData for the DashedLines
  96922. */
  96923. static CreateDashedLines(options: {
  96924. points: Vector3[];
  96925. dashSize?: number;
  96926. gapSize?: number;
  96927. dashNb?: number;
  96928. }): VertexData;
  96929. /**
  96930. * Creates the VertexData for a Ground
  96931. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96932. * - width the width (x direction) of the ground, optional, default 1
  96933. * - height the height (z direction) of the ground, optional, default 1
  96934. * - subdivisions the number of subdivisions per side, optional, default 1
  96935. * @returns the VertexData of the Ground
  96936. */
  96937. static CreateGround(options: {
  96938. width?: number;
  96939. height?: number;
  96940. subdivisions?: number;
  96941. subdivisionsX?: number;
  96942. subdivisionsY?: number;
  96943. }): VertexData;
  96944. /**
  96945. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96946. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96947. * * xmin the ground minimum X coordinate, optional, default -1
  96948. * * zmin the ground minimum Z coordinate, optional, default -1
  96949. * * xmax the ground maximum X coordinate, optional, default 1
  96950. * * zmax the ground maximum Z coordinate, optional, default 1
  96951. * * 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}
  96952. * * 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}
  96953. * @returns the VertexData of the TiledGround
  96954. */
  96955. static CreateTiledGround(options: {
  96956. xmin: number;
  96957. zmin: number;
  96958. xmax: number;
  96959. zmax: number;
  96960. subdivisions?: {
  96961. w: number;
  96962. h: number;
  96963. };
  96964. precision?: {
  96965. w: number;
  96966. h: number;
  96967. };
  96968. }): VertexData;
  96969. /**
  96970. * Creates the VertexData of the Ground designed from a heightmap
  96971. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96972. * * width the width (x direction) of the ground
  96973. * * height the height (z direction) of the ground
  96974. * * subdivisions the number of subdivisions per side
  96975. * * minHeight the minimum altitude on the ground, optional, default 0
  96976. * * maxHeight the maximum altitude on the ground, optional default 1
  96977. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96978. * * buffer the array holding the image color data
  96979. * * bufferWidth the width of image
  96980. * * bufferHeight the height of image
  96981. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96982. * @returns the VertexData of the Ground designed from a heightmap
  96983. */
  96984. static CreateGroundFromHeightMap(options: {
  96985. width: number;
  96986. height: number;
  96987. subdivisions: number;
  96988. minHeight: number;
  96989. maxHeight: number;
  96990. colorFilter: Color3;
  96991. buffer: Uint8Array;
  96992. bufferWidth: number;
  96993. bufferHeight: number;
  96994. alphaFilter: number;
  96995. }): VertexData;
  96996. /**
  96997. * Creates the VertexData for a Plane
  96998. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  96999. * * size sets the width and height of the plane to the value of size, optional default 1
  97000. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  97001. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  97002. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97003. * * 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)
  97004. * * 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)
  97005. * @returns the VertexData of the box
  97006. */
  97007. static CreatePlane(options: {
  97008. size?: number;
  97009. width?: number;
  97010. height?: number;
  97011. sideOrientation?: number;
  97012. frontUVs?: Vector4;
  97013. backUVs?: Vector4;
  97014. }): VertexData;
  97015. /**
  97016. * Creates the VertexData of the Disc or regular Polygon
  97017. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  97018. * * radius the radius of the disc, optional default 0.5
  97019. * * tessellation the number of polygon sides, optional, default 64
  97020. * * 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
  97021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97022. * * 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)
  97023. * * 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)
  97024. * @returns the VertexData of the box
  97025. */
  97026. static CreateDisc(options: {
  97027. radius?: number;
  97028. tessellation?: number;
  97029. arc?: number;
  97030. sideOrientation?: number;
  97031. frontUVs?: Vector4;
  97032. backUVs?: Vector4;
  97033. }): VertexData;
  97034. /**
  97035. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  97036. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  97037. * @param polygon a mesh built from polygonTriangulation.build()
  97038. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97039. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97040. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97041. * @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)
  97042. * @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)
  97043. * @returns the VertexData of the Polygon
  97044. */
  97045. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  97046. /**
  97047. * Creates the VertexData of the IcoSphere
  97048. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  97049. * * radius the radius of the IcoSphere, optional default 1
  97050. * * radiusX allows stretching in the x direction, optional, default radius
  97051. * * radiusY allows stretching in the y direction, optional, default radius
  97052. * * radiusZ allows stretching in the z direction, optional, default radius
  97053. * * flat when true creates a flat shaded mesh, optional, default true
  97054. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97055. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97056. * * 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)
  97057. * * 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)
  97058. * @returns the VertexData of the IcoSphere
  97059. */
  97060. static CreateIcoSphere(options: {
  97061. radius?: number;
  97062. radiusX?: number;
  97063. radiusY?: number;
  97064. radiusZ?: number;
  97065. flat?: boolean;
  97066. subdivisions?: number;
  97067. sideOrientation?: number;
  97068. frontUVs?: Vector4;
  97069. backUVs?: Vector4;
  97070. }): VertexData;
  97071. /**
  97072. * Creates the VertexData for a Polyhedron
  97073. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  97074. * * type provided types are:
  97075. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  97076. * * 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)
  97077. * * size the size of the IcoSphere, optional default 1
  97078. * * sizeX allows stretching in the x direction, optional, default size
  97079. * * sizeY allows stretching in the y direction, optional, default size
  97080. * * sizeZ allows stretching in the z direction, optional, default size
  97081. * * 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
  97082. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97083. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97084. * * flat when true creates a flat shaded mesh, optional, default true
  97085. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97086. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97087. * * 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)
  97088. * * 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)
  97089. * @returns the VertexData of the Polyhedron
  97090. */
  97091. static CreatePolyhedron(options: {
  97092. type?: number;
  97093. size?: number;
  97094. sizeX?: number;
  97095. sizeY?: number;
  97096. sizeZ?: number;
  97097. custom?: any;
  97098. faceUV?: Vector4[];
  97099. faceColors?: Color4[];
  97100. flat?: boolean;
  97101. sideOrientation?: number;
  97102. frontUVs?: Vector4;
  97103. backUVs?: Vector4;
  97104. }): VertexData;
  97105. /**
  97106. * Creates the VertexData for a TorusKnot
  97107. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  97108. * * radius the radius of the torus knot, optional, default 2
  97109. * * tube the thickness of the tube, optional, default 0.5
  97110. * * radialSegments the number of sides on each tube segments, optional, default 32
  97111. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  97112. * * p the number of windings around the z axis, optional, default 2
  97113. * * q the number of windings around the x axis, optional, default 3
  97114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97115. * * 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)
  97116. * * 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)
  97117. * @returns the VertexData of the Torus Knot
  97118. */
  97119. static CreateTorusKnot(options: {
  97120. radius?: number;
  97121. tube?: number;
  97122. radialSegments?: number;
  97123. tubularSegments?: number;
  97124. p?: number;
  97125. q?: number;
  97126. sideOrientation?: number;
  97127. frontUVs?: Vector4;
  97128. backUVs?: Vector4;
  97129. }): VertexData;
  97130. /**
  97131. * Compute normals for given positions and indices
  97132. * @param positions an array of vertex positions, [...., x, y, z, ......]
  97133. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  97134. * @param normals an array of vertex normals, [...., x, y, z, ......]
  97135. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  97136. * * facetNormals : optional array of facet normals (vector3)
  97137. * * facetPositions : optional array of facet positions (vector3)
  97138. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  97139. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  97140. * * bInfo : optional bounding info, required for facetPartitioning computation
  97141. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  97142. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  97143. * * useRightHandedSystem: optional boolean to for right handed system computation
  97144. * * depthSort : optional boolean to enable the facet depth sort computation
  97145. * * distanceTo : optional Vector3 to compute the facet depth from this location
  97146. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  97147. */
  97148. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  97149. facetNormals?: any;
  97150. facetPositions?: any;
  97151. facetPartitioning?: any;
  97152. ratio?: number;
  97153. bInfo?: any;
  97154. bbSize?: Vector3;
  97155. subDiv?: any;
  97156. useRightHandedSystem?: boolean;
  97157. depthSort?: boolean;
  97158. distanceTo?: Vector3;
  97159. depthSortedFacets?: any;
  97160. }): void;
  97161. /** @hidden */
  97162. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  97163. /**
  97164. * Applies VertexData created from the imported parameters to the geometry
  97165. * @param parsedVertexData the parsed data from an imported file
  97166. * @param geometry the geometry to apply the VertexData to
  97167. */
  97168. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  97169. }
  97170. }
  97171. declare module BABYLON {
  97172. /**
  97173. * Defines a target to use with MorphTargetManager
  97174. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97175. */
  97176. export class MorphTarget implements IAnimatable {
  97177. /** defines the name of the target */
  97178. name: string;
  97179. /**
  97180. * Gets or sets the list of animations
  97181. */
  97182. animations: Animation[];
  97183. private _scene;
  97184. private _positions;
  97185. private _normals;
  97186. private _tangents;
  97187. private _uvs;
  97188. private _influence;
  97189. private _uniqueId;
  97190. /**
  97191. * Observable raised when the influence changes
  97192. */
  97193. onInfluenceChanged: Observable<boolean>;
  97194. /** @hidden */
  97195. _onDataLayoutChanged: Observable<void>;
  97196. /**
  97197. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  97198. */
  97199. get influence(): number;
  97200. set influence(influence: number);
  97201. /**
  97202. * Gets or sets the id of the morph Target
  97203. */
  97204. id: string;
  97205. private _animationPropertiesOverride;
  97206. /**
  97207. * Gets or sets the animation properties override
  97208. */
  97209. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97210. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97211. /**
  97212. * Creates a new MorphTarget
  97213. * @param name defines the name of the target
  97214. * @param influence defines the influence to use
  97215. * @param scene defines the scene the morphtarget belongs to
  97216. */
  97217. constructor(
  97218. /** defines the name of the target */
  97219. name: string, influence?: number, scene?: Nullable<Scene>);
  97220. /**
  97221. * Gets the unique ID of this manager
  97222. */
  97223. get uniqueId(): number;
  97224. /**
  97225. * Gets a boolean defining if the target contains position data
  97226. */
  97227. get hasPositions(): boolean;
  97228. /**
  97229. * Gets a boolean defining if the target contains normal data
  97230. */
  97231. get hasNormals(): boolean;
  97232. /**
  97233. * Gets a boolean defining if the target contains tangent data
  97234. */
  97235. get hasTangents(): boolean;
  97236. /**
  97237. * Gets a boolean defining if the target contains texture coordinates data
  97238. */
  97239. get hasUVs(): boolean;
  97240. /**
  97241. * Affects position data to this target
  97242. * @param data defines the position data to use
  97243. */
  97244. setPositions(data: Nullable<FloatArray>): void;
  97245. /**
  97246. * Gets the position data stored in this target
  97247. * @returns a FloatArray containing the position data (or null if not present)
  97248. */
  97249. getPositions(): Nullable<FloatArray>;
  97250. /**
  97251. * Affects normal data to this target
  97252. * @param data defines the normal data to use
  97253. */
  97254. setNormals(data: Nullable<FloatArray>): void;
  97255. /**
  97256. * Gets the normal data stored in this target
  97257. * @returns a FloatArray containing the normal data (or null if not present)
  97258. */
  97259. getNormals(): Nullable<FloatArray>;
  97260. /**
  97261. * Affects tangent data to this target
  97262. * @param data defines the tangent data to use
  97263. */
  97264. setTangents(data: Nullable<FloatArray>): void;
  97265. /**
  97266. * Gets the tangent data stored in this target
  97267. * @returns a FloatArray containing the tangent data (or null if not present)
  97268. */
  97269. getTangents(): Nullable<FloatArray>;
  97270. /**
  97271. * Affects texture coordinates data to this target
  97272. * @param data defines the texture coordinates data to use
  97273. */
  97274. setUVs(data: Nullable<FloatArray>): void;
  97275. /**
  97276. * Gets the texture coordinates data stored in this target
  97277. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  97278. */
  97279. getUVs(): Nullable<FloatArray>;
  97280. /**
  97281. * Clone the current target
  97282. * @returns a new MorphTarget
  97283. */
  97284. clone(): MorphTarget;
  97285. /**
  97286. * Serializes the current target into a Serialization object
  97287. * @returns the serialized object
  97288. */
  97289. serialize(): any;
  97290. /**
  97291. * Returns the string "MorphTarget"
  97292. * @returns "MorphTarget"
  97293. */
  97294. getClassName(): string;
  97295. /**
  97296. * Creates a new target from serialized data
  97297. * @param serializationObject defines the serialized data to use
  97298. * @returns a new MorphTarget
  97299. */
  97300. static Parse(serializationObject: any): MorphTarget;
  97301. /**
  97302. * Creates a MorphTarget from mesh data
  97303. * @param mesh defines the source mesh
  97304. * @param name defines the name to use for the new target
  97305. * @param influence defines the influence to attach to the target
  97306. * @returns a new MorphTarget
  97307. */
  97308. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  97309. }
  97310. }
  97311. declare module BABYLON {
  97312. /**
  97313. * This class is used to deform meshes using morphing between different targets
  97314. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97315. */
  97316. export class MorphTargetManager {
  97317. private _targets;
  97318. private _targetInfluenceChangedObservers;
  97319. private _targetDataLayoutChangedObservers;
  97320. private _activeTargets;
  97321. private _scene;
  97322. private _influences;
  97323. private _supportsNormals;
  97324. private _supportsTangents;
  97325. private _supportsUVs;
  97326. private _vertexCount;
  97327. private _uniqueId;
  97328. private _tempInfluences;
  97329. /**
  97330. * Gets or sets a boolean indicating if normals must be morphed
  97331. */
  97332. enableNormalMorphing: boolean;
  97333. /**
  97334. * Gets or sets a boolean indicating if tangents must be morphed
  97335. */
  97336. enableTangentMorphing: boolean;
  97337. /**
  97338. * Gets or sets a boolean indicating if UV must be morphed
  97339. */
  97340. enableUVMorphing: boolean;
  97341. /**
  97342. * Creates a new MorphTargetManager
  97343. * @param scene defines the current scene
  97344. */
  97345. constructor(scene?: Nullable<Scene>);
  97346. /**
  97347. * Gets the unique ID of this manager
  97348. */
  97349. get uniqueId(): number;
  97350. /**
  97351. * Gets the number of vertices handled by this manager
  97352. */
  97353. get vertexCount(): number;
  97354. /**
  97355. * Gets a boolean indicating if this manager supports morphing of normals
  97356. */
  97357. get supportsNormals(): boolean;
  97358. /**
  97359. * Gets a boolean indicating if this manager supports morphing of tangents
  97360. */
  97361. get supportsTangents(): boolean;
  97362. /**
  97363. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  97364. */
  97365. get supportsUVs(): boolean;
  97366. /**
  97367. * Gets the number of targets stored in this manager
  97368. */
  97369. get numTargets(): number;
  97370. /**
  97371. * Gets the number of influencers (ie. the number of targets with influences > 0)
  97372. */
  97373. get numInfluencers(): number;
  97374. /**
  97375. * Gets the list of influences (one per target)
  97376. */
  97377. get influences(): Float32Array;
  97378. /**
  97379. * Gets the active target at specified index. An active target is a target with an influence > 0
  97380. * @param index defines the index to check
  97381. * @returns the requested target
  97382. */
  97383. getActiveTarget(index: number): MorphTarget;
  97384. /**
  97385. * Gets the target at specified index
  97386. * @param index defines the index to check
  97387. * @returns the requested target
  97388. */
  97389. getTarget(index: number): MorphTarget;
  97390. /**
  97391. * Add a new target to this manager
  97392. * @param target defines the target to add
  97393. */
  97394. addTarget(target: MorphTarget): void;
  97395. /**
  97396. * Removes a target from the manager
  97397. * @param target defines the target to remove
  97398. */
  97399. removeTarget(target: MorphTarget): void;
  97400. /**
  97401. * Clone the current manager
  97402. * @returns a new MorphTargetManager
  97403. */
  97404. clone(): MorphTargetManager;
  97405. /**
  97406. * Serializes the current manager into a Serialization object
  97407. * @returns the serialized object
  97408. */
  97409. serialize(): any;
  97410. private _syncActiveTargets;
  97411. /**
  97412. * Syncrhonize the targets with all the meshes using this morph target manager
  97413. */
  97414. synchronize(): void;
  97415. /**
  97416. * Creates a new MorphTargetManager from serialized data
  97417. * @param serializationObject defines the serialized data
  97418. * @param scene defines the hosting scene
  97419. * @returns the new MorphTargetManager
  97420. */
  97421. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  97422. }
  97423. }
  97424. declare module BABYLON {
  97425. /**
  97426. * Class used to represent a specific level of detail of a mesh
  97427. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97428. */
  97429. export class MeshLODLevel {
  97430. /** Defines the distance where this level should start being displayed */
  97431. distance: number;
  97432. /** Defines the mesh to use to render this level */
  97433. mesh: Nullable<Mesh>;
  97434. /**
  97435. * Creates a new LOD level
  97436. * @param distance defines the distance where this level should star being displayed
  97437. * @param mesh defines the mesh to use to render this level
  97438. */
  97439. constructor(
  97440. /** Defines the distance where this level should start being displayed */
  97441. distance: number,
  97442. /** Defines the mesh to use to render this level */
  97443. mesh: Nullable<Mesh>);
  97444. }
  97445. }
  97446. declare module BABYLON {
  97447. /**
  97448. * Mesh representing the gorund
  97449. */
  97450. export class GroundMesh extends Mesh {
  97451. /** If octree should be generated */
  97452. generateOctree: boolean;
  97453. private _heightQuads;
  97454. /** @hidden */
  97455. _subdivisionsX: number;
  97456. /** @hidden */
  97457. _subdivisionsY: number;
  97458. /** @hidden */
  97459. _width: number;
  97460. /** @hidden */
  97461. _height: number;
  97462. /** @hidden */
  97463. _minX: number;
  97464. /** @hidden */
  97465. _maxX: number;
  97466. /** @hidden */
  97467. _minZ: number;
  97468. /** @hidden */
  97469. _maxZ: number;
  97470. constructor(name: string, scene: Scene);
  97471. /**
  97472. * "GroundMesh"
  97473. * @returns "GroundMesh"
  97474. */
  97475. getClassName(): string;
  97476. /**
  97477. * The minimum of x and y subdivisions
  97478. */
  97479. get subdivisions(): number;
  97480. /**
  97481. * X subdivisions
  97482. */
  97483. get subdivisionsX(): number;
  97484. /**
  97485. * Y subdivisions
  97486. */
  97487. get subdivisionsY(): number;
  97488. /**
  97489. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97490. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97491. * @param chunksCount the number of subdivisions for x and y
  97492. * @param octreeBlocksSize (Default: 32)
  97493. */
  97494. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  97495. /**
  97496. * Returns a height (y) value in the Worl system :
  97497. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97498. * @param x x coordinate
  97499. * @param z z coordinate
  97500. * @returns the ground y position if (x, z) are outside the ground surface.
  97501. */
  97502. getHeightAtCoordinates(x: number, z: number): number;
  97503. /**
  97504. * Returns a normalized vector (Vector3) orthogonal to the ground
  97505. * at the ground coordinates (x, z) expressed in the World system.
  97506. * @param x x coordinate
  97507. * @param z z coordinate
  97508. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97509. */
  97510. getNormalAtCoordinates(x: number, z: number): Vector3;
  97511. /**
  97512. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97513. * at the ground coordinates (x, z) expressed in the World system.
  97514. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97515. * @param x x coordinate
  97516. * @param z z coordinate
  97517. * @param ref vector to store the result
  97518. * @returns the GroundMesh.
  97519. */
  97520. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  97521. /**
  97522. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97523. * if the ground has been updated.
  97524. * This can be used in the render loop.
  97525. * @returns the GroundMesh.
  97526. */
  97527. updateCoordinateHeights(): GroundMesh;
  97528. private _getFacetAt;
  97529. private _initHeightQuads;
  97530. private _computeHeightQuads;
  97531. /**
  97532. * Serializes this ground mesh
  97533. * @param serializationObject object to write serialization to
  97534. */
  97535. serialize(serializationObject: any): void;
  97536. /**
  97537. * Parses a serialized ground mesh
  97538. * @param parsedMesh the serialized mesh
  97539. * @param scene the scene to create the ground mesh in
  97540. * @returns the created ground mesh
  97541. */
  97542. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  97543. }
  97544. }
  97545. declare module BABYLON {
  97546. /**
  97547. * Interface for Physics-Joint data
  97548. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97549. */
  97550. export interface PhysicsJointData {
  97551. /**
  97552. * The main pivot of the joint
  97553. */
  97554. mainPivot?: Vector3;
  97555. /**
  97556. * The connected pivot of the joint
  97557. */
  97558. connectedPivot?: Vector3;
  97559. /**
  97560. * The main axis of the joint
  97561. */
  97562. mainAxis?: Vector3;
  97563. /**
  97564. * The connected axis of the joint
  97565. */
  97566. connectedAxis?: Vector3;
  97567. /**
  97568. * The collision of the joint
  97569. */
  97570. collision?: boolean;
  97571. /**
  97572. * Native Oimo/Cannon/Energy data
  97573. */
  97574. nativeParams?: any;
  97575. }
  97576. /**
  97577. * This is a holder class for the physics joint created by the physics plugin
  97578. * It holds a set of functions to control the underlying joint
  97579. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97580. */
  97581. export class PhysicsJoint {
  97582. /**
  97583. * The type of the physics joint
  97584. */
  97585. type: number;
  97586. /**
  97587. * The data for the physics joint
  97588. */
  97589. jointData: PhysicsJointData;
  97590. private _physicsJoint;
  97591. protected _physicsPlugin: IPhysicsEnginePlugin;
  97592. /**
  97593. * Initializes the physics joint
  97594. * @param type The type of the physics joint
  97595. * @param jointData The data for the physics joint
  97596. */
  97597. constructor(
  97598. /**
  97599. * The type of the physics joint
  97600. */
  97601. type: number,
  97602. /**
  97603. * The data for the physics joint
  97604. */
  97605. jointData: PhysicsJointData);
  97606. /**
  97607. * Gets the physics joint
  97608. */
  97609. get physicsJoint(): any;
  97610. /**
  97611. * Sets the physics joint
  97612. */
  97613. set physicsJoint(newJoint: any);
  97614. /**
  97615. * Sets the physics plugin
  97616. */
  97617. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  97618. /**
  97619. * Execute a function that is physics-plugin specific.
  97620. * @param {Function} func the function that will be executed.
  97621. * It accepts two parameters: the physics world and the physics joint
  97622. */
  97623. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  97624. /**
  97625. * Distance-Joint type
  97626. */
  97627. static DistanceJoint: number;
  97628. /**
  97629. * Hinge-Joint type
  97630. */
  97631. static HingeJoint: number;
  97632. /**
  97633. * Ball-and-Socket joint type
  97634. */
  97635. static BallAndSocketJoint: number;
  97636. /**
  97637. * Wheel-Joint type
  97638. */
  97639. static WheelJoint: number;
  97640. /**
  97641. * Slider-Joint type
  97642. */
  97643. static SliderJoint: number;
  97644. /**
  97645. * Prismatic-Joint type
  97646. */
  97647. static PrismaticJoint: number;
  97648. /**
  97649. * Universal-Joint type
  97650. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  97651. */
  97652. static UniversalJoint: number;
  97653. /**
  97654. * Hinge-Joint 2 type
  97655. */
  97656. static Hinge2Joint: number;
  97657. /**
  97658. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  97659. */
  97660. static PointToPointJoint: number;
  97661. /**
  97662. * Spring-Joint type
  97663. */
  97664. static SpringJoint: number;
  97665. /**
  97666. * Lock-Joint type
  97667. */
  97668. static LockJoint: number;
  97669. }
  97670. /**
  97671. * A class representing a physics distance joint
  97672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97673. */
  97674. export class DistanceJoint extends PhysicsJoint {
  97675. /**
  97676. *
  97677. * @param jointData The data for the Distance-Joint
  97678. */
  97679. constructor(jointData: DistanceJointData);
  97680. /**
  97681. * Update the predefined distance.
  97682. * @param maxDistance The maximum preferred distance
  97683. * @param minDistance The minimum preferred distance
  97684. */
  97685. updateDistance(maxDistance: number, minDistance?: number): void;
  97686. }
  97687. /**
  97688. * Represents a Motor-Enabled Joint
  97689. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97690. */
  97691. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  97692. /**
  97693. * Initializes the Motor-Enabled Joint
  97694. * @param type The type of the joint
  97695. * @param jointData The physica joint data for the joint
  97696. */
  97697. constructor(type: number, jointData: PhysicsJointData);
  97698. /**
  97699. * Set the motor values.
  97700. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97701. * @param force the force to apply
  97702. * @param maxForce max force for this motor.
  97703. */
  97704. setMotor(force?: number, maxForce?: number): void;
  97705. /**
  97706. * Set the motor's limits.
  97707. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97708. * @param upperLimit The upper limit of the motor
  97709. * @param lowerLimit The lower limit of the motor
  97710. */
  97711. setLimit(upperLimit: number, lowerLimit?: number): void;
  97712. }
  97713. /**
  97714. * This class represents a single physics Hinge-Joint
  97715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97716. */
  97717. export class HingeJoint extends MotorEnabledJoint {
  97718. /**
  97719. * Initializes the Hinge-Joint
  97720. * @param jointData The joint data for the Hinge-Joint
  97721. */
  97722. constructor(jointData: PhysicsJointData);
  97723. /**
  97724. * Set the motor values.
  97725. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97726. * @param {number} force the force to apply
  97727. * @param {number} maxForce max force for this motor.
  97728. */
  97729. setMotor(force?: number, maxForce?: number): void;
  97730. /**
  97731. * Set the motor's limits.
  97732. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97733. * @param upperLimit The upper limit of the motor
  97734. * @param lowerLimit The lower limit of the motor
  97735. */
  97736. setLimit(upperLimit: number, lowerLimit?: number): void;
  97737. }
  97738. /**
  97739. * This class represents a dual hinge physics joint (same as wheel joint)
  97740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97741. */
  97742. export class Hinge2Joint extends MotorEnabledJoint {
  97743. /**
  97744. * Initializes the Hinge2-Joint
  97745. * @param jointData The joint data for the Hinge2-Joint
  97746. */
  97747. constructor(jointData: PhysicsJointData);
  97748. /**
  97749. * Set the motor values.
  97750. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97751. * @param {number} targetSpeed the speed the motor is to reach
  97752. * @param {number} maxForce max force for this motor.
  97753. * @param {motorIndex} the motor's index, 0 or 1.
  97754. */
  97755. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  97756. /**
  97757. * Set the motor limits.
  97758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97759. * @param {number} upperLimit the upper limit
  97760. * @param {number} lowerLimit lower limit
  97761. * @param {motorIndex} the motor's index, 0 or 1.
  97762. */
  97763. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97764. }
  97765. /**
  97766. * Interface for a motor enabled joint
  97767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97768. */
  97769. export interface IMotorEnabledJoint {
  97770. /**
  97771. * Physics joint
  97772. */
  97773. physicsJoint: any;
  97774. /**
  97775. * Sets the motor of the motor-enabled joint
  97776. * @param force The force of the motor
  97777. * @param maxForce The maximum force of the motor
  97778. * @param motorIndex The index of the motor
  97779. */
  97780. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  97781. /**
  97782. * Sets the limit of the motor
  97783. * @param upperLimit The upper limit of the motor
  97784. * @param lowerLimit The lower limit of the motor
  97785. * @param motorIndex The index of the motor
  97786. */
  97787. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97788. }
  97789. /**
  97790. * Joint data for a Distance-Joint
  97791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97792. */
  97793. export interface DistanceJointData extends PhysicsJointData {
  97794. /**
  97795. * Max distance the 2 joint objects can be apart
  97796. */
  97797. maxDistance: number;
  97798. }
  97799. /**
  97800. * Joint data from a spring joint
  97801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97802. */
  97803. export interface SpringJointData extends PhysicsJointData {
  97804. /**
  97805. * Length of the spring
  97806. */
  97807. length: number;
  97808. /**
  97809. * Stiffness of the spring
  97810. */
  97811. stiffness: number;
  97812. /**
  97813. * Damping of the spring
  97814. */
  97815. damping: number;
  97816. /** this callback will be called when applying the force to the impostors. */
  97817. forceApplicationCallback: () => void;
  97818. }
  97819. }
  97820. declare module BABYLON {
  97821. /**
  97822. * Holds the data for the raycast result
  97823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97824. */
  97825. export class PhysicsRaycastResult {
  97826. private _hasHit;
  97827. private _hitDistance;
  97828. private _hitNormalWorld;
  97829. private _hitPointWorld;
  97830. private _rayFromWorld;
  97831. private _rayToWorld;
  97832. /**
  97833. * Gets if there was a hit
  97834. */
  97835. get hasHit(): boolean;
  97836. /**
  97837. * Gets the distance from the hit
  97838. */
  97839. get hitDistance(): number;
  97840. /**
  97841. * Gets the hit normal/direction in the world
  97842. */
  97843. get hitNormalWorld(): Vector3;
  97844. /**
  97845. * Gets the hit point in the world
  97846. */
  97847. get hitPointWorld(): Vector3;
  97848. /**
  97849. * Gets the ray "start point" of the ray in the world
  97850. */
  97851. get rayFromWorld(): Vector3;
  97852. /**
  97853. * Gets the ray "end point" of the ray in the world
  97854. */
  97855. get rayToWorld(): Vector3;
  97856. /**
  97857. * Sets the hit data (normal & point in world space)
  97858. * @param hitNormalWorld defines the normal in world space
  97859. * @param hitPointWorld defines the point in world space
  97860. */
  97861. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97862. /**
  97863. * Sets the distance from the start point to the hit point
  97864. * @param distance
  97865. */
  97866. setHitDistance(distance: number): void;
  97867. /**
  97868. * Calculates the distance manually
  97869. */
  97870. calculateHitDistance(): void;
  97871. /**
  97872. * Resets all the values to default
  97873. * @param from The from point on world space
  97874. * @param to The to point on world space
  97875. */
  97876. reset(from?: Vector3, to?: Vector3): void;
  97877. }
  97878. /**
  97879. * Interface for the size containing width and height
  97880. */
  97881. interface IXYZ {
  97882. /**
  97883. * X
  97884. */
  97885. x: number;
  97886. /**
  97887. * Y
  97888. */
  97889. y: number;
  97890. /**
  97891. * Z
  97892. */
  97893. z: number;
  97894. }
  97895. }
  97896. declare module BABYLON {
  97897. /**
  97898. * Interface used to describe a physics joint
  97899. */
  97900. export interface PhysicsImpostorJoint {
  97901. /** Defines the main impostor to which the joint is linked */
  97902. mainImpostor: PhysicsImpostor;
  97903. /** Defines the impostor that is connected to the main impostor using this joint */
  97904. connectedImpostor: PhysicsImpostor;
  97905. /** Defines the joint itself */
  97906. joint: PhysicsJoint;
  97907. }
  97908. /** @hidden */
  97909. export interface IPhysicsEnginePlugin {
  97910. world: any;
  97911. name: string;
  97912. setGravity(gravity: Vector3): void;
  97913. setTimeStep(timeStep: number): void;
  97914. getTimeStep(): number;
  97915. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97916. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97917. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97918. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97919. removePhysicsBody(impostor: PhysicsImpostor): void;
  97920. generateJoint(joint: PhysicsImpostorJoint): void;
  97921. removeJoint(joint: PhysicsImpostorJoint): void;
  97922. isSupported(): boolean;
  97923. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97924. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97925. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97926. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97927. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97928. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97929. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97930. getBodyMass(impostor: PhysicsImpostor): number;
  97931. getBodyFriction(impostor: PhysicsImpostor): number;
  97932. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97933. getBodyRestitution(impostor: PhysicsImpostor): number;
  97934. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97935. getBodyPressure?(impostor: PhysicsImpostor): number;
  97936. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97937. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97938. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97939. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97940. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97941. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97942. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97943. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97944. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97945. sleepBody(impostor: PhysicsImpostor): void;
  97946. wakeUpBody(impostor: PhysicsImpostor): void;
  97947. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97948. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97949. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97950. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97951. getRadius(impostor: PhysicsImpostor): number;
  97952. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97953. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97954. dispose(): void;
  97955. }
  97956. /**
  97957. * Interface used to define a physics engine
  97958. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97959. */
  97960. export interface IPhysicsEngine {
  97961. /**
  97962. * Gets the gravity vector used by the simulation
  97963. */
  97964. gravity: Vector3;
  97965. /**
  97966. * Sets the gravity vector used by the simulation
  97967. * @param gravity defines the gravity vector to use
  97968. */
  97969. setGravity(gravity: Vector3): void;
  97970. /**
  97971. * Set the time step of the physics engine.
  97972. * Default is 1/60.
  97973. * To slow it down, enter 1/600 for example.
  97974. * To speed it up, 1/30
  97975. * @param newTimeStep the new timestep to apply to this world.
  97976. */
  97977. setTimeStep(newTimeStep: number): void;
  97978. /**
  97979. * Get the time step of the physics engine.
  97980. * @returns the current time step
  97981. */
  97982. getTimeStep(): number;
  97983. /**
  97984. * Set the sub time step of the physics engine.
  97985. * Default is 0 meaning there is no sub steps
  97986. * To increase physics resolution precision, set a small value (like 1 ms)
  97987. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97988. */
  97989. setSubTimeStep(subTimeStep: number): void;
  97990. /**
  97991. * Get the sub time step of the physics engine.
  97992. * @returns the current sub time step
  97993. */
  97994. getSubTimeStep(): number;
  97995. /**
  97996. * Release all resources
  97997. */
  97998. dispose(): void;
  97999. /**
  98000. * Gets the name of the current physics plugin
  98001. * @returns the name of the plugin
  98002. */
  98003. getPhysicsPluginName(): string;
  98004. /**
  98005. * Adding a new impostor for the impostor tracking.
  98006. * This will be done by the impostor itself.
  98007. * @param impostor the impostor to add
  98008. */
  98009. addImpostor(impostor: PhysicsImpostor): void;
  98010. /**
  98011. * Remove an impostor from the engine.
  98012. * This impostor and its mesh will not longer be updated by the physics engine.
  98013. * @param impostor the impostor to remove
  98014. */
  98015. removeImpostor(impostor: PhysicsImpostor): void;
  98016. /**
  98017. * Add a joint to the physics engine
  98018. * @param mainImpostor defines the main impostor to which the joint is added.
  98019. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  98020. * @param joint defines the joint that will connect both impostors.
  98021. */
  98022. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98023. /**
  98024. * Removes a joint from the simulation
  98025. * @param mainImpostor defines the impostor used with the joint
  98026. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  98027. * @param joint defines the joint to remove
  98028. */
  98029. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98030. /**
  98031. * Gets the current plugin used to run the simulation
  98032. * @returns current plugin
  98033. */
  98034. getPhysicsPlugin(): IPhysicsEnginePlugin;
  98035. /**
  98036. * Gets the list of physic impostors
  98037. * @returns an array of PhysicsImpostor
  98038. */
  98039. getImpostors(): Array<PhysicsImpostor>;
  98040. /**
  98041. * Gets the impostor for a physics enabled object
  98042. * @param object defines the object impersonated by the impostor
  98043. * @returns the PhysicsImpostor or null if not found
  98044. */
  98045. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98046. /**
  98047. * Gets the impostor for a physics body object
  98048. * @param body defines physics body used by the impostor
  98049. * @returns the PhysicsImpostor or null if not found
  98050. */
  98051. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  98052. /**
  98053. * Does a raycast in the physics world
  98054. * @param from when should the ray start?
  98055. * @param to when should the ray end?
  98056. * @returns PhysicsRaycastResult
  98057. */
  98058. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  98059. /**
  98060. * Called by the scene. No need to call it.
  98061. * @param delta defines the timespam between frames
  98062. */
  98063. _step(delta: number): void;
  98064. }
  98065. }
  98066. declare module BABYLON {
  98067. /**
  98068. * The interface for the physics imposter parameters
  98069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98070. */
  98071. export interface PhysicsImpostorParameters {
  98072. /**
  98073. * The mass of the physics imposter
  98074. */
  98075. mass: number;
  98076. /**
  98077. * The friction of the physics imposter
  98078. */
  98079. friction?: number;
  98080. /**
  98081. * The coefficient of restitution of the physics imposter
  98082. */
  98083. restitution?: number;
  98084. /**
  98085. * The native options of the physics imposter
  98086. */
  98087. nativeOptions?: any;
  98088. /**
  98089. * Specifies if the parent should be ignored
  98090. */
  98091. ignoreParent?: boolean;
  98092. /**
  98093. * Specifies if bi-directional transformations should be disabled
  98094. */
  98095. disableBidirectionalTransformation?: boolean;
  98096. /**
  98097. * The pressure inside the physics imposter, soft object only
  98098. */
  98099. pressure?: number;
  98100. /**
  98101. * The stiffness the physics imposter, soft object only
  98102. */
  98103. stiffness?: number;
  98104. /**
  98105. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  98106. */
  98107. velocityIterations?: number;
  98108. /**
  98109. * The number of iterations used in maintaining consistent vertex positions, soft object only
  98110. */
  98111. positionIterations?: number;
  98112. /**
  98113. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  98114. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  98115. * Add to fix multiple points
  98116. */
  98117. fixedPoints?: number;
  98118. /**
  98119. * The collision margin around a soft object
  98120. */
  98121. margin?: number;
  98122. /**
  98123. * The collision margin around a soft object
  98124. */
  98125. damping?: number;
  98126. /**
  98127. * The path for a rope based on an extrusion
  98128. */
  98129. path?: any;
  98130. /**
  98131. * The shape of an extrusion used for a rope based on an extrusion
  98132. */
  98133. shape?: any;
  98134. }
  98135. /**
  98136. * Interface for a physics-enabled object
  98137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98138. */
  98139. export interface IPhysicsEnabledObject {
  98140. /**
  98141. * The position of the physics-enabled object
  98142. */
  98143. position: Vector3;
  98144. /**
  98145. * The rotation of the physics-enabled object
  98146. */
  98147. rotationQuaternion: Nullable<Quaternion>;
  98148. /**
  98149. * The scale of the physics-enabled object
  98150. */
  98151. scaling: Vector3;
  98152. /**
  98153. * The rotation of the physics-enabled object
  98154. */
  98155. rotation?: Vector3;
  98156. /**
  98157. * The parent of the physics-enabled object
  98158. */
  98159. parent?: any;
  98160. /**
  98161. * The bounding info of the physics-enabled object
  98162. * @returns The bounding info of the physics-enabled object
  98163. */
  98164. getBoundingInfo(): BoundingInfo;
  98165. /**
  98166. * Computes the world matrix
  98167. * @param force Specifies if the world matrix should be computed by force
  98168. * @returns A world matrix
  98169. */
  98170. computeWorldMatrix(force: boolean): Matrix;
  98171. /**
  98172. * Gets the world matrix
  98173. * @returns A world matrix
  98174. */
  98175. getWorldMatrix?(): Matrix;
  98176. /**
  98177. * Gets the child meshes
  98178. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  98179. * @returns An array of abstract meshes
  98180. */
  98181. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  98182. /**
  98183. * Gets the vertex data
  98184. * @param kind The type of vertex data
  98185. * @returns A nullable array of numbers, or a float32 array
  98186. */
  98187. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  98188. /**
  98189. * Gets the indices from the mesh
  98190. * @returns A nullable array of index arrays
  98191. */
  98192. getIndices?(): Nullable<IndicesArray>;
  98193. /**
  98194. * Gets the scene from the mesh
  98195. * @returns the indices array or null
  98196. */
  98197. getScene?(): Scene;
  98198. /**
  98199. * Gets the absolute position from the mesh
  98200. * @returns the absolute position
  98201. */
  98202. getAbsolutePosition(): Vector3;
  98203. /**
  98204. * Gets the absolute pivot point from the mesh
  98205. * @returns the absolute pivot point
  98206. */
  98207. getAbsolutePivotPoint(): Vector3;
  98208. /**
  98209. * Rotates the mesh
  98210. * @param axis The axis of rotation
  98211. * @param amount The amount of rotation
  98212. * @param space The space of the rotation
  98213. * @returns The rotation transform node
  98214. */
  98215. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  98216. /**
  98217. * Translates the mesh
  98218. * @param axis The axis of translation
  98219. * @param distance The distance of translation
  98220. * @param space The space of the translation
  98221. * @returns The transform node
  98222. */
  98223. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  98224. /**
  98225. * Sets the absolute position of the mesh
  98226. * @param absolutePosition The absolute position of the mesh
  98227. * @returns The transform node
  98228. */
  98229. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  98230. /**
  98231. * Gets the class name of the mesh
  98232. * @returns The class name
  98233. */
  98234. getClassName(): string;
  98235. }
  98236. /**
  98237. * Represents a physics imposter
  98238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98239. */
  98240. export class PhysicsImpostor {
  98241. /**
  98242. * The physics-enabled object used as the physics imposter
  98243. */
  98244. object: IPhysicsEnabledObject;
  98245. /**
  98246. * The type of the physics imposter
  98247. */
  98248. type: number;
  98249. private _options;
  98250. private _scene?;
  98251. /**
  98252. * The default object size of the imposter
  98253. */
  98254. static DEFAULT_OBJECT_SIZE: Vector3;
  98255. /**
  98256. * The identity quaternion of the imposter
  98257. */
  98258. static IDENTITY_QUATERNION: Quaternion;
  98259. /** @hidden */
  98260. _pluginData: any;
  98261. private _physicsEngine;
  98262. private _physicsBody;
  98263. private _bodyUpdateRequired;
  98264. private _onBeforePhysicsStepCallbacks;
  98265. private _onAfterPhysicsStepCallbacks;
  98266. /** @hidden */
  98267. _onPhysicsCollideCallbacks: Array<{
  98268. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  98269. otherImpostors: Array<PhysicsImpostor>;
  98270. }>;
  98271. private _deltaPosition;
  98272. private _deltaRotation;
  98273. private _deltaRotationConjugated;
  98274. /** @hidden */
  98275. _isFromLine: boolean;
  98276. private _parent;
  98277. private _isDisposed;
  98278. private static _tmpVecs;
  98279. private static _tmpQuat;
  98280. /**
  98281. * Specifies if the physics imposter is disposed
  98282. */
  98283. get isDisposed(): boolean;
  98284. /**
  98285. * Gets the mass of the physics imposter
  98286. */
  98287. get mass(): number;
  98288. set mass(value: number);
  98289. /**
  98290. * Gets the coefficient of friction
  98291. */
  98292. get friction(): number;
  98293. /**
  98294. * Sets the coefficient of friction
  98295. */
  98296. set friction(value: number);
  98297. /**
  98298. * Gets the coefficient of restitution
  98299. */
  98300. get restitution(): number;
  98301. /**
  98302. * Sets the coefficient of restitution
  98303. */
  98304. set restitution(value: number);
  98305. /**
  98306. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  98307. */
  98308. get pressure(): number;
  98309. /**
  98310. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  98311. */
  98312. set pressure(value: number);
  98313. /**
  98314. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98315. */
  98316. get stiffness(): number;
  98317. /**
  98318. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98319. */
  98320. set stiffness(value: number);
  98321. /**
  98322. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98323. */
  98324. get velocityIterations(): number;
  98325. /**
  98326. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98327. */
  98328. set velocityIterations(value: number);
  98329. /**
  98330. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98331. */
  98332. get positionIterations(): number;
  98333. /**
  98334. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98335. */
  98336. set positionIterations(value: number);
  98337. /**
  98338. * The unique id of the physics imposter
  98339. * set by the physics engine when adding this impostor to the array
  98340. */
  98341. uniqueId: number;
  98342. /**
  98343. * @hidden
  98344. */
  98345. soft: boolean;
  98346. /**
  98347. * @hidden
  98348. */
  98349. segments: number;
  98350. private _joints;
  98351. /**
  98352. * Initializes the physics imposter
  98353. * @param object The physics-enabled object used as the physics imposter
  98354. * @param type The type of the physics imposter
  98355. * @param _options The options for the physics imposter
  98356. * @param _scene The Babylon scene
  98357. */
  98358. constructor(
  98359. /**
  98360. * The physics-enabled object used as the physics imposter
  98361. */
  98362. object: IPhysicsEnabledObject,
  98363. /**
  98364. * The type of the physics imposter
  98365. */
  98366. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  98367. /**
  98368. * This function will completly initialize this impostor.
  98369. * It will create a new body - but only if this mesh has no parent.
  98370. * If it has, this impostor will not be used other than to define the impostor
  98371. * of the child mesh.
  98372. * @hidden
  98373. */
  98374. _init(): void;
  98375. private _getPhysicsParent;
  98376. /**
  98377. * Should a new body be generated.
  98378. * @returns boolean specifying if body initialization is required
  98379. */
  98380. isBodyInitRequired(): boolean;
  98381. /**
  98382. * Sets the updated scaling
  98383. * @param updated Specifies if the scaling is updated
  98384. */
  98385. setScalingUpdated(): void;
  98386. /**
  98387. * Force a regeneration of this or the parent's impostor's body.
  98388. * Use under cautious - This will remove all joints already implemented.
  98389. */
  98390. forceUpdate(): void;
  98391. /**
  98392. * Gets the body that holds this impostor. Either its own, or its parent.
  98393. */
  98394. get physicsBody(): any;
  98395. /**
  98396. * Get the parent of the physics imposter
  98397. * @returns Physics imposter or null
  98398. */
  98399. get parent(): Nullable<PhysicsImpostor>;
  98400. /**
  98401. * Sets the parent of the physics imposter
  98402. */
  98403. set parent(value: Nullable<PhysicsImpostor>);
  98404. /**
  98405. * Set the physics body. Used mainly by the physics engine/plugin
  98406. */
  98407. set physicsBody(physicsBody: any);
  98408. /**
  98409. * Resets the update flags
  98410. */
  98411. resetUpdateFlags(): void;
  98412. /**
  98413. * Gets the object extend size
  98414. * @returns the object extend size
  98415. */
  98416. getObjectExtendSize(): Vector3;
  98417. /**
  98418. * Gets the object center
  98419. * @returns The object center
  98420. */
  98421. getObjectCenter(): Vector3;
  98422. /**
  98423. * Get a specific parameter from the options parameters
  98424. * @param paramName The object parameter name
  98425. * @returns The object parameter
  98426. */
  98427. getParam(paramName: string): any;
  98428. /**
  98429. * Sets a specific parameter in the options given to the physics plugin
  98430. * @param paramName The parameter name
  98431. * @param value The value of the parameter
  98432. */
  98433. setParam(paramName: string, value: number): void;
  98434. /**
  98435. * Specifically change the body's mass option. Won't recreate the physics body object
  98436. * @param mass The mass of the physics imposter
  98437. */
  98438. setMass(mass: number): void;
  98439. /**
  98440. * Gets the linear velocity
  98441. * @returns linear velocity or null
  98442. */
  98443. getLinearVelocity(): Nullable<Vector3>;
  98444. /**
  98445. * Sets the linear velocity
  98446. * @param velocity linear velocity or null
  98447. */
  98448. setLinearVelocity(velocity: Nullable<Vector3>): void;
  98449. /**
  98450. * Gets the angular velocity
  98451. * @returns angular velocity or null
  98452. */
  98453. getAngularVelocity(): Nullable<Vector3>;
  98454. /**
  98455. * Sets the angular velocity
  98456. * @param velocity The velocity or null
  98457. */
  98458. setAngularVelocity(velocity: Nullable<Vector3>): void;
  98459. /**
  98460. * Execute a function with the physics plugin native code
  98461. * Provide a function the will have two variables - the world object and the physics body object
  98462. * @param func The function to execute with the physics plugin native code
  98463. */
  98464. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  98465. /**
  98466. * Register a function that will be executed before the physics world is stepping forward
  98467. * @param func The function to execute before the physics world is stepped forward
  98468. */
  98469. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98470. /**
  98471. * Unregister a function that will be executed before the physics world is stepping forward
  98472. * @param func The function to execute before the physics world is stepped forward
  98473. */
  98474. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98475. /**
  98476. * Register a function that will be executed after the physics step
  98477. * @param func The function to execute after physics step
  98478. */
  98479. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98480. /**
  98481. * Unregisters a function that will be executed after the physics step
  98482. * @param func The function to execute after physics step
  98483. */
  98484. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98485. /**
  98486. * register a function that will be executed when this impostor collides against a different body
  98487. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  98488. * @param func Callback that is executed on collision
  98489. */
  98490. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  98491. /**
  98492. * Unregisters the physics imposter on contact
  98493. * @param collideAgainst The physics object to collide against
  98494. * @param func Callback to execute on collision
  98495. */
  98496. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  98497. private _tmpQuat;
  98498. private _tmpQuat2;
  98499. /**
  98500. * Get the parent rotation
  98501. * @returns The parent rotation
  98502. */
  98503. getParentsRotation(): Quaternion;
  98504. /**
  98505. * this function is executed by the physics engine.
  98506. */
  98507. beforeStep: () => void;
  98508. /**
  98509. * this function is executed by the physics engine
  98510. */
  98511. afterStep: () => void;
  98512. /**
  98513. * Legacy collision detection event support
  98514. */
  98515. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  98516. /**
  98517. * event and body object due to cannon's event-based architecture.
  98518. */
  98519. onCollide: (e: {
  98520. body: any;
  98521. }) => void;
  98522. /**
  98523. * Apply a force
  98524. * @param force The force to apply
  98525. * @param contactPoint The contact point for the force
  98526. * @returns The physics imposter
  98527. */
  98528. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98529. /**
  98530. * Apply an impulse
  98531. * @param force The impulse force
  98532. * @param contactPoint The contact point for the impulse force
  98533. * @returns The physics imposter
  98534. */
  98535. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98536. /**
  98537. * A help function to create a joint
  98538. * @param otherImpostor A physics imposter used to create a joint
  98539. * @param jointType The type of joint
  98540. * @param jointData The data for the joint
  98541. * @returns The physics imposter
  98542. */
  98543. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  98544. /**
  98545. * Add a joint to this impostor with a different impostor
  98546. * @param otherImpostor A physics imposter used to add a joint
  98547. * @param joint The joint to add
  98548. * @returns The physics imposter
  98549. */
  98550. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  98551. /**
  98552. * Add an anchor to a cloth impostor
  98553. * @param otherImpostor rigid impostor to anchor to
  98554. * @param width ratio across width from 0 to 1
  98555. * @param height ratio up height from 0 to 1
  98556. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  98557. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  98558. * @returns impostor the soft imposter
  98559. */
  98560. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98561. /**
  98562. * Add a hook to a rope impostor
  98563. * @param otherImpostor rigid impostor to anchor to
  98564. * @param length ratio across rope from 0 to 1
  98565. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  98566. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  98567. * @returns impostor the rope imposter
  98568. */
  98569. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98570. /**
  98571. * Will keep this body still, in a sleep mode.
  98572. * @returns the physics imposter
  98573. */
  98574. sleep(): PhysicsImpostor;
  98575. /**
  98576. * Wake the body up.
  98577. * @returns The physics imposter
  98578. */
  98579. wakeUp(): PhysicsImpostor;
  98580. /**
  98581. * Clones the physics imposter
  98582. * @param newObject The physics imposter clones to this physics-enabled object
  98583. * @returns A nullable physics imposter
  98584. */
  98585. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98586. /**
  98587. * Disposes the physics imposter
  98588. */
  98589. dispose(): void;
  98590. /**
  98591. * Sets the delta position
  98592. * @param position The delta position amount
  98593. */
  98594. setDeltaPosition(position: Vector3): void;
  98595. /**
  98596. * Sets the delta rotation
  98597. * @param rotation The delta rotation amount
  98598. */
  98599. setDeltaRotation(rotation: Quaternion): void;
  98600. /**
  98601. * Gets the box size of the physics imposter and stores the result in the input parameter
  98602. * @param result Stores the box size
  98603. * @returns The physics imposter
  98604. */
  98605. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  98606. /**
  98607. * Gets the radius of the physics imposter
  98608. * @returns Radius of the physics imposter
  98609. */
  98610. getRadius(): number;
  98611. /**
  98612. * Sync a bone with this impostor
  98613. * @param bone The bone to sync to the impostor.
  98614. * @param boneMesh The mesh that the bone is influencing.
  98615. * @param jointPivot The pivot of the joint / bone in local space.
  98616. * @param distToJoint Optional distance from the impostor to the joint.
  98617. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98618. */
  98619. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  98620. /**
  98621. * Sync impostor to a bone
  98622. * @param bone The bone that the impostor will be synced to.
  98623. * @param boneMesh The mesh that the bone is influencing.
  98624. * @param jointPivot The pivot of the joint / bone in local space.
  98625. * @param distToJoint Optional distance from the impostor to the joint.
  98626. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98627. * @param boneAxis Optional vector3 axis the bone is aligned with
  98628. */
  98629. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  98630. /**
  98631. * No-Imposter type
  98632. */
  98633. static NoImpostor: number;
  98634. /**
  98635. * Sphere-Imposter type
  98636. */
  98637. static SphereImpostor: number;
  98638. /**
  98639. * Box-Imposter type
  98640. */
  98641. static BoxImpostor: number;
  98642. /**
  98643. * Plane-Imposter type
  98644. */
  98645. static PlaneImpostor: number;
  98646. /**
  98647. * Mesh-imposter type
  98648. */
  98649. static MeshImpostor: number;
  98650. /**
  98651. * Capsule-Impostor type (Ammo.js plugin only)
  98652. */
  98653. static CapsuleImpostor: number;
  98654. /**
  98655. * Cylinder-Imposter type
  98656. */
  98657. static CylinderImpostor: number;
  98658. /**
  98659. * Particle-Imposter type
  98660. */
  98661. static ParticleImpostor: number;
  98662. /**
  98663. * Heightmap-Imposter type
  98664. */
  98665. static HeightmapImpostor: number;
  98666. /**
  98667. * ConvexHull-Impostor type (Ammo.js plugin only)
  98668. */
  98669. static ConvexHullImpostor: number;
  98670. /**
  98671. * Custom-Imposter type (Ammo.js plugin only)
  98672. */
  98673. static CustomImpostor: number;
  98674. /**
  98675. * Rope-Imposter type
  98676. */
  98677. static RopeImpostor: number;
  98678. /**
  98679. * Cloth-Imposter type
  98680. */
  98681. static ClothImpostor: number;
  98682. /**
  98683. * Softbody-Imposter type
  98684. */
  98685. static SoftbodyImpostor: number;
  98686. }
  98687. }
  98688. declare module BABYLON {
  98689. /**
  98690. * @hidden
  98691. **/
  98692. export class _CreationDataStorage {
  98693. closePath?: boolean;
  98694. closeArray?: boolean;
  98695. idx: number[];
  98696. dashSize: number;
  98697. gapSize: number;
  98698. path3D: Path3D;
  98699. pathArray: Vector3[][];
  98700. arc: number;
  98701. radius: number;
  98702. cap: number;
  98703. tessellation: number;
  98704. }
  98705. /**
  98706. * @hidden
  98707. **/
  98708. class _InstanceDataStorage {
  98709. visibleInstances: any;
  98710. batchCache: _InstancesBatch;
  98711. instancesBufferSize: number;
  98712. instancesBuffer: Nullable<Buffer>;
  98713. instancesData: Float32Array;
  98714. overridenInstanceCount: number;
  98715. isFrozen: boolean;
  98716. previousBatch: Nullable<_InstancesBatch>;
  98717. hardwareInstancedRendering: boolean;
  98718. sideOrientation: number;
  98719. manualUpdate: boolean;
  98720. }
  98721. /**
  98722. * @hidden
  98723. **/
  98724. export class _InstancesBatch {
  98725. mustReturn: boolean;
  98726. visibleInstances: Nullable<InstancedMesh[]>[];
  98727. renderSelf: boolean[];
  98728. hardwareInstancedRendering: boolean[];
  98729. }
  98730. /**
  98731. * Class used to represent renderable models
  98732. */
  98733. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  98734. /**
  98735. * Mesh side orientation : usually the external or front surface
  98736. */
  98737. static readonly FRONTSIDE: number;
  98738. /**
  98739. * Mesh side orientation : usually the internal or back surface
  98740. */
  98741. static readonly BACKSIDE: number;
  98742. /**
  98743. * Mesh side orientation : both internal and external or front and back surfaces
  98744. */
  98745. static readonly DOUBLESIDE: number;
  98746. /**
  98747. * Mesh side orientation : by default, `FRONTSIDE`
  98748. */
  98749. static readonly DEFAULTSIDE: number;
  98750. /**
  98751. * Mesh cap setting : no cap
  98752. */
  98753. static readonly NO_CAP: number;
  98754. /**
  98755. * Mesh cap setting : one cap at the beginning of the mesh
  98756. */
  98757. static readonly CAP_START: number;
  98758. /**
  98759. * Mesh cap setting : one cap at the end of the mesh
  98760. */
  98761. static readonly CAP_END: number;
  98762. /**
  98763. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  98764. */
  98765. static readonly CAP_ALL: number;
  98766. /**
  98767. * Mesh pattern setting : no flip or rotate
  98768. */
  98769. static readonly NO_FLIP: number;
  98770. /**
  98771. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  98772. */
  98773. static readonly FLIP_TILE: number;
  98774. /**
  98775. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  98776. */
  98777. static readonly ROTATE_TILE: number;
  98778. /**
  98779. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  98780. */
  98781. static readonly FLIP_ROW: number;
  98782. /**
  98783. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  98784. */
  98785. static readonly ROTATE_ROW: number;
  98786. /**
  98787. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  98788. */
  98789. static readonly FLIP_N_ROTATE_TILE: number;
  98790. /**
  98791. * Mesh pattern setting : rotate pattern and rotate
  98792. */
  98793. static readonly FLIP_N_ROTATE_ROW: number;
  98794. /**
  98795. * Mesh tile positioning : part tiles same on left/right or top/bottom
  98796. */
  98797. static readonly CENTER: number;
  98798. /**
  98799. * Mesh tile positioning : part tiles on left
  98800. */
  98801. static readonly LEFT: number;
  98802. /**
  98803. * Mesh tile positioning : part tiles on right
  98804. */
  98805. static readonly RIGHT: number;
  98806. /**
  98807. * Mesh tile positioning : part tiles on top
  98808. */
  98809. static readonly TOP: number;
  98810. /**
  98811. * Mesh tile positioning : part tiles on bottom
  98812. */
  98813. static readonly BOTTOM: number;
  98814. /**
  98815. * Gets the default side orientation.
  98816. * @param orientation the orientation to value to attempt to get
  98817. * @returns the default orientation
  98818. * @hidden
  98819. */
  98820. static _GetDefaultSideOrientation(orientation?: number): number;
  98821. private _internalMeshDataInfo;
  98822. /**
  98823. * An event triggered before rendering the mesh
  98824. */
  98825. get onBeforeRenderObservable(): Observable<Mesh>;
  98826. /**
  98827. * An event triggered before binding the mesh
  98828. */
  98829. get onBeforeBindObservable(): Observable<Mesh>;
  98830. /**
  98831. * An event triggered after rendering the mesh
  98832. */
  98833. get onAfterRenderObservable(): Observable<Mesh>;
  98834. /**
  98835. * An event triggered before drawing the mesh
  98836. */
  98837. get onBeforeDrawObservable(): Observable<Mesh>;
  98838. private _onBeforeDrawObserver;
  98839. /**
  98840. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98841. */
  98842. set onBeforeDraw(callback: () => void);
  98843. get hasInstances(): boolean;
  98844. /**
  98845. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98846. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98847. */
  98848. delayLoadState: number;
  98849. /**
  98850. * Gets the list of instances created from this mesh
  98851. * it is not supposed to be modified manually.
  98852. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98853. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98854. */
  98855. instances: InstancedMesh[];
  98856. /**
  98857. * Gets the file containing delay loading data for this mesh
  98858. */
  98859. delayLoadingFile: string;
  98860. /** @hidden */
  98861. _binaryInfo: any;
  98862. /**
  98863. * User defined function used to change how LOD level selection is done
  98864. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98865. */
  98866. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98867. /**
  98868. * Gets or sets the morph target manager
  98869. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98870. */
  98871. get morphTargetManager(): Nullable<MorphTargetManager>;
  98872. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98873. /** @hidden */
  98874. _creationDataStorage: Nullable<_CreationDataStorage>;
  98875. /** @hidden */
  98876. _geometry: Nullable<Geometry>;
  98877. /** @hidden */
  98878. _delayInfo: Array<string>;
  98879. /** @hidden */
  98880. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98881. /** @hidden */
  98882. _instanceDataStorage: _InstanceDataStorage;
  98883. private _effectiveMaterial;
  98884. /** @hidden */
  98885. _shouldGenerateFlatShading: boolean;
  98886. /** @hidden */
  98887. _originalBuilderSideOrientation: number;
  98888. /**
  98889. * Use this property to change the original side orientation defined at construction time
  98890. */
  98891. overrideMaterialSideOrientation: Nullable<number>;
  98892. /**
  98893. * Gets the source mesh (the one used to clone this one from)
  98894. */
  98895. get source(): Nullable<Mesh>;
  98896. /**
  98897. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98898. */
  98899. get isUnIndexed(): boolean;
  98900. set isUnIndexed(value: boolean);
  98901. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98902. get worldMatrixInstancedBuffer(): Float32Array;
  98903. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98904. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98905. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98906. /**
  98907. * @constructor
  98908. * @param name The value used by scene.getMeshByName() to do a lookup.
  98909. * @param scene The scene to add this mesh to.
  98910. * @param parent The parent of this mesh, if it has one
  98911. * @param source An optional Mesh from which geometry is shared, cloned.
  98912. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98913. * When false, achieved by calling a clone(), also passing False.
  98914. * This will make creation of children, recursive.
  98915. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98916. */
  98917. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98918. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98919. doNotInstantiate: boolean;
  98920. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98921. /**
  98922. * Gets the class name
  98923. * @returns the string "Mesh".
  98924. */
  98925. getClassName(): string;
  98926. /** @hidden */
  98927. get _isMesh(): boolean;
  98928. /**
  98929. * Returns a description of this mesh
  98930. * @param fullDetails define if full details about this mesh must be used
  98931. * @returns a descriptive string representing this mesh
  98932. */
  98933. toString(fullDetails?: boolean): string;
  98934. /** @hidden */
  98935. _unBindEffect(): void;
  98936. /**
  98937. * Gets a boolean indicating if this mesh has LOD
  98938. */
  98939. get hasLODLevels(): boolean;
  98940. /**
  98941. * Gets the list of MeshLODLevel associated with the current mesh
  98942. * @returns an array of MeshLODLevel
  98943. */
  98944. getLODLevels(): MeshLODLevel[];
  98945. private _sortLODLevels;
  98946. /**
  98947. * Add a mesh as LOD level triggered at the given distance.
  98948. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98949. * @param distance The distance from the center of the object to show this level
  98950. * @param mesh The mesh to be added as LOD level (can be null)
  98951. * @return This mesh (for chaining)
  98952. */
  98953. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98954. /**
  98955. * Returns the LOD level mesh at the passed distance or null if not found.
  98956. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98957. * @param distance The distance from the center of the object to show this level
  98958. * @returns a Mesh or `null`
  98959. */
  98960. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98961. /**
  98962. * Remove a mesh from the LOD array
  98963. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98964. * @param mesh defines the mesh to be removed
  98965. * @return This mesh (for chaining)
  98966. */
  98967. removeLODLevel(mesh: Mesh): Mesh;
  98968. /**
  98969. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98970. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98971. * @param camera defines the camera to use to compute distance
  98972. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98973. * @return This mesh (for chaining)
  98974. */
  98975. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98976. /**
  98977. * Gets the mesh internal Geometry object
  98978. */
  98979. get geometry(): Nullable<Geometry>;
  98980. /**
  98981. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98982. * @returns the total number of vertices
  98983. */
  98984. getTotalVertices(): number;
  98985. /**
  98986. * Returns the content of an associated vertex buffer
  98987. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98988. * - VertexBuffer.PositionKind
  98989. * - VertexBuffer.UVKind
  98990. * - VertexBuffer.UV2Kind
  98991. * - VertexBuffer.UV3Kind
  98992. * - VertexBuffer.UV4Kind
  98993. * - VertexBuffer.UV5Kind
  98994. * - VertexBuffer.UV6Kind
  98995. * - VertexBuffer.ColorKind
  98996. * - VertexBuffer.MatricesIndicesKind
  98997. * - VertexBuffer.MatricesIndicesExtraKind
  98998. * - VertexBuffer.MatricesWeightsKind
  98999. * - VertexBuffer.MatricesWeightsExtraKind
  99000. * @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
  99001. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  99002. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  99003. */
  99004. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  99005. /**
  99006. * Returns the mesh VertexBuffer object from the requested `kind`
  99007. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99008. * - VertexBuffer.PositionKind
  99009. * - VertexBuffer.NormalKind
  99010. * - VertexBuffer.UVKind
  99011. * - VertexBuffer.UV2Kind
  99012. * - VertexBuffer.UV3Kind
  99013. * - VertexBuffer.UV4Kind
  99014. * - VertexBuffer.UV5Kind
  99015. * - VertexBuffer.UV6Kind
  99016. * - VertexBuffer.ColorKind
  99017. * - VertexBuffer.MatricesIndicesKind
  99018. * - VertexBuffer.MatricesIndicesExtraKind
  99019. * - VertexBuffer.MatricesWeightsKind
  99020. * - VertexBuffer.MatricesWeightsExtraKind
  99021. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  99022. */
  99023. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  99024. /**
  99025. * Tests if a specific vertex buffer is associated with this mesh
  99026. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99027. * - VertexBuffer.PositionKind
  99028. * - VertexBuffer.NormalKind
  99029. * - VertexBuffer.UVKind
  99030. * - VertexBuffer.UV2Kind
  99031. * - VertexBuffer.UV3Kind
  99032. * - VertexBuffer.UV4Kind
  99033. * - VertexBuffer.UV5Kind
  99034. * - VertexBuffer.UV6Kind
  99035. * - VertexBuffer.ColorKind
  99036. * - VertexBuffer.MatricesIndicesKind
  99037. * - VertexBuffer.MatricesIndicesExtraKind
  99038. * - VertexBuffer.MatricesWeightsKind
  99039. * - VertexBuffer.MatricesWeightsExtraKind
  99040. * @returns a boolean
  99041. */
  99042. isVerticesDataPresent(kind: string): boolean;
  99043. /**
  99044. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  99045. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99046. * - VertexBuffer.PositionKind
  99047. * - VertexBuffer.UVKind
  99048. * - VertexBuffer.UV2Kind
  99049. * - VertexBuffer.UV3Kind
  99050. * - VertexBuffer.UV4Kind
  99051. * - VertexBuffer.UV5Kind
  99052. * - VertexBuffer.UV6Kind
  99053. * - VertexBuffer.ColorKind
  99054. * - VertexBuffer.MatricesIndicesKind
  99055. * - VertexBuffer.MatricesIndicesExtraKind
  99056. * - VertexBuffer.MatricesWeightsKind
  99057. * - VertexBuffer.MatricesWeightsExtraKind
  99058. * @returns a boolean
  99059. */
  99060. isVertexBufferUpdatable(kind: string): boolean;
  99061. /**
  99062. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  99063. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99064. * - VertexBuffer.PositionKind
  99065. * - VertexBuffer.NormalKind
  99066. * - VertexBuffer.UVKind
  99067. * - VertexBuffer.UV2Kind
  99068. * - VertexBuffer.UV3Kind
  99069. * - VertexBuffer.UV4Kind
  99070. * - VertexBuffer.UV5Kind
  99071. * - VertexBuffer.UV6Kind
  99072. * - VertexBuffer.ColorKind
  99073. * - VertexBuffer.MatricesIndicesKind
  99074. * - VertexBuffer.MatricesIndicesExtraKind
  99075. * - VertexBuffer.MatricesWeightsKind
  99076. * - VertexBuffer.MatricesWeightsExtraKind
  99077. * @returns an array of strings
  99078. */
  99079. getVerticesDataKinds(): string[];
  99080. /**
  99081. * Returns a positive integer : the total number of indices in this mesh geometry.
  99082. * @returns the numner of indices or zero if the mesh has no geometry.
  99083. */
  99084. getTotalIndices(): number;
  99085. /**
  99086. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  99087. * @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.
  99088. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  99089. * @returns the indices array or an empty array if the mesh has no geometry
  99090. */
  99091. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  99092. get isBlocked(): boolean;
  99093. /**
  99094. * Determine if the current mesh is ready to be rendered
  99095. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99096. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  99097. * @returns true if all associated assets are ready (material, textures, shaders)
  99098. */
  99099. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  99100. /**
  99101. * 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.
  99102. */
  99103. get areNormalsFrozen(): boolean;
  99104. /**
  99105. * 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.
  99106. * @returns the current mesh
  99107. */
  99108. freezeNormals(): Mesh;
  99109. /**
  99110. * 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
  99111. * @returns the current mesh
  99112. */
  99113. unfreezeNormals(): Mesh;
  99114. /**
  99115. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  99116. */
  99117. set overridenInstanceCount(count: number);
  99118. /** @hidden */
  99119. _preActivate(): Mesh;
  99120. /** @hidden */
  99121. _preActivateForIntermediateRendering(renderId: number): Mesh;
  99122. /** @hidden */
  99123. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  99124. /**
  99125. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99126. * This means the mesh underlying bounding box and sphere are recomputed.
  99127. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99128. * @returns the current mesh
  99129. */
  99130. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  99131. /** @hidden */
  99132. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  99133. /**
  99134. * This function will subdivide the mesh into multiple submeshes
  99135. * @param count defines the expected number of submeshes
  99136. */
  99137. subdivide(count: number): void;
  99138. /**
  99139. * Copy a FloatArray into a specific associated vertex buffer
  99140. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99141. * - VertexBuffer.PositionKind
  99142. * - VertexBuffer.UVKind
  99143. * - VertexBuffer.UV2Kind
  99144. * - VertexBuffer.UV3Kind
  99145. * - VertexBuffer.UV4Kind
  99146. * - VertexBuffer.UV5Kind
  99147. * - VertexBuffer.UV6Kind
  99148. * - VertexBuffer.ColorKind
  99149. * - VertexBuffer.MatricesIndicesKind
  99150. * - VertexBuffer.MatricesIndicesExtraKind
  99151. * - VertexBuffer.MatricesWeightsKind
  99152. * - VertexBuffer.MatricesWeightsExtraKind
  99153. * @param data defines the data source
  99154. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99155. * @param stride defines the data stride size (can be null)
  99156. * @returns the current mesh
  99157. */
  99158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99159. /**
  99160. * Delete a vertex buffer associated with this mesh
  99161. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  99162. * - VertexBuffer.PositionKind
  99163. * - VertexBuffer.UVKind
  99164. * - VertexBuffer.UV2Kind
  99165. * - VertexBuffer.UV3Kind
  99166. * - VertexBuffer.UV4Kind
  99167. * - VertexBuffer.UV5Kind
  99168. * - VertexBuffer.UV6Kind
  99169. * - VertexBuffer.ColorKind
  99170. * - VertexBuffer.MatricesIndicesKind
  99171. * - VertexBuffer.MatricesIndicesExtraKind
  99172. * - VertexBuffer.MatricesWeightsKind
  99173. * - VertexBuffer.MatricesWeightsExtraKind
  99174. */
  99175. removeVerticesData(kind: string): void;
  99176. /**
  99177. * Flags an associated vertex buffer as updatable
  99178. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  99179. * - VertexBuffer.PositionKind
  99180. * - VertexBuffer.UVKind
  99181. * - VertexBuffer.UV2Kind
  99182. * - VertexBuffer.UV3Kind
  99183. * - VertexBuffer.UV4Kind
  99184. * - VertexBuffer.UV5Kind
  99185. * - VertexBuffer.UV6Kind
  99186. * - VertexBuffer.ColorKind
  99187. * - VertexBuffer.MatricesIndicesKind
  99188. * - VertexBuffer.MatricesIndicesExtraKind
  99189. * - VertexBuffer.MatricesWeightsKind
  99190. * - VertexBuffer.MatricesWeightsExtraKind
  99191. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99192. */
  99193. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  99194. /**
  99195. * Sets the mesh global Vertex Buffer
  99196. * @param buffer defines the buffer to use
  99197. * @returns the current mesh
  99198. */
  99199. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  99200. /**
  99201. * Update a specific associated vertex buffer
  99202. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99203. * - VertexBuffer.PositionKind
  99204. * - VertexBuffer.UVKind
  99205. * - VertexBuffer.UV2Kind
  99206. * - VertexBuffer.UV3Kind
  99207. * - VertexBuffer.UV4Kind
  99208. * - VertexBuffer.UV5Kind
  99209. * - VertexBuffer.UV6Kind
  99210. * - VertexBuffer.ColorKind
  99211. * - VertexBuffer.MatricesIndicesKind
  99212. * - VertexBuffer.MatricesIndicesExtraKind
  99213. * - VertexBuffer.MatricesWeightsKind
  99214. * - VertexBuffer.MatricesWeightsExtraKind
  99215. * @param data defines the data source
  99216. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  99217. * @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)
  99218. * @returns the current mesh
  99219. */
  99220. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99221. /**
  99222. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  99223. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  99224. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  99225. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  99226. * @returns the current mesh
  99227. */
  99228. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  99229. /**
  99230. * Creates a un-shared specific occurence of the geometry for the mesh.
  99231. * @returns the current mesh
  99232. */
  99233. makeGeometryUnique(): Mesh;
  99234. /**
  99235. * Set the index buffer of this mesh
  99236. * @param indices defines the source data
  99237. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99238. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99239. * @returns the current mesh
  99240. */
  99241. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  99242. /**
  99243. * Update the current index buffer
  99244. * @param indices defines the source data
  99245. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99246. * @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)
  99247. * @returns the current mesh
  99248. */
  99249. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99250. /**
  99251. * Invert the geometry to move from a right handed system to a left handed one.
  99252. * @returns the current mesh
  99253. */
  99254. toLeftHanded(): Mesh;
  99255. /** @hidden */
  99256. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  99257. /** @hidden */
  99258. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  99259. /**
  99260. * Registers for this mesh a javascript function called just before the rendering process
  99261. * @param func defines the function to call before rendering this mesh
  99262. * @returns the current mesh
  99263. */
  99264. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99265. /**
  99266. * Disposes a previously registered javascript function called before the rendering
  99267. * @param func defines the function to remove
  99268. * @returns the current mesh
  99269. */
  99270. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99271. /**
  99272. * Registers for this mesh a javascript function called just after the rendering is complete
  99273. * @param func defines the function to call after rendering this mesh
  99274. * @returns the current mesh
  99275. */
  99276. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99277. /**
  99278. * Disposes a previously registered javascript function called after the rendering.
  99279. * @param func defines the function to remove
  99280. * @returns the current mesh
  99281. */
  99282. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99283. /** @hidden */
  99284. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  99285. /** @hidden */
  99286. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  99287. /** @hidden */
  99288. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  99289. /** @hidden */
  99290. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  99291. /** @hidden */
  99292. _rebuild(): void;
  99293. /** @hidden */
  99294. _freeze(): void;
  99295. /** @hidden */
  99296. _unFreeze(): void;
  99297. /**
  99298. * 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
  99299. * @param subMesh defines the subMesh to render
  99300. * @param enableAlphaMode defines if alpha mode can be changed
  99301. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  99302. * @returns the current mesh
  99303. */
  99304. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  99305. private _onBeforeDraw;
  99306. /**
  99307. * Renormalize the mesh and patch it up if there are no weights
  99308. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99309. * However in the case of zero weights then we set just a single influence to 1.
  99310. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99311. */
  99312. cleanMatrixWeights(): void;
  99313. private normalizeSkinFourWeights;
  99314. private normalizeSkinWeightsAndExtra;
  99315. /**
  99316. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99317. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99318. * the user know there was an issue with importing the mesh
  99319. * @returns a validation object with skinned, valid and report string
  99320. */
  99321. validateSkinning(): {
  99322. skinned: boolean;
  99323. valid: boolean;
  99324. report: string;
  99325. };
  99326. /** @hidden */
  99327. _checkDelayState(): Mesh;
  99328. private _queueLoad;
  99329. /**
  99330. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99331. * A mesh is in the frustum if its bounding box intersects the frustum
  99332. * @param frustumPlanes defines the frustum to test
  99333. * @returns true if the mesh is in the frustum planes
  99334. */
  99335. isInFrustum(frustumPlanes: Plane[]): boolean;
  99336. /**
  99337. * Sets the mesh material by the material or multiMaterial `id` property
  99338. * @param id is a string identifying the material or the multiMaterial
  99339. * @returns the current mesh
  99340. */
  99341. setMaterialByID(id: string): Mesh;
  99342. /**
  99343. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99344. * @returns an array of IAnimatable
  99345. */
  99346. getAnimatables(): IAnimatable[];
  99347. /**
  99348. * Modifies the mesh geometry according to the passed transformation matrix.
  99349. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99350. * The mesh normals are modified using the same transformation.
  99351. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99352. * @param transform defines the transform matrix to use
  99353. * @see http://doc.babylonjs.com/resources/baking_transformations
  99354. * @returns the current mesh
  99355. */
  99356. bakeTransformIntoVertices(transform: Matrix): Mesh;
  99357. /**
  99358. * Modifies the mesh geometry according to its own current World Matrix.
  99359. * The mesh World Matrix is then reset.
  99360. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99361. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99362. * @see http://doc.babylonjs.com/resources/baking_transformations
  99363. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  99364. * @returns the current mesh
  99365. */
  99366. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  99367. /** @hidden */
  99368. get _positions(): Nullable<Vector3[]>;
  99369. /** @hidden */
  99370. _resetPointsArrayCache(): Mesh;
  99371. /** @hidden */
  99372. _generatePointsArray(): boolean;
  99373. /**
  99374. * Returns a new Mesh object generated from the current mesh properties.
  99375. * This method must not get confused with createInstance()
  99376. * @param name is a string, the name given to the new mesh
  99377. * @param newParent can be any Node object (default `null`)
  99378. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99379. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99380. * @returns a new mesh
  99381. */
  99382. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  99383. /**
  99384. * Releases resources associated with this mesh.
  99385. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99386. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99387. */
  99388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99389. /** @hidden */
  99390. _disposeInstanceSpecificData(): void;
  99391. /**
  99392. * Modifies the mesh geometry according to a displacement map.
  99393. * 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.
  99394. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99395. * @param url is a string, the URL from the image file is to be downloaded.
  99396. * @param minHeight is the lower limit of the displacement.
  99397. * @param maxHeight is the upper limit of the displacement.
  99398. * @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.
  99399. * @param uvOffset is an optional vector2 used to offset UV.
  99400. * @param uvScale is an optional vector2 used to scale UV.
  99401. * @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.
  99402. * @returns the Mesh.
  99403. */
  99404. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99405. /**
  99406. * Modifies the mesh geometry according to a displacementMap buffer.
  99407. * 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.
  99408. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99409. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  99410. * @param heightMapWidth is the width of the buffer image.
  99411. * @param heightMapHeight is the height of the buffer image.
  99412. * @param minHeight is the lower limit of the displacement.
  99413. * @param maxHeight is the upper limit of the displacement.
  99414. * @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.
  99415. * @param uvOffset is an optional vector2 used to offset UV.
  99416. * @param uvScale is an optional vector2 used to scale UV.
  99417. * @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.
  99418. * @returns the Mesh.
  99419. */
  99420. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99421. /**
  99422. * Modify the mesh to get a flat shading rendering.
  99423. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  99424. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  99425. * @returns current mesh
  99426. */
  99427. convertToFlatShadedMesh(): Mesh;
  99428. /**
  99429. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  99430. * In other words, more vertices, no more indices and a single bigger VBO.
  99431. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  99432. * @returns current mesh
  99433. */
  99434. convertToUnIndexedMesh(): Mesh;
  99435. /**
  99436. * Inverses facet orientations.
  99437. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99438. * @param flipNormals will also inverts the normals
  99439. * @returns current mesh
  99440. */
  99441. flipFaces(flipNormals?: boolean): Mesh;
  99442. /**
  99443. * Increase the number of facets and hence vertices in a mesh
  99444. * Vertex normals are interpolated from existing vertex normals
  99445. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99446. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  99447. */
  99448. increaseVertices(numberPerEdge: number): void;
  99449. /**
  99450. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  99451. * This will undo any application of covertToFlatShadedMesh
  99452. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99453. */
  99454. forceSharedVertices(): void;
  99455. /** @hidden */
  99456. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  99457. /** @hidden */
  99458. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  99459. /**
  99460. * Creates a new InstancedMesh object from the mesh model.
  99461. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99462. * @param name defines the name of the new instance
  99463. * @returns a new InstancedMesh
  99464. */
  99465. createInstance(name: string): InstancedMesh;
  99466. /**
  99467. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  99468. * After this call, all the mesh instances have the same submeshes than the current mesh.
  99469. * @returns the current mesh
  99470. */
  99471. synchronizeInstances(): Mesh;
  99472. /**
  99473. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  99474. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  99475. * This should be used together with the simplification to avoid disappearing triangles.
  99476. * @param successCallback an optional success callback to be called after the optimization finished.
  99477. * @returns the current mesh
  99478. */
  99479. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  99480. /**
  99481. * Serialize current mesh
  99482. * @param serializationObject defines the object which will receive the serialization data
  99483. */
  99484. serialize(serializationObject: any): void;
  99485. /** @hidden */
  99486. _syncGeometryWithMorphTargetManager(): void;
  99487. /** @hidden */
  99488. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  99489. /**
  99490. * Returns a new Mesh object parsed from the source provided.
  99491. * @param parsedMesh is the source
  99492. * @param scene defines the hosting scene
  99493. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  99494. * @returns a new Mesh
  99495. */
  99496. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  99497. /**
  99498. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  99499. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99500. * @param name defines the name of the mesh to create
  99501. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  99502. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  99503. * @param closePath creates a seam between the first and the last points of each path of the path array
  99504. * @param offset is taken in account only if the `pathArray` is containing a single path
  99505. * @param scene defines the hosting scene
  99506. * @param updatable defines if the mesh must be flagged as updatable
  99507. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99508. * @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)
  99509. * @returns a new Mesh
  99510. */
  99511. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99512. /**
  99513. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  99514. * @param name defines the name of the mesh to create
  99515. * @param radius sets the radius size (float) of the polygon (default 0.5)
  99516. * @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
  99517. * @param scene defines the hosting scene
  99518. * @param updatable defines if the mesh must be flagged as updatable
  99519. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99520. * @returns a new Mesh
  99521. */
  99522. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99523. /**
  99524. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  99525. * @param name defines the name of the mesh to create
  99526. * @param size sets the size (float) of each box side (default 1)
  99527. * @param scene defines the hosting scene
  99528. * @param updatable defines if the mesh must be flagged as updatable
  99529. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99530. * @returns a new Mesh
  99531. */
  99532. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99533. /**
  99534. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  99535. * @param name defines the name of the mesh to create
  99536. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99537. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99538. * @param scene defines the hosting scene
  99539. * @param updatable defines if the mesh must be flagged as updatable
  99540. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99541. * @returns a new Mesh
  99542. */
  99543. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99544. /**
  99545. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  99546. * @param name defines the name of the mesh to create
  99547. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99548. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99549. * @param scene defines the hosting scene
  99550. * @returns a new Mesh
  99551. */
  99552. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  99553. /**
  99554. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  99555. * @param name defines the name of the mesh to create
  99556. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  99557. * @param diameterTop set the top cap diameter (floats, default 1)
  99558. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  99559. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  99560. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  99561. * @param scene defines the hosting scene
  99562. * @param updatable defines if the mesh must be flagged as updatable
  99563. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99564. * @returns a new Mesh
  99565. */
  99566. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  99567. /**
  99568. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  99569. * @param name defines the name of the mesh to create
  99570. * @param diameter sets the diameter size (float) of the torus (default 1)
  99571. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  99572. * @param tessellation sets the number of torus sides (postive integer, default 16)
  99573. * @param scene defines the hosting scene
  99574. * @param updatable defines if the mesh must be flagged as updatable
  99575. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99576. * @returns a new Mesh
  99577. */
  99578. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99579. /**
  99580. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  99581. * @param name defines the name of the mesh to create
  99582. * @param radius sets the global radius size (float) of the torus knot (default 2)
  99583. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  99584. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  99585. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  99586. * @param p the number of windings on X axis (positive integers, default 2)
  99587. * @param q the number of windings on Y axis (positive integers, default 3)
  99588. * @param scene defines the hosting scene
  99589. * @param updatable defines if the mesh must be flagged as updatable
  99590. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99591. * @returns a new Mesh
  99592. */
  99593. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99594. /**
  99595. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  99596. * @param name defines the name of the mesh to create
  99597. * @param points is an array successive Vector3
  99598. * @param scene defines the hosting scene
  99599. * @param updatable defines if the mesh must be flagged as updatable
  99600. * @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).
  99601. * @returns a new Mesh
  99602. */
  99603. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  99604. /**
  99605. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  99606. * @param name defines the name of the mesh to create
  99607. * @param points is an array successive Vector3
  99608. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  99609. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  99610. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  99611. * @param scene defines the hosting scene
  99612. * @param updatable defines if the mesh must be flagged as updatable
  99613. * @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)
  99614. * @returns a new Mesh
  99615. */
  99616. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  99617. /**
  99618. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  99619. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  99620. * 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.
  99621. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99622. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99623. * Remember you can only change the shape positions, not their number when updating a polygon.
  99624. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  99625. * @param name defines the name of the mesh to create
  99626. * @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
  99627. * @param scene defines the hosting scene
  99628. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99629. * @param updatable defines if the mesh must be flagged as updatable
  99630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99631. * @param earcutInjection can be used to inject your own earcut reference
  99632. * @returns a new Mesh
  99633. */
  99634. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99635. /**
  99636. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  99637. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  99638. * @param name defines the name of the mesh to create
  99639. * @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
  99640. * @param depth defines the height of extrusion
  99641. * @param scene defines the hosting scene
  99642. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99643. * @param updatable defines if the mesh must be flagged as updatable
  99644. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99645. * @param earcutInjection can be used to inject your own earcut reference
  99646. * @returns a new Mesh
  99647. */
  99648. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99649. /**
  99650. * Creates an extruded shape mesh.
  99651. * 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
  99652. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99653. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99654. * @param name defines the name of the mesh to create
  99655. * @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
  99656. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99657. * @param scale is the value to scale the shape
  99658. * @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
  99659. * @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
  99660. * @param scene defines the hosting scene
  99661. * @param updatable defines if the mesh must be flagged as updatable
  99662. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99663. * @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)
  99664. * @returns a new Mesh
  99665. */
  99666. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99667. /**
  99668. * Creates an custom extruded shape mesh.
  99669. * The custom extrusion is a parametric shape.
  99670. * It has no predefined shape. Its final shape will depend on the input parameters.
  99671. * Please consider using the same method from the MeshBuilder class instead
  99672. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99673. * @param name defines the name of the mesh to create
  99674. * @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
  99675. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99676. * @param scaleFunction is a custom Javascript function called on each path point
  99677. * @param rotationFunction is a custom Javascript function called on each path point
  99678. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  99679. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  99680. * @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
  99681. * @param scene defines the hosting scene
  99682. * @param updatable defines if the mesh must be flagged as updatable
  99683. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99684. * @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)
  99685. * @returns a new Mesh
  99686. */
  99687. 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;
  99688. /**
  99689. * Creates lathe mesh.
  99690. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  99691. * Please consider using the same method from the MeshBuilder class instead
  99692. * @param name defines the name of the mesh to create
  99693. * @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
  99694. * @param radius is the radius value of the lathe
  99695. * @param tessellation is the side number of the lathe.
  99696. * @param scene defines the hosting scene
  99697. * @param updatable defines if the mesh must be flagged as updatable
  99698. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99699. * @returns a new Mesh
  99700. */
  99701. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99702. /**
  99703. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  99704. * @param name defines the name of the mesh to create
  99705. * @param size sets the size (float) of both sides of the plane at once (default 1)
  99706. * @param scene defines the hosting scene
  99707. * @param updatable defines if the mesh must be flagged as updatable
  99708. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99709. * @returns a new Mesh
  99710. */
  99711. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99712. /**
  99713. * Creates a ground mesh.
  99714. * Please consider using the same method from the MeshBuilder class instead
  99715. * @param name defines the name of the mesh to create
  99716. * @param width set the width of the ground
  99717. * @param height set the height of the ground
  99718. * @param subdivisions sets the number of subdivisions per side
  99719. * @param scene defines the hosting scene
  99720. * @param updatable defines if the mesh must be flagged as updatable
  99721. * @returns a new Mesh
  99722. */
  99723. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  99724. /**
  99725. * Creates a tiled ground mesh.
  99726. * Please consider using the same method from the MeshBuilder class instead
  99727. * @param name defines the name of the mesh to create
  99728. * @param xmin set the ground minimum X coordinate
  99729. * @param zmin set the ground minimum Y coordinate
  99730. * @param xmax set the ground maximum X coordinate
  99731. * @param zmax set the ground maximum Z coordinate
  99732. * @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
  99733. * @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
  99734. * @param scene defines the hosting scene
  99735. * @param updatable defines if the mesh must be flagged as updatable
  99736. * @returns a new Mesh
  99737. */
  99738. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  99739. w: number;
  99740. h: number;
  99741. }, precision: {
  99742. w: number;
  99743. h: number;
  99744. }, scene: Scene, updatable?: boolean): Mesh;
  99745. /**
  99746. * Creates a ground mesh from a height map.
  99747. * Please consider using the same method from the MeshBuilder class instead
  99748. * @see http://doc.babylonjs.com/babylon101/height_map
  99749. * @param name defines the name of the mesh to create
  99750. * @param url sets the URL of the height map image resource
  99751. * @param width set the ground width size
  99752. * @param height set the ground height size
  99753. * @param subdivisions sets the number of subdivision per side
  99754. * @param minHeight is the minimum altitude on the ground
  99755. * @param maxHeight is the maximum altitude on the ground
  99756. * @param scene defines the hosting scene
  99757. * @param updatable defines if the mesh must be flagged as updatable
  99758. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  99759. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99760. * @returns a new Mesh
  99761. */
  99762. 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;
  99763. /**
  99764. * Creates a tube mesh.
  99765. * The tube is a parametric shape.
  99766. * It has no predefined shape. Its final shape will depend on the input parameters.
  99767. * Please consider using the same method from the MeshBuilder class instead
  99768. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99769. * @param name defines the name of the mesh to create
  99770. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  99771. * @param radius sets the tube radius size
  99772. * @param tessellation is the number of sides on the tubular surface
  99773. * @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
  99774. * @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
  99775. * @param scene defines the hosting scene
  99776. * @param updatable defines if the mesh must be flagged as updatable
  99777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99778. * @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)
  99779. * @returns a new Mesh
  99780. */
  99781. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  99782. (i: number, distance: number): number;
  99783. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99784. /**
  99785. * Creates a polyhedron mesh.
  99786. * Please consider using the same method from the MeshBuilder class instead.
  99787. * * 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
  99788. * * The parameter `size` (positive float, default 1) sets the polygon size
  99789. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99790. * * 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`
  99791. * * 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
  99792. * * 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)`)
  99793. * * 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
  99794. * * 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
  99795. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99796. * * If you create a double-sided mesh, you can choose what parts of 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
  99797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99798. * @param name defines the name of the mesh to create
  99799. * @param options defines the options used to create the mesh
  99800. * @param scene defines the hosting scene
  99801. * @returns a new Mesh
  99802. */
  99803. static CreatePolyhedron(name: string, options: {
  99804. type?: number;
  99805. size?: number;
  99806. sizeX?: number;
  99807. sizeY?: number;
  99808. sizeZ?: number;
  99809. custom?: any;
  99810. faceUV?: Vector4[];
  99811. faceColors?: Color4[];
  99812. updatable?: boolean;
  99813. sideOrientation?: number;
  99814. }, scene: Scene): Mesh;
  99815. /**
  99816. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  99817. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  99818. * * 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`)
  99819. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  99820. * * 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
  99821. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99822. * * If you create a double-sided mesh, you can choose what parts of 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
  99823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99824. * @param name defines the name of the mesh
  99825. * @param options defines the options used to create the mesh
  99826. * @param scene defines the hosting scene
  99827. * @returns a new Mesh
  99828. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99829. */
  99830. static CreateIcoSphere(name: string, options: {
  99831. radius?: number;
  99832. flat?: boolean;
  99833. subdivisions?: number;
  99834. sideOrientation?: number;
  99835. updatable?: boolean;
  99836. }, scene: Scene): Mesh;
  99837. /**
  99838. * Creates a decal mesh.
  99839. * Please consider using the same method from the MeshBuilder class instead.
  99840. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99841. * @param name defines the name of the mesh
  99842. * @param sourceMesh defines the mesh receiving the decal
  99843. * @param position sets the position of the decal in world coordinates
  99844. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99845. * @param size sets the decal scaling
  99846. * @param angle sets the angle to rotate the decal
  99847. * @returns a new Mesh
  99848. */
  99849. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99850. /**
  99851. * Prepare internal position array for software CPU skinning
  99852. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99853. */
  99854. setPositionsForCPUSkinning(): Float32Array;
  99855. /**
  99856. * Prepare internal normal array for software CPU skinning
  99857. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99858. */
  99859. setNormalsForCPUSkinning(): Float32Array;
  99860. /**
  99861. * Updates the vertex buffer by applying transformation from the bones
  99862. * @param skeleton defines the skeleton to apply to current mesh
  99863. * @returns the current mesh
  99864. */
  99865. applySkeleton(skeleton: Skeleton): Mesh;
  99866. /**
  99867. * 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
  99868. * @param meshes defines the list of meshes to scan
  99869. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99870. */
  99871. static MinMax(meshes: AbstractMesh[]): {
  99872. min: Vector3;
  99873. max: Vector3;
  99874. };
  99875. /**
  99876. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99877. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99878. * @returns a vector3
  99879. */
  99880. static Center(meshesOrMinMaxVector: {
  99881. min: Vector3;
  99882. max: Vector3;
  99883. } | AbstractMesh[]): Vector3;
  99884. /**
  99885. * Merge the array of meshes into a single mesh for performance reasons.
  99886. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99887. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99888. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99889. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99890. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99891. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99892. * @returns a new mesh
  99893. */
  99894. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99895. /** @hidden */
  99896. addInstance(instance: InstancedMesh): void;
  99897. /** @hidden */
  99898. removeInstance(instance: InstancedMesh): void;
  99899. }
  99900. }
  99901. declare module BABYLON {
  99902. /**
  99903. * This is the base class of all the camera used in the application.
  99904. * @see http://doc.babylonjs.com/features/cameras
  99905. */
  99906. export class Camera extends Node {
  99907. /** @hidden */
  99908. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99909. /**
  99910. * This is the default projection mode used by the cameras.
  99911. * It helps recreating a feeling of perspective and better appreciate depth.
  99912. * This is the best way to simulate real life cameras.
  99913. */
  99914. static readonly PERSPECTIVE_CAMERA: number;
  99915. /**
  99916. * This helps creating camera with an orthographic mode.
  99917. * 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.
  99918. */
  99919. static readonly ORTHOGRAPHIC_CAMERA: number;
  99920. /**
  99921. * This is the default FOV mode for perspective cameras.
  99922. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99923. */
  99924. static readonly FOVMODE_VERTICAL_FIXED: number;
  99925. /**
  99926. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99927. */
  99928. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99929. /**
  99930. * This specifies ther is no need for a camera rig.
  99931. * Basically only one eye is rendered corresponding to the camera.
  99932. */
  99933. static readonly RIG_MODE_NONE: number;
  99934. /**
  99935. * Simulates a camera Rig with one blue eye and one red eye.
  99936. * This can be use with 3d blue and red glasses.
  99937. */
  99938. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99939. /**
  99940. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99941. */
  99942. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99943. /**
  99944. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99945. */
  99946. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99947. /**
  99948. * Defines that both eyes of the camera will be rendered over under each other.
  99949. */
  99950. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99951. /**
  99952. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99953. */
  99954. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99955. /**
  99956. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99957. */
  99958. static readonly RIG_MODE_VR: number;
  99959. /**
  99960. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99961. */
  99962. static readonly RIG_MODE_WEBVR: number;
  99963. /**
  99964. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99965. */
  99966. static readonly RIG_MODE_CUSTOM: number;
  99967. /**
  99968. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99969. */
  99970. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99971. /**
  99972. * Define the input manager associated with the camera.
  99973. */
  99974. inputs: CameraInputsManager<Camera>;
  99975. /** @hidden */
  99976. _position: Vector3;
  99977. /**
  99978. * Define the current local position of the camera in the scene
  99979. */
  99980. get position(): Vector3;
  99981. set position(newPosition: Vector3);
  99982. /**
  99983. * The vector the camera should consider as up.
  99984. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99985. */
  99986. upVector: Vector3;
  99987. /**
  99988. * Define the current limit on the left side for an orthographic camera
  99989. * In scene unit
  99990. */
  99991. orthoLeft: Nullable<number>;
  99992. /**
  99993. * Define the current limit on the right side for an orthographic camera
  99994. * In scene unit
  99995. */
  99996. orthoRight: Nullable<number>;
  99997. /**
  99998. * Define the current limit on the bottom side for an orthographic camera
  99999. * In scene unit
  100000. */
  100001. orthoBottom: Nullable<number>;
  100002. /**
  100003. * Define the current limit on the top side for an orthographic camera
  100004. * In scene unit
  100005. */
  100006. orthoTop: Nullable<number>;
  100007. /**
  100008. * Field Of View is set in Radians. (default is 0.8)
  100009. */
  100010. fov: number;
  100011. /**
  100012. * Define the minimum distance the camera can see from.
  100013. * This is important to note that the depth buffer are not infinite and the closer it starts
  100014. * the more your scene might encounter depth fighting issue.
  100015. */
  100016. minZ: number;
  100017. /**
  100018. * Define the maximum distance the camera can see to.
  100019. * This is important to note that the depth buffer are not infinite and the further it end
  100020. * the more your scene might encounter depth fighting issue.
  100021. */
  100022. maxZ: number;
  100023. /**
  100024. * Define the default inertia of the camera.
  100025. * This helps giving a smooth feeling to the camera movement.
  100026. */
  100027. inertia: number;
  100028. /**
  100029. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  100030. */
  100031. mode: number;
  100032. /**
  100033. * Define whether the camera is intermediate.
  100034. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  100035. */
  100036. isIntermediate: boolean;
  100037. /**
  100038. * Define the viewport of the camera.
  100039. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  100040. */
  100041. viewport: Viewport;
  100042. /**
  100043. * Restricts the camera to viewing objects with the same layerMask.
  100044. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  100045. */
  100046. layerMask: number;
  100047. /**
  100048. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  100049. */
  100050. fovMode: number;
  100051. /**
  100052. * Rig mode of the camera.
  100053. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  100054. * This is normally controlled byt the camera themselves as internal use.
  100055. */
  100056. cameraRigMode: number;
  100057. /**
  100058. * Defines the distance between both "eyes" in case of a RIG
  100059. */
  100060. interaxialDistance: number;
  100061. /**
  100062. * Defines if stereoscopic rendering is done side by side or over under.
  100063. */
  100064. isStereoscopicSideBySide: boolean;
  100065. /**
  100066. * 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
  100067. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  100068. * else in the scene. (Eg. security camera)
  100069. *
  100070. * 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)
  100071. */
  100072. customRenderTargets: RenderTargetTexture[];
  100073. /**
  100074. * When set, the camera will render to this render target instead of the default canvas
  100075. *
  100076. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  100077. */
  100078. outputRenderTarget: Nullable<RenderTargetTexture>;
  100079. /**
  100080. * Observable triggered when the camera view matrix has changed.
  100081. */
  100082. onViewMatrixChangedObservable: Observable<Camera>;
  100083. /**
  100084. * Observable triggered when the camera Projection matrix has changed.
  100085. */
  100086. onProjectionMatrixChangedObservable: Observable<Camera>;
  100087. /**
  100088. * Observable triggered when the inputs have been processed.
  100089. */
  100090. onAfterCheckInputsObservable: Observable<Camera>;
  100091. /**
  100092. * Observable triggered when reset has been called and applied to the camera.
  100093. */
  100094. onRestoreStateObservable: Observable<Camera>;
  100095. /**
  100096. * Is this camera a part of a rig system?
  100097. */
  100098. isRigCamera: boolean;
  100099. /**
  100100. * If isRigCamera set to true this will be set with the parent camera.
  100101. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  100102. */
  100103. rigParent?: Camera;
  100104. /** @hidden */
  100105. _cameraRigParams: any;
  100106. /** @hidden */
  100107. _rigCameras: Camera[];
  100108. /** @hidden */
  100109. _rigPostProcess: Nullable<PostProcess>;
  100110. protected _webvrViewMatrix: Matrix;
  100111. /** @hidden */
  100112. _skipRendering: boolean;
  100113. /** @hidden */
  100114. _projectionMatrix: Matrix;
  100115. /** @hidden */
  100116. _postProcesses: Nullable<PostProcess>[];
  100117. /** @hidden */
  100118. _activeMeshes: SmartArray<AbstractMesh>;
  100119. protected _globalPosition: Vector3;
  100120. /** @hidden */
  100121. _computedViewMatrix: Matrix;
  100122. private _doNotComputeProjectionMatrix;
  100123. private _transformMatrix;
  100124. private _frustumPlanes;
  100125. private _refreshFrustumPlanes;
  100126. private _storedFov;
  100127. private _stateStored;
  100128. /**
  100129. * Instantiates a new camera object.
  100130. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  100131. * @see http://doc.babylonjs.com/features/cameras
  100132. * @param name Defines the name of the camera in the scene
  100133. * @param position Defines the position of the camera
  100134. * @param scene Defines the scene the camera belongs too
  100135. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  100136. */
  100137. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100138. /**
  100139. * Store current camera state (fov, position, etc..)
  100140. * @returns the camera
  100141. */
  100142. storeState(): Camera;
  100143. /**
  100144. * Restores the camera state values if it has been stored. You must call storeState() first
  100145. */
  100146. protected _restoreStateValues(): boolean;
  100147. /**
  100148. * Restored camera state. You must call storeState() first.
  100149. * @returns true if restored and false otherwise
  100150. */
  100151. restoreState(): boolean;
  100152. /**
  100153. * Gets the class name of the camera.
  100154. * @returns the class name
  100155. */
  100156. getClassName(): string;
  100157. /** @hidden */
  100158. readonly _isCamera: boolean;
  100159. /**
  100160. * Gets a string representation of the camera useful for debug purpose.
  100161. * @param fullDetails Defines that a more verboe level of logging is required
  100162. * @returns the string representation
  100163. */
  100164. toString(fullDetails?: boolean): string;
  100165. /**
  100166. * Gets the current world space position of the camera.
  100167. */
  100168. get globalPosition(): Vector3;
  100169. /**
  100170. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  100171. * @returns the active meshe list
  100172. */
  100173. getActiveMeshes(): SmartArray<AbstractMesh>;
  100174. /**
  100175. * Check whether a mesh is part of the current active mesh list of the camera
  100176. * @param mesh Defines the mesh to check
  100177. * @returns true if active, false otherwise
  100178. */
  100179. isActiveMesh(mesh: Mesh): boolean;
  100180. /**
  100181. * Is this camera ready to be used/rendered
  100182. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  100183. * @return true if the camera is ready
  100184. */
  100185. isReady(completeCheck?: boolean): boolean;
  100186. /** @hidden */
  100187. _initCache(): void;
  100188. /** @hidden */
  100189. _updateCache(ignoreParentClass?: boolean): void;
  100190. /** @hidden */
  100191. _isSynchronized(): boolean;
  100192. /** @hidden */
  100193. _isSynchronizedViewMatrix(): boolean;
  100194. /** @hidden */
  100195. _isSynchronizedProjectionMatrix(): boolean;
  100196. /**
  100197. * Attach the input controls to a specific dom element to get the input from.
  100198. * @param element Defines the element the controls should be listened from
  100199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100200. */
  100201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100202. /**
  100203. * Detach the current controls from the specified dom element.
  100204. * @param element Defines the element to stop listening the inputs from
  100205. */
  100206. detachControl(element: HTMLElement): void;
  100207. /**
  100208. * Update the camera state according to the different inputs gathered during the frame.
  100209. */
  100210. update(): void;
  100211. /** @hidden */
  100212. _checkInputs(): void;
  100213. /** @hidden */
  100214. get rigCameras(): Camera[];
  100215. /**
  100216. * Gets the post process used by the rig cameras
  100217. */
  100218. get rigPostProcess(): Nullable<PostProcess>;
  100219. /**
  100220. * Internal, gets the first post proces.
  100221. * @returns the first post process to be run on this camera.
  100222. */
  100223. _getFirstPostProcess(): Nullable<PostProcess>;
  100224. private _cascadePostProcessesToRigCams;
  100225. /**
  100226. * Attach a post process to the camera.
  100227. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100228. * @param postProcess The post process to attach to the camera
  100229. * @param insertAt The position of the post process in case several of them are in use in the scene
  100230. * @returns the position the post process has been inserted at
  100231. */
  100232. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  100233. /**
  100234. * Detach a post process to the camera.
  100235. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100236. * @param postProcess The post process to detach from the camera
  100237. */
  100238. detachPostProcess(postProcess: PostProcess): void;
  100239. /**
  100240. * Gets the current world matrix of the camera
  100241. */
  100242. getWorldMatrix(): Matrix;
  100243. /** @hidden */
  100244. _getViewMatrix(): Matrix;
  100245. /**
  100246. * Gets the current view matrix of the camera.
  100247. * @param force forces the camera to recompute the matrix without looking at the cached state
  100248. * @returns the view matrix
  100249. */
  100250. getViewMatrix(force?: boolean): Matrix;
  100251. /**
  100252. * Freeze the projection matrix.
  100253. * It will prevent the cache check of the camera projection compute and can speed up perf
  100254. * if no parameter of the camera are meant to change
  100255. * @param projection Defines manually a projection if necessary
  100256. */
  100257. freezeProjectionMatrix(projection?: Matrix): void;
  100258. /**
  100259. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  100260. */
  100261. unfreezeProjectionMatrix(): void;
  100262. /**
  100263. * Gets the current projection matrix of the camera.
  100264. * @param force forces the camera to recompute the matrix without looking at the cached state
  100265. * @returns the projection matrix
  100266. */
  100267. getProjectionMatrix(force?: boolean): Matrix;
  100268. /**
  100269. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  100270. * @returns a Matrix
  100271. */
  100272. getTransformationMatrix(): Matrix;
  100273. private _updateFrustumPlanes;
  100274. /**
  100275. * Checks if a cullable object (mesh...) is in the camera frustum
  100276. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  100277. * @param target The object to check
  100278. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  100279. * @returns true if the object is in frustum otherwise false
  100280. */
  100281. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  100282. /**
  100283. * Checks if a cullable object (mesh...) is in the camera frustum
  100284. * Unlike isInFrustum this cheks the full bounding box
  100285. * @param target The object to check
  100286. * @returns true if the object is in frustum otherwise false
  100287. */
  100288. isCompletelyInFrustum(target: ICullable): boolean;
  100289. /**
  100290. * Gets a ray in the forward direction from the camera.
  100291. * @param length Defines the length of the ray to create
  100292. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  100293. * @param origin Defines the start point of the ray which defaults to the camera position
  100294. * @returns the forward ray
  100295. */
  100296. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  100297. /**
  100298. * Releases resources associated with this node.
  100299. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100300. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100301. */
  100302. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100303. /** @hidden */
  100304. _isLeftCamera: boolean;
  100305. /**
  100306. * Gets the left camera of a rig setup in case of Rigged Camera
  100307. */
  100308. get isLeftCamera(): boolean;
  100309. /** @hidden */
  100310. _isRightCamera: boolean;
  100311. /**
  100312. * Gets the right camera of a rig setup in case of Rigged Camera
  100313. */
  100314. get isRightCamera(): boolean;
  100315. /**
  100316. * Gets the left camera of a rig setup in case of Rigged Camera
  100317. */
  100318. get leftCamera(): Nullable<FreeCamera>;
  100319. /**
  100320. * Gets the right camera of a rig setup in case of Rigged Camera
  100321. */
  100322. get rightCamera(): Nullable<FreeCamera>;
  100323. /**
  100324. * Gets the left camera target of a rig setup in case of Rigged Camera
  100325. * @returns the target position
  100326. */
  100327. getLeftTarget(): Nullable<Vector3>;
  100328. /**
  100329. * Gets the right camera target of a rig setup in case of Rigged Camera
  100330. * @returns the target position
  100331. */
  100332. getRightTarget(): Nullable<Vector3>;
  100333. /**
  100334. * @hidden
  100335. */
  100336. setCameraRigMode(mode: number, rigParams: any): void;
  100337. /** @hidden */
  100338. static _setStereoscopicRigMode(camera: Camera): void;
  100339. /** @hidden */
  100340. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  100341. /** @hidden */
  100342. static _setVRRigMode(camera: Camera, rigParams: any): void;
  100343. /** @hidden */
  100344. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  100345. /** @hidden */
  100346. _getVRProjectionMatrix(): Matrix;
  100347. protected _updateCameraRotationMatrix(): void;
  100348. protected _updateWebVRCameraRotationMatrix(): void;
  100349. /**
  100350. * This function MUST be overwritten by the different WebVR cameras available.
  100351. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100352. * @hidden
  100353. */
  100354. _getWebVRProjectionMatrix(): Matrix;
  100355. /**
  100356. * This function MUST be overwritten by the different WebVR cameras available.
  100357. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100358. * @hidden
  100359. */
  100360. _getWebVRViewMatrix(): Matrix;
  100361. /** @hidden */
  100362. setCameraRigParameter(name: string, value: any): void;
  100363. /**
  100364. * needs to be overridden by children so sub has required properties to be copied
  100365. * @hidden
  100366. */
  100367. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  100368. /**
  100369. * May need to be overridden by children
  100370. * @hidden
  100371. */
  100372. _updateRigCameras(): void;
  100373. /** @hidden */
  100374. _setupInputs(): void;
  100375. /**
  100376. * Serialiaze the camera setup to a json represention
  100377. * @returns the JSON representation
  100378. */
  100379. serialize(): any;
  100380. /**
  100381. * Clones the current camera.
  100382. * @param name The cloned camera name
  100383. * @returns the cloned camera
  100384. */
  100385. clone(name: string): Camera;
  100386. /**
  100387. * Gets the direction of the camera relative to a given local axis.
  100388. * @param localAxis Defines the reference axis to provide a relative direction.
  100389. * @return the direction
  100390. */
  100391. getDirection(localAxis: Vector3): Vector3;
  100392. /**
  100393. * Returns the current camera absolute rotation
  100394. */
  100395. get absoluteRotation(): Quaternion;
  100396. /**
  100397. * Gets the direction of the camera relative to a given local axis into a passed vector.
  100398. * @param localAxis Defines the reference axis to provide a relative direction.
  100399. * @param result Defines the vector to store the result in
  100400. */
  100401. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  100402. /**
  100403. * Gets a camera constructor for a given camera type
  100404. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  100405. * @param name The name of the camera the result will be able to instantiate
  100406. * @param scene The scene the result will construct the camera in
  100407. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  100408. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  100409. * @returns a factory method to construc the camera
  100410. */
  100411. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  100412. /**
  100413. * Compute the world matrix of the camera.
  100414. * @returns the camera world matrix
  100415. */
  100416. computeWorldMatrix(): Matrix;
  100417. /**
  100418. * Parse a JSON and creates the camera from the parsed information
  100419. * @param parsedCamera The JSON to parse
  100420. * @param scene The scene to instantiate the camera in
  100421. * @returns the newly constructed camera
  100422. */
  100423. static Parse(parsedCamera: any, scene: Scene): Camera;
  100424. }
  100425. }
  100426. declare module BABYLON {
  100427. /**
  100428. * Class containing static functions to help procedurally build meshes
  100429. */
  100430. export class DiscBuilder {
  100431. /**
  100432. * Creates a plane polygonal mesh. By default, this is a disc
  100433. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  100434. * * 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
  100435. * * 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
  100436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100439. * @param name defines the name of the mesh
  100440. * @param options defines the options used to create the mesh
  100441. * @param scene defines the hosting scene
  100442. * @returns the plane polygonal mesh
  100443. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  100444. */
  100445. static CreateDisc(name: string, options: {
  100446. radius?: number;
  100447. tessellation?: number;
  100448. arc?: number;
  100449. updatable?: boolean;
  100450. sideOrientation?: number;
  100451. frontUVs?: Vector4;
  100452. backUVs?: Vector4;
  100453. }, scene?: Nullable<Scene>): Mesh;
  100454. }
  100455. }
  100456. declare module BABYLON {
  100457. /**
  100458. * Options to be used when creating a FresnelParameters.
  100459. */
  100460. export type IFresnelParametersCreationOptions = {
  100461. /**
  100462. * Define the color used on edges (grazing angle)
  100463. */
  100464. leftColor?: Color3;
  100465. /**
  100466. * Define the color used on center
  100467. */
  100468. rightColor?: Color3;
  100469. /**
  100470. * Define bias applied to computed fresnel term
  100471. */
  100472. bias?: number;
  100473. /**
  100474. * Defined the power exponent applied to fresnel term
  100475. */
  100476. power?: number;
  100477. /**
  100478. * Define if the fresnel effect is enable or not.
  100479. */
  100480. isEnabled?: boolean;
  100481. };
  100482. /**
  100483. * Serialized format for FresnelParameters.
  100484. */
  100485. export type IFresnelParametersSerialized = {
  100486. /**
  100487. * Define the color used on edges (grazing angle) [as an array]
  100488. */
  100489. leftColor: number[];
  100490. /**
  100491. * Define the color used on center [as an array]
  100492. */
  100493. rightColor: number[];
  100494. /**
  100495. * Define bias applied to computed fresnel term
  100496. */
  100497. bias: number;
  100498. /**
  100499. * Defined the power exponent applied to fresnel term
  100500. */
  100501. power?: number;
  100502. /**
  100503. * Define if the fresnel effect is enable or not.
  100504. */
  100505. isEnabled: boolean;
  100506. };
  100507. /**
  100508. * This represents all the required information to add a fresnel effect on a material:
  100509. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100510. */
  100511. export class FresnelParameters {
  100512. private _isEnabled;
  100513. /**
  100514. * Define if the fresnel effect is enable or not.
  100515. */
  100516. get isEnabled(): boolean;
  100517. set isEnabled(value: boolean);
  100518. /**
  100519. * Define the color used on edges (grazing angle)
  100520. */
  100521. leftColor: Color3;
  100522. /**
  100523. * Define the color used on center
  100524. */
  100525. rightColor: Color3;
  100526. /**
  100527. * Define bias applied to computed fresnel term
  100528. */
  100529. bias: number;
  100530. /**
  100531. * Defined the power exponent applied to fresnel term
  100532. */
  100533. power: number;
  100534. /**
  100535. * Creates a new FresnelParameters object.
  100536. *
  100537. * @param options provide your own settings to optionally to override defaults
  100538. */
  100539. constructor(options?: IFresnelParametersCreationOptions);
  100540. /**
  100541. * Clones the current fresnel and its valuues
  100542. * @returns a clone fresnel configuration
  100543. */
  100544. clone(): FresnelParameters;
  100545. /**
  100546. * Determines equality between FresnelParameters objects
  100547. * @param otherFresnelParameters defines the second operand
  100548. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  100549. */
  100550. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  100551. /**
  100552. * Serializes the current fresnel parameters to a JSON representation.
  100553. * @return the JSON serialization
  100554. */
  100555. serialize(): IFresnelParametersSerialized;
  100556. /**
  100557. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  100558. * @param parsedFresnelParameters Define the JSON representation
  100559. * @returns the parsed parameters
  100560. */
  100561. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  100562. }
  100563. }
  100564. declare module BABYLON {
  100565. /**
  100566. * Base class of materials working in push mode in babylon JS
  100567. * @hidden
  100568. */
  100569. export class PushMaterial extends Material {
  100570. protected _activeEffect: Effect;
  100571. protected _normalMatrix: Matrix;
  100572. /**
  100573. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100574. * This means that the material can keep using a previous shader while a new one is being compiled.
  100575. * This is mostly used when shader parallel compilation is supported (true by default)
  100576. */
  100577. allowShaderHotSwapping: boolean;
  100578. constructor(name: string, scene: Scene);
  100579. getEffect(): Effect;
  100580. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100581. /**
  100582. * Binds the given world matrix to the active effect
  100583. *
  100584. * @param world the matrix to bind
  100585. */
  100586. bindOnlyWorldMatrix(world: Matrix): void;
  100587. /**
  100588. * Binds the given normal matrix to the active effect
  100589. *
  100590. * @param normalMatrix the matrix to bind
  100591. */
  100592. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100593. bind(world: Matrix, mesh?: Mesh): void;
  100594. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100595. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100596. }
  100597. }
  100598. declare module BABYLON {
  100599. /**
  100600. * This groups all the flags used to control the materials channel.
  100601. */
  100602. export class MaterialFlags {
  100603. private static _DiffuseTextureEnabled;
  100604. /**
  100605. * Are diffuse textures enabled in the application.
  100606. */
  100607. static get DiffuseTextureEnabled(): boolean;
  100608. static set DiffuseTextureEnabled(value: boolean);
  100609. private static _AmbientTextureEnabled;
  100610. /**
  100611. * Are ambient textures enabled in the application.
  100612. */
  100613. static get AmbientTextureEnabled(): boolean;
  100614. static set AmbientTextureEnabled(value: boolean);
  100615. private static _OpacityTextureEnabled;
  100616. /**
  100617. * Are opacity textures enabled in the application.
  100618. */
  100619. static get OpacityTextureEnabled(): boolean;
  100620. static set OpacityTextureEnabled(value: boolean);
  100621. private static _ReflectionTextureEnabled;
  100622. /**
  100623. * Are reflection textures enabled in the application.
  100624. */
  100625. static get ReflectionTextureEnabled(): boolean;
  100626. static set ReflectionTextureEnabled(value: boolean);
  100627. private static _EmissiveTextureEnabled;
  100628. /**
  100629. * Are emissive textures enabled in the application.
  100630. */
  100631. static get EmissiveTextureEnabled(): boolean;
  100632. static set EmissiveTextureEnabled(value: boolean);
  100633. private static _SpecularTextureEnabled;
  100634. /**
  100635. * Are specular textures enabled in the application.
  100636. */
  100637. static get SpecularTextureEnabled(): boolean;
  100638. static set SpecularTextureEnabled(value: boolean);
  100639. private static _BumpTextureEnabled;
  100640. /**
  100641. * Are bump textures enabled in the application.
  100642. */
  100643. static get BumpTextureEnabled(): boolean;
  100644. static set BumpTextureEnabled(value: boolean);
  100645. private static _LightmapTextureEnabled;
  100646. /**
  100647. * Are lightmap textures enabled in the application.
  100648. */
  100649. static get LightmapTextureEnabled(): boolean;
  100650. static set LightmapTextureEnabled(value: boolean);
  100651. private static _RefractionTextureEnabled;
  100652. /**
  100653. * Are refraction textures enabled in the application.
  100654. */
  100655. static get RefractionTextureEnabled(): boolean;
  100656. static set RefractionTextureEnabled(value: boolean);
  100657. private static _ColorGradingTextureEnabled;
  100658. /**
  100659. * Are color grading textures enabled in the application.
  100660. */
  100661. static get ColorGradingTextureEnabled(): boolean;
  100662. static set ColorGradingTextureEnabled(value: boolean);
  100663. private static _FresnelEnabled;
  100664. /**
  100665. * Are fresnels enabled in the application.
  100666. */
  100667. static get FresnelEnabled(): boolean;
  100668. static set FresnelEnabled(value: boolean);
  100669. private static _ClearCoatTextureEnabled;
  100670. /**
  100671. * Are clear coat textures enabled in the application.
  100672. */
  100673. static get ClearCoatTextureEnabled(): boolean;
  100674. static set ClearCoatTextureEnabled(value: boolean);
  100675. private static _ClearCoatBumpTextureEnabled;
  100676. /**
  100677. * Are clear coat bump textures enabled in the application.
  100678. */
  100679. static get ClearCoatBumpTextureEnabled(): boolean;
  100680. static set ClearCoatBumpTextureEnabled(value: boolean);
  100681. private static _ClearCoatTintTextureEnabled;
  100682. /**
  100683. * Are clear coat tint textures enabled in the application.
  100684. */
  100685. static get ClearCoatTintTextureEnabled(): boolean;
  100686. static set ClearCoatTintTextureEnabled(value: boolean);
  100687. private static _SheenTextureEnabled;
  100688. /**
  100689. * Are sheen textures enabled in the application.
  100690. */
  100691. static get SheenTextureEnabled(): boolean;
  100692. static set SheenTextureEnabled(value: boolean);
  100693. private static _AnisotropicTextureEnabled;
  100694. /**
  100695. * Are anisotropic textures enabled in the application.
  100696. */
  100697. static get AnisotropicTextureEnabled(): boolean;
  100698. static set AnisotropicTextureEnabled(value: boolean);
  100699. private static _ThicknessTextureEnabled;
  100700. /**
  100701. * Are thickness textures enabled in the application.
  100702. */
  100703. static get ThicknessTextureEnabled(): boolean;
  100704. static set ThicknessTextureEnabled(value: boolean);
  100705. }
  100706. }
  100707. declare module BABYLON {
  100708. /** @hidden */
  100709. export var defaultFragmentDeclaration: {
  100710. name: string;
  100711. shader: string;
  100712. };
  100713. }
  100714. declare module BABYLON {
  100715. /** @hidden */
  100716. export var defaultUboDeclaration: {
  100717. name: string;
  100718. shader: string;
  100719. };
  100720. }
  100721. declare module BABYLON {
  100722. /** @hidden */
  100723. export var lightFragmentDeclaration: {
  100724. name: string;
  100725. shader: string;
  100726. };
  100727. }
  100728. declare module BABYLON {
  100729. /** @hidden */
  100730. export var lightUboDeclaration: {
  100731. name: string;
  100732. shader: string;
  100733. };
  100734. }
  100735. declare module BABYLON {
  100736. /** @hidden */
  100737. export var lightsFragmentFunctions: {
  100738. name: string;
  100739. shader: string;
  100740. };
  100741. }
  100742. declare module BABYLON {
  100743. /** @hidden */
  100744. export var shadowsFragmentFunctions: {
  100745. name: string;
  100746. shader: string;
  100747. };
  100748. }
  100749. declare module BABYLON {
  100750. /** @hidden */
  100751. export var fresnelFunction: {
  100752. name: string;
  100753. shader: string;
  100754. };
  100755. }
  100756. declare module BABYLON {
  100757. /** @hidden */
  100758. export var reflectionFunction: {
  100759. name: string;
  100760. shader: string;
  100761. };
  100762. }
  100763. declare module BABYLON {
  100764. /** @hidden */
  100765. export var bumpFragmentFunctions: {
  100766. name: string;
  100767. shader: string;
  100768. };
  100769. }
  100770. declare module BABYLON {
  100771. /** @hidden */
  100772. export var logDepthDeclaration: {
  100773. name: string;
  100774. shader: string;
  100775. };
  100776. }
  100777. declare module BABYLON {
  100778. /** @hidden */
  100779. export var bumpFragment: {
  100780. name: string;
  100781. shader: string;
  100782. };
  100783. }
  100784. declare module BABYLON {
  100785. /** @hidden */
  100786. export var depthPrePass: {
  100787. name: string;
  100788. shader: string;
  100789. };
  100790. }
  100791. declare module BABYLON {
  100792. /** @hidden */
  100793. export var lightFragment: {
  100794. name: string;
  100795. shader: string;
  100796. };
  100797. }
  100798. declare module BABYLON {
  100799. /** @hidden */
  100800. export var logDepthFragment: {
  100801. name: string;
  100802. shader: string;
  100803. };
  100804. }
  100805. declare module BABYLON {
  100806. /** @hidden */
  100807. export var defaultPixelShader: {
  100808. name: string;
  100809. shader: string;
  100810. };
  100811. }
  100812. declare module BABYLON {
  100813. /** @hidden */
  100814. export var defaultVertexDeclaration: {
  100815. name: string;
  100816. shader: string;
  100817. };
  100818. }
  100819. declare module BABYLON {
  100820. /** @hidden */
  100821. export var bumpVertexDeclaration: {
  100822. name: string;
  100823. shader: string;
  100824. };
  100825. }
  100826. declare module BABYLON {
  100827. /** @hidden */
  100828. export var bumpVertex: {
  100829. name: string;
  100830. shader: string;
  100831. };
  100832. }
  100833. declare module BABYLON {
  100834. /** @hidden */
  100835. export var fogVertex: {
  100836. name: string;
  100837. shader: string;
  100838. };
  100839. }
  100840. declare module BABYLON {
  100841. /** @hidden */
  100842. export var shadowsVertex: {
  100843. name: string;
  100844. shader: string;
  100845. };
  100846. }
  100847. declare module BABYLON {
  100848. /** @hidden */
  100849. export var pointCloudVertex: {
  100850. name: string;
  100851. shader: string;
  100852. };
  100853. }
  100854. declare module BABYLON {
  100855. /** @hidden */
  100856. export var logDepthVertex: {
  100857. name: string;
  100858. shader: string;
  100859. };
  100860. }
  100861. declare module BABYLON {
  100862. /** @hidden */
  100863. export var defaultVertexShader: {
  100864. name: string;
  100865. shader: string;
  100866. };
  100867. }
  100868. declare module BABYLON {
  100869. /** @hidden */
  100870. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100871. MAINUV1: boolean;
  100872. MAINUV2: boolean;
  100873. DIFFUSE: boolean;
  100874. DIFFUSEDIRECTUV: number;
  100875. AMBIENT: boolean;
  100876. AMBIENTDIRECTUV: number;
  100877. OPACITY: boolean;
  100878. OPACITYDIRECTUV: number;
  100879. OPACITYRGB: boolean;
  100880. REFLECTION: boolean;
  100881. EMISSIVE: boolean;
  100882. EMISSIVEDIRECTUV: number;
  100883. SPECULAR: boolean;
  100884. SPECULARDIRECTUV: number;
  100885. BUMP: boolean;
  100886. BUMPDIRECTUV: number;
  100887. PARALLAX: boolean;
  100888. PARALLAXOCCLUSION: boolean;
  100889. SPECULAROVERALPHA: boolean;
  100890. CLIPPLANE: boolean;
  100891. CLIPPLANE2: boolean;
  100892. CLIPPLANE3: boolean;
  100893. CLIPPLANE4: boolean;
  100894. CLIPPLANE5: boolean;
  100895. CLIPPLANE6: boolean;
  100896. ALPHATEST: boolean;
  100897. DEPTHPREPASS: boolean;
  100898. ALPHAFROMDIFFUSE: boolean;
  100899. POINTSIZE: boolean;
  100900. FOG: boolean;
  100901. SPECULARTERM: boolean;
  100902. DIFFUSEFRESNEL: boolean;
  100903. OPACITYFRESNEL: boolean;
  100904. REFLECTIONFRESNEL: boolean;
  100905. REFRACTIONFRESNEL: boolean;
  100906. EMISSIVEFRESNEL: boolean;
  100907. FRESNEL: boolean;
  100908. NORMAL: boolean;
  100909. UV1: boolean;
  100910. UV2: boolean;
  100911. VERTEXCOLOR: boolean;
  100912. VERTEXALPHA: boolean;
  100913. NUM_BONE_INFLUENCERS: number;
  100914. BonesPerMesh: number;
  100915. BONETEXTURE: boolean;
  100916. INSTANCES: boolean;
  100917. GLOSSINESS: boolean;
  100918. ROUGHNESS: boolean;
  100919. EMISSIVEASILLUMINATION: boolean;
  100920. LINKEMISSIVEWITHDIFFUSE: boolean;
  100921. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100922. LIGHTMAP: boolean;
  100923. LIGHTMAPDIRECTUV: number;
  100924. OBJECTSPACE_NORMALMAP: boolean;
  100925. USELIGHTMAPASSHADOWMAP: boolean;
  100926. REFLECTIONMAP_3D: boolean;
  100927. REFLECTIONMAP_SPHERICAL: boolean;
  100928. REFLECTIONMAP_PLANAR: boolean;
  100929. REFLECTIONMAP_CUBIC: boolean;
  100930. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100931. REFLECTIONMAP_PROJECTION: boolean;
  100932. REFLECTIONMAP_SKYBOX: boolean;
  100933. REFLECTIONMAP_EXPLICIT: boolean;
  100934. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100935. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100936. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100937. INVERTCUBICMAP: boolean;
  100938. LOGARITHMICDEPTH: boolean;
  100939. REFRACTION: boolean;
  100940. REFRACTIONMAP_3D: boolean;
  100941. REFLECTIONOVERALPHA: boolean;
  100942. TWOSIDEDLIGHTING: boolean;
  100943. SHADOWFLOAT: boolean;
  100944. MORPHTARGETS: boolean;
  100945. MORPHTARGETS_NORMAL: boolean;
  100946. MORPHTARGETS_TANGENT: boolean;
  100947. MORPHTARGETS_UV: boolean;
  100948. NUM_MORPH_INFLUENCERS: number;
  100949. NONUNIFORMSCALING: boolean;
  100950. PREMULTIPLYALPHA: boolean;
  100951. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100952. ALPHABLEND: boolean;
  100953. IMAGEPROCESSING: boolean;
  100954. VIGNETTE: boolean;
  100955. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100956. VIGNETTEBLENDMODEOPAQUE: boolean;
  100957. TONEMAPPING: boolean;
  100958. TONEMAPPING_ACES: boolean;
  100959. CONTRAST: boolean;
  100960. COLORCURVES: boolean;
  100961. COLORGRADING: boolean;
  100962. COLORGRADING3D: boolean;
  100963. SAMPLER3DGREENDEPTH: boolean;
  100964. SAMPLER3DBGRMAP: boolean;
  100965. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100966. MULTIVIEW: boolean;
  100967. /**
  100968. * If the reflection texture on this material is in linear color space
  100969. * @hidden
  100970. */
  100971. IS_REFLECTION_LINEAR: boolean;
  100972. /**
  100973. * If the refraction texture on this material is in linear color space
  100974. * @hidden
  100975. */
  100976. IS_REFRACTION_LINEAR: boolean;
  100977. EXPOSURE: boolean;
  100978. constructor();
  100979. setReflectionMode(modeToEnable: string): void;
  100980. }
  100981. /**
  100982. * This is the default material used in Babylon. It is the best trade off between quality
  100983. * and performances.
  100984. * @see http://doc.babylonjs.com/babylon101/materials
  100985. */
  100986. export class StandardMaterial extends PushMaterial {
  100987. private _diffuseTexture;
  100988. /**
  100989. * The basic texture of the material as viewed under a light.
  100990. */
  100991. diffuseTexture: Nullable<BaseTexture>;
  100992. private _ambientTexture;
  100993. /**
  100994. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100995. */
  100996. ambientTexture: Nullable<BaseTexture>;
  100997. private _opacityTexture;
  100998. /**
  100999. * Define the transparency of the material from a texture.
  101000. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101001. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101002. */
  101003. opacityTexture: Nullable<BaseTexture>;
  101004. private _reflectionTexture;
  101005. /**
  101006. * Define the texture used to display the reflection.
  101007. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101008. */
  101009. reflectionTexture: Nullable<BaseTexture>;
  101010. private _emissiveTexture;
  101011. /**
  101012. * Define texture of the material as if self lit.
  101013. * This will be mixed in the final result even in the absence of light.
  101014. */
  101015. emissiveTexture: Nullable<BaseTexture>;
  101016. private _specularTexture;
  101017. /**
  101018. * Define how the color and intensity of the highlight given by the light in the material.
  101019. */
  101020. specularTexture: Nullable<BaseTexture>;
  101021. private _bumpTexture;
  101022. /**
  101023. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101024. * 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.
  101025. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101026. */
  101027. bumpTexture: Nullable<BaseTexture>;
  101028. private _lightmapTexture;
  101029. /**
  101030. * Complex lighting can be computationally expensive to compute at runtime.
  101031. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101032. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101033. */
  101034. lightmapTexture: Nullable<BaseTexture>;
  101035. private _refractionTexture;
  101036. /**
  101037. * Define the texture used to display the refraction.
  101038. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101039. */
  101040. refractionTexture: Nullable<BaseTexture>;
  101041. /**
  101042. * The color of the material lit by the environmental background lighting.
  101043. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101044. */
  101045. ambientColor: Color3;
  101046. /**
  101047. * The basic color of the material as viewed under a light.
  101048. */
  101049. diffuseColor: Color3;
  101050. /**
  101051. * Define how the color and intensity of the highlight given by the light in the material.
  101052. */
  101053. specularColor: Color3;
  101054. /**
  101055. * Define the color of the material as if self lit.
  101056. * This will be mixed in the final result even in the absence of light.
  101057. */
  101058. emissiveColor: Color3;
  101059. /**
  101060. * Defines how sharp are the highlights in the material.
  101061. * The bigger the value the sharper giving a more glossy feeling to the result.
  101062. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101063. */
  101064. specularPower: number;
  101065. private _useAlphaFromDiffuseTexture;
  101066. /**
  101067. * Does the transparency come from the diffuse texture alpha channel.
  101068. */
  101069. useAlphaFromDiffuseTexture: boolean;
  101070. private _useEmissiveAsIllumination;
  101071. /**
  101072. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101073. */
  101074. useEmissiveAsIllumination: boolean;
  101075. private _linkEmissiveWithDiffuse;
  101076. /**
  101077. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101078. * the emissive level when the final color is close to one.
  101079. */
  101080. linkEmissiveWithDiffuse: boolean;
  101081. private _useSpecularOverAlpha;
  101082. /**
  101083. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101084. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101085. */
  101086. useSpecularOverAlpha: boolean;
  101087. private _useReflectionOverAlpha;
  101088. /**
  101089. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101090. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101091. */
  101092. useReflectionOverAlpha: boolean;
  101093. private _disableLighting;
  101094. /**
  101095. * Does lights from the scene impacts this material.
  101096. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101097. */
  101098. disableLighting: boolean;
  101099. private _useObjectSpaceNormalMap;
  101100. /**
  101101. * Allows using an object space normal map (instead of tangent space).
  101102. */
  101103. useObjectSpaceNormalMap: boolean;
  101104. private _useParallax;
  101105. /**
  101106. * Is parallax enabled or not.
  101107. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101108. */
  101109. useParallax: boolean;
  101110. private _useParallaxOcclusion;
  101111. /**
  101112. * Is parallax occlusion enabled or not.
  101113. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101114. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101115. */
  101116. useParallaxOcclusion: boolean;
  101117. /**
  101118. * 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.
  101119. */
  101120. parallaxScaleBias: number;
  101121. private _roughness;
  101122. /**
  101123. * Helps to define how blurry the reflections should appears in the material.
  101124. */
  101125. roughness: number;
  101126. /**
  101127. * In case of refraction, define the value of the index of refraction.
  101128. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101129. */
  101130. indexOfRefraction: number;
  101131. /**
  101132. * Invert the refraction texture alongside the y axis.
  101133. * It can be useful with procedural textures or probe for instance.
  101134. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101135. */
  101136. invertRefractionY: boolean;
  101137. /**
  101138. * Defines the alpha limits in alpha test mode.
  101139. */
  101140. alphaCutOff: number;
  101141. private _useLightmapAsShadowmap;
  101142. /**
  101143. * In case of light mapping, define whether the map contains light or shadow informations.
  101144. */
  101145. useLightmapAsShadowmap: boolean;
  101146. private _diffuseFresnelParameters;
  101147. /**
  101148. * Define the diffuse fresnel parameters of the material.
  101149. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101150. */
  101151. diffuseFresnelParameters: FresnelParameters;
  101152. private _opacityFresnelParameters;
  101153. /**
  101154. * Define the opacity fresnel parameters of the material.
  101155. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101156. */
  101157. opacityFresnelParameters: FresnelParameters;
  101158. private _reflectionFresnelParameters;
  101159. /**
  101160. * Define the reflection fresnel parameters of the material.
  101161. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101162. */
  101163. reflectionFresnelParameters: FresnelParameters;
  101164. private _refractionFresnelParameters;
  101165. /**
  101166. * Define the refraction fresnel parameters of the material.
  101167. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101168. */
  101169. refractionFresnelParameters: FresnelParameters;
  101170. private _emissiveFresnelParameters;
  101171. /**
  101172. * Define the emissive fresnel parameters of the material.
  101173. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101174. */
  101175. emissiveFresnelParameters: FresnelParameters;
  101176. private _useReflectionFresnelFromSpecular;
  101177. /**
  101178. * If true automatically deducts the fresnels values from the material specularity.
  101179. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101180. */
  101181. useReflectionFresnelFromSpecular: boolean;
  101182. private _useGlossinessFromSpecularMapAlpha;
  101183. /**
  101184. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101185. */
  101186. useGlossinessFromSpecularMapAlpha: boolean;
  101187. private _maxSimultaneousLights;
  101188. /**
  101189. * Defines the maximum number of lights that can be used in the material
  101190. */
  101191. maxSimultaneousLights: number;
  101192. private _invertNormalMapX;
  101193. /**
  101194. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101195. */
  101196. invertNormalMapX: boolean;
  101197. private _invertNormalMapY;
  101198. /**
  101199. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101200. */
  101201. invertNormalMapY: boolean;
  101202. private _twoSidedLighting;
  101203. /**
  101204. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101205. */
  101206. twoSidedLighting: boolean;
  101207. /**
  101208. * Default configuration related to image processing available in the standard Material.
  101209. */
  101210. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101211. /**
  101212. * Gets the image processing configuration used either in this material.
  101213. */
  101214. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101215. /**
  101216. * Sets the Default image processing configuration used either in the this material.
  101217. *
  101218. * If sets to null, the scene one is in use.
  101219. */
  101220. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101221. /**
  101222. * Keep track of the image processing observer to allow dispose and replace.
  101223. */
  101224. private _imageProcessingObserver;
  101225. /**
  101226. * Attaches a new image processing configuration to the Standard Material.
  101227. * @param configuration
  101228. */
  101229. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101230. /**
  101231. * Gets wether the color curves effect is enabled.
  101232. */
  101233. get cameraColorCurvesEnabled(): boolean;
  101234. /**
  101235. * Sets wether the color curves effect is enabled.
  101236. */
  101237. set cameraColorCurvesEnabled(value: boolean);
  101238. /**
  101239. * Gets wether the color grading effect is enabled.
  101240. */
  101241. get cameraColorGradingEnabled(): boolean;
  101242. /**
  101243. * Gets wether the color grading effect is enabled.
  101244. */
  101245. set cameraColorGradingEnabled(value: boolean);
  101246. /**
  101247. * Gets wether tonemapping is enabled or not.
  101248. */
  101249. get cameraToneMappingEnabled(): boolean;
  101250. /**
  101251. * Sets wether tonemapping is enabled or not
  101252. */
  101253. set cameraToneMappingEnabled(value: boolean);
  101254. /**
  101255. * The camera exposure used on this material.
  101256. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101257. * This corresponds to a photographic exposure.
  101258. */
  101259. get cameraExposure(): number;
  101260. /**
  101261. * The camera exposure used on this material.
  101262. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101263. * This corresponds to a photographic exposure.
  101264. */
  101265. set cameraExposure(value: number);
  101266. /**
  101267. * Gets The camera contrast used on this material.
  101268. */
  101269. get cameraContrast(): number;
  101270. /**
  101271. * Sets The camera contrast used on this material.
  101272. */
  101273. set cameraContrast(value: number);
  101274. /**
  101275. * Gets the Color Grading 2D Lookup Texture.
  101276. */
  101277. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  101278. /**
  101279. * Sets the Color Grading 2D Lookup Texture.
  101280. */
  101281. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  101282. /**
  101283. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101284. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101285. * 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;
  101286. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101287. */
  101288. get cameraColorCurves(): Nullable<ColorCurves>;
  101289. /**
  101290. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101291. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101292. * 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;
  101293. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101294. */
  101295. set cameraColorCurves(value: Nullable<ColorCurves>);
  101296. /**
  101297. * Custom callback helping to override the default shader used in the material.
  101298. */
  101299. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  101300. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101301. protected _worldViewProjectionMatrix: Matrix;
  101302. protected _globalAmbientColor: Color3;
  101303. protected _useLogarithmicDepth: boolean;
  101304. protected _rebuildInParallel: boolean;
  101305. /**
  101306. * Instantiates a new standard material.
  101307. * This is the default material used in Babylon. It is the best trade off between quality
  101308. * and performances.
  101309. * @see http://doc.babylonjs.com/babylon101/materials
  101310. * @param name Define the name of the material in the scene
  101311. * @param scene Define the scene the material belong to
  101312. */
  101313. constructor(name: string, scene: Scene);
  101314. /**
  101315. * Gets a boolean indicating that current material needs to register RTT
  101316. */
  101317. get hasRenderTargetTextures(): boolean;
  101318. /**
  101319. * Gets the current class name of the material e.g. "StandardMaterial"
  101320. * Mainly use in serialization.
  101321. * @returns the class name
  101322. */
  101323. getClassName(): string;
  101324. /**
  101325. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101326. * You can try switching to logarithmic depth.
  101327. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101328. */
  101329. get useLogarithmicDepth(): boolean;
  101330. set useLogarithmicDepth(value: boolean);
  101331. /**
  101332. * Specifies if the material will require alpha blending
  101333. * @returns a boolean specifying if alpha blending is needed
  101334. */
  101335. needAlphaBlending(): boolean;
  101336. /**
  101337. * Specifies if this material should be rendered in alpha test mode
  101338. * @returns a boolean specifying if an alpha test is needed.
  101339. */
  101340. needAlphaTesting(): boolean;
  101341. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101342. /**
  101343. * Get the texture used for alpha test purpose.
  101344. * @returns the diffuse texture in case of the standard material.
  101345. */
  101346. getAlphaTestTexture(): Nullable<BaseTexture>;
  101347. /**
  101348. * Get if the submesh is ready to be used and all its information available.
  101349. * Child classes can use it to update shaders
  101350. * @param mesh defines the mesh to check
  101351. * @param subMesh defines which submesh to check
  101352. * @param useInstances specifies that instances should be used
  101353. * @returns a boolean indicating that the submesh is ready or not
  101354. */
  101355. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101356. /**
  101357. * Builds the material UBO layouts.
  101358. * Used internally during the effect preparation.
  101359. */
  101360. buildUniformLayout(): void;
  101361. /**
  101362. * Unbinds the material from the mesh
  101363. */
  101364. unbind(): void;
  101365. /**
  101366. * Binds the submesh to this material by preparing the effect and shader to draw
  101367. * @param world defines the world transformation matrix
  101368. * @param mesh defines the mesh containing the submesh
  101369. * @param subMesh defines the submesh to bind the material to
  101370. */
  101371. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101372. /**
  101373. * Get the list of animatables in the material.
  101374. * @returns the list of animatables object used in the material
  101375. */
  101376. getAnimatables(): IAnimatable[];
  101377. /**
  101378. * Gets the active textures from the material
  101379. * @returns an array of textures
  101380. */
  101381. getActiveTextures(): BaseTexture[];
  101382. /**
  101383. * Specifies if the material uses a texture
  101384. * @param texture defines the texture to check against the material
  101385. * @returns a boolean specifying if the material uses the texture
  101386. */
  101387. hasTexture(texture: BaseTexture): boolean;
  101388. /**
  101389. * Disposes the material
  101390. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101391. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101392. */
  101393. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101394. /**
  101395. * Makes a duplicate of the material, and gives it a new name
  101396. * @param name defines the new name for the duplicated material
  101397. * @returns the cloned material
  101398. */
  101399. clone(name: string): StandardMaterial;
  101400. /**
  101401. * Serializes this material in a JSON representation
  101402. * @returns the serialized material object
  101403. */
  101404. serialize(): any;
  101405. /**
  101406. * Creates a standard material from parsed material data
  101407. * @param source defines the JSON representation of the material
  101408. * @param scene defines the hosting scene
  101409. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101410. * @returns a new standard material
  101411. */
  101412. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101413. /**
  101414. * Are diffuse textures enabled in the application.
  101415. */
  101416. static get DiffuseTextureEnabled(): boolean;
  101417. static set DiffuseTextureEnabled(value: boolean);
  101418. /**
  101419. * Are ambient textures enabled in the application.
  101420. */
  101421. static get AmbientTextureEnabled(): boolean;
  101422. static set AmbientTextureEnabled(value: boolean);
  101423. /**
  101424. * Are opacity textures enabled in the application.
  101425. */
  101426. static get OpacityTextureEnabled(): boolean;
  101427. static set OpacityTextureEnabled(value: boolean);
  101428. /**
  101429. * Are reflection textures enabled in the application.
  101430. */
  101431. static get ReflectionTextureEnabled(): boolean;
  101432. static set ReflectionTextureEnabled(value: boolean);
  101433. /**
  101434. * Are emissive textures enabled in the application.
  101435. */
  101436. static get EmissiveTextureEnabled(): boolean;
  101437. static set EmissiveTextureEnabled(value: boolean);
  101438. /**
  101439. * Are specular textures enabled in the application.
  101440. */
  101441. static get SpecularTextureEnabled(): boolean;
  101442. static set SpecularTextureEnabled(value: boolean);
  101443. /**
  101444. * Are bump textures enabled in the application.
  101445. */
  101446. static get BumpTextureEnabled(): boolean;
  101447. static set BumpTextureEnabled(value: boolean);
  101448. /**
  101449. * Are lightmap textures enabled in the application.
  101450. */
  101451. static get LightmapTextureEnabled(): boolean;
  101452. static set LightmapTextureEnabled(value: boolean);
  101453. /**
  101454. * Are refraction textures enabled in the application.
  101455. */
  101456. static get RefractionTextureEnabled(): boolean;
  101457. static set RefractionTextureEnabled(value: boolean);
  101458. /**
  101459. * Are color grading textures enabled in the application.
  101460. */
  101461. static get ColorGradingTextureEnabled(): boolean;
  101462. static set ColorGradingTextureEnabled(value: boolean);
  101463. /**
  101464. * Are fresnels enabled in the application.
  101465. */
  101466. static get FresnelEnabled(): boolean;
  101467. static set FresnelEnabled(value: boolean);
  101468. }
  101469. }
  101470. declare module BABYLON {
  101471. /**
  101472. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  101473. *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.
  101474. * The SPS is also a particle system. It provides some methods to manage the particles.
  101475. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  101476. *
  101477. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  101478. */
  101479. export class SolidParticleSystem implements IDisposable {
  101480. /**
  101481. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  101482. * Example : var p = SPS.particles[i];
  101483. */
  101484. particles: SolidParticle[];
  101485. /**
  101486. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  101487. */
  101488. nbParticles: number;
  101489. /**
  101490. * If the particles must ever face the camera (default false). Useful for planar particles.
  101491. */
  101492. billboard: boolean;
  101493. /**
  101494. * Recompute normals when adding a shape
  101495. */
  101496. recomputeNormals: boolean;
  101497. /**
  101498. * This a counter ofr your own usage. It's not set by any SPS functions.
  101499. */
  101500. counter: number;
  101501. /**
  101502. * The SPS name. This name is also given to the underlying mesh.
  101503. */
  101504. name: string;
  101505. /**
  101506. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  101507. */
  101508. mesh: Mesh;
  101509. /**
  101510. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  101511. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  101512. */
  101513. vars: any;
  101514. /**
  101515. * This array is populated when the SPS is set as 'pickable'.
  101516. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  101517. * Each element of this array is an object `{idx: int, faceId: int}`.
  101518. * `idx` is the picked particle index in the `SPS.particles` array
  101519. * `faceId` is the picked face index counted within this particle.
  101520. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  101521. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  101522. * Use the method SPS.pickedParticle(pickingInfo) instead.
  101523. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101524. */
  101525. pickedParticles: {
  101526. idx: number;
  101527. faceId: number;
  101528. }[];
  101529. /**
  101530. * This array is populated when the SPS is set as 'pickable'
  101531. * Each key of this array is a submesh index.
  101532. * Each element of this array is a second array defined like this :
  101533. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  101534. * Each element of this second array is an object `{idx: int, faceId: int}`.
  101535. * `idx` is the picked particle index in the `SPS.particles` array
  101536. * `faceId` is the picked face index counted within this particle.
  101537. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  101538. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101539. */
  101540. pickedBySubMesh: {
  101541. idx: number;
  101542. faceId: number;
  101543. }[][];
  101544. /**
  101545. * This array is populated when `enableDepthSort` is set to true.
  101546. * Each element of this array is an instance of the class DepthSortedParticle.
  101547. */
  101548. depthSortedParticles: DepthSortedParticle[];
  101549. /**
  101550. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  101551. * @hidden
  101552. */
  101553. _bSphereOnly: boolean;
  101554. /**
  101555. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  101556. * @hidden
  101557. */
  101558. _bSphereRadiusFactor: number;
  101559. private _scene;
  101560. private _positions;
  101561. private _indices;
  101562. private _normals;
  101563. private _colors;
  101564. private _uvs;
  101565. private _indices32;
  101566. private _positions32;
  101567. private _normals32;
  101568. private _fixedNormal32;
  101569. private _colors32;
  101570. private _uvs32;
  101571. private _index;
  101572. private _updatable;
  101573. private _pickable;
  101574. private _isVisibilityBoxLocked;
  101575. private _alwaysVisible;
  101576. private _depthSort;
  101577. private _expandable;
  101578. private _shapeCounter;
  101579. private _copy;
  101580. private _color;
  101581. private _computeParticleColor;
  101582. private _computeParticleTexture;
  101583. private _computeParticleRotation;
  101584. private _computeParticleVertex;
  101585. private _computeBoundingBox;
  101586. private _depthSortParticles;
  101587. private _camera;
  101588. private _mustUnrotateFixedNormals;
  101589. private _particlesIntersect;
  101590. private _needs32Bits;
  101591. private _isNotBuilt;
  101592. private _lastParticleId;
  101593. private _idxOfId;
  101594. private _multimaterialEnabled;
  101595. private _useModelMaterial;
  101596. private _indicesByMaterial;
  101597. private _materialIndexes;
  101598. private _depthSortFunction;
  101599. private _materialSortFunction;
  101600. private _materials;
  101601. private _multimaterial;
  101602. private _materialIndexesById;
  101603. private _defaultMaterial;
  101604. private _autoUpdateSubMeshes;
  101605. /**
  101606. * Creates a SPS (Solid Particle System) object.
  101607. * @param name (String) is the SPS name, this will be the underlying mesh name.
  101608. * @param scene (Scene) is the scene in which the SPS is added.
  101609. * @param options defines the options of the sps e.g.
  101610. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  101611. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  101612. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  101613. * * 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.
  101614. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  101615. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  101616. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  101617. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  101618. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  101619. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  101620. */
  101621. constructor(name: string, scene: Scene, options?: {
  101622. updatable?: boolean;
  101623. isPickable?: boolean;
  101624. enableDepthSort?: boolean;
  101625. particleIntersection?: boolean;
  101626. boundingSphereOnly?: boolean;
  101627. bSphereRadiusFactor?: number;
  101628. expandable?: boolean;
  101629. useModelMaterial?: boolean;
  101630. enableMultiMaterial?: boolean;
  101631. });
  101632. /**
  101633. * Builds the SPS underlying mesh. Returns a standard Mesh.
  101634. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  101635. * @returns the created mesh
  101636. */
  101637. buildMesh(): Mesh;
  101638. /**
  101639. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  101640. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  101641. * Thus the particles generated from `digest()` have their property `position` set yet.
  101642. * @param mesh ( Mesh ) is the mesh to be digested
  101643. * @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
  101644. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  101645. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  101646. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101647. * @returns the current SPS
  101648. */
  101649. digest(mesh: Mesh, options?: {
  101650. facetNb?: number;
  101651. number?: number;
  101652. delta?: number;
  101653. storage?: [];
  101654. }): SolidParticleSystem;
  101655. /**
  101656. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  101657. * @hidden
  101658. */
  101659. private _unrotateFixedNormals;
  101660. /**
  101661. * Resets the temporary working copy particle
  101662. * @hidden
  101663. */
  101664. private _resetCopy;
  101665. /**
  101666. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  101667. * @param p the current index in the positions array to be updated
  101668. * @param ind the current index in the indices array
  101669. * @param shape a Vector3 array, the shape geometry
  101670. * @param positions the positions array to be updated
  101671. * @param meshInd the shape indices array
  101672. * @param indices the indices array to be updated
  101673. * @param meshUV the shape uv array
  101674. * @param uvs the uv array to be updated
  101675. * @param meshCol the shape color array
  101676. * @param colors the color array to be updated
  101677. * @param meshNor the shape normals array
  101678. * @param normals the normals array to be updated
  101679. * @param idx the particle index
  101680. * @param idxInShape the particle index in its shape
  101681. * @param options the addShape() method passed options
  101682. * @model the particle model
  101683. * @hidden
  101684. */
  101685. private _meshBuilder;
  101686. /**
  101687. * Returns a shape Vector3 array from positions float array
  101688. * @param positions float array
  101689. * @returns a vector3 array
  101690. * @hidden
  101691. */
  101692. private _posToShape;
  101693. /**
  101694. * Returns a shapeUV array from a float uvs (array deep copy)
  101695. * @param uvs as a float array
  101696. * @returns a shapeUV array
  101697. * @hidden
  101698. */
  101699. private _uvsToShapeUV;
  101700. /**
  101701. * Adds a new particle object in the particles array
  101702. * @param idx particle index in particles array
  101703. * @param id particle id
  101704. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  101705. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  101706. * @param model particle ModelShape object
  101707. * @param shapeId model shape identifier
  101708. * @param idxInShape index of the particle in the current model
  101709. * @param bInfo model bounding info object
  101710. * @param storage target storage array, if any
  101711. * @hidden
  101712. */
  101713. private _addParticle;
  101714. /**
  101715. * Adds some particles to the SPS from the model shape. Returns the shape id.
  101716. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  101717. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  101718. * @param nb (positive integer) the number of particles to be created from this model
  101719. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  101720. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  101721. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101722. * @returns the number of shapes in the system
  101723. */
  101724. addShape(mesh: Mesh, nb: number, options?: {
  101725. positionFunction?: any;
  101726. vertexFunction?: any;
  101727. storage?: [];
  101728. }): number;
  101729. /**
  101730. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  101731. * @hidden
  101732. */
  101733. private _rebuildParticle;
  101734. /**
  101735. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  101736. * @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.
  101737. * @returns the SPS.
  101738. */
  101739. rebuildMesh(reset?: boolean): SolidParticleSystem;
  101740. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  101741. * Returns an array with the removed particles.
  101742. * 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.
  101743. * The SPS can't be empty so at least one particle needs to remain in place.
  101744. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  101745. * @param start index of the first particle to remove
  101746. * @param end index of the last particle to remove (included)
  101747. * @returns an array populated with the removed particles
  101748. */
  101749. removeParticles(start: number, end: number): SolidParticle[];
  101750. /**
  101751. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  101752. * @param solidParticleArray an array populated with Solid Particles objects
  101753. * @returns the SPS
  101754. */
  101755. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  101756. /**
  101757. * Creates a new particle and modifies the SPS mesh geometry :
  101758. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  101759. * - calls _addParticle() to populate the particle array
  101760. * factorized code from addShape() and insertParticlesFromArray()
  101761. * @param idx particle index in the particles array
  101762. * @param i particle index in its shape
  101763. * @param modelShape particle ModelShape object
  101764. * @param shape shape vertex array
  101765. * @param meshInd shape indices array
  101766. * @param meshUV shape uv array
  101767. * @param meshCol shape color array
  101768. * @param meshNor shape normals array
  101769. * @param bbInfo shape bounding info
  101770. * @param storage target particle storage
  101771. * @options addShape() passed options
  101772. * @hidden
  101773. */
  101774. private _insertNewParticle;
  101775. /**
  101776. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  101777. * This method calls `updateParticle()` for each particle of the SPS.
  101778. * For an animated SPS, it is usually called within the render loop.
  101779. * 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.
  101780. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  101781. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  101782. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  101783. * @returns the SPS.
  101784. */
  101785. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  101786. /**
  101787. * Disposes the SPS.
  101788. */
  101789. dispose(): void;
  101790. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  101791. * idx is the particle index in the SPS
  101792. * faceId is the picked face index counted within this particle.
  101793. * Returns null if the pickInfo can't identify a picked particle.
  101794. * @param pickingInfo (PickingInfo object)
  101795. * @returns {idx: number, faceId: number} or null
  101796. */
  101797. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  101798. idx: number;
  101799. faceId: number;
  101800. }>;
  101801. /**
  101802. * Returns a SolidParticle object from its identifier : particle.id
  101803. * @param id (integer) the particle Id
  101804. * @returns the searched particle or null if not found in the SPS.
  101805. */
  101806. getParticleById(id: number): Nullable<SolidParticle>;
  101807. /**
  101808. * Returns a new array populated with the particles having the passed shapeId.
  101809. * @param shapeId (integer) the shape identifier
  101810. * @returns a new solid particle array
  101811. */
  101812. getParticlesByShapeId(shapeId: number): SolidParticle[];
  101813. /**
  101814. * Populates the passed array "ref" with the particles having the passed shapeId.
  101815. * @param shapeId the shape identifier
  101816. * @returns the SPS
  101817. * @param ref
  101818. */
  101819. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  101820. /**
  101821. * Computes the required SubMeshes according the materials assigned to the particles.
  101822. * @returns the solid particle system.
  101823. * Does nothing if called before the SPS mesh is built.
  101824. */
  101825. computeSubMeshes(): SolidParticleSystem;
  101826. /**
  101827. * Sorts the solid particles by material when MultiMaterial is enabled.
  101828. * Updates the indices32 array.
  101829. * Updates the indicesByMaterial array.
  101830. * Updates the mesh indices array.
  101831. * @returns the SPS
  101832. * @hidden
  101833. */
  101834. private _sortParticlesByMaterial;
  101835. /**
  101836. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  101837. * @hidden
  101838. */
  101839. private _setMaterialIndexesById;
  101840. /**
  101841. * Returns an array with unique values of Materials from the passed array
  101842. * @param array the material array to be checked and filtered
  101843. * @hidden
  101844. */
  101845. private _filterUniqueMaterialId;
  101846. /**
  101847. * Sets a new Standard Material as _defaultMaterial if not already set.
  101848. * @hidden
  101849. */
  101850. private _setDefaultMaterial;
  101851. /**
  101852. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  101853. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101854. * @returns the SPS.
  101855. */
  101856. refreshVisibleSize(): SolidParticleSystem;
  101857. /**
  101858. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  101859. * @param size the size (float) of the visibility box
  101860. * note : this doesn't lock the SPS mesh bounding box.
  101861. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101862. */
  101863. setVisibilityBox(size: number): void;
  101864. /**
  101865. * Gets whether the SPS as always visible or not
  101866. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101867. */
  101868. get isAlwaysVisible(): boolean;
  101869. /**
  101870. * Sets the SPS as always visible or not
  101871. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101872. */
  101873. set isAlwaysVisible(val: boolean);
  101874. /**
  101875. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101876. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101877. */
  101878. set isVisibilityBoxLocked(val: boolean);
  101879. /**
  101880. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101881. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101882. */
  101883. get isVisibilityBoxLocked(): boolean;
  101884. /**
  101885. * Tells to `setParticles()` to compute the particle rotations or not.
  101886. * Default value : true. The SPS is faster when it's set to false.
  101887. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101888. */
  101889. set computeParticleRotation(val: boolean);
  101890. /**
  101891. * Tells to `setParticles()` to compute the particle colors or not.
  101892. * Default value : true. The SPS is faster when it's set to false.
  101893. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101894. */
  101895. set computeParticleColor(val: boolean);
  101896. set computeParticleTexture(val: boolean);
  101897. /**
  101898. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101899. * Default value : false. The SPS is faster when it's set to false.
  101900. * Note : the particle custom vertex positions aren't stored values.
  101901. */
  101902. set computeParticleVertex(val: boolean);
  101903. /**
  101904. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101905. */
  101906. set computeBoundingBox(val: boolean);
  101907. /**
  101908. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101909. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101910. * Default : `true`
  101911. */
  101912. set depthSortParticles(val: boolean);
  101913. /**
  101914. * Gets if `setParticles()` computes the particle rotations or not.
  101915. * Default value : true. The SPS is faster when it's set to false.
  101916. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101917. */
  101918. get computeParticleRotation(): boolean;
  101919. /**
  101920. * Gets if `setParticles()` computes the particle colors or not.
  101921. * Default value : true. The SPS is faster when it's set to false.
  101922. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101923. */
  101924. get computeParticleColor(): boolean;
  101925. /**
  101926. * Gets if `setParticles()` computes the particle textures or not.
  101927. * Default value : true. The SPS is faster when it's set to false.
  101928. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101929. */
  101930. get computeParticleTexture(): boolean;
  101931. /**
  101932. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101933. * Default value : false. The SPS is faster when it's set to false.
  101934. * Note : the particle custom vertex positions aren't stored values.
  101935. */
  101936. get computeParticleVertex(): boolean;
  101937. /**
  101938. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101939. */
  101940. get computeBoundingBox(): boolean;
  101941. /**
  101942. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101943. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101944. * Default : `true`
  101945. */
  101946. get depthSortParticles(): boolean;
  101947. /**
  101948. * Gets if the SPS is created as expandable at construction time.
  101949. * Default : `false`
  101950. */
  101951. get expandable(): boolean;
  101952. /**
  101953. * Gets if the SPS supports the Multi Materials
  101954. */
  101955. get multimaterialEnabled(): boolean;
  101956. /**
  101957. * Gets if the SPS uses the model materials for its own multimaterial.
  101958. */
  101959. get useModelMaterial(): boolean;
  101960. /**
  101961. * The SPS used material array.
  101962. */
  101963. get materials(): Material[];
  101964. /**
  101965. * Sets the SPS MultiMaterial from the passed materials.
  101966. * Note : the passed array is internally copied and not used then by reference.
  101967. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101968. */
  101969. setMultiMaterial(materials: Material[]): void;
  101970. /**
  101971. * The SPS computed multimaterial object
  101972. */
  101973. get multimaterial(): MultiMaterial;
  101974. set multimaterial(mm: MultiMaterial);
  101975. /**
  101976. * If the subMeshes must be updated on the next call to setParticles()
  101977. */
  101978. get autoUpdateSubMeshes(): boolean;
  101979. set autoUpdateSubMeshes(val: boolean);
  101980. /**
  101981. * This function does nothing. It may be overwritten to set all the particle first values.
  101982. * The SPS doesn't call this function, you may have to call it by your own.
  101983. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101984. */
  101985. initParticles(): void;
  101986. /**
  101987. * This function does nothing. It may be overwritten to recycle a particle.
  101988. * The SPS doesn't call this function, you may have to call it by your own.
  101989. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101990. * @param particle The particle to recycle
  101991. * @returns the recycled particle
  101992. */
  101993. recycleParticle(particle: SolidParticle): SolidParticle;
  101994. /**
  101995. * Updates a particle : this function should be overwritten by the user.
  101996. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  101997. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101998. * @example : just set a particle position or velocity and recycle conditions
  101999. * @param particle The particle to update
  102000. * @returns the updated particle
  102001. */
  102002. updateParticle(particle: SolidParticle): SolidParticle;
  102003. /**
  102004. * Updates a vertex of a particle : it can be overwritten by the user.
  102005. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  102006. * @param particle the current particle
  102007. * @param vertex the current index of the current particle
  102008. * @param pt the index of the current vertex in the particle shape
  102009. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  102010. * @example : just set a vertex particle position
  102011. * @returns the updated vertex
  102012. */
  102013. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  102014. /**
  102015. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  102016. * This does nothing and may be overwritten by the user.
  102017. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102018. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102019. * @param update the boolean update value actually passed to setParticles()
  102020. */
  102021. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102022. /**
  102023. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  102024. * This will be passed three parameters.
  102025. * This does nothing and may be overwritten by the user.
  102026. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102027. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102028. * @param update the boolean update value actually passed to setParticles()
  102029. */
  102030. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102031. }
  102032. }
  102033. declare module BABYLON {
  102034. /**
  102035. * Represents one particle of a solid particle system.
  102036. */
  102037. export class SolidParticle {
  102038. /**
  102039. * particle global index
  102040. */
  102041. idx: number;
  102042. /**
  102043. * particle identifier
  102044. */
  102045. id: number;
  102046. /**
  102047. * The color of the particle
  102048. */
  102049. color: Nullable<Color4>;
  102050. /**
  102051. * The world space position of the particle.
  102052. */
  102053. position: Vector3;
  102054. /**
  102055. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  102056. */
  102057. rotation: Vector3;
  102058. /**
  102059. * The world space rotation quaternion of the particle.
  102060. */
  102061. rotationQuaternion: Nullable<Quaternion>;
  102062. /**
  102063. * The scaling of the particle.
  102064. */
  102065. scaling: Vector3;
  102066. /**
  102067. * The uvs of the particle.
  102068. */
  102069. uvs: Vector4;
  102070. /**
  102071. * The current speed of the particle.
  102072. */
  102073. velocity: Vector3;
  102074. /**
  102075. * The pivot point in the particle local space.
  102076. */
  102077. pivot: Vector3;
  102078. /**
  102079. * Must the particle be translated from its pivot point in its local space ?
  102080. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  102081. * Default : false
  102082. */
  102083. translateFromPivot: boolean;
  102084. /**
  102085. * Is the particle active or not ?
  102086. */
  102087. alive: boolean;
  102088. /**
  102089. * Is the particle visible or not ?
  102090. */
  102091. isVisible: boolean;
  102092. /**
  102093. * Index of this particle in the global "positions" array (Internal use)
  102094. * @hidden
  102095. */
  102096. _pos: number;
  102097. /**
  102098. * @hidden Index of this particle in the global "indices" array (Internal use)
  102099. */
  102100. _ind: number;
  102101. /**
  102102. * @hidden ModelShape of this particle (Internal use)
  102103. */
  102104. _model: ModelShape;
  102105. /**
  102106. * ModelShape id of this particle
  102107. */
  102108. shapeId: number;
  102109. /**
  102110. * Index of the particle in its shape id
  102111. */
  102112. idxInShape: number;
  102113. /**
  102114. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  102115. */
  102116. _modelBoundingInfo: BoundingInfo;
  102117. /**
  102118. * @hidden Particle BoundingInfo object (Internal use)
  102119. */
  102120. _boundingInfo: BoundingInfo;
  102121. /**
  102122. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  102123. */
  102124. _sps: SolidParticleSystem;
  102125. /**
  102126. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  102127. */
  102128. _stillInvisible: boolean;
  102129. /**
  102130. * @hidden Last computed particle rotation matrix
  102131. */
  102132. _rotationMatrix: number[];
  102133. /**
  102134. * Parent particle Id, if any.
  102135. * Default null.
  102136. */
  102137. parentId: Nullable<number>;
  102138. /**
  102139. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  102140. */
  102141. materialIndex: Nullable<number>;
  102142. /**
  102143. * Custom object or properties.
  102144. */
  102145. props: Nullable<any>;
  102146. /**
  102147. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  102148. * The possible values are :
  102149. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102150. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102151. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102152. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102153. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102154. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  102155. * */
  102156. cullingStrategy: number;
  102157. /**
  102158. * @hidden Internal global position in the SPS.
  102159. */
  102160. _globalPosition: Vector3;
  102161. /**
  102162. * Creates a Solid Particle object.
  102163. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  102164. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  102165. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  102166. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  102167. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  102168. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  102169. * @param shapeId (integer) is the model shape identifier in the SPS.
  102170. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  102171. * @param sps defines the sps it is associated to
  102172. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  102173. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  102174. */
  102175. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  102176. /**
  102177. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  102178. * @param target the particle target
  102179. * @returns the current particle
  102180. */
  102181. copyToRef(target: SolidParticle): SolidParticle;
  102182. /**
  102183. * Legacy support, changed scale to scaling
  102184. */
  102185. get scale(): Vector3;
  102186. /**
  102187. * Legacy support, changed scale to scaling
  102188. */
  102189. set scale(scale: Vector3);
  102190. /**
  102191. * Legacy support, changed quaternion to rotationQuaternion
  102192. */
  102193. get quaternion(): Nullable<Quaternion>;
  102194. /**
  102195. * Legacy support, changed quaternion to rotationQuaternion
  102196. */
  102197. set quaternion(q: Nullable<Quaternion>);
  102198. /**
  102199. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  102200. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  102201. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  102202. * @returns true if it intersects
  102203. */
  102204. intersectsMesh(target: Mesh | SolidParticle): boolean;
  102205. /**
  102206. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  102207. * A particle is in the frustum if its bounding box intersects the frustum
  102208. * @param frustumPlanes defines the frustum to test
  102209. * @returns true if the particle is in the frustum planes
  102210. */
  102211. isInFrustum(frustumPlanes: Plane[]): boolean;
  102212. /**
  102213. * get the rotation matrix of the particle
  102214. * @hidden
  102215. */
  102216. getRotationMatrix(m: Matrix): void;
  102217. }
  102218. /**
  102219. * Represents the shape of the model used by one particle of a solid particle system.
  102220. * SPS internal tool, don't use it manually.
  102221. */
  102222. export class ModelShape {
  102223. /**
  102224. * The shape id
  102225. * @hidden
  102226. */
  102227. shapeID: number;
  102228. /**
  102229. * flat array of model positions (internal use)
  102230. * @hidden
  102231. */
  102232. _shape: Vector3[];
  102233. /**
  102234. * flat array of model UVs (internal use)
  102235. * @hidden
  102236. */
  102237. _shapeUV: number[];
  102238. /**
  102239. * color array of the model
  102240. * @hidden
  102241. */
  102242. _shapeColors: number[];
  102243. /**
  102244. * indices array of the model
  102245. * @hidden
  102246. */
  102247. _indices: number[];
  102248. /**
  102249. * normals array of the model
  102250. * @hidden
  102251. */
  102252. _normals: number[];
  102253. /**
  102254. * length of the shape in the model indices array (internal use)
  102255. * @hidden
  102256. */
  102257. _indicesLength: number;
  102258. /**
  102259. * Custom position function (internal use)
  102260. * @hidden
  102261. */
  102262. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  102263. /**
  102264. * Custom vertex function (internal use)
  102265. * @hidden
  102266. */
  102267. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  102268. /**
  102269. * Model material (internal use)
  102270. * @hidden
  102271. */
  102272. _material: Nullable<Material>;
  102273. /**
  102274. * 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.
  102275. * SPS internal tool, don't use it manually.
  102276. * @hidden
  102277. */
  102278. 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>);
  102279. }
  102280. /**
  102281. * Represents a Depth Sorted Particle in the solid particle system.
  102282. * @hidden
  102283. */
  102284. export class DepthSortedParticle {
  102285. /**
  102286. * Particle index
  102287. */
  102288. idx: number;
  102289. /**
  102290. * Index of the particle in the "indices" array
  102291. */
  102292. ind: number;
  102293. /**
  102294. * Length of the particle shape in the "indices" array
  102295. */
  102296. indicesLength: number;
  102297. /**
  102298. * Squared distance from the particle to the camera
  102299. */
  102300. sqDistance: number;
  102301. /**
  102302. * Material index when used with MultiMaterials
  102303. */
  102304. materialIndex: number;
  102305. /**
  102306. * Creates a new sorted particle
  102307. * @param materialIndex
  102308. */
  102309. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  102310. }
  102311. }
  102312. declare module BABYLON {
  102313. /**
  102314. * @hidden
  102315. */
  102316. export class _MeshCollisionData {
  102317. _checkCollisions: boolean;
  102318. _collisionMask: number;
  102319. _collisionGroup: number;
  102320. _surroundingMeshes: Nullable<AbstractMesh[]>;
  102321. _collider: Nullable<Collider>;
  102322. _oldPositionForCollisions: Vector3;
  102323. _diffPositionForCollisions: Vector3;
  102324. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  102325. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  102326. }
  102327. }
  102328. declare module BABYLON {
  102329. /** @hidden */
  102330. class _FacetDataStorage {
  102331. facetPositions: Vector3[];
  102332. facetNormals: Vector3[];
  102333. facetPartitioning: number[][];
  102334. facetNb: number;
  102335. partitioningSubdivisions: number;
  102336. partitioningBBoxRatio: number;
  102337. facetDataEnabled: boolean;
  102338. facetParameters: any;
  102339. bbSize: Vector3;
  102340. subDiv: {
  102341. max: number;
  102342. X: number;
  102343. Y: number;
  102344. Z: number;
  102345. };
  102346. facetDepthSort: boolean;
  102347. facetDepthSortEnabled: boolean;
  102348. depthSortedIndices: IndicesArray;
  102349. depthSortedFacets: {
  102350. ind: number;
  102351. sqDistance: number;
  102352. }[];
  102353. facetDepthSortFunction: (f1: {
  102354. ind: number;
  102355. sqDistance: number;
  102356. }, f2: {
  102357. ind: number;
  102358. sqDistance: number;
  102359. }) => number;
  102360. facetDepthSortFrom: Vector3;
  102361. facetDepthSortOrigin: Vector3;
  102362. invertedMatrix: Matrix;
  102363. }
  102364. /**
  102365. * @hidden
  102366. **/
  102367. class _InternalAbstractMeshDataInfo {
  102368. _hasVertexAlpha: boolean;
  102369. _useVertexColors: boolean;
  102370. _numBoneInfluencers: number;
  102371. _applyFog: boolean;
  102372. _receiveShadows: boolean;
  102373. _facetData: _FacetDataStorage;
  102374. _visibility: number;
  102375. _skeleton: Nullable<Skeleton>;
  102376. _layerMask: number;
  102377. _computeBonesUsingShaders: boolean;
  102378. _isActive: boolean;
  102379. _onlyForInstances: boolean;
  102380. _isActiveIntermediate: boolean;
  102381. _onlyForInstancesIntermediate: boolean;
  102382. _actAsRegularMesh: boolean;
  102383. }
  102384. /**
  102385. * Class used to store all common mesh properties
  102386. */
  102387. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  102388. /** No occlusion */
  102389. static OCCLUSION_TYPE_NONE: number;
  102390. /** Occlusion set to optimisitic */
  102391. static OCCLUSION_TYPE_OPTIMISTIC: number;
  102392. /** Occlusion set to strict */
  102393. static OCCLUSION_TYPE_STRICT: number;
  102394. /** Use an accurante occlusion algorithm */
  102395. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  102396. /** Use a conservative occlusion algorithm */
  102397. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  102398. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  102399. * Test order :
  102400. * Is the bounding sphere outside the frustum ?
  102401. * If not, are the bounding box vertices outside the frustum ?
  102402. * It not, then the cullable object is in the frustum.
  102403. */
  102404. static readonly CULLINGSTRATEGY_STANDARD: number;
  102405. /** Culling strategy : Bounding Sphere Only.
  102406. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  102407. * It's also less accurate than the standard because some not visible objects can still be selected.
  102408. * Test : is the bounding sphere outside the frustum ?
  102409. * If not, then the cullable object is in the frustum.
  102410. */
  102411. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  102412. /** Culling strategy : Optimistic Inclusion.
  102413. * This in an inclusion test first, then the standard exclusion test.
  102414. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  102415. * 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.
  102416. * Anyway, it's as accurate as the standard strategy.
  102417. * Test :
  102418. * Is the cullable object bounding sphere center in the frustum ?
  102419. * If not, apply the default culling strategy.
  102420. */
  102421. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  102422. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  102423. * This in an inclusion test first, then the bounding sphere only exclusion test.
  102424. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  102425. * 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.
  102426. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  102427. * Test :
  102428. * Is the cullable object bounding sphere center in the frustum ?
  102429. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  102430. */
  102431. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  102432. /**
  102433. * No billboard
  102434. */
  102435. static get BILLBOARDMODE_NONE(): number;
  102436. /** Billboard on X axis */
  102437. static get BILLBOARDMODE_X(): number;
  102438. /** Billboard on Y axis */
  102439. static get BILLBOARDMODE_Y(): number;
  102440. /** Billboard on Z axis */
  102441. static get BILLBOARDMODE_Z(): number;
  102442. /** Billboard on all axes */
  102443. static get BILLBOARDMODE_ALL(): number;
  102444. /** Billboard on using position instead of orientation */
  102445. static get BILLBOARDMODE_USE_POSITION(): number;
  102446. /** @hidden */
  102447. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  102448. /**
  102449. * The culling strategy to use to check whether the mesh must be rendered or not.
  102450. * This value can be changed at any time and will be used on the next render mesh selection.
  102451. * The possible values are :
  102452. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102453. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102454. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102455. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102456. * Please read each static variable documentation to get details about the culling process.
  102457. * */
  102458. cullingStrategy: number;
  102459. /**
  102460. * Gets the number of facets in the mesh
  102461. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102462. */
  102463. get facetNb(): number;
  102464. /**
  102465. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  102466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102467. */
  102468. get partitioningSubdivisions(): number;
  102469. set partitioningSubdivisions(nb: number);
  102470. /**
  102471. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  102472. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  102473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102474. */
  102475. get partitioningBBoxRatio(): number;
  102476. set partitioningBBoxRatio(ratio: number);
  102477. /**
  102478. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  102479. * Works only for updatable meshes.
  102480. * Doesn't work with multi-materials
  102481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102482. */
  102483. get mustDepthSortFacets(): boolean;
  102484. set mustDepthSortFacets(sort: boolean);
  102485. /**
  102486. * The location (Vector3) where the facet depth sort must be computed from.
  102487. * By default, the active camera position.
  102488. * Used only when facet depth sort is enabled
  102489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102490. */
  102491. get facetDepthSortFrom(): Vector3;
  102492. set facetDepthSortFrom(location: Vector3);
  102493. /**
  102494. * gets a boolean indicating if facetData is enabled
  102495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102496. */
  102497. get isFacetDataEnabled(): boolean;
  102498. /** @hidden */
  102499. _updateNonUniformScalingState(value: boolean): boolean;
  102500. /**
  102501. * An event triggered when this mesh collides with another one
  102502. */
  102503. onCollideObservable: Observable<AbstractMesh>;
  102504. /** Set a function to call when this mesh collides with another one */
  102505. set onCollide(callback: () => void);
  102506. /**
  102507. * An event triggered when the collision's position changes
  102508. */
  102509. onCollisionPositionChangeObservable: Observable<Vector3>;
  102510. /** Set a function to call when the collision's position changes */
  102511. set onCollisionPositionChange(callback: () => void);
  102512. /**
  102513. * An event triggered when material is changed
  102514. */
  102515. onMaterialChangedObservable: Observable<AbstractMesh>;
  102516. /**
  102517. * Gets or sets the orientation for POV movement & rotation
  102518. */
  102519. definedFacingForward: boolean;
  102520. /** @hidden */
  102521. _occlusionQuery: Nullable<WebGLQuery>;
  102522. /** @hidden */
  102523. _renderingGroup: Nullable<RenderingGroup>;
  102524. /**
  102525. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102526. */
  102527. get visibility(): number;
  102528. /**
  102529. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102530. */
  102531. set visibility(value: number);
  102532. /** Gets or sets the alpha index used to sort transparent meshes
  102533. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  102534. */
  102535. alphaIndex: number;
  102536. /**
  102537. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  102538. */
  102539. isVisible: boolean;
  102540. /**
  102541. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  102542. */
  102543. isPickable: boolean;
  102544. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  102545. showSubMeshesBoundingBox: boolean;
  102546. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  102547. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102548. */
  102549. isBlocker: boolean;
  102550. /**
  102551. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  102552. */
  102553. enablePointerMoveEvents: boolean;
  102554. /**
  102555. * Specifies the rendering group id for this mesh (0 by default)
  102556. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  102557. */
  102558. renderingGroupId: number;
  102559. private _material;
  102560. /** Gets or sets current material */
  102561. get material(): Nullable<Material>;
  102562. set material(value: Nullable<Material>);
  102563. /**
  102564. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  102565. * @see http://doc.babylonjs.com/babylon101/shadows
  102566. */
  102567. get receiveShadows(): boolean;
  102568. set receiveShadows(value: boolean);
  102569. /** Defines color to use when rendering outline */
  102570. outlineColor: Color3;
  102571. /** Define width to use when rendering outline */
  102572. outlineWidth: number;
  102573. /** Defines color to use when rendering overlay */
  102574. overlayColor: Color3;
  102575. /** Defines alpha to use when rendering overlay */
  102576. overlayAlpha: number;
  102577. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  102578. get hasVertexAlpha(): boolean;
  102579. set hasVertexAlpha(value: boolean);
  102580. /** 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) */
  102581. get useVertexColors(): boolean;
  102582. set useVertexColors(value: boolean);
  102583. /**
  102584. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  102585. */
  102586. get computeBonesUsingShaders(): boolean;
  102587. set computeBonesUsingShaders(value: boolean);
  102588. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  102589. get numBoneInfluencers(): number;
  102590. set numBoneInfluencers(value: number);
  102591. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  102592. get applyFog(): boolean;
  102593. set applyFog(value: boolean);
  102594. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  102595. useOctreeForRenderingSelection: boolean;
  102596. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  102597. useOctreeForPicking: boolean;
  102598. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  102599. useOctreeForCollisions: boolean;
  102600. /**
  102601. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  102602. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  102603. */
  102604. get layerMask(): number;
  102605. set layerMask(value: number);
  102606. /**
  102607. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  102608. */
  102609. alwaysSelectAsActiveMesh: boolean;
  102610. /**
  102611. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  102612. */
  102613. doNotSyncBoundingInfo: boolean;
  102614. /**
  102615. * Gets or sets the current action manager
  102616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102617. */
  102618. actionManager: Nullable<AbstractActionManager>;
  102619. private _meshCollisionData;
  102620. /**
  102621. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  102622. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102623. */
  102624. ellipsoid: Vector3;
  102625. /**
  102626. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  102627. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102628. */
  102629. ellipsoidOffset: Vector3;
  102630. /**
  102631. * Gets or sets a collision mask used to mask collisions (default is -1).
  102632. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102633. */
  102634. get collisionMask(): number;
  102635. set collisionMask(mask: number);
  102636. /**
  102637. * Gets or sets the current collision group mask (-1 by default).
  102638. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102639. */
  102640. get collisionGroup(): number;
  102641. set collisionGroup(mask: number);
  102642. /**
  102643. * Gets or sets current surrounding meshes (null by default).
  102644. *
  102645. * By default collision detection is tested against every mesh in the scene.
  102646. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  102647. * meshes will be tested for the collision.
  102648. *
  102649. * Note: if set to an empty array no collision will happen when this mesh is moved.
  102650. */
  102651. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  102652. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  102653. /**
  102654. * Defines edge width used when edgesRenderer is enabled
  102655. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102656. */
  102657. edgesWidth: number;
  102658. /**
  102659. * Defines edge color used when edgesRenderer is enabled
  102660. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102661. */
  102662. edgesColor: Color4;
  102663. /** @hidden */
  102664. _edgesRenderer: Nullable<IEdgesRenderer>;
  102665. /** @hidden */
  102666. _masterMesh: Nullable<AbstractMesh>;
  102667. /** @hidden */
  102668. _boundingInfo: Nullable<BoundingInfo>;
  102669. /** @hidden */
  102670. _renderId: number;
  102671. /**
  102672. * Gets or sets the list of subMeshes
  102673. * @see http://doc.babylonjs.com/how_to/multi_materials
  102674. */
  102675. subMeshes: SubMesh[];
  102676. /** @hidden */
  102677. _intersectionsInProgress: AbstractMesh[];
  102678. /** @hidden */
  102679. _unIndexed: boolean;
  102680. /** @hidden */
  102681. _lightSources: Light[];
  102682. /** Gets the list of lights affecting that mesh */
  102683. get lightSources(): Light[];
  102684. /** @hidden */
  102685. get _positions(): Nullable<Vector3[]>;
  102686. /** @hidden */
  102687. _waitingData: {
  102688. lods: Nullable<any>;
  102689. actions: Nullable<any>;
  102690. freezeWorldMatrix: Nullable<boolean>;
  102691. };
  102692. /** @hidden */
  102693. _bonesTransformMatrices: Nullable<Float32Array>;
  102694. /** @hidden */
  102695. _transformMatrixTexture: Nullable<RawTexture>;
  102696. /**
  102697. * Gets or sets a skeleton to apply skining transformations
  102698. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102699. */
  102700. set skeleton(value: Nullable<Skeleton>);
  102701. get skeleton(): Nullable<Skeleton>;
  102702. /**
  102703. * An event triggered when the mesh is rebuilt.
  102704. */
  102705. onRebuildObservable: Observable<AbstractMesh>;
  102706. /**
  102707. * Creates a new AbstractMesh
  102708. * @param name defines the name of the mesh
  102709. * @param scene defines the hosting scene
  102710. */
  102711. constructor(name: string, scene?: Nullable<Scene>);
  102712. /**
  102713. * Returns the string "AbstractMesh"
  102714. * @returns "AbstractMesh"
  102715. */
  102716. getClassName(): string;
  102717. /**
  102718. * Gets a string representation of the current mesh
  102719. * @param fullDetails defines a boolean indicating if full details must be included
  102720. * @returns a string representation of the current mesh
  102721. */
  102722. toString(fullDetails?: boolean): string;
  102723. /**
  102724. * @hidden
  102725. */
  102726. protected _getEffectiveParent(): Nullable<Node>;
  102727. /** @hidden */
  102728. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102729. /** @hidden */
  102730. _rebuild(): void;
  102731. /** @hidden */
  102732. _resyncLightSources(): void;
  102733. /** @hidden */
  102734. _resyncLightSource(light: Light): void;
  102735. /** @hidden */
  102736. _unBindEffect(): void;
  102737. /** @hidden */
  102738. _removeLightSource(light: Light, dispose: boolean): void;
  102739. private _markSubMeshesAsDirty;
  102740. /** @hidden */
  102741. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  102742. /** @hidden */
  102743. _markSubMeshesAsAttributesDirty(): void;
  102744. /** @hidden */
  102745. _markSubMeshesAsMiscDirty(): void;
  102746. /**
  102747. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  102748. */
  102749. get scaling(): Vector3;
  102750. set scaling(newScaling: Vector3);
  102751. /**
  102752. * Returns true if the mesh is blocked. Implemented by child classes
  102753. */
  102754. get isBlocked(): boolean;
  102755. /**
  102756. * Returns the mesh itself by default. Implemented by child classes
  102757. * @param camera defines the camera to use to pick the right LOD level
  102758. * @returns the currentAbstractMesh
  102759. */
  102760. getLOD(camera: Camera): Nullable<AbstractMesh>;
  102761. /**
  102762. * Returns 0 by default. Implemented by child classes
  102763. * @returns an integer
  102764. */
  102765. getTotalVertices(): number;
  102766. /**
  102767. * Returns a positive integer : the total number of indices in this mesh geometry.
  102768. * @returns the numner of indices or zero if the mesh has no geometry.
  102769. */
  102770. getTotalIndices(): number;
  102771. /**
  102772. * Returns null by default. Implemented by child classes
  102773. * @returns null
  102774. */
  102775. getIndices(): Nullable<IndicesArray>;
  102776. /**
  102777. * Returns the array of the requested vertex data kind. Implemented by child classes
  102778. * @param kind defines the vertex data kind to use
  102779. * @returns null
  102780. */
  102781. getVerticesData(kind: string): Nullable<FloatArray>;
  102782. /**
  102783. * Sets the vertex data of the mesh geometry for the requested `kind`.
  102784. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  102785. * Note that a new underlying VertexBuffer object is created each call.
  102786. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  102787. * @param kind defines vertex data kind:
  102788. * * VertexBuffer.PositionKind
  102789. * * VertexBuffer.UVKind
  102790. * * VertexBuffer.UV2Kind
  102791. * * VertexBuffer.UV3Kind
  102792. * * VertexBuffer.UV4Kind
  102793. * * VertexBuffer.UV5Kind
  102794. * * VertexBuffer.UV6Kind
  102795. * * VertexBuffer.ColorKind
  102796. * * VertexBuffer.MatricesIndicesKind
  102797. * * VertexBuffer.MatricesIndicesExtraKind
  102798. * * VertexBuffer.MatricesWeightsKind
  102799. * * VertexBuffer.MatricesWeightsExtraKind
  102800. * @param data defines the data source
  102801. * @param updatable defines if the data must be flagged as updatable (or static)
  102802. * @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
  102803. * @returns the current mesh
  102804. */
  102805. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  102806. /**
  102807. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  102808. * If the mesh has no geometry, it is simply returned as it is.
  102809. * @param kind defines vertex data kind:
  102810. * * VertexBuffer.PositionKind
  102811. * * VertexBuffer.UVKind
  102812. * * VertexBuffer.UV2Kind
  102813. * * VertexBuffer.UV3Kind
  102814. * * VertexBuffer.UV4Kind
  102815. * * VertexBuffer.UV5Kind
  102816. * * VertexBuffer.UV6Kind
  102817. * * VertexBuffer.ColorKind
  102818. * * VertexBuffer.MatricesIndicesKind
  102819. * * VertexBuffer.MatricesIndicesExtraKind
  102820. * * VertexBuffer.MatricesWeightsKind
  102821. * * VertexBuffer.MatricesWeightsExtraKind
  102822. * @param data defines the data source
  102823. * @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
  102824. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  102825. * @returns the current mesh
  102826. */
  102827. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  102828. /**
  102829. * Sets the mesh indices,
  102830. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  102831. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  102832. * @param totalVertices Defines the total number of vertices
  102833. * @returns the current mesh
  102834. */
  102835. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  102836. /**
  102837. * Gets a boolean indicating if specific vertex data is present
  102838. * @param kind defines the vertex data kind to use
  102839. * @returns true is data kind is present
  102840. */
  102841. isVerticesDataPresent(kind: string): boolean;
  102842. /**
  102843. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  102844. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  102845. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  102846. * @returns a BoundingInfo
  102847. */
  102848. getBoundingInfo(): BoundingInfo;
  102849. /**
  102850. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  102851. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  102852. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  102853. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  102854. * @returns the current mesh
  102855. */
  102856. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  102857. /**
  102858. * Overwrite the current bounding info
  102859. * @param boundingInfo defines the new bounding info
  102860. * @returns the current mesh
  102861. */
  102862. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  102863. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  102864. get useBones(): boolean;
  102865. /** @hidden */
  102866. _preActivate(): void;
  102867. /** @hidden */
  102868. _preActivateForIntermediateRendering(renderId: number): void;
  102869. /** @hidden */
  102870. _activate(renderId: number, intermediateRendering: boolean): boolean;
  102871. /** @hidden */
  102872. _postActivate(): void;
  102873. /** @hidden */
  102874. _freeze(): void;
  102875. /** @hidden */
  102876. _unFreeze(): void;
  102877. /**
  102878. * Gets the current world matrix
  102879. * @returns a Matrix
  102880. */
  102881. getWorldMatrix(): Matrix;
  102882. /** @hidden */
  102883. _getWorldMatrixDeterminant(): number;
  102884. /**
  102885. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  102886. */
  102887. get isAnInstance(): boolean;
  102888. /**
  102889. * Gets a boolean indicating if this mesh has instances
  102890. */
  102891. get hasInstances(): boolean;
  102892. /**
  102893. * Perform relative position change from the point of view of behind the front of the mesh.
  102894. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102895. * Supports definition of mesh facing forward or backward
  102896. * @param amountRight defines the distance on the right axis
  102897. * @param amountUp defines the distance on the up axis
  102898. * @param amountForward defines the distance on the forward axis
  102899. * @returns the current mesh
  102900. */
  102901. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102902. /**
  102903. * Calculate relative position change from the point of view of behind the front of the mesh.
  102904. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102905. * Supports definition of mesh facing forward or backward
  102906. * @param amountRight defines the distance on the right axis
  102907. * @param amountUp defines the distance on the up axis
  102908. * @param amountForward defines the distance on the forward axis
  102909. * @returns the new displacement vector
  102910. */
  102911. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102912. /**
  102913. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102914. * Supports definition of mesh facing forward or backward
  102915. * @param flipBack defines the flip
  102916. * @param twirlClockwise defines the twirl
  102917. * @param tiltRight defines the tilt
  102918. * @returns the current mesh
  102919. */
  102920. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102921. /**
  102922. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102923. * Supports definition of mesh facing forward or backward.
  102924. * @param flipBack defines the flip
  102925. * @param twirlClockwise defines the twirl
  102926. * @param tiltRight defines the tilt
  102927. * @returns the new rotation vector
  102928. */
  102929. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102930. /**
  102931. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102932. * This means the mesh underlying bounding box and sphere are recomputed.
  102933. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102934. * @returns the current mesh
  102935. */
  102936. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102937. /** @hidden */
  102938. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102939. /** @hidden */
  102940. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102941. /** @hidden */
  102942. _updateBoundingInfo(): AbstractMesh;
  102943. /** @hidden */
  102944. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102945. /** @hidden */
  102946. protected _afterComputeWorldMatrix(): void;
  102947. /** @hidden */
  102948. get _effectiveMesh(): AbstractMesh;
  102949. /**
  102950. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102951. * A mesh is in the frustum if its bounding box intersects the frustum
  102952. * @param frustumPlanes defines the frustum to test
  102953. * @returns true if the mesh is in the frustum planes
  102954. */
  102955. isInFrustum(frustumPlanes: Plane[]): boolean;
  102956. /**
  102957. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102958. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102959. * @param frustumPlanes defines the frustum to test
  102960. * @returns true if the mesh is completely in the frustum planes
  102961. */
  102962. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102963. /**
  102964. * True if the mesh intersects another mesh or a SolidParticle object
  102965. * @param mesh defines a target mesh or SolidParticle to test
  102966. * @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)
  102967. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102968. * @returns true if there is an intersection
  102969. */
  102970. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102971. /**
  102972. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102973. * @param point defines the point to test
  102974. * @returns true if there is an intersection
  102975. */
  102976. intersectsPoint(point: Vector3): boolean;
  102977. /**
  102978. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102979. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102980. */
  102981. get checkCollisions(): boolean;
  102982. set checkCollisions(collisionEnabled: boolean);
  102983. /**
  102984. * Gets Collider object used to compute collisions (not physics)
  102985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102986. */
  102987. get collider(): Nullable<Collider>;
  102988. /**
  102989. * Move the mesh using collision engine
  102990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102991. * @param displacement defines the requested displacement vector
  102992. * @returns the current mesh
  102993. */
  102994. moveWithCollisions(displacement: Vector3): AbstractMesh;
  102995. private _onCollisionPositionChange;
  102996. /** @hidden */
  102997. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  102998. /** @hidden */
  102999. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  103000. /** @hidden */
  103001. _checkCollision(collider: Collider): AbstractMesh;
  103002. /** @hidden */
  103003. _generatePointsArray(): boolean;
  103004. /**
  103005. * Checks if the passed Ray intersects with the mesh
  103006. * @param ray defines the ray to use
  103007. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  103008. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103009. * @returns the picking info
  103010. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  103011. */
  103012. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  103013. /**
  103014. * Clones the current mesh
  103015. * @param name defines the mesh name
  103016. * @param newParent defines the new mesh parent
  103017. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  103018. * @returns the new mesh
  103019. */
  103020. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  103021. /**
  103022. * Disposes all the submeshes of the current meshnp
  103023. * @returns the current mesh
  103024. */
  103025. releaseSubMeshes(): AbstractMesh;
  103026. /**
  103027. * Releases resources associated with this abstract mesh.
  103028. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103029. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103030. */
  103031. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103032. /**
  103033. * Adds the passed mesh as a child to the current mesh
  103034. * @param mesh defines the child mesh
  103035. * @returns the current mesh
  103036. */
  103037. addChild(mesh: AbstractMesh): AbstractMesh;
  103038. /**
  103039. * Removes the passed mesh from the current mesh children list
  103040. * @param mesh defines the child mesh
  103041. * @returns the current mesh
  103042. */
  103043. removeChild(mesh: AbstractMesh): AbstractMesh;
  103044. /** @hidden */
  103045. private _initFacetData;
  103046. /**
  103047. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  103048. * This method can be called within the render loop.
  103049. * 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
  103050. * @returns the current mesh
  103051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103052. */
  103053. updateFacetData(): AbstractMesh;
  103054. /**
  103055. * Returns the facetLocalNormals array.
  103056. * The normals are expressed in the mesh local spac
  103057. * @returns an array of Vector3
  103058. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103059. */
  103060. getFacetLocalNormals(): Vector3[];
  103061. /**
  103062. * Returns the facetLocalPositions array.
  103063. * The facet positions are expressed in the mesh local space
  103064. * @returns an array of Vector3
  103065. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103066. */
  103067. getFacetLocalPositions(): Vector3[];
  103068. /**
  103069. * Returns the facetLocalPartioning array
  103070. * @returns an array of array of numbers
  103071. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103072. */
  103073. getFacetLocalPartitioning(): number[][];
  103074. /**
  103075. * Returns the i-th facet position in the world system.
  103076. * This method allocates a new Vector3 per call
  103077. * @param i defines the facet index
  103078. * @returns a new Vector3
  103079. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103080. */
  103081. getFacetPosition(i: number): Vector3;
  103082. /**
  103083. * Sets the reference Vector3 with the i-th facet position in the world system
  103084. * @param i defines the facet index
  103085. * @param ref defines the target vector
  103086. * @returns the current mesh
  103087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103088. */
  103089. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  103090. /**
  103091. * Returns the i-th facet normal in the world system.
  103092. * This method allocates a new Vector3 per call
  103093. * @param i defines the facet index
  103094. * @returns a new Vector3
  103095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103096. */
  103097. getFacetNormal(i: number): Vector3;
  103098. /**
  103099. * Sets the reference Vector3 with the i-th facet normal in the world system
  103100. * @param i defines the facet index
  103101. * @param ref defines the target vector
  103102. * @returns the current mesh
  103103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103104. */
  103105. getFacetNormalToRef(i: number, ref: Vector3): this;
  103106. /**
  103107. * 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)
  103108. * @param x defines x coordinate
  103109. * @param y defines y coordinate
  103110. * @param z defines z coordinate
  103111. * @returns the array of facet indexes
  103112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103113. */
  103114. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  103115. /**
  103116. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  103117. * @param projected sets as the (x,y,z) world projection on the facet
  103118. * @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
  103119. * @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
  103120. * @param x defines x coordinate
  103121. * @param y defines y coordinate
  103122. * @param z defines z coordinate
  103123. * @returns the face index if found (or null instead)
  103124. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103125. */
  103126. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103127. /**
  103128. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  103129. * @param projected sets as the (x,y,z) local projection on the facet
  103130. * @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
  103131. * @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
  103132. * @param x defines x coordinate
  103133. * @param y defines y coordinate
  103134. * @param z defines z coordinate
  103135. * @returns the face index if found (or null instead)
  103136. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103137. */
  103138. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103139. /**
  103140. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  103141. * @returns the parameters
  103142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103143. */
  103144. getFacetDataParameters(): any;
  103145. /**
  103146. * Disables the feature FacetData and frees the related memory
  103147. * @returns the current mesh
  103148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103149. */
  103150. disableFacetData(): AbstractMesh;
  103151. /**
  103152. * Updates the AbstractMesh indices array
  103153. * @param indices defines the data source
  103154. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  103155. * @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)
  103156. * @returns the current mesh
  103157. */
  103158. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  103159. /**
  103160. * Creates new normals data for the mesh
  103161. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  103162. * @returns the current mesh
  103163. */
  103164. createNormals(updatable: boolean): AbstractMesh;
  103165. /**
  103166. * Align the mesh with a normal
  103167. * @param normal defines the normal to use
  103168. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  103169. * @returns the current mesh
  103170. */
  103171. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  103172. /** @hidden */
  103173. _checkOcclusionQuery(): boolean;
  103174. /**
  103175. * Disables the mesh edge rendering mode
  103176. * @returns the currentAbstractMesh
  103177. */
  103178. disableEdgesRendering(): AbstractMesh;
  103179. /**
  103180. * Enables the edge rendering mode on the mesh.
  103181. * This mode makes the mesh edges visible
  103182. * @param epsilon defines the maximal distance between two angles to detect a face
  103183. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  103184. * @returns the currentAbstractMesh
  103185. * @see https://www.babylonjs-playground.com/#19O9TU#0
  103186. */
  103187. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  103188. }
  103189. }
  103190. declare module BABYLON {
  103191. /**
  103192. * Interface used to define ActionEvent
  103193. */
  103194. export interface IActionEvent {
  103195. /** The mesh or sprite that triggered the action */
  103196. source: any;
  103197. /** The X mouse cursor position at the time of the event */
  103198. pointerX: number;
  103199. /** The Y mouse cursor position at the time of the event */
  103200. pointerY: number;
  103201. /** The mesh that is currently pointed at (can be null) */
  103202. meshUnderPointer: Nullable<AbstractMesh>;
  103203. /** the original (browser) event that triggered the ActionEvent */
  103204. sourceEvent?: any;
  103205. /** additional data for the event */
  103206. additionalData?: any;
  103207. }
  103208. /**
  103209. * ActionEvent is the event being sent when an action is triggered.
  103210. */
  103211. export class ActionEvent implements IActionEvent {
  103212. /** The mesh or sprite that triggered the action */
  103213. source: any;
  103214. /** The X mouse cursor position at the time of the event */
  103215. pointerX: number;
  103216. /** The Y mouse cursor position at the time of the event */
  103217. pointerY: number;
  103218. /** The mesh that is currently pointed at (can be null) */
  103219. meshUnderPointer: Nullable<AbstractMesh>;
  103220. /** the original (browser) event that triggered the ActionEvent */
  103221. sourceEvent?: any;
  103222. /** additional data for the event */
  103223. additionalData?: any;
  103224. /**
  103225. * Creates a new ActionEvent
  103226. * @param source The mesh or sprite that triggered the action
  103227. * @param pointerX The X mouse cursor position at the time of the event
  103228. * @param pointerY The Y mouse cursor position at the time of the event
  103229. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  103230. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  103231. * @param additionalData additional data for the event
  103232. */
  103233. constructor(
  103234. /** The mesh or sprite that triggered the action */
  103235. source: any,
  103236. /** The X mouse cursor position at the time of the event */
  103237. pointerX: number,
  103238. /** The Y mouse cursor position at the time of the event */
  103239. pointerY: number,
  103240. /** The mesh that is currently pointed at (can be null) */
  103241. meshUnderPointer: Nullable<AbstractMesh>,
  103242. /** the original (browser) event that triggered the ActionEvent */
  103243. sourceEvent?: any,
  103244. /** additional data for the event */
  103245. additionalData?: any);
  103246. /**
  103247. * Helper function to auto-create an ActionEvent from a source mesh.
  103248. * @param source The source mesh that triggered the event
  103249. * @param evt The original (browser) event
  103250. * @param additionalData additional data for the event
  103251. * @returns the new ActionEvent
  103252. */
  103253. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  103254. /**
  103255. * Helper function to auto-create an ActionEvent from a source sprite
  103256. * @param source The source sprite that triggered the event
  103257. * @param scene Scene associated with the sprite
  103258. * @param evt The original (browser) event
  103259. * @param additionalData additional data for the event
  103260. * @returns the new ActionEvent
  103261. */
  103262. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  103263. /**
  103264. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  103265. * @param scene the scene where the event occurred
  103266. * @param evt The original (browser) event
  103267. * @returns the new ActionEvent
  103268. */
  103269. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  103270. /**
  103271. * Helper function to auto-create an ActionEvent from a primitive
  103272. * @param prim defines the target primitive
  103273. * @param pointerPos defines the pointer position
  103274. * @param evt The original (browser) event
  103275. * @param additionalData additional data for the event
  103276. * @returns the new ActionEvent
  103277. */
  103278. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  103279. }
  103280. }
  103281. declare module BABYLON {
  103282. /**
  103283. * Abstract class used to decouple action Manager from scene and meshes.
  103284. * Do not instantiate.
  103285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103286. */
  103287. export abstract class AbstractActionManager implements IDisposable {
  103288. /** Gets the list of active triggers */
  103289. static Triggers: {
  103290. [key: string]: number;
  103291. };
  103292. /** Gets the cursor to use when hovering items */
  103293. hoverCursor: string;
  103294. /** Gets the list of actions */
  103295. actions: IAction[];
  103296. /**
  103297. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  103298. */
  103299. isRecursive: boolean;
  103300. /**
  103301. * Releases all associated resources
  103302. */
  103303. abstract dispose(): void;
  103304. /**
  103305. * Does this action manager has pointer triggers
  103306. */
  103307. abstract get hasPointerTriggers(): boolean;
  103308. /**
  103309. * Does this action manager has pick triggers
  103310. */
  103311. abstract get hasPickTriggers(): boolean;
  103312. /**
  103313. * Process a specific trigger
  103314. * @param trigger defines the trigger to process
  103315. * @param evt defines the event details to be processed
  103316. */
  103317. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  103318. /**
  103319. * Does this action manager handles actions of any of the given triggers
  103320. * @param triggers defines the triggers to be tested
  103321. * @return a boolean indicating whether one (or more) of the triggers is handled
  103322. */
  103323. abstract hasSpecificTriggers(triggers: number[]): boolean;
  103324. /**
  103325. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  103326. * speed.
  103327. * @param triggerA defines the trigger to be tested
  103328. * @param triggerB defines the trigger to be tested
  103329. * @return a boolean indicating whether one (or more) of the triggers is handled
  103330. */
  103331. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  103332. /**
  103333. * Does this action manager handles actions of a given trigger
  103334. * @param trigger defines the trigger to be tested
  103335. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  103336. * @return whether the trigger is handled
  103337. */
  103338. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  103339. /**
  103340. * Serialize this manager to a JSON object
  103341. * @param name defines the property name to store this manager
  103342. * @returns a JSON representation of this manager
  103343. */
  103344. abstract serialize(name: string): any;
  103345. /**
  103346. * Registers an action to this action manager
  103347. * @param action defines the action to be registered
  103348. * @return the action amended (prepared) after registration
  103349. */
  103350. abstract registerAction(action: IAction): Nullable<IAction>;
  103351. /**
  103352. * Unregisters an action to this action manager
  103353. * @param action defines the action to be unregistered
  103354. * @return a boolean indicating whether the action has been unregistered
  103355. */
  103356. abstract unregisterAction(action: IAction): Boolean;
  103357. /**
  103358. * Does exist one action manager with at least one trigger
  103359. **/
  103360. static get HasTriggers(): boolean;
  103361. /**
  103362. * Does exist one action manager with at least one pick trigger
  103363. **/
  103364. static get HasPickTriggers(): boolean;
  103365. /**
  103366. * Does exist one action manager that handles actions of a given trigger
  103367. * @param trigger defines the trigger to be tested
  103368. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  103369. **/
  103370. static HasSpecificTrigger(trigger: number): boolean;
  103371. }
  103372. }
  103373. declare module BABYLON {
  103374. /**
  103375. * Defines how a node can be built from a string name.
  103376. */
  103377. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  103378. /**
  103379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  103380. */
  103381. export class Node implements IBehaviorAware<Node> {
  103382. /** @hidden */
  103383. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  103384. private static _NodeConstructors;
  103385. /**
  103386. * Add a new node constructor
  103387. * @param type defines the type name of the node to construct
  103388. * @param constructorFunc defines the constructor function
  103389. */
  103390. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  103391. /**
  103392. * Returns a node constructor based on type name
  103393. * @param type defines the type name
  103394. * @param name defines the new node name
  103395. * @param scene defines the hosting scene
  103396. * @param options defines optional options to transmit to constructors
  103397. * @returns the new constructor or null
  103398. */
  103399. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  103400. /**
  103401. * Gets or sets the name of the node
  103402. */
  103403. name: string;
  103404. /**
  103405. * Gets or sets the id of the node
  103406. */
  103407. id: string;
  103408. /**
  103409. * Gets or sets the unique id of the node
  103410. */
  103411. uniqueId: number;
  103412. /**
  103413. * Gets or sets a string used to store user defined state for the node
  103414. */
  103415. state: string;
  103416. /**
  103417. * Gets or sets an object used to store user defined information for the node
  103418. */
  103419. metadata: any;
  103420. /**
  103421. * For internal use only. Please do not use.
  103422. */
  103423. reservedDataStore: any;
  103424. /**
  103425. * List of inspectable custom properties (used by the Inspector)
  103426. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103427. */
  103428. inspectableCustomProperties: IInspectable[];
  103429. private _doNotSerialize;
  103430. /**
  103431. * Gets or sets a boolean used to define if the node must be serialized
  103432. */
  103433. get doNotSerialize(): boolean;
  103434. set doNotSerialize(value: boolean);
  103435. /** @hidden */
  103436. _isDisposed: boolean;
  103437. /**
  103438. * Gets a list of Animations associated with the node
  103439. */
  103440. animations: Animation[];
  103441. protected _ranges: {
  103442. [name: string]: Nullable<AnimationRange>;
  103443. };
  103444. /**
  103445. * Callback raised when the node is ready to be used
  103446. */
  103447. onReady: Nullable<(node: Node) => void>;
  103448. private _isEnabled;
  103449. private _isParentEnabled;
  103450. private _isReady;
  103451. /** @hidden */
  103452. _currentRenderId: number;
  103453. private _parentUpdateId;
  103454. /** @hidden */
  103455. _childUpdateId: number;
  103456. /** @hidden */
  103457. _waitingParentId: Nullable<string>;
  103458. /** @hidden */
  103459. _scene: Scene;
  103460. /** @hidden */
  103461. _cache: any;
  103462. private _parentNode;
  103463. private _children;
  103464. /** @hidden */
  103465. _worldMatrix: Matrix;
  103466. /** @hidden */
  103467. _worldMatrixDeterminant: number;
  103468. /** @hidden */
  103469. _worldMatrixDeterminantIsDirty: boolean;
  103470. /** @hidden */
  103471. private _sceneRootNodesIndex;
  103472. /**
  103473. * Gets a boolean indicating if the node has been disposed
  103474. * @returns true if the node was disposed
  103475. */
  103476. isDisposed(): boolean;
  103477. /**
  103478. * Gets or sets the parent of the node (without keeping the current position in the scene)
  103479. * @see https://doc.babylonjs.com/how_to/parenting
  103480. */
  103481. set parent(parent: Nullable<Node>);
  103482. get parent(): Nullable<Node>;
  103483. /** @hidden */
  103484. _addToSceneRootNodes(): void;
  103485. /** @hidden */
  103486. _removeFromSceneRootNodes(): void;
  103487. private _animationPropertiesOverride;
  103488. /**
  103489. * Gets or sets the animation properties override
  103490. */
  103491. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103492. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103493. /**
  103494. * Gets a string idenfifying the name of the class
  103495. * @returns "Node" string
  103496. */
  103497. getClassName(): string;
  103498. /** @hidden */
  103499. readonly _isNode: boolean;
  103500. /**
  103501. * An event triggered when the mesh is disposed
  103502. */
  103503. onDisposeObservable: Observable<Node>;
  103504. private _onDisposeObserver;
  103505. /**
  103506. * Sets a callback that will be raised when the node will be disposed
  103507. */
  103508. set onDispose(callback: () => void);
  103509. /**
  103510. * Creates a new Node
  103511. * @param name the name and id to be given to this node
  103512. * @param scene the scene this node will be added to
  103513. */
  103514. constructor(name: string, scene?: Nullable<Scene>);
  103515. /**
  103516. * Gets the scene of the node
  103517. * @returns a scene
  103518. */
  103519. getScene(): Scene;
  103520. /**
  103521. * Gets the engine of the node
  103522. * @returns a Engine
  103523. */
  103524. getEngine(): Engine;
  103525. private _behaviors;
  103526. /**
  103527. * Attach a behavior to the node
  103528. * @see http://doc.babylonjs.com/features/behaviour
  103529. * @param behavior defines the behavior to attach
  103530. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  103531. * @returns the current Node
  103532. */
  103533. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  103534. /**
  103535. * Remove an attached behavior
  103536. * @see http://doc.babylonjs.com/features/behaviour
  103537. * @param behavior defines the behavior to attach
  103538. * @returns the current Node
  103539. */
  103540. removeBehavior(behavior: Behavior<Node>): Node;
  103541. /**
  103542. * Gets the list of attached behaviors
  103543. * @see http://doc.babylonjs.com/features/behaviour
  103544. */
  103545. get behaviors(): Behavior<Node>[];
  103546. /**
  103547. * Gets an attached behavior by name
  103548. * @param name defines the name of the behavior to look for
  103549. * @see http://doc.babylonjs.com/features/behaviour
  103550. * @returns null if behavior was not found else the requested behavior
  103551. */
  103552. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  103553. /**
  103554. * Returns the latest update of the World matrix
  103555. * @returns a Matrix
  103556. */
  103557. getWorldMatrix(): Matrix;
  103558. /** @hidden */
  103559. _getWorldMatrixDeterminant(): number;
  103560. /**
  103561. * Returns directly the latest state of the mesh World matrix.
  103562. * A Matrix is returned.
  103563. */
  103564. get worldMatrixFromCache(): Matrix;
  103565. /** @hidden */
  103566. _initCache(): void;
  103567. /** @hidden */
  103568. updateCache(force?: boolean): void;
  103569. /** @hidden */
  103570. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103571. /** @hidden */
  103572. _updateCache(ignoreParentClass?: boolean): void;
  103573. /** @hidden */
  103574. _isSynchronized(): boolean;
  103575. /** @hidden */
  103576. _markSyncedWithParent(): void;
  103577. /** @hidden */
  103578. isSynchronizedWithParent(): boolean;
  103579. /** @hidden */
  103580. isSynchronized(): boolean;
  103581. /**
  103582. * Is this node ready to be used/rendered
  103583. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  103584. * @return true if the node is ready
  103585. */
  103586. isReady(completeCheck?: boolean): boolean;
  103587. /**
  103588. * Is this node enabled?
  103589. * 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
  103590. * @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
  103591. * @return whether this node (and its parent) is enabled
  103592. */
  103593. isEnabled(checkAncestors?: boolean): boolean;
  103594. /** @hidden */
  103595. protected _syncParentEnabledState(): void;
  103596. /**
  103597. * Set the enabled state of this node
  103598. * @param value defines the new enabled state
  103599. */
  103600. setEnabled(value: boolean): void;
  103601. /**
  103602. * Is this node a descendant of the given node?
  103603. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  103604. * @param ancestor defines the parent node to inspect
  103605. * @returns a boolean indicating if this node is a descendant of the given node
  103606. */
  103607. isDescendantOf(ancestor: Node): boolean;
  103608. /** @hidden */
  103609. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  103610. /**
  103611. * Will return all nodes that have this node as ascendant
  103612. * @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
  103613. * @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
  103614. * @return all children nodes of all types
  103615. */
  103616. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  103617. /**
  103618. * Get all child-meshes of this node
  103619. * @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)
  103620. * @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
  103621. * @returns an array of AbstractMesh
  103622. */
  103623. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  103624. /**
  103625. * Get all direct children of this node
  103626. * @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
  103627. * @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)
  103628. * @returns an array of Node
  103629. */
  103630. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  103631. /** @hidden */
  103632. _setReady(state: boolean): void;
  103633. /**
  103634. * Get an animation by name
  103635. * @param name defines the name of the animation to look for
  103636. * @returns null if not found else the requested animation
  103637. */
  103638. getAnimationByName(name: string): Nullable<Animation>;
  103639. /**
  103640. * Creates an animation range for this node
  103641. * @param name defines the name of the range
  103642. * @param from defines the starting key
  103643. * @param to defines the end key
  103644. */
  103645. createAnimationRange(name: string, from: number, to: number): void;
  103646. /**
  103647. * Delete a specific animation range
  103648. * @param name defines the name of the range to delete
  103649. * @param deleteFrames defines if animation frames from the range must be deleted as well
  103650. */
  103651. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  103652. /**
  103653. * Get an animation range by name
  103654. * @param name defines the name of the animation range to look for
  103655. * @returns null if not found else the requested animation range
  103656. */
  103657. getAnimationRange(name: string): Nullable<AnimationRange>;
  103658. /**
  103659. * Gets the list of all animation ranges defined on this node
  103660. * @returns an array
  103661. */
  103662. getAnimationRanges(): Nullable<AnimationRange>[];
  103663. /**
  103664. * Will start the animation sequence
  103665. * @param name defines the range frames for animation sequence
  103666. * @param loop defines if the animation should loop (false by default)
  103667. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  103668. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  103669. * @returns the object created for this animation. If range does not exist, it will return null
  103670. */
  103671. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  103672. /**
  103673. * Serialize animation ranges into a JSON compatible object
  103674. * @returns serialization object
  103675. */
  103676. serializeAnimationRanges(): any;
  103677. /**
  103678. * Computes the world matrix of the node
  103679. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  103680. * @returns the world matrix
  103681. */
  103682. computeWorldMatrix(force?: boolean): Matrix;
  103683. /**
  103684. * Releases resources associated with this node.
  103685. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103686. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103687. */
  103688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103689. /**
  103690. * Parse animation range data from a serialization object and store them into a given node
  103691. * @param node defines where to store the animation ranges
  103692. * @param parsedNode defines the serialization object to read data from
  103693. * @param scene defines the hosting scene
  103694. */
  103695. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  103696. /**
  103697. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  103698. * @param includeDescendants Include bounding info from descendants as well (true by default)
  103699. * @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
  103700. * @returns the new bounding vectors
  103701. */
  103702. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  103703. min: Vector3;
  103704. max: Vector3;
  103705. };
  103706. }
  103707. }
  103708. declare module BABYLON {
  103709. /**
  103710. * @hidden
  103711. */
  103712. export class _IAnimationState {
  103713. key: number;
  103714. repeatCount: number;
  103715. workValue?: any;
  103716. loopMode?: number;
  103717. offsetValue?: any;
  103718. highLimitValue?: any;
  103719. }
  103720. /**
  103721. * Class used to store any kind of animation
  103722. */
  103723. export class Animation {
  103724. /**Name of the animation */
  103725. name: string;
  103726. /**Property to animate */
  103727. targetProperty: string;
  103728. /**The frames per second of the animation */
  103729. framePerSecond: number;
  103730. /**The data type of the animation */
  103731. dataType: number;
  103732. /**The loop mode of the animation */
  103733. loopMode?: number | undefined;
  103734. /**Specifies if blending should be enabled */
  103735. enableBlending?: boolean | undefined;
  103736. /**
  103737. * Use matrix interpolation instead of using direct key value when animating matrices
  103738. */
  103739. static AllowMatricesInterpolation: boolean;
  103740. /**
  103741. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  103742. */
  103743. static AllowMatrixDecomposeForInterpolation: boolean;
  103744. /**
  103745. * Stores the key frames of the animation
  103746. */
  103747. private _keys;
  103748. /**
  103749. * Stores the easing function of the animation
  103750. */
  103751. private _easingFunction;
  103752. /**
  103753. * @hidden Internal use only
  103754. */
  103755. _runtimeAnimations: RuntimeAnimation[];
  103756. /**
  103757. * The set of event that will be linked to this animation
  103758. */
  103759. private _events;
  103760. /**
  103761. * Stores an array of target property paths
  103762. */
  103763. targetPropertyPath: string[];
  103764. /**
  103765. * Stores the blending speed of the animation
  103766. */
  103767. blendingSpeed: number;
  103768. /**
  103769. * Stores the animation ranges for the animation
  103770. */
  103771. private _ranges;
  103772. /**
  103773. * @hidden Internal use
  103774. */
  103775. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  103776. /**
  103777. * Sets up an animation
  103778. * @param property The property to animate
  103779. * @param animationType The animation type to apply
  103780. * @param framePerSecond The frames per second of the animation
  103781. * @param easingFunction The easing function used in the animation
  103782. * @returns The created animation
  103783. */
  103784. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  103785. /**
  103786. * Create and start an animation on a node
  103787. * @param name defines the name of the global animation that will be run on all nodes
  103788. * @param node defines the root node where the animation will take place
  103789. * @param targetProperty defines property to animate
  103790. * @param framePerSecond defines the number of frame per second yo use
  103791. * @param totalFrame defines the number of frames in total
  103792. * @param from defines the initial value
  103793. * @param to defines the final value
  103794. * @param loopMode defines which loop mode you want to use (off by default)
  103795. * @param easingFunction defines the easing function to use (linear by default)
  103796. * @param onAnimationEnd defines the callback to call when animation end
  103797. * @returns the animatable created for this animation
  103798. */
  103799. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103800. /**
  103801. * Create and start an animation on a node and its descendants
  103802. * @param name defines the name of the global animation that will be run on all nodes
  103803. * @param node defines the root node where the animation will take place
  103804. * @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
  103805. * @param targetProperty defines property to animate
  103806. * @param framePerSecond defines the number of frame per second to use
  103807. * @param totalFrame defines the number of frames in total
  103808. * @param from defines the initial value
  103809. * @param to defines the final value
  103810. * @param loopMode defines which loop mode you want to use (off by default)
  103811. * @param easingFunction defines the easing function to use (linear by default)
  103812. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  103813. * @returns the list of animatables created for all nodes
  103814. * @example https://www.babylonjs-playground.com/#MH0VLI
  103815. */
  103816. 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[]>;
  103817. /**
  103818. * Creates a new animation, merges it with the existing animations and starts it
  103819. * @param name Name of the animation
  103820. * @param node Node which contains the scene that begins the animations
  103821. * @param targetProperty Specifies which property to animate
  103822. * @param framePerSecond The frames per second of the animation
  103823. * @param totalFrame The total number of frames
  103824. * @param from The frame at the beginning of the animation
  103825. * @param to The frame at the end of the animation
  103826. * @param loopMode Specifies the loop mode of the animation
  103827. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  103828. * @param onAnimationEnd Callback to run once the animation is complete
  103829. * @returns Nullable animation
  103830. */
  103831. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103832. /**
  103833. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  103834. * @param sourceAnimation defines the Animation containing keyframes to convert
  103835. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  103836. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  103837. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  103838. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  103839. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  103840. */
  103841. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  103842. /**
  103843. * Transition property of an host to the target Value
  103844. * @param property The property to transition
  103845. * @param targetValue The target Value of the property
  103846. * @param host The object where the property to animate belongs
  103847. * @param scene Scene used to run the animation
  103848. * @param frameRate Framerate (in frame/s) to use
  103849. * @param transition The transition type we want to use
  103850. * @param duration The duration of the animation, in milliseconds
  103851. * @param onAnimationEnd Callback trigger at the end of the animation
  103852. * @returns Nullable animation
  103853. */
  103854. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  103855. /**
  103856. * Return the array of runtime animations currently using this animation
  103857. */
  103858. get runtimeAnimations(): RuntimeAnimation[];
  103859. /**
  103860. * Specifies if any of the runtime animations are currently running
  103861. */
  103862. get hasRunningRuntimeAnimations(): boolean;
  103863. /**
  103864. * Initializes the animation
  103865. * @param name Name of the animation
  103866. * @param targetProperty Property to animate
  103867. * @param framePerSecond The frames per second of the animation
  103868. * @param dataType The data type of the animation
  103869. * @param loopMode The loop mode of the animation
  103870. * @param enableBlending Specifies if blending should be enabled
  103871. */
  103872. constructor(
  103873. /**Name of the animation */
  103874. name: string,
  103875. /**Property to animate */
  103876. targetProperty: string,
  103877. /**The frames per second of the animation */
  103878. framePerSecond: number,
  103879. /**The data type of the animation */
  103880. dataType: number,
  103881. /**The loop mode of the animation */
  103882. loopMode?: number | undefined,
  103883. /**Specifies if blending should be enabled */
  103884. enableBlending?: boolean | undefined);
  103885. /**
  103886. * Converts the animation to a string
  103887. * @param fullDetails support for multiple levels of logging within scene loading
  103888. * @returns String form of the animation
  103889. */
  103890. toString(fullDetails?: boolean): string;
  103891. /**
  103892. * Add an event to this animation
  103893. * @param event Event to add
  103894. */
  103895. addEvent(event: AnimationEvent): void;
  103896. /**
  103897. * Remove all events found at the given frame
  103898. * @param frame The frame to remove events from
  103899. */
  103900. removeEvents(frame: number): void;
  103901. /**
  103902. * Retrieves all the events from the animation
  103903. * @returns Events from the animation
  103904. */
  103905. getEvents(): AnimationEvent[];
  103906. /**
  103907. * Creates an animation range
  103908. * @param name Name of the animation range
  103909. * @param from Starting frame of the animation range
  103910. * @param to Ending frame of the animation
  103911. */
  103912. createRange(name: string, from: number, to: number): void;
  103913. /**
  103914. * Deletes an animation range by name
  103915. * @param name Name of the animation range to delete
  103916. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103917. */
  103918. deleteRange(name: string, deleteFrames?: boolean): void;
  103919. /**
  103920. * Gets the animation range by name, or null if not defined
  103921. * @param name Name of the animation range
  103922. * @returns Nullable animation range
  103923. */
  103924. getRange(name: string): Nullable<AnimationRange>;
  103925. /**
  103926. * Gets the key frames from the animation
  103927. * @returns The key frames of the animation
  103928. */
  103929. getKeys(): Array<IAnimationKey>;
  103930. /**
  103931. * Gets the highest frame rate of the animation
  103932. * @returns Highest frame rate of the animation
  103933. */
  103934. getHighestFrame(): number;
  103935. /**
  103936. * Gets the easing function of the animation
  103937. * @returns Easing function of the animation
  103938. */
  103939. getEasingFunction(): IEasingFunction;
  103940. /**
  103941. * Sets the easing function of the animation
  103942. * @param easingFunction A custom mathematical formula for animation
  103943. */
  103944. setEasingFunction(easingFunction: EasingFunction): void;
  103945. /**
  103946. * Interpolates a scalar linearly
  103947. * @param startValue Start value of the animation curve
  103948. * @param endValue End value of the animation curve
  103949. * @param gradient Scalar amount to interpolate
  103950. * @returns Interpolated scalar value
  103951. */
  103952. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103953. /**
  103954. * Interpolates a scalar cubically
  103955. * @param startValue Start value of the animation curve
  103956. * @param outTangent End tangent of the animation
  103957. * @param endValue End value of the animation curve
  103958. * @param inTangent Start tangent of the animation curve
  103959. * @param gradient Scalar amount to interpolate
  103960. * @returns Interpolated scalar value
  103961. */
  103962. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103963. /**
  103964. * Interpolates a quaternion using a spherical linear interpolation
  103965. * @param startValue Start value of the animation curve
  103966. * @param endValue End value of the animation curve
  103967. * @param gradient Scalar amount to interpolate
  103968. * @returns Interpolated quaternion value
  103969. */
  103970. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103971. /**
  103972. * Interpolates a quaternion cubically
  103973. * @param startValue Start value of the animation curve
  103974. * @param outTangent End tangent of the animation curve
  103975. * @param endValue End value of the animation curve
  103976. * @param inTangent Start tangent of the animation curve
  103977. * @param gradient Scalar amount to interpolate
  103978. * @returns Interpolated quaternion value
  103979. */
  103980. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103981. /**
  103982. * Interpolates a Vector3 linearl
  103983. * @param startValue Start value of the animation curve
  103984. * @param endValue End value of the animation curve
  103985. * @param gradient Scalar amount to interpolate
  103986. * @returns Interpolated scalar value
  103987. */
  103988. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  103989. /**
  103990. * Interpolates a Vector3 cubically
  103991. * @param startValue Start value of the animation curve
  103992. * @param outTangent End tangent of the animation
  103993. * @param endValue End value of the animation curve
  103994. * @param inTangent Start tangent of the animation curve
  103995. * @param gradient Scalar amount to interpolate
  103996. * @returns InterpolatedVector3 value
  103997. */
  103998. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  103999. /**
  104000. * Interpolates a Vector2 linearly
  104001. * @param startValue Start value of the animation curve
  104002. * @param endValue End value of the animation curve
  104003. * @param gradient Scalar amount to interpolate
  104004. * @returns Interpolated Vector2 value
  104005. */
  104006. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  104007. /**
  104008. * Interpolates a Vector2 cubically
  104009. * @param startValue Start value of the animation curve
  104010. * @param outTangent End tangent of the animation
  104011. * @param endValue End value of the animation curve
  104012. * @param inTangent Start tangent of the animation curve
  104013. * @param gradient Scalar amount to interpolate
  104014. * @returns Interpolated Vector2 value
  104015. */
  104016. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  104017. /**
  104018. * Interpolates a size linearly
  104019. * @param startValue Start value of the animation curve
  104020. * @param endValue End value of the animation curve
  104021. * @param gradient Scalar amount to interpolate
  104022. * @returns Interpolated Size value
  104023. */
  104024. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  104025. /**
  104026. * Interpolates a Color3 linearly
  104027. * @param startValue Start value of the animation curve
  104028. * @param endValue End value of the animation curve
  104029. * @param gradient Scalar amount to interpolate
  104030. * @returns Interpolated Color3 value
  104031. */
  104032. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  104033. /**
  104034. * Interpolates a Color4 linearly
  104035. * @param startValue Start value of the animation curve
  104036. * @param endValue End value of the animation curve
  104037. * @param gradient Scalar amount to interpolate
  104038. * @returns Interpolated Color3 value
  104039. */
  104040. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  104041. /**
  104042. * @hidden Internal use only
  104043. */
  104044. _getKeyValue(value: any): any;
  104045. /**
  104046. * @hidden Internal use only
  104047. */
  104048. _interpolate(currentFrame: number, state: _IAnimationState): any;
  104049. /**
  104050. * Defines the function to use to interpolate matrices
  104051. * @param startValue defines the start matrix
  104052. * @param endValue defines the end matrix
  104053. * @param gradient defines the gradient between both matrices
  104054. * @param result defines an optional target matrix where to store the interpolation
  104055. * @returns the interpolated matrix
  104056. */
  104057. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  104058. /**
  104059. * Makes a copy of the animation
  104060. * @returns Cloned animation
  104061. */
  104062. clone(): Animation;
  104063. /**
  104064. * Sets the key frames of the animation
  104065. * @param values The animation key frames to set
  104066. */
  104067. setKeys(values: Array<IAnimationKey>): void;
  104068. /**
  104069. * Serializes the animation to an object
  104070. * @returns Serialized object
  104071. */
  104072. serialize(): any;
  104073. /**
  104074. * Float animation type
  104075. */
  104076. static readonly ANIMATIONTYPE_FLOAT: number;
  104077. /**
  104078. * Vector3 animation type
  104079. */
  104080. static readonly ANIMATIONTYPE_VECTOR3: number;
  104081. /**
  104082. * Quaternion animation type
  104083. */
  104084. static readonly ANIMATIONTYPE_QUATERNION: number;
  104085. /**
  104086. * Matrix animation type
  104087. */
  104088. static readonly ANIMATIONTYPE_MATRIX: number;
  104089. /**
  104090. * Color3 animation type
  104091. */
  104092. static readonly ANIMATIONTYPE_COLOR3: number;
  104093. /**
  104094. * Color3 animation type
  104095. */
  104096. static readonly ANIMATIONTYPE_COLOR4: number;
  104097. /**
  104098. * Vector2 animation type
  104099. */
  104100. static readonly ANIMATIONTYPE_VECTOR2: number;
  104101. /**
  104102. * Size animation type
  104103. */
  104104. static readonly ANIMATIONTYPE_SIZE: number;
  104105. /**
  104106. * Relative Loop Mode
  104107. */
  104108. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  104109. /**
  104110. * Cycle Loop Mode
  104111. */
  104112. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  104113. /**
  104114. * Constant Loop Mode
  104115. */
  104116. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  104117. /** @hidden */
  104118. static _UniversalLerp(left: any, right: any, amount: number): any;
  104119. /**
  104120. * Parses an animation object and creates an animation
  104121. * @param parsedAnimation Parsed animation object
  104122. * @returns Animation object
  104123. */
  104124. static Parse(parsedAnimation: any): Animation;
  104125. /**
  104126. * Appends the serialized animations from the source animations
  104127. * @param source Source containing the animations
  104128. * @param destination Target to store the animations
  104129. */
  104130. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104131. }
  104132. }
  104133. declare module BABYLON {
  104134. /**
  104135. * Interface containing an array of animations
  104136. */
  104137. export interface IAnimatable {
  104138. /**
  104139. * Array of animations
  104140. */
  104141. animations: Nullable<Array<Animation>>;
  104142. }
  104143. }
  104144. declare module BABYLON {
  104145. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  104146. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104147. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104148. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104149. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104150. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104151. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104152. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104153. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104154. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104155. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104156. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104157. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104158. /**
  104159. * Decorator used to define property that can be serialized as reference to a camera
  104160. * @param sourceName defines the name of the property to decorate
  104161. */
  104162. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104163. /**
  104164. * Class used to help serialization objects
  104165. */
  104166. export class SerializationHelper {
  104167. /** @hidden */
  104168. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  104169. /** @hidden */
  104170. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  104171. /** @hidden */
  104172. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  104173. /** @hidden */
  104174. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  104175. /**
  104176. * Appends the serialized animations from the source animations
  104177. * @param source Source containing the animations
  104178. * @param destination Target to store the animations
  104179. */
  104180. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104181. /**
  104182. * Static function used to serialized a specific entity
  104183. * @param entity defines the entity to serialize
  104184. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  104185. * @returns a JSON compatible object representing the serialization of the entity
  104186. */
  104187. static Serialize<T>(entity: T, serializationObject?: any): any;
  104188. /**
  104189. * Creates a new entity from a serialization data object
  104190. * @param creationFunction defines a function used to instanciated the new entity
  104191. * @param source defines the source serialization data
  104192. * @param scene defines the hosting scene
  104193. * @param rootUrl defines the root url for resources
  104194. * @returns a new entity
  104195. */
  104196. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  104197. /**
  104198. * Clones an object
  104199. * @param creationFunction defines the function used to instanciate the new object
  104200. * @param source defines the source object
  104201. * @returns the cloned object
  104202. */
  104203. static Clone<T>(creationFunction: () => T, source: T): T;
  104204. /**
  104205. * Instanciates a new object based on a source one (some data will be shared between both object)
  104206. * @param creationFunction defines the function used to instanciate the new object
  104207. * @param source defines the source object
  104208. * @returns the new object
  104209. */
  104210. static Instanciate<T>(creationFunction: () => T, source: T): T;
  104211. }
  104212. }
  104213. declare module BABYLON {
  104214. /**
  104215. * Class used to manipulate GUIDs
  104216. */
  104217. export class GUID {
  104218. /**
  104219. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104220. * Be aware Math.random() could cause collisions, but:
  104221. * "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"
  104222. * @returns a pseudo random id
  104223. */
  104224. static RandomId(): string;
  104225. }
  104226. }
  104227. declare module BABYLON {
  104228. /**
  104229. * Base class of all the textures in babylon.
  104230. * It groups all the common properties the materials, post process, lights... might need
  104231. * in order to make a correct use of the texture.
  104232. */
  104233. export class BaseTexture implements IAnimatable {
  104234. /**
  104235. * Default anisotropic filtering level for the application.
  104236. * It is set to 4 as a good tradeoff between perf and quality.
  104237. */
  104238. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  104239. /**
  104240. * Gets or sets the unique id of the texture
  104241. */
  104242. uniqueId: number;
  104243. /**
  104244. * Define the name of the texture.
  104245. */
  104246. name: string;
  104247. /**
  104248. * Gets or sets an object used to store user defined information.
  104249. */
  104250. metadata: any;
  104251. /**
  104252. * For internal use only. Please do not use.
  104253. */
  104254. reservedDataStore: any;
  104255. private _hasAlpha;
  104256. /**
  104257. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  104258. */
  104259. set hasAlpha(value: boolean);
  104260. get hasAlpha(): boolean;
  104261. /**
  104262. * Defines if the alpha value should be determined via the rgb values.
  104263. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  104264. */
  104265. getAlphaFromRGB: boolean;
  104266. /**
  104267. * Intensity or strength of the texture.
  104268. * It is commonly used by materials to fine tune the intensity of the texture
  104269. */
  104270. level: number;
  104271. /**
  104272. * Define the UV chanel to use starting from 0 and defaulting to 0.
  104273. * This is part of the texture as textures usually maps to one uv set.
  104274. */
  104275. coordinatesIndex: number;
  104276. private _coordinatesMode;
  104277. /**
  104278. * How a texture is mapped.
  104279. *
  104280. * | Value | Type | Description |
  104281. * | ----- | ----------------------------------- | ----------- |
  104282. * | 0 | EXPLICIT_MODE | |
  104283. * | 1 | SPHERICAL_MODE | |
  104284. * | 2 | PLANAR_MODE | |
  104285. * | 3 | CUBIC_MODE | |
  104286. * | 4 | PROJECTION_MODE | |
  104287. * | 5 | SKYBOX_MODE | |
  104288. * | 6 | INVCUBIC_MODE | |
  104289. * | 7 | EQUIRECTANGULAR_MODE | |
  104290. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  104291. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  104292. */
  104293. set coordinatesMode(value: number);
  104294. get coordinatesMode(): number;
  104295. /**
  104296. * | Value | Type | Description |
  104297. * | ----- | ------------------ | ----------- |
  104298. * | 0 | CLAMP_ADDRESSMODE | |
  104299. * | 1 | WRAP_ADDRESSMODE | |
  104300. * | 2 | MIRROR_ADDRESSMODE | |
  104301. */
  104302. wrapU: number;
  104303. /**
  104304. * | Value | Type | Description |
  104305. * | ----- | ------------------ | ----------- |
  104306. * | 0 | CLAMP_ADDRESSMODE | |
  104307. * | 1 | WRAP_ADDRESSMODE | |
  104308. * | 2 | MIRROR_ADDRESSMODE | |
  104309. */
  104310. wrapV: number;
  104311. /**
  104312. * | Value | Type | Description |
  104313. * | ----- | ------------------ | ----------- |
  104314. * | 0 | CLAMP_ADDRESSMODE | |
  104315. * | 1 | WRAP_ADDRESSMODE | |
  104316. * | 2 | MIRROR_ADDRESSMODE | |
  104317. */
  104318. wrapR: number;
  104319. /**
  104320. * With compliant hardware and browser (supporting anisotropic filtering)
  104321. * this defines the level of anisotropic filtering in the texture.
  104322. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  104323. */
  104324. anisotropicFilteringLevel: number;
  104325. /**
  104326. * Define if the texture is a cube texture or if false a 2d texture.
  104327. */
  104328. get isCube(): boolean;
  104329. set isCube(value: boolean);
  104330. /**
  104331. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  104332. */
  104333. get is3D(): boolean;
  104334. set is3D(value: boolean);
  104335. /**
  104336. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  104337. */
  104338. get is2DArray(): boolean;
  104339. set is2DArray(value: boolean);
  104340. /**
  104341. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  104342. * HDR texture are usually stored in linear space.
  104343. * This only impacts the PBR and Background materials
  104344. */
  104345. gammaSpace: boolean;
  104346. /**
  104347. * Gets or sets whether or not the texture contains RGBD data.
  104348. */
  104349. get isRGBD(): boolean;
  104350. set isRGBD(value: boolean);
  104351. /**
  104352. * Is Z inverted in the texture (useful in a cube texture).
  104353. */
  104354. invertZ: boolean;
  104355. /**
  104356. * Are mip maps generated for this texture or not.
  104357. */
  104358. get noMipmap(): boolean;
  104359. /**
  104360. * @hidden
  104361. */
  104362. lodLevelInAlpha: boolean;
  104363. /**
  104364. * With prefiltered texture, defined the offset used during the prefiltering steps.
  104365. */
  104366. get lodGenerationOffset(): number;
  104367. set lodGenerationOffset(value: number);
  104368. /**
  104369. * With prefiltered texture, defined the scale used during the prefiltering steps.
  104370. */
  104371. get lodGenerationScale(): number;
  104372. set lodGenerationScale(value: number);
  104373. /**
  104374. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  104375. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  104376. * average roughness values.
  104377. */
  104378. get linearSpecularLOD(): boolean;
  104379. set linearSpecularLOD(value: boolean);
  104380. /**
  104381. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  104382. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  104383. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  104384. */
  104385. get irradianceTexture(): Nullable<BaseTexture>;
  104386. set irradianceTexture(value: Nullable<BaseTexture>);
  104387. /**
  104388. * Define if the texture is a render target.
  104389. */
  104390. isRenderTarget: boolean;
  104391. /**
  104392. * Define the unique id of the texture in the scene.
  104393. */
  104394. get uid(): string;
  104395. /**
  104396. * Return a string representation of the texture.
  104397. * @returns the texture as a string
  104398. */
  104399. toString(): string;
  104400. /**
  104401. * Get the class name of the texture.
  104402. * @returns "BaseTexture"
  104403. */
  104404. getClassName(): string;
  104405. /**
  104406. * Define the list of animation attached to the texture.
  104407. */
  104408. animations: Animation[];
  104409. /**
  104410. * An event triggered when the texture is disposed.
  104411. */
  104412. onDisposeObservable: Observable<BaseTexture>;
  104413. private _onDisposeObserver;
  104414. /**
  104415. * Callback triggered when the texture has been disposed.
  104416. * Kept for back compatibility, you can use the onDisposeObservable instead.
  104417. */
  104418. set onDispose(callback: () => void);
  104419. /**
  104420. * Define the current state of the loading sequence when in delayed load mode.
  104421. */
  104422. delayLoadState: number;
  104423. private _scene;
  104424. /** @hidden */
  104425. _texture: Nullable<InternalTexture>;
  104426. private _uid;
  104427. /**
  104428. * Define if the texture is preventinga material to render or not.
  104429. * If not and the texture is not ready, the engine will use a default black texture instead.
  104430. */
  104431. get isBlocking(): boolean;
  104432. /**
  104433. * Instantiates a new BaseTexture.
  104434. * Base class of all the textures in babylon.
  104435. * It groups all the common properties the materials, post process, lights... might need
  104436. * in order to make a correct use of the texture.
  104437. * @param scene Define the scene the texture blongs to
  104438. */
  104439. constructor(scene: Nullable<Scene>);
  104440. /**
  104441. * Get the scene the texture belongs to.
  104442. * @returns the scene or null if undefined
  104443. */
  104444. getScene(): Nullable<Scene>;
  104445. /**
  104446. * Get the texture transform matrix used to offset tile the texture for istance.
  104447. * @returns the transformation matrix
  104448. */
  104449. getTextureMatrix(): Matrix;
  104450. /**
  104451. * Get the texture reflection matrix used to rotate/transform the reflection.
  104452. * @returns the reflection matrix
  104453. */
  104454. getReflectionTextureMatrix(): Matrix;
  104455. /**
  104456. * Get the underlying lower level texture from Babylon.
  104457. * @returns the insternal texture
  104458. */
  104459. getInternalTexture(): Nullable<InternalTexture>;
  104460. /**
  104461. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  104462. * @returns true if ready or not blocking
  104463. */
  104464. isReadyOrNotBlocking(): boolean;
  104465. /**
  104466. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  104467. * @returns true if fully ready
  104468. */
  104469. isReady(): boolean;
  104470. private _cachedSize;
  104471. /**
  104472. * Get the size of the texture.
  104473. * @returns the texture size.
  104474. */
  104475. getSize(): ISize;
  104476. /**
  104477. * Get the base size of the texture.
  104478. * It can be different from the size if the texture has been resized for POT for instance
  104479. * @returns the base size
  104480. */
  104481. getBaseSize(): ISize;
  104482. /**
  104483. * Update the sampling mode of the texture.
  104484. * Default is Trilinear mode.
  104485. *
  104486. * | Value | Type | Description |
  104487. * | ----- | ------------------ | ----------- |
  104488. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  104489. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  104490. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  104491. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  104492. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  104493. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  104494. * | 7 | NEAREST_LINEAR | |
  104495. * | 8 | NEAREST_NEAREST | |
  104496. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  104497. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  104498. * | 11 | LINEAR_LINEAR | |
  104499. * | 12 | LINEAR_NEAREST | |
  104500. *
  104501. * > _mag_: magnification filter (close to the viewer)
  104502. * > _min_: minification filter (far from the viewer)
  104503. * > _mip_: filter used between mip map levels
  104504. *@param samplingMode Define the new sampling mode of the texture
  104505. */
  104506. updateSamplingMode(samplingMode: number): void;
  104507. /**
  104508. * Scales the texture if is `canRescale()`
  104509. * @param ratio the resize factor we want to use to rescale
  104510. */
  104511. scale(ratio: number): void;
  104512. /**
  104513. * Get if the texture can rescale.
  104514. */
  104515. get canRescale(): boolean;
  104516. /** @hidden */
  104517. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  104518. /** @hidden */
  104519. _rebuild(): void;
  104520. /**
  104521. * Triggers the load sequence in delayed load mode.
  104522. */
  104523. delayLoad(): void;
  104524. /**
  104525. * Clones the texture.
  104526. * @returns the cloned texture
  104527. */
  104528. clone(): Nullable<BaseTexture>;
  104529. /**
  104530. * Get the texture underlying type (INT, FLOAT...)
  104531. */
  104532. get textureType(): number;
  104533. /**
  104534. * Get the texture underlying format (RGB, RGBA...)
  104535. */
  104536. get textureFormat(): number;
  104537. /**
  104538. * Indicates that textures need to be re-calculated for all materials
  104539. */
  104540. protected _markAllSubMeshesAsTexturesDirty(): void;
  104541. /**
  104542. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  104543. * This will returns an RGBA array buffer containing either in values (0-255) or
  104544. * float values (0-1) depending of the underlying buffer type.
  104545. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  104546. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  104547. * @param buffer defines a user defined buffer to fill with data (can be null)
  104548. * @returns The Array buffer containing the pixels data.
  104549. */
  104550. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  104551. /**
  104552. * Release and destroy the underlying lower level texture aka internalTexture.
  104553. */
  104554. releaseInternalTexture(): void;
  104555. /** @hidden */
  104556. get _lodTextureHigh(): Nullable<BaseTexture>;
  104557. /** @hidden */
  104558. get _lodTextureMid(): Nullable<BaseTexture>;
  104559. /** @hidden */
  104560. get _lodTextureLow(): Nullable<BaseTexture>;
  104561. /**
  104562. * Dispose the texture and release its associated resources.
  104563. */
  104564. dispose(): void;
  104565. /**
  104566. * Serialize the texture into a JSON representation that can be parsed later on.
  104567. * @returns the JSON representation of the texture
  104568. */
  104569. serialize(): any;
  104570. /**
  104571. * Helper function to be called back once a list of texture contains only ready textures.
  104572. * @param textures Define the list of textures to wait for
  104573. * @param callback Define the callback triggered once the entire list will be ready
  104574. */
  104575. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  104576. }
  104577. }
  104578. declare module BABYLON {
  104579. /**
  104580. * Options to be used when creating an effect.
  104581. */
  104582. export interface IEffectCreationOptions {
  104583. /**
  104584. * Atrributes that will be used in the shader.
  104585. */
  104586. attributes: string[];
  104587. /**
  104588. * Uniform varible names that will be set in the shader.
  104589. */
  104590. uniformsNames: string[];
  104591. /**
  104592. * Uniform buffer variable names that will be set in the shader.
  104593. */
  104594. uniformBuffersNames: string[];
  104595. /**
  104596. * Sampler texture variable names that will be set in the shader.
  104597. */
  104598. samplers: string[];
  104599. /**
  104600. * Define statements that will be set in the shader.
  104601. */
  104602. defines: any;
  104603. /**
  104604. * Possible fallbacks for this effect to improve performance when needed.
  104605. */
  104606. fallbacks: Nullable<IEffectFallbacks>;
  104607. /**
  104608. * Callback that will be called when the shader is compiled.
  104609. */
  104610. onCompiled: Nullable<(effect: Effect) => void>;
  104611. /**
  104612. * Callback that will be called if an error occurs during shader compilation.
  104613. */
  104614. onError: Nullable<(effect: Effect, errors: string) => void>;
  104615. /**
  104616. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104617. */
  104618. indexParameters?: any;
  104619. /**
  104620. * Max number of lights that can be used in the shader.
  104621. */
  104622. maxSimultaneousLights?: number;
  104623. /**
  104624. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  104625. */
  104626. transformFeedbackVaryings?: Nullable<string[]>;
  104627. }
  104628. /**
  104629. * Effect containing vertex and fragment shader that can be executed on an object.
  104630. */
  104631. export class Effect implements IDisposable {
  104632. /**
  104633. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104634. */
  104635. static ShadersRepository: string;
  104636. /**
  104637. * Enable logging of the shader code when a compilation error occurs
  104638. */
  104639. static LogShaderCodeOnCompilationError: boolean;
  104640. /**
  104641. * Name of the effect.
  104642. */
  104643. name: any;
  104644. /**
  104645. * String container all the define statements that should be set on the shader.
  104646. */
  104647. defines: string;
  104648. /**
  104649. * Callback that will be called when the shader is compiled.
  104650. */
  104651. onCompiled: Nullable<(effect: Effect) => void>;
  104652. /**
  104653. * Callback that will be called if an error occurs during shader compilation.
  104654. */
  104655. onError: Nullable<(effect: Effect, errors: string) => void>;
  104656. /**
  104657. * Callback that will be called when effect is bound.
  104658. */
  104659. onBind: Nullable<(effect: Effect) => void>;
  104660. /**
  104661. * Unique ID of the effect.
  104662. */
  104663. uniqueId: number;
  104664. /**
  104665. * Observable that will be called when the shader is compiled.
  104666. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  104667. */
  104668. onCompileObservable: Observable<Effect>;
  104669. /**
  104670. * Observable that will be called if an error occurs during shader compilation.
  104671. */
  104672. onErrorObservable: Observable<Effect>;
  104673. /** @hidden */
  104674. _onBindObservable: Nullable<Observable<Effect>>;
  104675. /**
  104676. * @hidden
  104677. * Specifies if the effect was previously ready
  104678. */
  104679. _wasPreviouslyReady: boolean;
  104680. /**
  104681. * Observable that will be called when effect is bound.
  104682. */
  104683. get onBindObservable(): Observable<Effect>;
  104684. /** @hidden */
  104685. _bonesComputationForcedToCPU: boolean;
  104686. private static _uniqueIdSeed;
  104687. private _engine;
  104688. private _uniformBuffersNames;
  104689. private _uniformsNames;
  104690. private _samplerList;
  104691. private _samplers;
  104692. private _isReady;
  104693. private _compilationError;
  104694. private _allFallbacksProcessed;
  104695. private _attributesNames;
  104696. private _attributes;
  104697. private _attributeLocationByName;
  104698. private _uniforms;
  104699. /**
  104700. * Key for the effect.
  104701. * @hidden
  104702. */
  104703. _key: string;
  104704. private _indexParameters;
  104705. private _fallbacks;
  104706. private _vertexSourceCode;
  104707. private _fragmentSourceCode;
  104708. private _vertexSourceCodeOverride;
  104709. private _fragmentSourceCodeOverride;
  104710. private _transformFeedbackVaryings;
  104711. /**
  104712. * Compiled shader to webGL program.
  104713. * @hidden
  104714. */
  104715. _pipelineContext: Nullable<IPipelineContext>;
  104716. private _valueCache;
  104717. private static _baseCache;
  104718. /**
  104719. * Instantiates an effect.
  104720. * An effect can be used to create/manage/execute vertex and fragment shaders.
  104721. * @param baseName Name of the effect.
  104722. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  104723. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  104724. * @param samplers List of sampler variables that will be passed to the shader.
  104725. * @param engine Engine to be used to render the effect
  104726. * @param defines Define statements to be added to the shader.
  104727. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  104728. * @param onCompiled Callback that will be called when the shader is compiled.
  104729. * @param onError Callback that will be called if an error occurs during shader compilation.
  104730. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104731. */
  104732. 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);
  104733. private _useFinalCode;
  104734. /**
  104735. * Unique key for this effect
  104736. */
  104737. get key(): string;
  104738. /**
  104739. * If the effect has been compiled and prepared.
  104740. * @returns if the effect is compiled and prepared.
  104741. */
  104742. isReady(): boolean;
  104743. private _isReadyInternal;
  104744. /**
  104745. * The engine the effect was initialized with.
  104746. * @returns the engine.
  104747. */
  104748. getEngine(): Engine;
  104749. /**
  104750. * The pipeline context for this effect
  104751. * @returns the associated pipeline context
  104752. */
  104753. getPipelineContext(): Nullable<IPipelineContext>;
  104754. /**
  104755. * The set of names of attribute variables for the shader.
  104756. * @returns An array of attribute names.
  104757. */
  104758. getAttributesNames(): string[];
  104759. /**
  104760. * Returns the attribute at the given index.
  104761. * @param index The index of the attribute.
  104762. * @returns The location of the attribute.
  104763. */
  104764. getAttributeLocation(index: number): number;
  104765. /**
  104766. * Returns the attribute based on the name of the variable.
  104767. * @param name of the attribute to look up.
  104768. * @returns the attribute location.
  104769. */
  104770. getAttributeLocationByName(name: string): number;
  104771. /**
  104772. * The number of attributes.
  104773. * @returns the numnber of attributes.
  104774. */
  104775. getAttributesCount(): number;
  104776. /**
  104777. * Gets the index of a uniform variable.
  104778. * @param uniformName of the uniform to look up.
  104779. * @returns the index.
  104780. */
  104781. getUniformIndex(uniformName: string): number;
  104782. /**
  104783. * Returns the attribute based on the name of the variable.
  104784. * @param uniformName of the uniform to look up.
  104785. * @returns the location of the uniform.
  104786. */
  104787. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  104788. /**
  104789. * Returns an array of sampler variable names
  104790. * @returns The array of sampler variable neames.
  104791. */
  104792. getSamplers(): string[];
  104793. /**
  104794. * The error from the last compilation.
  104795. * @returns the error string.
  104796. */
  104797. getCompilationError(): string;
  104798. /**
  104799. * Gets a boolean indicating that all fallbacks were used during compilation
  104800. * @returns true if all fallbacks were used
  104801. */
  104802. allFallbacksProcessed(): boolean;
  104803. /**
  104804. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  104805. * @param func The callback to be used.
  104806. */
  104807. executeWhenCompiled(func: (effect: Effect) => void): void;
  104808. private _checkIsReady;
  104809. private _loadShader;
  104810. /**
  104811. * Recompiles the webGL program
  104812. * @param vertexSourceCode The source code for the vertex shader.
  104813. * @param fragmentSourceCode The source code for the fragment shader.
  104814. * @param onCompiled Callback called when completed.
  104815. * @param onError Callback called on error.
  104816. * @hidden
  104817. */
  104818. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  104819. /**
  104820. * Prepares the effect
  104821. * @hidden
  104822. */
  104823. _prepareEffect(): void;
  104824. private _getShaderCodeAndErrorLine;
  104825. private _processCompilationErrors;
  104826. /**
  104827. * Checks if the effect is supported. (Must be called after compilation)
  104828. */
  104829. get isSupported(): boolean;
  104830. /**
  104831. * Binds a texture to the engine to be used as output of the shader.
  104832. * @param channel Name of the output variable.
  104833. * @param texture Texture to bind.
  104834. * @hidden
  104835. */
  104836. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  104837. /**
  104838. * Sets a texture on the engine to be used in the shader.
  104839. * @param channel Name of the sampler variable.
  104840. * @param texture Texture to set.
  104841. */
  104842. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  104843. /**
  104844. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  104845. * @param channel Name of the sampler variable.
  104846. * @param texture Texture to set.
  104847. */
  104848. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  104849. /**
  104850. * Sets an array of textures on the engine to be used in the shader.
  104851. * @param channel Name of the variable.
  104852. * @param textures Textures to set.
  104853. */
  104854. setTextureArray(channel: string, textures: BaseTexture[]): void;
  104855. /**
  104856. * 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)
  104857. * @param channel Name of the sampler variable.
  104858. * @param postProcess Post process to get the input texture from.
  104859. */
  104860. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  104861. /**
  104862. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  104863. * 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)
  104864. * @param channel Name of the sampler variable.
  104865. * @param postProcess Post process to get the output texture from.
  104866. */
  104867. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  104868. /** @hidden */
  104869. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  104870. /** @hidden */
  104871. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  104872. /** @hidden */
  104873. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  104874. /** @hidden */
  104875. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  104876. /**
  104877. * Binds a buffer to a uniform.
  104878. * @param buffer Buffer to bind.
  104879. * @param name Name of the uniform variable to bind to.
  104880. */
  104881. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  104882. /**
  104883. * Binds block to a uniform.
  104884. * @param blockName Name of the block to bind.
  104885. * @param index Index to bind.
  104886. */
  104887. bindUniformBlock(blockName: string, index: number): void;
  104888. /**
  104889. * Sets an interger value on a uniform variable.
  104890. * @param uniformName Name of the variable.
  104891. * @param value Value to be set.
  104892. * @returns this effect.
  104893. */
  104894. setInt(uniformName: string, value: number): Effect;
  104895. /**
  104896. * Sets an int array on a uniform variable.
  104897. * @param uniformName Name of the variable.
  104898. * @param array array to be set.
  104899. * @returns this effect.
  104900. */
  104901. setIntArray(uniformName: string, array: Int32Array): Effect;
  104902. /**
  104903. * 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)
  104904. * @param uniformName Name of the variable.
  104905. * @param array array to be set.
  104906. * @returns this effect.
  104907. */
  104908. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104909. /**
  104910. * 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)
  104911. * @param uniformName Name of the variable.
  104912. * @param array array to be set.
  104913. * @returns this effect.
  104914. */
  104915. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104916. /**
  104917. * 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)
  104918. * @param uniformName Name of the variable.
  104919. * @param array array to be set.
  104920. * @returns this effect.
  104921. */
  104922. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104923. /**
  104924. * Sets an float array on a uniform variable.
  104925. * @param uniformName Name of the variable.
  104926. * @param array array to be set.
  104927. * @returns this effect.
  104928. */
  104929. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104930. /**
  104931. * 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)
  104932. * @param uniformName Name of the variable.
  104933. * @param array array to be set.
  104934. * @returns this effect.
  104935. */
  104936. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104937. /**
  104938. * 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)
  104939. * @param uniformName Name of the variable.
  104940. * @param array array to be set.
  104941. * @returns this effect.
  104942. */
  104943. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104944. /**
  104945. * 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)
  104946. * @param uniformName Name of the variable.
  104947. * @param array array to be set.
  104948. * @returns this effect.
  104949. */
  104950. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104951. /**
  104952. * Sets an array on a uniform variable.
  104953. * @param uniformName Name of the variable.
  104954. * @param array array to be set.
  104955. * @returns this effect.
  104956. */
  104957. setArray(uniformName: string, array: number[]): Effect;
  104958. /**
  104959. * 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)
  104960. * @param uniformName Name of the variable.
  104961. * @param array array to be set.
  104962. * @returns this effect.
  104963. */
  104964. setArray2(uniformName: string, array: number[]): Effect;
  104965. /**
  104966. * 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)
  104967. * @param uniformName Name of the variable.
  104968. * @param array array to be set.
  104969. * @returns this effect.
  104970. */
  104971. setArray3(uniformName: string, array: number[]): Effect;
  104972. /**
  104973. * 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)
  104974. * @param uniformName Name of the variable.
  104975. * @param array array to be set.
  104976. * @returns this effect.
  104977. */
  104978. setArray4(uniformName: string, array: number[]): Effect;
  104979. /**
  104980. * Sets matrices on a uniform variable.
  104981. * @param uniformName Name of the variable.
  104982. * @param matrices matrices to be set.
  104983. * @returns this effect.
  104984. */
  104985. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104986. /**
  104987. * Sets matrix on a uniform variable.
  104988. * @param uniformName Name of the variable.
  104989. * @param matrix matrix to be set.
  104990. * @returns this effect.
  104991. */
  104992. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  104993. /**
  104994. * 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)
  104995. * @param uniformName Name of the variable.
  104996. * @param matrix matrix to be set.
  104997. * @returns this effect.
  104998. */
  104999. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  105000. /**
  105001. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  105002. * @param uniformName Name of the variable.
  105003. * @param matrix matrix to be set.
  105004. * @returns this effect.
  105005. */
  105006. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  105007. /**
  105008. * Sets a float on a uniform variable.
  105009. * @param uniformName Name of the variable.
  105010. * @param value value to be set.
  105011. * @returns this effect.
  105012. */
  105013. setFloat(uniformName: string, value: number): Effect;
  105014. /**
  105015. * Sets a boolean on a uniform variable.
  105016. * @param uniformName Name of the variable.
  105017. * @param bool value to be set.
  105018. * @returns this effect.
  105019. */
  105020. setBool(uniformName: string, bool: boolean): Effect;
  105021. /**
  105022. * Sets a Vector2 on a uniform variable.
  105023. * @param uniformName Name of the variable.
  105024. * @param vector2 vector2 to be set.
  105025. * @returns this effect.
  105026. */
  105027. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  105028. /**
  105029. * Sets a float2 on a uniform variable.
  105030. * @param uniformName Name of the variable.
  105031. * @param x First float in float2.
  105032. * @param y Second float in float2.
  105033. * @returns this effect.
  105034. */
  105035. setFloat2(uniformName: string, x: number, y: number): Effect;
  105036. /**
  105037. * Sets a Vector3 on a uniform variable.
  105038. * @param uniformName Name of the variable.
  105039. * @param vector3 Value to be set.
  105040. * @returns this effect.
  105041. */
  105042. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  105043. /**
  105044. * Sets a float3 on a uniform variable.
  105045. * @param uniformName Name of the variable.
  105046. * @param x First float in float3.
  105047. * @param y Second float in float3.
  105048. * @param z Third float in float3.
  105049. * @returns this effect.
  105050. */
  105051. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  105052. /**
  105053. * Sets a Vector4 on a uniform variable.
  105054. * @param uniformName Name of the variable.
  105055. * @param vector4 Value to be set.
  105056. * @returns this effect.
  105057. */
  105058. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  105059. /**
  105060. * Sets a float4 on a uniform variable.
  105061. * @param uniformName Name of the variable.
  105062. * @param x First float in float4.
  105063. * @param y Second float in float4.
  105064. * @param z Third float in float4.
  105065. * @param w Fourth float in float4.
  105066. * @returns this effect.
  105067. */
  105068. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  105069. /**
  105070. * Sets a Color3 on a uniform variable.
  105071. * @param uniformName Name of the variable.
  105072. * @param color3 Value to be set.
  105073. * @returns this effect.
  105074. */
  105075. setColor3(uniformName: string, color3: IColor3Like): Effect;
  105076. /**
  105077. * Sets a Color4 on a uniform variable.
  105078. * @param uniformName Name of the variable.
  105079. * @param color3 Value to be set.
  105080. * @param alpha Alpha value to be set.
  105081. * @returns this effect.
  105082. */
  105083. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  105084. /**
  105085. * Sets a Color4 on a uniform variable
  105086. * @param uniformName defines the name of the variable
  105087. * @param color4 defines the value to be set
  105088. * @returns this effect.
  105089. */
  105090. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  105091. /** Release all associated resources */
  105092. dispose(): void;
  105093. /**
  105094. * This function will add a new shader to the shader store
  105095. * @param name the name of the shader
  105096. * @param pixelShader optional pixel shader content
  105097. * @param vertexShader optional vertex shader content
  105098. */
  105099. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  105100. /**
  105101. * Store of each shader (The can be looked up using effect.key)
  105102. */
  105103. static ShadersStore: {
  105104. [key: string]: string;
  105105. };
  105106. /**
  105107. * Store of each included file for a shader (The can be looked up using effect.key)
  105108. */
  105109. static IncludesShadersStore: {
  105110. [key: string]: string;
  105111. };
  105112. /**
  105113. * Resets the cache of effects.
  105114. */
  105115. static ResetCache(): void;
  105116. }
  105117. }
  105118. declare module BABYLON {
  105119. /**
  105120. * Interface used to describe the capabilities of the engine relatively to the current browser
  105121. */
  105122. export interface EngineCapabilities {
  105123. /** Maximum textures units per fragment shader */
  105124. maxTexturesImageUnits: number;
  105125. /** Maximum texture units per vertex shader */
  105126. maxVertexTextureImageUnits: number;
  105127. /** Maximum textures units in the entire pipeline */
  105128. maxCombinedTexturesImageUnits: number;
  105129. /** Maximum texture size */
  105130. maxTextureSize: number;
  105131. /** Maximum texture samples */
  105132. maxSamples?: number;
  105133. /** Maximum cube texture size */
  105134. maxCubemapTextureSize: number;
  105135. /** Maximum render texture size */
  105136. maxRenderTextureSize: number;
  105137. /** Maximum number of vertex attributes */
  105138. maxVertexAttribs: number;
  105139. /** Maximum number of varyings */
  105140. maxVaryingVectors: number;
  105141. /** Maximum number of uniforms per vertex shader */
  105142. maxVertexUniformVectors: number;
  105143. /** Maximum number of uniforms per fragment shader */
  105144. maxFragmentUniformVectors: number;
  105145. /** Defines if standard derivates (dx/dy) are supported */
  105146. standardDerivatives: boolean;
  105147. /** Defines if s3tc texture compression is supported */
  105148. s3tc?: WEBGL_compressed_texture_s3tc;
  105149. /** Defines if pvrtc texture compression is supported */
  105150. pvrtc: any;
  105151. /** Defines if etc1 texture compression is supported */
  105152. etc1: any;
  105153. /** Defines if etc2 texture compression is supported */
  105154. etc2: any;
  105155. /** Defines if astc texture compression is supported */
  105156. astc: any;
  105157. /** Defines if float textures are supported */
  105158. textureFloat: boolean;
  105159. /** Defines if vertex array objects are supported */
  105160. vertexArrayObject: boolean;
  105161. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  105162. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  105163. /** Gets the maximum level of anisotropy supported */
  105164. maxAnisotropy: number;
  105165. /** Defines if instancing is supported */
  105166. instancedArrays: boolean;
  105167. /** Defines if 32 bits indices are supported */
  105168. uintIndices: boolean;
  105169. /** Defines if high precision shaders are supported */
  105170. highPrecisionShaderSupported: boolean;
  105171. /** Defines if depth reading in the fragment shader is supported */
  105172. fragmentDepthSupported: boolean;
  105173. /** Defines if float texture linear filtering is supported*/
  105174. textureFloatLinearFiltering: boolean;
  105175. /** Defines if rendering to float textures is supported */
  105176. textureFloatRender: boolean;
  105177. /** Defines if half float textures are supported*/
  105178. textureHalfFloat: boolean;
  105179. /** Defines if half float texture linear filtering is supported*/
  105180. textureHalfFloatLinearFiltering: boolean;
  105181. /** Defines if rendering to half float textures is supported */
  105182. textureHalfFloatRender: boolean;
  105183. /** Defines if textureLOD shader command is supported */
  105184. textureLOD: boolean;
  105185. /** Defines if draw buffers extension is supported */
  105186. drawBuffersExtension: boolean;
  105187. /** Defines if depth textures are supported */
  105188. depthTextureExtension: boolean;
  105189. /** Defines if float color buffer are supported */
  105190. colorBufferFloat: boolean;
  105191. /** Gets disjoint timer query extension (null if not supported) */
  105192. timerQuery?: EXT_disjoint_timer_query;
  105193. /** Defines if timestamp can be used with timer query */
  105194. canUseTimestampForTimerQuery: boolean;
  105195. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  105196. multiview?: any;
  105197. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  105198. oculusMultiview?: any;
  105199. /** Function used to let the system compiles shaders in background */
  105200. parallelShaderCompile?: {
  105201. COMPLETION_STATUS_KHR: number;
  105202. };
  105203. /** Max number of texture samples for MSAA */
  105204. maxMSAASamples: number;
  105205. /** Defines if the blend min max extension is supported */
  105206. blendMinMax: boolean;
  105207. }
  105208. }
  105209. declare module BABYLON {
  105210. /**
  105211. * @hidden
  105212. **/
  105213. export class DepthCullingState {
  105214. private _isDepthTestDirty;
  105215. private _isDepthMaskDirty;
  105216. private _isDepthFuncDirty;
  105217. private _isCullFaceDirty;
  105218. private _isCullDirty;
  105219. private _isZOffsetDirty;
  105220. private _isFrontFaceDirty;
  105221. private _depthTest;
  105222. private _depthMask;
  105223. private _depthFunc;
  105224. private _cull;
  105225. private _cullFace;
  105226. private _zOffset;
  105227. private _frontFace;
  105228. /**
  105229. * Initializes the state.
  105230. */
  105231. constructor();
  105232. get isDirty(): boolean;
  105233. get zOffset(): number;
  105234. set zOffset(value: number);
  105235. get cullFace(): Nullable<number>;
  105236. set cullFace(value: Nullable<number>);
  105237. get cull(): Nullable<boolean>;
  105238. set cull(value: Nullable<boolean>);
  105239. get depthFunc(): Nullable<number>;
  105240. set depthFunc(value: Nullable<number>);
  105241. get depthMask(): boolean;
  105242. set depthMask(value: boolean);
  105243. get depthTest(): boolean;
  105244. set depthTest(value: boolean);
  105245. get frontFace(): Nullable<number>;
  105246. set frontFace(value: Nullable<number>);
  105247. reset(): void;
  105248. apply(gl: WebGLRenderingContext): void;
  105249. }
  105250. }
  105251. declare module BABYLON {
  105252. /**
  105253. * @hidden
  105254. **/
  105255. export class StencilState {
  105256. /** 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 */
  105257. static readonly ALWAYS: number;
  105258. /** Passed to stencilOperation to specify that stencil value must be kept */
  105259. static readonly KEEP: number;
  105260. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105261. static readonly REPLACE: number;
  105262. private _isStencilTestDirty;
  105263. private _isStencilMaskDirty;
  105264. private _isStencilFuncDirty;
  105265. private _isStencilOpDirty;
  105266. private _stencilTest;
  105267. private _stencilMask;
  105268. private _stencilFunc;
  105269. private _stencilFuncRef;
  105270. private _stencilFuncMask;
  105271. private _stencilOpStencilFail;
  105272. private _stencilOpDepthFail;
  105273. private _stencilOpStencilDepthPass;
  105274. get isDirty(): boolean;
  105275. get stencilFunc(): number;
  105276. set stencilFunc(value: number);
  105277. get stencilFuncRef(): number;
  105278. set stencilFuncRef(value: number);
  105279. get stencilFuncMask(): number;
  105280. set stencilFuncMask(value: number);
  105281. get stencilOpStencilFail(): number;
  105282. set stencilOpStencilFail(value: number);
  105283. get stencilOpDepthFail(): number;
  105284. set stencilOpDepthFail(value: number);
  105285. get stencilOpStencilDepthPass(): number;
  105286. set stencilOpStencilDepthPass(value: number);
  105287. get stencilMask(): number;
  105288. set stencilMask(value: number);
  105289. get stencilTest(): boolean;
  105290. set stencilTest(value: boolean);
  105291. constructor();
  105292. reset(): void;
  105293. apply(gl: WebGLRenderingContext): void;
  105294. }
  105295. }
  105296. declare module BABYLON {
  105297. /**
  105298. * @hidden
  105299. **/
  105300. export class AlphaState {
  105301. private _isAlphaBlendDirty;
  105302. private _isBlendFunctionParametersDirty;
  105303. private _isBlendEquationParametersDirty;
  105304. private _isBlendConstantsDirty;
  105305. private _alphaBlend;
  105306. private _blendFunctionParameters;
  105307. private _blendEquationParameters;
  105308. private _blendConstants;
  105309. /**
  105310. * Initializes the state.
  105311. */
  105312. constructor();
  105313. get isDirty(): boolean;
  105314. get alphaBlend(): boolean;
  105315. set alphaBlend(value: boolean);
  105316. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  105317. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  105318. setAlphaEquationParameters(rgb: number, alpha: number): void;
  105319. reset(): void;
  105320. apply(gl: WebGLRenderingContext): void;
  105321. }
  105322. }
  105323. declare module BABYLON {
  105324. /** @hidden */
  105325. export class WebGL2ShaderProcessor implements IShaderProcessor {
  105326. attributeProcessor(attribute: string): string;
  105327. varyingProcessor(varying: string, isFragment: boolean): string;
  105328. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  105329. }
  105330. }
  105331. declare module BABYLON {
  105332. /**
  105333. * Interface for attribute information associated with buffer instanciation
  105334. */
  105335. export interface InstancingAttributeInfo {
  105336. /**
  105337. * Name of the GLSL attribute
  105338. * if attribute index is not specified, this is used to retrieve the index from the effect
  105339. */
  105340. attributeName: string;
  105341. /**
  105342. * Index/offset of the attribute in the vertex shader
  105343. * if not specified, this will be computes from the name.
  105344. */
  105345. index?: number;
  105346. /**
  105347. * size of the attribute, 1, 2, 3 or 4
  105348. */
  105349. attributeSize: number;
  105350. /**
  105351. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  105352. */
  105353. offset: number;
  105354. /**
  105355. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  105356. * default to 1
  105357. */
  105358. divisor?: number;
  105359. /**
  105360. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  105361. * default is FLOAT
  105362. */
  105363. attributeType?: number;
  105364. /**
  105365. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  105366. */
  105367. normalized?: boolean;
  105368. }
  105369. }
  105370. declare module BABYLON {
  105371. interface ThinEngine {
  105372. /**
  105373. * Update a video texture
  105374. * @param texture defines the texture to update
  105375. * @param video defines the video element to use
  105376. * @param invertY defines if data must be stored with Y axis inverted
  105377. */
  105378. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  105379. }
  105380. }
  105381. declare module BABYLON {
  105382. /**
  105383. * Settings for finer control over video usage
  105384. */
  105385. export interface VideoTextureSettings {
  105386. /**
  105387. * Applies `autoplay` to video, if specified
  105388. */
  105389. autoPlay?: boolean;
  105390. /**
  105391. * Applies `loop` to video, if specified
  105392. */
  105393. loop?: boolean;
  105394. /**
  105395. * Automatically updates internal texture from video at every frame in the render loop
  105396. */
  105397. autoUpdateTexture: boolean;
  105398. /**
  105399. * Image src displayed during the video loading or until the user interacts with the video.
  105400. */
  105401. poster?: string;
  105402. }
  105403. /**
  105404. * If you want to display a video in your scene, this is the special texture for that.
  105405. * This special texture works similar to other textures, with the exception of a few parameters.
  105406. * @see https://doc.babylonjs.com/how_to/video_texture
  105407. */
  105408. export class VideoTexture extends Texture {
  105409. /**
  105410. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  105411. */
  105412. readonly autoUpdateTexture: boolean;
  105413. /**
  105414. * The video instance used by the texture internally
  105415. */
  105416. readonly video: HTMLVideoElement;
  105417. private _onUserActionRequestedObservable;
  105418. /**
  105419. * Event triggerd when a dom action is required by the user to play the video.
  105420. * This happens due to recent changes in browser policies preventing video to auto start.
  105421. */
  105422. get onUserActionRequestedObservable(): Observable<Texture>;
  105423. private _generateMipMaps;
  105424. private _engine;
  105425. private _stillImageCaptured;
  105426. private _displayingPosterTexture;
  105427. private _settings;
  105428. private _createInternalTextureOnEvent;
  105429. private _frameId;
  105430. private _currentSrc;
  105431. /**
  105432. * Creates a video texture.
  105433. * If you want to display a video in your scene, this is the special texture for that.
  105434. * This special texture works similar to other textures, with the exception of a few parameters.
  105435. * @see https://doc.babylonjs.com/how_to/video_texture
  105436. * @param name optional name, will detect from video source, if not defined
  105437. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  105438. * @param scene is obviously the current scene.
  105439. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  105440. * @param invertY is false by default but can be used to invert video on Y axis
  105441. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  105442. * @param settings allows finer control over video usage
  105443. */
  105444. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  105445. private _getName;
  105446. private _getVideo;
  105447. private _createInternalTexture;
  105448. private reset;
  105449. /**
  105450. * @hidden Internal method to initiate `update`.
  105451. */
  105452. _rebuild(): void;
  105453. /**
  105454. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  105455. */
  105456. update(): void;
  105457. /**
  105458. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  105459. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  105460. */
  105461. updateTexture(isVisible: boolean): void;
  105462. protected _updateInternalTexture: () => void;
  105463. /**
  105464. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  105465. * @param url New url.
  105466. */
  105467. updateURL(url: string): void;
  105468. /**
  105469. * Clones the texture.
  105470. * @returns the cloned texture
  105471. */
  105472. clone(): VideoTexture;
  105473. /**
  105474. * Dispose the texture and release its associated resources.
  105475. */
  105476. dispose(): void;
  105477. /**
  105478. * Creates a video texture straight from a stream.
  105479. * @param scene Define the scene the texture should be created in
  105480. * @param stream Define the stream the texture should be created from
  105481. * @returns The created video texture as a promise
  105482. */
  105483. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  105484. /**
  105485. * Creates a video texture straight from your WebCam video feed.
  105486. * @param scene Define the scene the texture should be created in
  105487. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105488. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105489. * @returns The created video texture as a promise
  105490. */
  105491. static CreateFromWebCamAsync(scene: Scene, constraints: {
  105492. minWidth: number;
  105493. maxWidth: number;
  105494. minHeight: number;
  105495. maxHeight: number;
  105496. deviceId: string;
  105497. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  105498. /**
  105499. * Creates a video texture straight from your WebCam video feed.
  105500. * @param scene Define the scene the texture should be created in
  105501. * @param onReady Define a callback to triggered once the texture will be ready
  105502. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105503. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105504. */
  105505. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  105506. minWidth: number;
  105507. maxWidth: number;
  105508. minHeight: number;
  105509. maxHeight: number;
  105510. deviceId: string;
  105511. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  105512. }
  105513. }
  105514. declare module BABYLON {
  105515. /**
  105516. * Defines the interface used by objects working like Scene
  105517. * @hidden
  105518. */
  105519. export interface ISceneLike {
  105520. _addPendingData(data: any): void;
  105521. _removePendingData(data: any): void;
  105522. offlineProvider: IOfflineProvider;
  105523. }
  105524. /** Interface defining initialization parameters for Engine class */
  105525. export interface EngineOptions extends WebGLContextAttributes {
  105526. /**
  105527. * Defines if the engine should no exceed a specified device ratio
  105528. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  105529. */
  105530. limitDeviceRatio?: number;
  105531. /**
  105532. * Defines if webvr should be enabled automatically
  105533. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105534. */
  105535. autoEnableWebVR?: boolean;
  105536. /**
  105537. * Defines if webgl2 should be turned off even if supported
  105538. * @see http://doc.babylonjs.com/features/webgl2
  105539. */
  105540. disableWebGL2Support?: boolean;
  105541. /**
  105542. * Defines if webaudio should be initialized as well
  105543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105544. */
  105545. audioEngine?: boolean;
  105546. /**
  105547. * Defines if animations should run using a deterministic lock step
  105548. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105549. */
  105550. deterministicLockstep?: boolean;
  105551. /** Defines the maximum steps to use with deterministic lock step mode */
  105552. lockstepMaxSteps?: number;
  105553. /** Defines the seconds between each deterministic lock step */
  105554. timeStep?: number;
  105555. /**
  105556. * Defines that engine should ignore context lost events
  105557. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  105558. */
  105559. doNotHandleContextLost?: boolean;
  105560. /**
  105561. * Defines that engine should ignore modifying touch action attribute and style
  105562. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  105563. */
  105564. doNotHandleTouchAction?: boolean;
  105565. /**
  105566. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  105567. */
  105568. useHighPrecisionFloats?: boolean;
  105569. }
  105570. /**
  105571. * The base engine class (root of all engines)
  105572. */
  105573. export class ThinEngine {
  105574. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  105575. static ExceptionList: ({
  105576. key: string;
  105577. capture: string;
  105578. captureConstraint: number;
  105579. targets: string[];
  105580. } | {
  105581. key: string;
  105582. capture: null;
  105583. captureConstraint: null;
  105584. targets: string[];
  105585. })[];
  105586. /** @hidden */
  105587. static _TextureLoaders: IInternalTextureLoader[];
  105588. /**
  105589. * Returns the current npm package of the sdk
  105590. */
  105591. static get NpmPackage(): string;
  105592. /**
  105593. * Returns the current version of the framework
  105594. */
  105595. static get Version(): string;
  105596. /**
  105597. * Returns a string describing the current engine
  105598. */
  105599. get description(): string;
  105600. /**
  105601. * Gets or sets the epsilon value used by collision engine
  105602. */
  105603. static CollisionsEpsilon: number;
  105604. /**
  105605. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105606. */
  105607. static get ShadersRepository(): string;
  105608. static set ShadersRepository(value: string);
  105609. /** @hidden */
  105610. _shaderProcessor: IShaderProcessor;
  105611. /**
  105612. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  105613. */
  105614. forcePOTTextures: boolean;
  105615. /**
  105616. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  105617. */
  105618. isFullscreen: boolean;
  105619. /**
  105620. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  105621. */
  105622. cullBackFaces: boolean;
  105623. /**
  105624. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  105625. */
  105626. renderEvenInBackground: boolean;
  105627. /**
  105628. * Gets or sets a boolean indicating that cache can be kept between frames
  105629. */
  105630. preventCacheWipeBetweenFrames: boolean;
  105631. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  105632. validateShaderPrograms: boolean;
  105633. /**
  105634. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  105635. * This can provide greater z depth for distant objects.
  105636. */
  105637. useReverseDepthBuffer: boolean;
  105638. /**
  105639. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  105640. */
  105641. disableUniformBuffers: boolean;
  105642. /** @hidden */
  105643. _uniformBuffers: UniformBuffer[];
  105644. /**
  105645. * Gets a boolean indicating that the engine supports uniform buffers
  105646. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  105647. */
  105648. get supportsUniformBuffers(): boolean;
  105649. /** @hidden */
  105650. _gl: WebGLRenderingContext;
  105651. /** @hidden */
  105652. _webGLVersion: number;
  105653. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  105654. protected _windowIsBackground: boolean;
  105655. protected _creationOptions: EngineOptions;
  105656. protected _highPrecisionShadersAllowed: boolean;
  105657. /** @hidden */
  105658. get _shouldUseHighPrecisionShader(): boolean;
  105659. /**
  105660. * Gets a boolean indicating that only power of 2 textures are supported
  105661. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  105662. */
  105663. get needPOTTextures(): boolean;
  105664. /** @hidden */
  105665. _badOS: boolean;
  105666. /** @hidden */
  105667. _badDesktopOS: boolean;
  105668. private _hardwareScalingLevel;
  105669. /** @hidden */
  105670. _caps: EngineCapabilities;
  105671. private _isStencilEnable;
  105672. private _glVersion;
  105673. private _glRenderer;
  105674. private _glVendor;
  105675. /** @hidden */
  105676. _videoTextureSupported: boolean;
  105677. protected _renderingQueueLaunched: boolean;
  105678. protected _activeRenderLoops: (() => void)[];
  105679. /**
  105680. * Observable signaled when a context lost event is raised
  105681. */
  105682. onContextLostObservable: Observable<ThinEngine>;
  105683. /**
  105684. * Observable signaled when a context restored event is raised
  105685. */
  105686. onContextRestoredObservable: Observable<ThinEngine>;
  105687. private _onContextLost;
  105688. private _onContextRestored;
  105689. protected _contextWasLost: boolean;
  105690. /** @hidden */
  105691. _doNotHandleContextLost: boolean;
  105692. /**
  105693. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  105694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  105695. */
  105696. get doNotHandleContextLost(): boolean;
  105697. set doNotHandleContextLost(value: boolean);
  105698. /**
  105699. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  105700. */
  105701. disableVertexArrayObjects: boolean;
  105702. /** @hidden */
  105703. protected _colorWrite: boolean;
  105704. /** @hidden */
  105705. protected _colorWriteChanged: boolean;
  105706. /** @hidden */
  105707. protected _depthCullingState: DepthCullingState;
  105708. /** @hidden */
  105709. protected _stencilState: StencilState;
  105710. /** @hidden */
  105711. _alphaState: AlphaState;
  105712. /** @hidden */
  105713. _alphaMode: number;
  105714. /** @hidden */
  105715. _alphaEquation: number;
  105716. /** @hidden */
  105717. _internalTexturesCache: InternalTexture[];
  105718. /** @hidden */
  105719. protected _activeChannel: number;
  105720. private _currentTextureChannel;
  105721. /** @hidden */
  105722. protected _boundTexturesCache: {
  105723. [key: string]: Nullable<InternalTexture>;
  105724. };
  105725. /** @hidden */
  105726. protected _currentEffect: Nullable<Effect>;
  105727. /** @hidden */
  105728. protected _currentProgram: Nullable<WebGLProgram>;
  105729. private _compiledEffects;
  105730. private _vertexAttribArraysEnabled;
  105731. /** @hidden */
  105732. protected _cachedViewport: Nullable<IViewportLike>;
  105733. private _cachedVertexArrayObject;
  105734. /** @hidden */
  105735. protected _cachedVertexBuffers: any;
  105736. /** @hidden */
  105737. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  105738. /** @hidden */
  105739. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  105740. /** @hidden */
  105741. _currentRenderTarget: Nullable<InternalTexture>;
  105742. private _uintIndicesCurrentlySet;
  105743. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  105744. /** @hidden */
  105745. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  105746. private _currentBufferPointers;
  105747. private _currentInstanceLocations;
  105748. private _currentInstanceBuffers;
  105749. private _textureUnits;
  105750. /** @hidden */
  105751. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105752. /** @hidden */
  105753. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105754. /** @hidden */
  105755. _boundRenderFunction: any;
  105756. private _vaoRecordInProgress;
  105757. private _mustWipeVertexAttributes;
  105758. private _emptyTexture;
  105759. private _emptyCubeTexture;
  105760. private _emptyTexture3D;
  105761. private _emptyTexture2DArray;
  105762. /** @hidden */
  105763. _frameHandler: number;
  105764. private _nextFreeTextureSlots;
  105765. private _maxSimultaneousTextures;
  105766. private _activeRequests;
  105767. /** @hidden */
  105768. _transformTextureUrl: Nullable<(url: string) => string>;
  105769. protected get _supportsHardwareTextureRescaling(): boolean;
  105770. private _framebufferDimensionsObject;
  105771. /**
  105772. * sets the object from which width and height will be taken from when getting render width and height
  105773. * Will fallback to the gl object
  105774. * @param dimensions the framebuffer width and height that will be used.
  105775. */
  105776. set framebufferDimensionsObject(dimensions: Nullable<{
  105777. framebufferWidth: number;
  105778. framebufferHeight: number;
  105779. }>);
  105780. /**
  105781. * Gets the current viewport
  105782. */
  105783. get currentViewport(): Nullable<IViewportLike>;
  105784. /**
  105785. * Gets the default empty texture
  105786. */
  105787. get emptyTexture(): InternalTexture;
  105788. /**
  105789. * Gets the default empty 3D texture
  105790. */
  105791. get emptyTexture3D(): InternalTexture;
  105792. /**
  105793. * Gets the default empty 2D array texture
  105794. */
  105795. get emptyTexture2DArray(): InternalTexture;
  105796. /**
  105797. * Gets the default empty cube texture
  105798. */
  105799. get emptyCubeTexture(): InternalTexture;
  105800. /**
  105801. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  105802. */
  105803. readonly premultipliedAlpha: boolean;
  105804. /**
  105805. * Observable event triggered before each texture is initialized
  105806. */
  105807. onBeforeTextureInitObservable: Observable<Texture>;
  105808. /**
  105809. * Creates a new engine
  105810. * @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
  105811. * @param antialias defines enable antialiasing (default: false)
  105812. * @param options defines further options to be sent to the getContext() function
  105813. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105814. */
  105815. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105816. private _rebuildInternalTextures;
  105817. private _rebuildEffects;
  105818. /**
  105819. * Gets a boolean indicating if all created effects are ready
  105820. * @returns true if all effects are ready
  105821. */
  105822. areAllEffectsReady(): boolean;
  105823. protected _rebuildBuffers(): void;
  105824. protected _initGLContext(): void;
  105825. /**
  105826. * Gets version of the current webGL context
  105827. */
  105828. get webGLVersion(): number;
  105829. /**
  105830. * Gets a string idenfifying the name of the class
  105831. * @returns "Engine" string
  105832. */
  105833. getClassName(): string;
  105834. /**
  105835. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  105836. */
  105837. get isStencilEnable(): boolean;
  105838. /** @hidden */
  105839. _prepareWorkingCanvas(): void;
  105840. /**
  105841. * Reset the texture cache to empty state
  105842. */
  105843. resetTextureCache(): void;
  105844. /**
  105845. * Gets an object containing information about the current webGL context
  105846. * @returns an object containing the vender, the renderer and the version of the current webGL context
  105847. */
  105848. getGlInfo(): {
  105849. vendor: string;
  105850. renderer: string;
  105851. version: string;
  105852. };
  105853. /**
  105854. * Defines the hardware scaling level.
  105855. * By default the hardware scaling level is computed from the window device ratio.
  105856. * 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.
  105857. * @param level defines the level to use
  105858. */
  105859. setHardwareScalingLevel(level: number): void;
  105860. /**
  105861. * Gets the current hardware scaling level.
  105862. * By default the hardware scaling level is computed from the window device ratio.
  105863. * 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.
  105864. * @returns a number indicating the current hardware scaling level
  105865. */
  105866. getHardwareScalingLevel(): number;
  105867. /**
  105868. * Gets the list of loaded textures
  105869. * @returns an array containing all loaded textures
  105870. */
  105871. getLoadedTexturesCache(): InternalTexture[];
  105872. /**
  105873. * Gets the object containing all engine capabilities
  105874. * @returns the EngineCapabilities object
  105875. */
  105876. getCaps(): EngineCapabilities;
  105877. /**
  105878. * stop executing a render loop function and remove it from the execution array
  105879. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  105880. */
  105881. stopRenderLoop(renderFunction?: () => void): void;
  105882. /** @hidden */
  105883. _renderLoop(): void;
  105884. /**
  105885. * Gets the HTML canvas attached with the current webGL context
  105886. * @returns a HTML canvas
  105887. */
  105888. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  105889. /**
  105890. * Gets host window
  105891. * @returns the host window object
  105892. */
  105893. getHostWindow(): Nullable<Window>;
  105894. /**
  105895. * Gets the current render width
  105896. * @param useScreen defines if screen size must be used (or the current render target if any)
  105897. * @returns a number defining the current render width
  105898. */
  105899. getRenderWidth(useScreen?: boolean): number;
  105900. /**
  105901. * Gets the current render height
  105902. * @param useScreen defines if screen size must be used (or the current render target if any)
  105903. * @returns a number defining the current render height
  105904. */
  105905. getRenderHeight(useScreen?: boolean): number;
  105906. /**
  105907. * Can be used to override the current requestAnimationFrame requester.
  105908. * @hidden
  105909. */
  105910. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105911. /**
  105912. * Register and execute a render loop. The engine can have more than one render function
  105913. * @param renderFunction defines the function to continuously execute
  105914. */
  105915. runRenderLoop(renderFunction: () => void): void;
  105916. /**
  105917. * Clear the current render buffer or the current render target (if any is set up)
  105918. * @param color defines the color to use
  105919. * @param backBuffer defines if the back buffer must be cleared
  105920. * @param depth defines if the depth buffer must be cleared
  105921. * @param stencil defines if the stencil buffer must be cleared
  105922. */
  105923. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105924. private _viewportCached;
  105925. /** @hidden */
  105926. _viewport(x: number, y: number, width: number, height: number): void;
  105927. /**
  105928. * Set the WebGL's viewport
  105929. * @param viewport defines the viewport element to be used
  105930. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105931. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105932. */
  105933. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105934. /**
  105935. * Begin a new frame
  105936. */
  105937. beginFrame(): void;
  105938. /**
  105939. * Enf the current frame
  105940. */
  105941. endFrame(): void;
  105942. /**
  105943. * Resize the view according to the canvas' size
  105944. */
  105945. resize(): void;
  105946. /**
  105947. * Force a specific size of the canvas
  105948. * @param width defines the new canvas' width
  105949. * @param height defines the new canvas' height
  105950. */
  105951. setSize(width: number, height: number): void;
  105952. /**
  105953. * Binds the frame buffer to the specified texture.
  105954. * @param texture The texture to render to or null for the default canvas
  105955. * @param faceIndex The face of the texture to render to in case of cube texture
  105956. * @param requiredWidth The width of the target to render to
  105957. * @param requiredHeight The height of the target to render to
  105958. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105959. * @param lodLevel defines the lod level to bind to the frame buffer
  105960. * @param layer defines the 2d array index to bind to frame buffer to
  105961. */
  105962. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105963. /** @hidden */
  105964. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105965. /**
  105966. * Unbind the current render target texture from the webGL context
  105967. * @param texture defines the render target texture to unbind
  105968. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105969. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105970. */
  105971. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105972. /**
  105973. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105974. */
  105975. flushFramebuffer(): void;
  105976. /**
  105977. * Unbind the current render target and bind the default framebuffer
  105978. */
  105979. restoreDefaultFramebuffer(): void;
  105980. /** @hidden */
  105981. protected _resetVertexBufferBinding(): void;
  105982. /**
  105983. * Creates a vertex buffer
  105984. * @param data the data for the vertex buffer
  105985. * @returns the new WebGL static buffer
  105986. */
  105987. createVertexBuffer(data: DataArray): DataBuffer;
  105988. private _createVertexBuffer;
  105989. /**
  105990. * Creates a dynamic vertex buffer
  105991. * @param data the data for the dynamic vertex buffer
  105992. * @returns the new WebGL dynamic buffer
  105993. */
  105994. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  105995. protected _resetIndexBufferBinding(): void;
  105996. /**
  105997. * Creates a new index buffer
  105998. * @param indices defines the content of the index buffer
  105999. * @param updatable defines if the index buffer must be updatable
  106000. * @returns a new webGL buffer
  106001. */
  106002. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  106003. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  106004. /**
  106005. * Bind a webGL buffer to the webGL context
  106006. * @param buffer defines the buffer to bind
  106007. */
  106008. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  106009. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  106010. private bindBuffer;
  106011. /**
  106012. * update the bound buffer with the given data
  106013. * @param data defines the data to update
  106014. */
  106015. updateArrayBuffer(data: Float32Array): void;
  106016. private _vertexAttribPointer;
  106017. /** @hidden */
  106018. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  106019. private _bindVertexBuffersAttributes;
  106020. /**
  106021. * Records a vertex array object
  106022. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106023. * @param vertexBuffers defines the list of vertex buffers to store
  106024. * @param indexBuffer defines the index buffer to store
  106025. * @param effect defines the effect to store
  106026. * @returns the new vertex array object
  106027. */
  106028. recordVertexArrayObject(vertexBuffers: {
  106029. [key: string]: VertexBuffer;
  106030. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  106031. /**
  106032. * Bind a specific vertex array object
  106033. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106034. * @param vertexArrayObject defines the vertex array object to bind
  106035. * @param indexBuffer defines the index buffer to bind
  106036. */
  106037. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  106038. /**
  106039. * Bind webGl buffers directly to the webGL context
  106040. * @param vertexBuffer defines the vertex buffer to bind
  106041. * @param indexBuffer defines the index buffer to bind
  106042. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  106043. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  106044. * @param effect defines the effect associated with the vertex buffer
  106045. */
  106046. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  106047. private _unbindVertexArrayObject;
  106048. /**
  106049. * Bind a list of vertex buffers to the webGL context
  106050. * @param vertexBuffers defines the list of vertex buffers to bind
  106051. * @param indexBuffer defines the index buffer to bind
  106052. * @param effect defines the effect associated with the vertex buffers
  106053. */
  106054. bindBuffers(vertexBuffers: {
  106055. [key: string]: Nullable<VertexBuffer>;
  106056. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  106057. /**
  106058. * Unbind all instance attributes
  106059. */
  106060. unbindInstanceAttributes(): void;
  106061. /**
  106062. * Release and free the memory of a vertex array object
  106063. * @param vao defines the vertex array object to delete
  106064. */
  106065. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  106066. /** @hidden */
  106067. _releaseBuffer(buffer: DataBuffer): boolean;
  106068. protected _deleteBuffer(buffer: DataBuffer): void;
  106069. /**
  106070. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  106071. * @param instancesBuffer defines the webGL buffer to update and bind
  106072. * @param data defines the data to store in the buffer
  106073. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  106074. */
  106075. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  106076. /**
  106077. * Bind the content of a webGL buffer used with instantiation
  106078. * @param instancesBuffer defines the webGL buffer to bind
  106079. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  106080. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  106081. */
  106082. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  106083. /**
  106084. * Disable the instance attribute corresponding to the name in parameter
  106085. * @param name defines the name of the attribute to disable
  106086. */
  106087. disableInstanceAttributeByName(name: string): void;
  106088. /**
  106089. * Disable the instance attribute corresponding to the location in parameter
  106090. * @param attributeLocation defines the attribute location of the attribute to disable
  106091. */
  106092. disableInstanceAttribute(attributeLocation: number): void;
  106093. /**
  106094. * Disable the attribute corresponding to the location in parameter
  106095. * @param attributeLocation defines the attribute location of the attribute to disable
  106096. */
  106097. disableAttributeByIndex(attributeLocation: number): void;
  106098. /**
  106099. * Send a draw order
  106100. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106101. * @param indexStart defines the starting index
  106102. * @param indexCount defines the number of index to draw
  106103. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106104. */
  106105. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106106. /**
  106107. * Draw a list of points
  106108. * @param verticesStart defines the index of first vertex to draw
  106109. * @param verticesCount defines the count of vertices to draw
  106110. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106111. */
  106112. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106113. /**
  106114. * Draw a list of unindexed primitives
  106115. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106116. * @param verticesStart defines the index of first vertex to draw
  106117. * @param verticesCount defines the count of vertices to draw
  106118. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106119. */
  106120. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106121. /**
  106122. * Draw a list of indexed primitives
  106123. * @param fillMode defines the primitive to use
  106124. * @param indexStart defines the starting index
  106125. * @param indexCount defines the number of index to draw
  106126. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106127. */
  106128. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106129. /**
  106130. * Draw a list of unindexed primitives
  106131. * @param fillMode defines the primitive to use
  106132. * @param verticesStart defines the index of first vertex to draw
  106133. * @param verticesCount defines the count of vertices to draw
  106134. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106135. */
  106136. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106137. private _drawMode;
  106138. /** @hidden */
  106139. protected _reportDrawCall(): void;
  106140. /** @hidden */
  106141. _releaseEffect(effect: Effect): void;
  106142. /** @hidden */
  106143. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106144. /**
  106145. * Create a new effect (used to store vertex/fragment shaders)
  106146. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  106147. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  106148. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  106149. * @param samplers defines an array of string used to represent textures
  106150. * @param defines defines the string containing the defines to use to compile the shaders
  106151. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106152. * @param onCompiled defines a function to call when the effect creation is successful
  106153. * @param onError defines a function to call when the effect creation has failed
  106154. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  106155. * @returns the new Effect
  106156. */
  106157. 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;
  106158. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  106159. private _compileShader;
  106160. private _compileRawShader;
  106161. /** @hidden */
  106162. _getShaderSource(shader: WebGLShader): Nullable<string>;
  106163. /**
  106164. * Directly creates a webGL program
  106165. * @param pipelineContext defines the pipeline context to attach to
  106166. * @param vertexCode defines the vertex shader code to use
  106167. * @param fragmentCode defines the fragment shader code to use
  106168. * @param context defines the webGL context to use (if not set, the current one will be used)
  106169. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106170. * @returns the new webGL program
  106171. */
  106172. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106173. /**
  106174. * Creates a webGL program
  106175. * @param pipelineContext defines the pipeline context to attach to
  106176. * @param vertexCode defines the vertex shader code to use
  106177. * @param fragmentCode defines the fragment shader code to use
  106178. * @param defines defines the string containing the defines to use to compile the shaders
  106179. * @param context defines the webGL context to use (if not set, the current one will be used)
  106180. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106181. * @returns the new webGL program
  106182. */
  106183. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106184. /**
  106185. * Creates a new pipeline context
  106186. * @returns the new pipeline
  106187. */
  106188. createPipelineContext(): IPipelineContext;
  106189. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106190. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  106191. /** @hidden */
  106192. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  106193. /** @hidden */
  106194. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  106195. /** @hidden */
  106196. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  106197. /**
  106198. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  106199. * @param pipelineContext defines the pipeline context to use
  106200. * @param uniformsNames defines the list of uniform names
  106201. * @returns an array of webGL uniform locations
  106202. */
  106203. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106204. /**
  106205. * Gets the lsit of active attributes for a given webGL program
  106206. * @param pipelineContext defines the pipeline context to use
  106207. * @param attributesNames defines the list of attribute names to get
  106208. * @returns an array of indices indicating the offset of each attribute
  106209. */
  106210. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106211. /**
  106212. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  106213. * @param effect defines the effect to activate
  106214. */
  106215. enableEffect(effect: Nullable<Effect>): void;
  106216. /**
  106217. * Set the value of an uniform to a number (int)
  106218. * @param uniform defines the webGL uniform location where to store the value
  106219. * @param value defines the int number to store
  106220. */
  106221. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106222. /**
  106223. * Set the value of an uniform to an array of int32
  106224. * @param uniform defines the webGL uniform location where to store the value
  106225. * @param array defines the array of int32 to store
  106226. */
  106227. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106228. /**
  106229. * Set the value of an uniform to an array of int32 (stored as vec2)
  106230. * @param uniform defines the webGL uniform location where to store the value
  106231. * @param array defines the array of int32 to store
  106232. */
  106233. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106234. /**
  106235. * Set the value of an uniform to an array of int32 (stored as vec3)
  106236. * @param uniform defines the webGL uniform location where to store the value
  106237. * @param array defines the array of int32 to store
  106238. */
  106239. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106240. /**
  106241. * Set the value of an uniform to an array of int32 (stored as vec4)
  106242. * @param uniform defines the webGL uniform location where to store the value
  106243. * @param array defines the array of int32 to store
  106244. */
  106245. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106246. /**
  106247. * Set the value of an uniform to an array of number
  106248. * @param uniform defines the webGL uniform location where to store the value
  106249. * @param array defines the array of number to store
  106250. */
  106251. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106252. /**
  106253. * Set the value of an uniform to an array of number (stored as vec2)
  106254. * @param uniform defines the webGL uniform location where to store the value
  106255. * @param array defines the array of number to store
  106256. */
  106257. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106258. /**
  106259. * Set the value of an uniform to an array of number (stored as vec3)
  106260. * @param uniform defines the webGL uniform location where to store the value
  106261. * @param array defines the array of number to store
  106262. */
  106263. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106264. /**
  106265. * Set the value of an uniform to an array of number (stored as vec4)
  106266. * @param uniform defines the webGL uniform location where to store the value
  106267. * @param array defines the array of number to store
  106268. */
  106269. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106270. /**
  106271. * Set the value of an uniform to an array of float32 (stored as matrices)
  106272. * @param uniform defines the webGL uniform location where to store the value
  106273. * @param matrices defines the array of float32 to store
  106274. */
  106275. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  106276. /**
  106277. * Set the value of an uniform to a matrix (3x3)
  106278. * @param uniform defines the webGL uniform location where to store the value
  106279. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  106280. */
  106281. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106282. /**
  106283. * Set the value of an uniform to a matrix (2x2)
  106284. * @param uniform defines the webGL uniform location where to store the value
  106285. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  106286. */
  106287. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106288. /**
  106289. * Set the value of an uniform to a number (float)
  106290. * @param uniform defines the webGL uniform location where to store the value
  106291. * @param value defines the float number to store
  106292. */
  106293. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106294. /**
  106295. * Set the value of an uniform to a vec2
  106296. * @param uniform defines the webGL uniform location where to store the value
  106297. * @param x defines the 1st component of the value
  106298. * @param y defines the 2nd component of the value
  106299. */
  106300. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  106301. /**
  106302. * Set the value of an uniform to a vec3
  106303. * @param uniform defines the webGL uniform location where to store the value
  106304. * @param x defines the 1st component of the value
  106305. * @param y defines the 2nd component of the value
  106306. * @param z defines the 3rd component of the value
  106307. */
  106308. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  106309. /**
  106310. * Set the value of an uniform to a vec4
  106311. * @param uniform defines the webGL uniform location where to store the value
  106312. * @param x defines the 1st component of the value
  106313. * @param y defines the 2nd component of the value
  106314. * @param z defines the 3rd component of the value
  106315. * @param w defines the 4th component of the value
  106316. */
  106317. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  106318. /**
  106319. * Apply all cached states (depth, culling, stencil and alpha)
  106320. */
  106321. applyStates(): void;
  106322. /**
  106323. * Enable or disable color writing
  106324. * @param enable defines the state to set
  106325. */
  106326. setColorWrite(enable: boolean): void;
  106327. /**
  106328. * Gets a boolean indicating if color writing is enabled
  106329. * @returns the current color writing state
  106330. */
  106331. getColorWrite(): boolean;
  106332. /**
  106333. * Gets the depth culling state manager
  106334. */
  106335. get depthCullingState(): DepthCullingState;
  106336. /**
  106337. * Gets the alpha state manager
  106338. */
  106339. get alphaState(): AlphaState;
  106340. /**
  106341. * Gets the stencil state manager
  106342. */
  106343. get stencilState(): StencilState;
  106344. /**
  106345. * Clears the list of texture accessible through engine.
  106346. * This can help preventing texture load conflict due to name collision.
  106347. */
  106348. clearInternalTexturesCache(): void;
  106349. /**
  106350. * Force the entire cache to be cleared
  106351. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  106352. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  106353. */
  106354. wipeCaches(bruteForce?: boolean): void;
  106355. /** @hidden */
  106356. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  106357. min: number;
  106358. mag: number;
  106359. };
  106360. /** @hidden */
  106361. _createTexture(): WebGLTexture;
  106362. /**
  106363. * Usually called from Texture.ts.
  106364. * Passed information to create a WebGLTexture
  106365. * @param url defines a value which contains one of the following:
  106366. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  106367. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  106368. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  106369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  106370. * @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)
  106371. * @param scene needed for loading to the correct scene
  106372. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  106373. * @param onLoad optional callback to be called upon successful completion
  106374. * @param onError optional callback to be called upon failure
  106375. * @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
  106376. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  106377. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  106378. * @param forcedExtension defines the extension to use to pick the right loader
  106379. * @param mimeType defines an optional mime type
  106380. * @returns a InternalTexture for assignment back into BABYLON.Texture
  106381. */
  106382. 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;
  106383. /**
  106384. * Loads an image as an HTMLImageElement.
  106385. * @param input url string, ArrayBuffer, or Blob to load
  106386. * @param onLoad callback called when the image successfully loads
  106387. * @param onError callback called when the image fails to load
  106388. * @param offlineProvider offline provider for caching
  106389. * @param mimeType optional mime type
  106390. * @returns the HTMLImageElement of the loaded image
  106391. * @hidden
  106392. */
  106393. 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>;
  106394. /**
  106395. * @hidden
  106396. */
  106397. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106398. /**
  106399. * Creates a raw texture
  106400. * @param data defines the data to store in the texture
  106401. * @param width defines the width of the texture
  106402. * @param height defines the height of the texture
  106403. * @param format defines the format of the data
  106404. * @param generateMipMaps defines if the engine should generate the mip levels
  106405. * @param invertY defines if data must be stored with Y axis inverted
  106406. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  106407. * @param compression defines the compression used (null by default)
  106408. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106409. * @returns the raw texture inside an InternalTexture
  106410. */
  106411. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  106412. /**
  106413. * Creates a new raw cube texture
  106414. * @param data defines the array of data to use to create each face
  106415. * @param size defines the size of the textures
  106416. * @param format defines the format of the data
  106417. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106418. * @param generateMipMaps defines if the engine should generate the mip levels
  106419. * @param invertY defines if data must be stored with Y axis inverted
  106420. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106421. * @param compression defines the compression used (null by default)
  106422. * @returns the cube texture as an InternalTexture
  106423. */
  106424. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  106425. /**
  106426. * Creates a new raw 3D texture
  106427. * @param data defines the data used to create the texture
  106428. * @param width defines the width of the texture
  106429. * @param height defines the height of the texture
  106430. * @param depth defines the depth of the texture
  106431. * @param format defines the format of the texture
  106432. * @param generateMipMaps defines if the engine must generate mip levels
  106433. * @param invertY defines if data must be stored with Y axis inverted
  106434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106435. * @param compression defines the compressed used (can be null)
  106436. * @param textureType defines the compressed used (can be null)
  106437. * @returns a new raw 3D texture (stored in an InternalTexture)
  106438. */
  106439. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106440. /**
  106441. * Creates a new raw 2D array texture
  106442. * @param data defines the data used to create the texture
  106443. * @param width defines the width of the texture
  106444. * @param height defines the height of the texture
  106445. * @param depth defines the number of layers of the texture
  106446. * @param format defines the format of the texture
  106447. * @param generateMipMaps defines if the engine must generate mip levels
  106448. * @param invertY defines if data must be stored with Y axis inverted
  106449. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106450. * @param compression defines the compressed used (can be null)
  106451. * @param textureType defines the compressed used (can be null)
  106452. * @returns a new raw 2D array texture (stored in an InternalTexture)
  106453. */
  106454. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106455. private _unpackFlipYCached;
  106456. /**
  106457. * In case you are sharing the context with other applications, it might
  106458. * be interested to not cache the unpack flip y state to ensure a consistent
  106459. * value would be set.
  106460. */
  106461. enableUnpackFlipYCached: boolean;
  106462. /** @hidden */
  106463. _unpackFlipY(value: boolean): void;
  106464. /** @hidden */
  106465. _getUnpackAlignement(): number;
  106466. private _getTextureTarget;
  106467. /**
  106468. * Update the sampling mode of a given texture
  106469. * @param samplingMode defines the required sampling mode
  106470. * @param texture defines the texture to update
  106471. * @param generateMipMaps defines whether to generate mipmaps for the texture
  106472. */
  106473. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  106474. /**
  106475. * Update the sampling mode of a given texture
  106476. * @param texture defines the texture to update
  106477. * @param wrapU defines the texture wrap mode of the u coordinates
  106478. * @param wrapV defines the texture wrap mode of the v coordinates
  106479. * @param wrapR defines the texture wrap mode of the r coordinates
  106480. */
  106481. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  106482. /** @hidden */
  106483. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  106484. width: number;
  106485. height: number;
  106486. layers?: number;
  106487. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  106488. /** @hidden */
  106489. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106490. /** @hidden */
  106491. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  106492. /**
  106493. * Update a portion of an internal texture
  106494. * @param texture defines the texture to update
  106495. * @param imageData defines the data to store into the texture
  106496. * @param xOffset defines the x coordinates of the update rectangle
  106497. * @param yOffset defines the y coordinates of the update rectangle
  106498. * @param width defines the width of the update rectangle
  106499. * @param height defines the height of the update rectangle
  106500. * @param faceIndex defines the face index if texture is a cube (0 by default)
  106501. * @param lod defines the lod level to update (0 by default)
  106502. */
  106503. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  106504. /** @hidden */
  106505. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106506. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  106507. private _prepareWebGLTexture;
  106508. /** @hidden */
  106509. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  106510. private _getDepthStencilBuffer;
  106511. /** @hidden */
  106512. _releaseFramebufferObjects(texture: InternalTexture): void;
  106513. /** @hidden */
  106514. _releaseTexture(texture: InternalTexture): void;
  106515. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  106516. protected _setProgram(program: WebGLProgram): void;
  106517. protected _boundUniforms: {
  106518. [key: number]: WebGLUniformLocation;
  106519. };
  106520. /**
  106521. * Binds an effect to the webGL context
  106522. * @param effect defines the effect to bind
  106523. */
  106524. bindSamplers(effect: Effect): void;
  106525. private _activateCurrentTexture;
  106526. /** @hidden */
  106527. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  106528. /** @hidden */
  106529. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  106530. /**
  106531. * Unbind all textures from the webGL context
  106532. */
  106533. unbindAllTextures(): void;
  106534. /**
  106535. * Sets a texture to the according uniform.
  106536. * @param channel The texture channel
  106537. * @param uniform The uniform to set
  106538. * @param texture The texture to apply
  106539. */
  106540. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  106541. private _bindSamplerUniformToChannel;
  106542. private _getTextureWrapMode;
  106543. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  106544. /**
  106545. * Sets an array of texture to the webGL context
  106546. * @param channel defines the channel where the texture array must be set
  106547. * @param uniform defines the associated uniform location
  106548. * @param textures defines the array of textures to bind
  106549. */
  106550. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  106551. /** @hidden */
  106552. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  106553. private _setTextureParameterFloat;
  106554. private _setTextureParameterInteger;
  106555. /**
  106556. * Unbind all vertex attributes from the webGL context
  106557. */
  106558. unbindAllAttributes(): void;
  106559. /**
  106560. * 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
  106561. */
  106562. releaseEffects(): void;
  106563. /**
  106564. * Dispose and release all associated resources
  106565. */
  106566. dispose(): void;
  106567. /**
  106568. * Attach a new callback raised when context lost event is fired
  106569. * @param callback defines the callback to call
  106570. */
  106571. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106572. /**
  106573. * Attach a new callback raised when context restored event is fired
  106574. * @param callback defines the callback to call
  106575. */
  106576. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106577. /**
  106578. * Get the current error code of the webGL context
  106579. * @returns the error code
  106580. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106581. */
  106582. getError(): number;
  106583. private _canRenderToFloatFramebuffer;
  106584. private _canRenderToHalfFloatFramebuffer;
  106585. private _canRenderToFramebuffer;
  106586. /** @hidden */
  106587. _getWebGLTextureType(type: number): number;
  106588. /** @hidden */
  106589. _getInternalFormat(format: number): number;
  106590. /** @hidden */
  106591. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  106592. /** @hidden */
  106593. _getRGBAMultiSampleBufferFormat(type: number): number;
  106594. /** @hidden */
  106595. _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;
  106596. /**
  106597. * Loads a file from a url
  106598. * @param url url to load
  106599. * @param onSuccess callback called when the file successfully loads
  106600. * @param onProgress callback called while file is loading (if the server supports this mode)
  106601. * @param offlineProvider defines the offline provider for caching
  106602. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106603. * @param onError callback called when the file fails to load
  106604. * @returns a file request object
  106605. * @hidden
  106606. */
  106607. 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;
  106608. /**
  106609. * Reads pixels from the current frame buffer. Please note that this function can be slow
  106610. * @param x defines the x coordinate of the rectangle where pixels must be read
  106611. * @param y defines the y coordinate of the rectangle where pixels must be read
  106612. * @param width defines the width of the rectangle where pixels must be read
  106613. * @param height defines the height of the rectangle where pixels must be read
  106614. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  106615. * @returns a Uint8Array containing RGBA colors
  106616. */
  106617. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  106618. private static _isSupported;
  106619. /**
  106620. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  106621. * @returns true if the engine can be created
  106622. * @ignorenaming
  106623. */
  106624. static isSupported(): boolean;
  106625. /**
  106626. * Find the next highest power of two.
  106627. * @param x Number to start search from.
  106628. * @return Next highest power of two.
  106629. */
  106630. static CeilingPOT(x: number): number;
  106631. /**
  106632. * Find the next lowest power of two.
  106633. * @param x Number to start search from.
  106634. * @return Next lowest power of two.
  106635. */
  106636. static FloorPOT(x: number): number;
  106637. /**
  106638. * Find the nearest power of two.
  106639. * @param x Number to start search from.
  106640. * @return Next nearest power of two.
  106641. */
  106642. static NearestPOT(x: number): number;
  106643. /**
  106644. * Get the closest exponent of two
  106645. * @param value defines the value to approximate
  106646. * @param max defines the maximum value to return
  106647. * @param mode defines how to define the closest value
  106648. * @returns closest exponent of two of the given value
  106649. */
  106650. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  106651. /**
  106652. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  106653. * @param func - the function to be called
  106654. * @param requester - the object that will request the next frame. Falls back to window.
  106655. * @returns frame number
  106656. */
  106657. static QueueNewFrame(func: () => void, requester?: any): number;
  106658. /**
  106659. * Gets host document
  106660. * @returns the host document object
  106661. */
  106662. getHostDocument(): Nullable<Document>;
  106663. }
  106664. }
  106665. declare module BABYLON {
  106666. /**
  106667. * Class representing spherical harmonics coefficients to the 3rd degree
  106668. */
  106669. export class SphericalHarmonics {
  106670. /**
  106671. * Defines whether or not the harmonics have been prescaled for rendering.
  106672. */
  106673. preScaled: boolean;
  106674. /**
  106675. * The l0,0 coefficients of the spherical harmonics
  106676. */
  106677. l00: Vector3;
  106678. /**
  106679. * The l1,-1 coefficients of the spherical harmonics
  106680. */
  106681. l1_1: Vector3;
  106682. /**
  106683. * The l1,0 coefficients of the spherical harmonics
  106684. */
  106685. l10: Vector3;
  106686. /**
  106687. * The l1,1 coefficients of the spherical harmonics
  106688. */
  106689. l11: Vector3;
  106690. /**
  106691. * The l2,-2 coefficients of the spherical harmonics
  106692. */
  106693. l2_2: Vector3;
  106694. /**
  106695. * The l2,-1 coefficients of the spherical harmonics
  106696. */
  106697. l2_1: Vector3;
  106698. /**
  106699. * The l2,0 coefficients of the spherical harmonics
  106700. */
  106701. l20: Vector3;
  106702. /**
  106703. * The l2,1 coefficients of the spherical harmonics
  106704. */
  106705. l21: Vector3;
  106706. /**
  106707. * The l2,2 coefficients of the spherical harmonics
  106708. */
  106709. l22: Vector3;
  106710. /**
  106711. * Adds a light to the spherical harmonics
  106712. * @param direction the direction of the light
  106713. * @param color the color of the light
  106714. * @param deltaSolidAngle the delta solid angle of the light
  106715. */
  106716. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106717. /**
  106718. * Scales the spherical harmonics by the given amount
  106719. * @param scale the amount to scale
  106720. */
  106721. scaleInPlace(scale: number): void;
  106722. /**
  106723. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106724. *
  106725. * ```
  106726. * E_lm = A_l * L_lm
  106727. * ```
  106728. *
  106729. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106730. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106731. * the scaling factors are given in equation 9.
  106732. */
  106733. convertIncidentRadianceToIrradiance(): void;
  106734. /**
  106735. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106736. *
  106737. * ```
  106738. * L = (1/pi) * E * rho
  106739. * ```
  106740. *
  106741. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106742. */
  106743. convertIrradianceToLambertianRadiance(): void;
  106744. /**
  106745. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106746. * required operations at run time.
  106747. *
  106748. * This is simply done by scaling back the SH with Ylm constants parameter.
  106749. * The trigonometric part being applied by the shader at run time.
  106750. */
  106751. preScaleForRendering(): void;
  106752. /**
  106753. * Constructs a spherical harmonics from an array.
  106754. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106755. * @returns the spherical harmonics
  106756. */
  106757. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106758. /**
  106759. * Gets the spherical harmonics from polynomial
  106760. * @param polynomial the spherical polynomial
  106761. * @returns the spherical harmonics
  106762. */
  106763. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106764. }
  106765. /**
  106766. * Class representing spherical polynomial coefficients to the 3rd degree
  106767. */
  106768. export class SphericalPolynomial {
  106769. private _harmonics;
  106770. /**
  106771. * The spherical harmonics used to create the polynomials.
  106772. */
  106773. get preScaledHarmonics(): SphericalHarmonics;
  106774. /**
  106775. * The x coefficients of the spherical polynomial
  106776. */
  106777. x: Vector3;
  106778. /**
  106779. * The y coefficients of the spherical polynomial
  106780. */
  106781. y: Vector3;
  106782. /**
  106783. * The z coefficients of the spherical polynomial
  106784. */
  106785. z: Vector3;
  106786. /**
  106787. * The xx coefficients of the spherical polynomial
  106788. */
  106789. xx: Vector3;
  106790. /**
  106791. * The yy coefficients of the spherical polynomial
  106792. */
  106793. yy: Vector3;
  106794. /**
  106795. * The zz coefficients of the spherical polynomial
  106796. */
  106797. zz: Vector3;
  106798. /**
  106799. * The xy coefficients of the spherical polynomial
  106800. */
  106801. xy: Vector3;
  106802. /**
  106803. * The yz coefficients of the spherical polynomial
  106804. */
  106805. yz: Vector3;
  106806. /**
  106807. * The zx coefficients of the spherical polynomial
  106808. */
  106809. zx: Vector3;
  106810. /**
  106811. * Adds an ambient color to the spherical polynomial
  106812. * @param color the color to add
  106813. */
  106814. addAmbient(color: Color3): void;
  106815. /**
  106816. * Scales the spherical polynomial by the given amount
  106817. * @param scale the amount to scale
  106818. */
  106819. scaleInPlace(scale: number): void;
  106820. /**
  106821. * Gets the spherical polynomial from harmonics
  106822. * @param harmonics the spherical harmonics
  106823. * @returns the spherical polynomial
  106824. */
  106825. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106826. /**
  106827. * Constructs a spherical polynomial from an array.
  106828. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106829. * @returns the spherical polynomial
  106830. */
  106831. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106832. }
  106833. }
  106834. declare module BABYLON {
  106835. /**
  106836. * Defines the source of the internal texture
  106837. */
  106838. export enum InternalTextureSource {
  106839. /**
  106840. * The source of the texture data is unknown
  106841. */
  106842. Unknown = 0,
  106843. /**
  106844. * Texture data comes from an URL
  106845. */
  106846. Url = 1,
  106847. /**
  106848. * Texture data is only used for temporary storage
  106849. */
  106850. Temp = 2,
  106851. /**
  106852. * Texture data comes from raw data (ArrayBuffer)
  106853. */
  106854. Raw = 3,
  106855. /**
  106856. * Texture content is dynamic (video or dynamic texture)
  106857. */
  106858. Dynamic = 4,
  106859. /**
  106860. * Texture content is generated by rendering to it
  106861. */
  106862. RenderTarget = 5,
  106863. /**
  106864. * Texture content is part of a multi render target process
  106865. */
  106866. MultiRenderTarget = 6,
  106867. /**
  106868. * Texture data comes from a cube data file
  106869. */
  106870. Cube = 7,
  106871. /**
  106872. * Texture data comes from a raw cube data
  106873. */
  106874. CubeRaw = 8,
  106875. /**
  106876. * Texture data come from a prefiltered cube data file
  106877. */
  106878. CubePrefiltered = 9,
  106879. /**
  106880. * Texture content is raw 3D data
  106881. */
  106882. Raw3D = 10,
  106883. /**
  106884. * Texture content is raw 2D array data
  106885. */
  106886. Raw2DArray = 11,
  106887. /**
  106888. * Texture content is a depth texture
  106889. */
  106890. Depth = 12,
  106891. /**
  106892. * Texture data comes from a raw cube data encoded with RGBD
  106893. */
  106894. CubeRawRGBD = 13
  106895. }
  106896. /**
  106897. * Class used to store data associated with WebGL texture data for the engine
  106898. * This class should not be used directly
  106899. */
  106900. export class InternalTexture {
  106901. /** @hidden */
  106902. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  106903. /**
  106904. * Defines if the texture is ready
  106905. */
  106906. isReady: boolean;
  106907. /**
  106908. * Defines if the texture is a cube texture
  106909. */
  106910. isCube: boolean;
  106911. /**
  106912. * Defines if the texture contains 3D data
  106913. */
  106914. is3D: boolean;
  106915. /**
  106916. * Defines if the texture contains 2D array data
  106917. */
  106918. is2DArray: boolean;
  106919. /**
  106920. * Defines if the texture contains multiview data
  106921. */
  106922. isMultiview: boolean;
  106923. /**
  106924. * Gets the URL used to load this texture
  106925. */
  106926. url: string;
  106927. /**
  106928. * Gets the sampling mode of the texture
  106929. */
  106930. samplingMode: number;
  106931. /**
  106932. * Gets a boolean indicating if the texture needs mipmaps generation
  106933. */
  106934. generateMipMaps: boolean;
  106935. /**
  106936. * Gets the number of samples used by the texture (WebGL2+ only)
  106937. */
  106938. samples: number;
  106939. /**
  106940. * Gets the type of the texture (int, float...)
  106941. */
  106942. type: number;
  106943. /**
  106944. * Gets the format of the texture (RGB, RGBA...)
  106945. */
  106946. format: number;
  106947. /**
  106948. * Observable called when the texture is loaded
  106949. */
  106950. onLoadedObservable: Observable<InternalTexture>;
  106951. /**
  106952. * Gets the width of the texture
  106953. */
  106954. width: number;
  106955. /**
  106956. * Gets the height of the texture
  106957. */
  106958. height: number;
  106959. /**
  106960. * Gets the depth of the texture
  106961. */
  106962. depth: number;
  106963. /**
  106964. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106965. */
  106966. baseWidth: number;
  106967. /**
  106968. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106969. */
  106970. baseHeight: number;
  106971. /**
  106972. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106973. */
  106974. baseDepth: number;
  106975. /**
  106976. * Gets a boolean indicating if the texture is inverted on Y axis
  106977. */
  106978. invertY: boolean;
  106979. /** @hidden */
  106980. _invertVScale: boolean;
  106981. /** @hidden */
  106982. _associatedChannel: number;
  106983. /** @hidden */
  106984. _source: InternalTextureSource;
  106985. /** @hidden */
  106986. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106987. /** @hidden */
  106988. _bufferView: Nullable<ArrayBufferView>;
  106989. /** @hidden */
  106990. _bufferViewArray: Nullable<ArrayBufferView[]>;
  106991. /** @hidden */
  106992. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  106993. /** @hidden */
  106994. _size: number;
  106995. /** @hidden */
  106996. _extension: string;
  106997. /** @hidden */
  106998. _files: Nullable<string[]>;
  106999. /** @hidden */
  107000. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107001. /** @hidden */
  107002. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107003. /** @hidden */
  107004. _framebuffer: Nullable<WebGLFramebuffer>;
  107005. /** @hidden */
  107006. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  107007. /** @hidden */
  107008. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  107009. /** @hidden */
  107010. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  107011. /** @hidden */
  107012. _attachments: Nullable<number[]>;
  107013. /** @hidden */
  107014. _cachedCoordinatesMode: Nullable<number>;
  107015. /** @hidden */
  107016. _cachedWrapU: Nullable<number>;
  107017. /** @hidden */
  107018. _cachedWrapV: Nullable<number>;
  107019. /** @hidden */
  107020. _cachedWrapR: Nullable<number>;
  107021. /** @hidden */
  107022. _cachedAnisotropicFilteringLevel: Nullable<number>;
  107023. /** @hidden */
  107024. _isDisabled: boolean;
  107025. /** @hidden */
  107026. _compression: Nullable<string>;
  107027. /** @hidden */
  107028. _generateStencilBuffer: boolean;
  107029. /** @hidden */
  107030. _generateDepthBuffer: boolean;
  107031. /** @hidden */
  107032. _comparisonFunction: number;
  107033. /** @hidden */
  107034. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  107035. /** @hidden */
  107036. _lodGenerationScale: number;
  107037. /** @hidden */
  107038. _lodGenerationOffset: number;
  107039. /** @hidden */
  107040. _depthStencilTexture: Nullable<InternalTexture>;
  107041. /** @hidden */
  107042. _colorTextureArray: Nullable<WebGLTexture>;
  107043. /** @hidden */
  107044. _depthStencilTextureArray: Nullable<WebGLTexture>;
  107045. /** @hidden */
  107046. _lodTextureHigh: Nullable<BaseTexture>;
  107047. /** @hidden */
  107048. _lodTextureMid: Nullable<BaseTexture>;
  107049. /** @hidden */
  107050. _lodTextureLow: Nullable<BaseTexture>;
  107051. /** @hidden */
  107052. _isRGBD: boolean;
  107053. /** @hidden */
  107054. _linearSpecularLOD: boolean;
  107055. /** @hidden */
  107056. _irradianceTexture: Nullable<BaseTexture>;
  107057. /** @hidden */
  107058. _webGLTexture: Nullable<WebGLTexture>;
  107059. /** @hidden */
  107060. _references: number;
  107061. private _engine;
  107062. /**
  107063. * Gets the Engine the texture belongs to.
  107064. * @returns The babylon engine
  107065. */
  107066. getEngine(): ThinEngine;
  107067. /**
  107068. * Gets the data source type of the texture
  107069. */
  107070. get source(): InternalTextureSource;
  107071. /**
  107072. * Creates a new InternalTexture
  107073. * @param engine defines the engine to use
  107074. * @param source defines the type of data that will be used
  107075. * @param delayAllocation if the texture allocation should be delayed (default: false)
  107076. */
  107077. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  107078. /**
  107079. * Increments the number of references (ie. the number of Texture that point to it)
  107080. */
  107081. incrementReferences(): void;
  107082. /**
  107083. * Change the size of the texture (not the size of the content)
  107084. * @param width defines the new width
  107085. * @param height defines the new height
  107086. * @param depth defines the new depth (1 by default)
  107087. */
  107088. updateSize(width: int, height: int, depth?: int): void;
  107089. /** @hidden */
  107090. _rebuild(): void;
  107091. /** @hidden */
  107092. _swapAndDie(target: InternalTexture): void;
  107093. /**
  107094. * Dispose the current allocated resources
  107095. */
  107096. dispose(): void;
  107097. }
  107098. }
  107099. declare module BABYLON {
  107100. /**
  107101. * Class used to work with sound analyzer using fast fourier transform (FFT)
  107102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107103. */
  107104. export class Analyser {
  107105. /**
  107106. * Gets or sets the smoothing
  107107. * @ignorenaming
  107108. */
  107109. SMOOTHING: number;
  107110. /**
  107111. * Gets or sets the FFT table size
  107112. * @ignorenaming
  107113. */
  107114. FFT_SIZE: number;
  107115. /**
  107116. * Gets or sets the bar graph amplitude
  107117. * @ignorenaming
  107118. */
  107119. BARGRAPHAMPLITUDE: number;
  107120. /**
  107121. * Gets or sets the position of the debug canvas
  107122. * @ignorenaming
  107123. */
  107124. DEBUGCANVASPOS: {
  107125. x: number;
  107126. y: number;
  107127. };
  107128. /**
  107129. * Gets or sets the debug canvas size
  107130. * @ignorenaming
  107131. */
  107132. DEBUGCANVASSIZE: {
  107133. width: number;
  107134. height: number;
  107135. };
  107136. private _byteFreqs;
  107137. private _byteTime;
  107138. private _floatFreqs;
  107139. private _webAudioAnalyser;
  107140. private _debugCanvas;
  107141. private _debugCanvasContext;
  107142. private _scene;
  107143. private _registerFunc;
  107144. private _audioEngine;
  107145. /**
  107146. * Creates a new analyser
  107147. * @param scene defines hosting scene
  107148. */
  107149. constructor(scene: Scene);
  107150. /**
  107151. * Get the number of data values you will have to play with for the visualization
  107152. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  107153. * @returns a number
  107154. */
  107155. getFrequencyBinCount(): number;
  107156. /**
  107157. * Gets the current frequency data as a byte array
  107158. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107159. * @returns a Uint8Array
  107160. */
  107161. getByteFrequencyData(): Uint8Array;
  107162. /**
  107163. * Gets the current waveform as a byte array
  107164. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  107165. * @returns a Uint8Array
  107166. */
  107167. getByteTimeDomainData(): Uint8Array;
  107168. /**
  107169. * Gets the current frequency data as a float array
  107170. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107171. * @returns a Float32Array
  107172. */
  107173. getFloatFrequencyData(): Float32Array;
  107174. /**
  107175. * Renders the debug canvas
  107176. */
  107177. drawDebugCanvas(): void;
  107178. /**
  107179. * Stops rendering the debug canvas and removes it
  107180. */
  107181. stopDebugCanvas(): void;
  107182. /**
  107183. * Connects two audio nodes
  107184. * @param inputAudioNode defines first node to connect
  107185. * @param outputAudioNode defines second node to connect
  107186. */
  107187. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  107188. /**
  107189. * Releases all associated resources
  107190. */
  107191. dispose(): void;
  107192. }
  107193. }
  107194. declare module BABYLON {
  107195. /**
  107196. * This represents an audio engine and it is responsible
  107197. * to play, synchronize and analyse sounds throughout the application.
  107198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107199. */
  107200. export interface IAudioEngine extends IDisposable {
  107201. /**
  107202. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107203. */
  107204. readonly canUseWebAudio: boolean;
  107205. /**
  107206. * Gets the current AudioContext if available.
  107207. */
  107208. readonly audioContext: Nullable<AudioContext>;
  107209. /**
  107210. * The master gain node defines the global audio volume of your audio engine.
  107211. */
  107212. readonly masterGain: GainNode;
  107213. /**
  107214. * Gets whether or not mp3 are supported by your browser.
  107215. */
  107216. readonly isMP3supported: boolean;
  107217. /**
  107218. * Gets whether or not ogg are supported by your browser.
  107219. */
  107220. readonly isOGGsupported: boolean;
  107221. /**
  107222. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107223. * @ignoreNaming
  107224. */
  107225. WarnedWebAudioUnsupported: boolean;
  107226. /**
  107227. * Defines if the audio engine relies on a custom unlocked button.
  107228. * In this case, the embedded button will not be displayed.
  107229. */
  107230. useCustomUnlockedButton: boolean;
  107231. /**
  107232. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  107233. */
  107234. readonly unlocked: boolean;
  107235. /**
  107236. * Event raised when audio has been unlocked on the browser.
  107237. */
  107238. onAudioUnlockedObservable: Observable<AudioEngine>;
  107239. /**
  107240. * Event raised when audio has been locked on the browser.
  107241. */
  107242. onAudioLockedObservable: Observable<AudioEngine>;
  107243. /**
  107244. * Flags the audio engine in Locked state.
  107245. * This happens due to new browser policies preventing audio to autoplay.
  107246. */
  107247. lock(): void;
  107248. /**
  107249. * Unlocks the audio engine once a user action has been done on the dom.
  107250. * This is helpful to resume play once browser policies have been satisfied.
  107251. */
  107252. unlock(): void;
  107253. /**
  107254. * Gets the global volume sets on the master gain.
  107255. * @returns the global volume if set or -1 otherwise
  107256. */
  107257. getGlobalVolume(): number;
  107258. /**
  107259. * Sets the global volume of your experience (sets on the master gain).
  107260. * @param newVolume Defines the new global volume of the application
  107261. */
  107262. setGlobalVolume(newVolume: number): void;
  107263. /**
  107264. * Connect the audio engine to an audio analyser allowing some amazing
  107265. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107267. * @param analyser The analyser to connect to the engine
  107268. */
  107269. connectToAnalyser(analyser: Analyser): void;
  107270. }
  107271. /**
  107272. * This represents the default audio engine used in babylon.
  107273. * It is responsible to play, synchronize and analyse sounds throughout the application.
  107274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107275. */
  107276. export class AudioEngine implements IAudioEngine {
  107277. private _audioContext;
  107278. private _audioContextInitialized;
  107279. private _muteButton;
  107280. private _hostElement;
  107281. /**
  107282. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107283. */
  107284. canUseWebAudio: boolean;
  107285. /**
  107286. * The master gain node defines the global audio volume of your audio engine.
  107287. */
  107288. masterGain: GainNode;
  107289. /**
  107290. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107291. * @ignoreNaming
  107292. */
  107293. WarnedWebAudioUnsupported: boolean;
  107294. /**
  107295. * Gets whether or not mp3 are supported by your browser.
  107296. */
  107297. isMP3supported: boolean;
  107298. /**
  107299. * Gets whether or not ogg are supported by your browser.
  107300. */
  107301. isOGGsupported: boolean;
  107302. /**
  107303. * Gets whether audio has been unlocked on the device.
  107304. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  107305. * a user interaction has happened.
  107306. */
  107307. unlocked: boolean;
  107308. /**
  107309. * Defines if the audio engine relies on a custom unlocked button.
  107310. * In this case, the embedded button will not be displayed.
  107311. */
  107312. useCustomUnlockedButton: boolean;
  107313. /**
  107314. * Event raised when audio has been unlocked on the browser.
  107315. */
  107316. onAudioUnlockedObservable: Observable<AudioEngine>;
  107317. /**
  107318. * Event raised when audio has been locked on the browser.
  107319. */
  107320. onAudioLockedObservable: Observable<AudioEngine>;
  107321. /**
  107322. * Gets the current AudioContext if available.
  107323. */
  107324. get audioContext(): Nullable<AudioContext>;
  107325. private _connectedAnalyser;
  107326. /**
  107327. * Instantiates a new audio engine.
  107328. *
  107329. * There should be only one per page as some browsers restrict the number
  107330. * of audio contexts you can create.
  107331. * @param hostElement defines the host element where to display the mute icon if necessary
  107332. */
  107333. constructor(hostElement?: Nullable<HTMLElement>);
  107334. /**
  107335. * Flags the audio engine in Locked state.
  107336. * This happens due to new browser policies preventing audio to autoplay.
  107337. */
  107338. lock(): void;
  107339. /**
  107340. * Unlocks the audio engine once a user action has been done on the dom.
  107341. * This is helpful to resume play once browser policies have been satisfied.
  107342. */
  107343. unlock(): void;
  107344. private _resumeAudioContext;
  107345. private _initializeAudioContext;
  107346. private _tryToRun;
  107347. private _triggerRunningState;
  107348. private _triggerSuspendedState;
  107349. private _displayMuteButton;
  107350. private _moveButtonToTopLeft;
  107351. private _onResize;
  107352. private _hideMuteButton;
  107353. /**
  107354. * Destroy and release the resources associated with the audio ccontext.
  107355. */
  107356. dispose(): void;
  107357. /**
  107358. * Gets the global volume sets on the master gain.
  107359. * @returns the global volume if set or -1 otherwise
  107360. */
  107361. getGlobalVolume(): number;
  107362. /**
  107363. * Sets the global volume of your experience (sets on the master gain).
  107364. * @param newVolume Defines the new global volume of the application
  107365. */
  107366. setGlobalVolume(newVolume: number): void;
  107367. /**
  107368. * Connect the audio engine to an audio analyser allowing some amazing
  107369. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107371. * @param analyser The analyser to connect to the engine
  107372. */
  107373. connectToAnalyser(analyser: Analyser): void;
  107374. }
  107375. }
  107376. declare module BABYLON {
  107377. /**
  107378. * Interface used to present a loading screen while loading a scene
  107379. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107380. */
  107381. export interface ILoadingScreen {
  107382. /**
  107383. * Function called to display the loading screen
  107384. */
  107385. displayLoadingUI: () => void;
  107386. /**
  107387. * Function called to hide the loading screen
  107388. */
  107389. hideLoadingUI: () => void;
  107390. /**
  107391. * Gets or sets the color to use for the background
  107392. */
  107393. loadingUIBackgroundColor: string;
  107394. /**
  107395. * Gets or sets the text to display while loading
  107396. */
  107397. loadingUIText: string;
  107398. }
  107399. /**
  107400. * Class used for the default loading screen
  107401. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107402. */
  107403. export class DefaultLoadingScreen implements ILoadingScreen {
  107404. private _renderingCanvas;
  107405. private _loadingText;
  107406. private _loadingDivBackgroundColor;
  107407. private _loadingDiv;
  107408. private _loadingTextDiv;
  107409. /** Gets or sets the logo url to use for the default loading screen */
  107410. static DefaultLogoUrl: string;
  107411. /** Gets or sets the spinner url to use for the default loading screen */
  107412. static DefaultSpinnerUrl: string;
  107413. /**
  107414. * Creates a new default loading screen
  107415. * @param _renderingCanvas defines the canvas used to render the scene
  107416. * @param _loadingText defines the default text to display
  107417. * @param _loadingDivBackgroundColor defines the default background color
  107418. */
  107419. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  107420. /**
  107421. * Function called to display the loading screen
  107422. */
  107423. displayLoadingUI(): void;
  107424. /**
  107425. * Function called to hide the loading screen
  107426. */
  107427. hideLoadingUI(): void;
  107428. /**
  107429. * Gets or sets the text to display while loading
  107430. */
  107431. set loadingUIText(text: string);
  107432. get loadingUIText(): string;
  107433. /**
  107434. * Gets or sets the color to use for the background
  107435. */
  107436. get loadingUIBackgroundColor(): string;
  107437. set loadingUIBackgroundColor(color: string);
  107438. private _resizeLoadingUI;
  107439. }
  107440. }
  107441. declare module BABYLON {
  107442. /**
  107443. * Interface for any object that can request an animation frame
  107444. */
  107445. export interface ICustomAnimationFrameRequester {
  107446. /**
  107447. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  107448. */
  107449. renderFunction?: Function;
  107450. /**
  107451. * Called to request the next frame to render to
  107452. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  107453. */
  107454. requestAnimationFrame: Function;
  107455. /**
  107456. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  107457. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  107458. */
  107459. requestID?: number;
  107460. }
  107461. }
  107462. declare module BABYLON {
  107463. /**
  107464. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  107465. */
  107466. export class PerformanceMonitor {
  107467. private _enabled;
  107468. private _rollingFrameTime;
  107469. private _lastFrameTimeMs;
  107470. /**
  107471. * constructor
  107472. * @param frameSampleSize The number of samples required to saturate the sliding window
  107473. */
  107474. constructor(frameSampleSize?: number);
  107475. /**
  107476. * Samples current frame
  107477. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  107478. */
  107479. sampleFrame(timeMs?: number): void;
  107480. /**
  107481. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107482. */
  107483. get averageFrameTime(): number;
  107484. /**
  107485. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107486. */
  107487. get averageFrameTimeVariance(): number;
  107488. /**
  107489. * Returns the frame time of the most recent frame
  107490. */
  107491. get instantaneousFrameTime(): number;
  107492. /**
  107493. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  107494. */
  107495. get averageFPS(): number;
  107496. /**
  107497. * Returns the average framerate in frames per second using the most recent frame time
  107498. */
  107499. get instantaneousFPS(): number;
  107500. /**
  107501. * Returns true if enough samples have been taken to completely fill the sliding window
  107502. */
  107503. get isSaturated(): boolean;
  107504. /**
  107505. * Enables contributions to the sliding window sample set
  107506. */
  107507. enable(): void;
  107508. /**
  107509. * Disables contributions to the sliding window sample set
  107510. * Samples will not be interpolated over the disabled period
  107511. */
  107512. disable(): void;
  107513. /**
  107514. * Returns true if sampling is enabled
  107515. */
  107516. get isEnabled(): boolean;
  107517. /**
  107518. * Resets performance monitor
  107519. */
  107520. reset(): void;
  107521. }
  107522. /**
  107523. * RollingAverage
  107524. *
  107525. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  107526. */
  107527. export class RollingAverage {
  107528. /**
  107529. * Current average
  107530. */
  107531. average: number;
  107532. /**
  107533. * Current variance
  107534. */
  107535. variance: number;
  107536. protected _samples: Array<number>;
  107537. protected _sampleCount: number;
  107538. protected _pos: number;
  107539. protected _m2: number;
  107540. /**
  107541. * constructor
  107542. * @param length The number of samples required to saturate the sliding window
  107543. */
  107544. constructor(length: number);
  107545. /**
  107546. * Adds a sample to the sample set
  107547. * @param v The sample value
  107548. */
  107549. add(v: number): void;
  107550. /**
  107551. * Returns previously added values or null if outside of history or outside the sliding window domain
  107552. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  107553. * @return Value previously recorded with add() or null if outside of range
  107554. */
  107555. history(i: number): number;
  107556. /**
  107557. * Returns true if enough samples have been taken to completely fill the sliding window
  107558. * @return true if sample-set saturated
  107559. */
  107560. isSaturated(): boolean;
  107561. /**
  107562. * Resets the rolling average (equivalent to 0 samples taken so far)
  107563. */
  107564. reset(): void;
  107565. /**
  107566. * Wraps a value around the sample range boundaries
  107567. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  107568. * @return Wrapped position in sample range
  107569. */
  107570. protected _wrapPosition(i: number): number;
  107571. }
  107572. }
  107573. declare module BABYLON {
  107574. /**
  107575. * This class is used to track a performance counter which is number based.
  107576. * The user has access to many properties which give statistics of different nature.
  107577. *
  107578. * The implementer can track two kinds of Performance Counter: time and count.
  107579. * 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.
  107580. * 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.
  107581. */
  107582. export class PerfCounter {
  107583. /**
  107584. * Gets or sets a global boolean to turn on and off all the counters
  107585. */
  107586. static Enabled: boolean;
  107587. /**
  107588. * Returns the smallest value ever
  107589. */
  107590. get min(): number;
  107591. /**
  107592. * Returns the biggest value ever
  107593. */
  107594. get max(): number;
  107595. /**
  107596. * Returns the average value since the performance counter is running
  107597. */
  107598. get average(): number;
  107599. /**
  107600. * Returns the average value of the last second the counter was monitored
  107601. */
  107602. get lastSecAverage(): number;
  107603. /**
  107604. * Returns the current value
  107605. */
  107606. get current(): number;
  107607. /**
  107608. * Gets the accumulated total
  107609. */
  107610. get total(): number;
  107611. /**
  107612. * Gets the total value count
  107613. */
  107614. get count(): number;
  107615. /**
  107616. * Creates a new counter
  107617. */
  107618. constructor();
  107619. /**
  107620. * Call this method to start monitoring a new frame.
  107621. * 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.
  107622. */
  107623. fetchNewFrame(): void;
  107624. /**
  107625. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  107626. * @param newCount the count value to add to the monitored count
  107627. * @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.
  107628. */
  107629. addCount(newCount: number, fetchResult: boolean): void;
  107630. /**
  107631. * Start monitoring this performance counter
  107632. */
  107633. beginMonitoring(): void;
  107634. /**
  107635. * Compute the time lapsed since the previous beginMonitoring() call.
  107636. * @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
  107637. */
  107638. endMonitoring(newFrame?: boolean): void;
  107639. private _fetchResult;
  107640. private _startMonitoringTime;
  107641. private _min;
  107642. private _max;
  107643. private _average;
  107644. private _current;
  107645. private _totalValueCount;
  107646. private _totalAccumulated;
  107647. private _lastSecAverage;
  107648. private _lastSecAccumulated;
  107649. private _lastSecTime;
  107650. private _lastSecValueCount;
  107651. }
  107652. }
  107653. declare module BABYLON {
  107654. interface ThinEngine {
  107655. /**
  107656. * Sets alpha constants used by some alpha blending modes
  107657. * @param r defines the red component
  107658. * @param g defines the green component
  107659. * @param b defines the blue component
  107660. * @param a defines the alpha component
  107661. */
  107662. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  107663. /**
  107664. * Sets the current alpha mode
  107665. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  107666. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  107667. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107668. */
  107669. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107670. /**
  107671. * Gets the current alpha mode
  107672. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107673. * @returns the current alpha mode
  107674. */
  107675. getAlphaMode(): number;
  107676. /**
  107677. * Sets the current alpha equation
  107678. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  107679. */
  107680. setAlphaEquation(equation: number): void;
  107681. /**
  107682. * Gets the current alpha equation.
  107683. * @returns the current alpha equation
  107684. */
  107685. getAlphaEquation(): number;
  107686. }
  107687. }
  107688. declare module BABYLON {
  107689. /**
  107690. * Defines the interface used by display changed events
  107691. */
  107692. export interface IDisplayChangedEventArgs {
  107693. /** Gets the vrDisplay object (if any) */
  107694. vrDisplay: Nullable<any>;
  107695. /** Gets a boolean indicating if webVR is supported */
  107696. vrSupported: boolean;
  107697. }
  107698. /**
  107699. * Defines the interface used by objects containing a viewport (like a camera)
  107700. */
  107701. interface IViewportOwnerLike {
  107702. /**
  107703. * Gets or sets the viewport
  107704. */
  107705. viewport: IViewportLike;
  107706. }
  107707. /**
  107708. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  107709. */
  107710. export class Engine extends ThinEngine {
  107711. /** Defines that alpha blending is disabled */
  107712. static readonly ALPHA_DISABLE: number;
  107713. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  107714. static readonly ALPHA_ADD: number;
  107715. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  107716. static readonly ALPHA_COMBINE: number;
  107717. /** Defines that alpha blending to DEST - SRC * DEST */
  107718. static readonly ALPHA_SUBTRACT: number;
  107719. /** Defines that alpha blending to SRC * DEST */
  107720. static readonly ALPHA_MULTIPLY: number;
  107721. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  107722. static readonly ALPHA_MAXIMIZED: number;
  107723. /** Defines that alpha blending to SRC + DEST */
  107724. static readonly ALPHA_ONEONE: number;
  107725. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  107726. static readonly ALPHA_PREMULTIPLIED: number;
  107727. /**
  107728. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  107729. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  107730. */
  107731. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  107732. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  107733. static readonly ALPHA_INTERPOLATE: number;
  107734. /**
  107735. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  107736. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  107737. */
  107738. static readonly ALPHA_SCREENMODE: number;
  107739. /** Defines that the ressource is not delayed*/
  107740. static readonly DELAYLOADSTATE_NONE: number;
  107741. /** Defines that the ressource was successfully delay loaded */
  107742. static readonly DELAYLOADSTATE_LOADED: number;
  107743. /** Defines that the ressource is currently delay loading */
  107744. static readonly DELAYLOADSTATE_LOADING: number;
  107745. /** Defines that the ressource is delayed and has not started loading */
  107746. static readonly DELAYLOADSTATE_NOTLOADED: number;
  107747. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  107748. static readonly NEVER: number;
  107749. /** 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 */
  107750. static readonly ALWAYS: number;
  107751. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  107752. static readonly LESS: number;
  107753. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  107754. static readonly EQUAL: number;
  107755. /** 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 */
  107756. static readonly LEQUAL: number;
  107757. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  107758. static readonly GREATER: number;
  107759. /** 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 */
  107760. static readonly GEQUAL: number;
  107761. /** 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 */
  107762. static readonly NOTEQUAL: number;
  107763. /** Passed to stencilOperation to specify that stencil value must be kept */
  107764. static readonly KEEP: number;
  107765. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107766. static readonly REPLACE: number;
  107767. /** Passed to stencilOperation to specify that stencil value must be incremented */
  107768. static readonly INCR: number;
  107769. /** Passed to stencilOperation to specify that stencil value must be decremented */
  107770. static readonly DECR: number;
  107771. /** Passed to stencilOperation to specify that stencil value must be inverted */
  107772. static readonly INVERT: number;
  107773. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  107774. static readonly INCR_WRAP: number;
  107775. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  107776. static readonly DECR_WRAP: number;
  107777. /** Texture is not repeating outside of 0..1 UVs */
  107778. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  107779. /** Texture is repeating outside of 0..1 UVs */
  107780. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  107781. /** Texture is repeating and mirrored */
  107782. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  107783. /** ALPHA */
  107784. static readonly TEXTUREFORMAT_ALPHA: number;
  107785. /** LUMINANCE */
  107786. static readonly TEXTUREFORMAT_LUMINANCE: number;
  107787. /** LUMINANCE_ALPHA */
  107788. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  107789. /** RGB */
  107790. static readonly TEXTUREFORMAT_RGB: number;
  107791. /** RGBA */
  107792. static readonly TEXTUREFORMAT_RGBA: number;
  107793. /** RED */
  107794. static readonly TEXTUREFORMAT_RED: number;
  107795. /** RED (2nd reference) */
  107796. static readonly TEXTUREFORMAT_R: number;
  107797. /** RG */
  107798. static readonly TEXTUREFORMAT_RG: number;
  107799. /** RED_INTEGER */
  107800. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  107801. /** RED_INTEGER (2nd reference) */
  107802. static readonly TEXTUREFORMAT_R_INTEGER: number;
  107803. /** RG_INTEGER */
  107804. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  107805. /** RGB_INTEGER */
  107806. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  107807. /** RGBA_INTEGER */
  107808. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  107809. /** UNSIGNED_BYTE */
  107810. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  107811. /** UNSIGNED_BYTE (2nd reference) */
  107812. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  107813. /** FLOAT */
  107814. static readonly TEXTURETYPE_FLOAT: number;
  107815. /** HALF_FLOAT */
  107816. static readonly TEXTURETYPE_HALF_FLOAT: number;
  107817. /** BYTE */
  107818. static readonly TEXTURETYPE_BYTE: number;
  107819. /** SHORT */
  107820. static readonly TEXTURETYPE_SHORT: number;
  107821. /** UNSIGNED_SHORT */
  107822. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  107823. /** INT */
  107824. static readonly TEXTURETYPE_INT: number;
  107825. /** UNSIGNED_INT */
  107826. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  107827. /** UNSIGNED_SHORT_4_4_4_4 */
  107828. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  107829. /** UNSIGNED_SHORT_5_5_5_1 */
  107830. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  107831. /** UNSIGNED_SHORT_5_6_5 */
  107832. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  107833. /** UNSIGNED_INT_2_10_10_10_REV */
  107834. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  107835. /** UNSIGNED_INT_24_8 */
  107836. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  107837. /** UNSIGNED_INT_10F_11F_11F_REV */
  107838. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  107839. /** UNSIGNED_INT_5_9_9_9_REV */
  107840. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  107841. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  107842. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  107843. /** nearest is mag = nearest and min = nearest and mip = linear */
  107844. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  107845. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107846. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  107847. /** Trilinear is mag = linear and min = linear and mip = linear */
  107848. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  107849. /** nearest is mag = nearest and min = nearest and mip = linear */
  107850. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  107851. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107852. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  107853. /** Trilinear is mag = linear and min = linear and mip = linear */
  107854. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  107855. /** mag = nearest and min = nearest and mip = nearest */
  107856. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  107857. /** mag = nearest and min = linear and mip = nearest */
  107858. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  107859. /** mag = nearest and min = linear and mip = linear */
  107860. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  107861. /** mag = nearest and min = linear and mip = none */
  107862. static readonly TEXTURE_NEAREST_LINEAR: number;
  107863. /** mag = nearest and min = nearest and mip = none */
  107864. static readonly TEXTURE_NEAREST_NEAREST: number;
  107865. /** mag = linear and min = nearest and mip = nearest */
  107866. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  107867. /** mag = linear and min = nearest and mip = linear */
  107868. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  107869. /** mag = linear and min = linear and mip = none */
  107870. static readonly TEXTURE_LINEAR_LINEAR: number;
  107871. /** mag = linear and min = nearest and mip = none */
  107872. static readonly TEXTURE_LINEAR_NEAREST: number;
  107873. /** Explicit coordinates mode */
  107874. static readonly TEXTURE_EXPLICIT_MODE: number;
  107875. /** Spherical coordinates mode */
  107876. static readonly TEXTURE_SPHERICAL_MODE: number;
  107877. /** Planar coordinates mode */
  107878. static readonly TEXTURE_PLANAR_MODE: number;
  107879. /** Cubic coordinates mode */
  107880. static readonly TEXTURE_CUBIC_MODE: number;
  107881. /** Projection coordinates mode */
  107882. static readonly TEXTURE_PROJECTION_MODE: number;
  107883. /** Skybox coordinates mode */
  107884. static readonly TEXTURE_SKYBOX_MODE: number;
  107885. /** Inverse Cubic coordinates mode */
  107886. static readonly TEXTURE_INVCUBIC_MODE: number;
  107887. /** Equirectangular coordinates mode */
  107888. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  107889. /** Equirectangular Fixed coordinates mode */
  107890. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  107891. /** Equirectangular Fixed Mirrored coordinates mode */
  107892. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  107893. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  107894. static readonly SCALEMODE_FLOOR: number;
  107895. /** Defines that texture rescaling will look for the nearest power of 2 size */
  107896. static readonly SCALEMODE_NEAREST: number;
  107897. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  107898. static readonly SCALEMODE_CEILING: number;
  107899. /**
  107900. * Returns the current npm package of the sdk
  107901. */
  107902. static get NpmPackage(): string;
  107903. /**
  107904. * Returns the current version of the framework
  107905. */
  107906. static get Version(): string;
  107907. /** Gets the list of created engines */
  107908. static get Instances(): Engine[];
  107909. /**
  107910. * Gets the latest created engine
  107911. */
  107912. static get LastCreatedEngine(): Nullable<Engine>;
  107913. /**
  107914. * Gets the latest created scene
  107915. */
  107916. static get LastCreatedScene(): Nullable<Scene>;
  107917. /**
  107918. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107919. * @param flag defines which part of the materials must be marked as dirty
  107920. * @param predicate defines a predicate used to filter which materials should be affected
  107921. */
  107922. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107923. /**
  107924. * Method called to create the default loading screen.
  107925. * This can be overriden in your own app.
  107926. * @param canvas The rendering canvas element
  107927. * @returns The loading screen
  107928. */
  107929. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107930. /**
  107931. * Method called to create the default rescale post process on each engine.
  107932. */
  107933. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107934. /**
  107935. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107936. **/
  107937. enableOfflineSupport: boolean;
  107938. /**
  107939. * 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)
  107940. **/
  107941. disableManifestCheck: boolean;
  107942. /**
  107943. * Gets the list of created scenes
  107944. */
  107945. scenes: Scene[];
  107946. /**
  107947. * Event raised when a new scene is created
  107948. */
  107949. onNewSceneAddedObservable: Observable<Scene>;
  107950. /**
  107951. * Gets the list of created postprocesses
  107952. */
  107953. postProcesses: PostProcess[];
  107954. /**
  107955. * Gets a boolean indicating if the pointer is currently locked
  107956. */
  107957. isPointerLock: boolean;
  107958. /**
  107959. * Observable event triggered each time the rendering canvas is resized
  107960. */
  107961. onResizeObservable: Observable<Engine>;
  107962. /**
  107963. * Observable event triggered each time the canvas loses focus
  107964. */
  107965. onCanvasBlurObservable: Observable<Engine>;
  107966. /**
  107967. * Observable event triggered each time the canvas gains focus
  107968. */
  107969. onCanvasFocusObservable: Observable<Engine>;
  107970. /**
  107971. * Observable event triggered each time the canvas receives pointerout event
  107972. */
  107973. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107974. /**
  107975. * Observable raised when the engine begins a new frame
  107976. */
  107977. onBeginFrameObservable: Observable<Engine>;
  107978. /**
  107979. * If set, will be used to request the next animation frame for the render loop
  107980. */
  107981. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107982. /**
  107983. * Observable raised when the engine ends the current frame
  107984. */
  107985. onEndFrameObservable: Observable<Engine>;
  107986. /**
  107987. * Observable raised when the engine is about to compile a shader
  107988. */
  107989. onBeforeShaderCompilationObservable: Observable<Engine>;
  107990. /**
  107991. * Observable raised when the engine has jsut compiled a shader
  107992. */
  107993. onAfterShaderCompilationObservable: Observable<Engine>;
  107994. /**
  107995. * Gets the audio engine
  107996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107997. * @ignorenaming
  107998. */
  107999. static audioEngine: IAudioEngine;
  108000. /**
  108001. * Default AudioEngine factory responsible of creating the Audio Engine.
  108002. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  108003. */
  108004. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  108005. /**
  108006. * Default offline support factory responsible of creating a tool used to store data locally.
  108007. * By default, this will create a Database object if the workload has been embedded.
  108008. */
  108009. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  108010. private _loadingScreen;
  108011. private _pointerLockRequested;
  108012. private _dummyFramebuffer;
  108013. private _rescalePostProcess;
  108014. private _deterministicLockstep;
  108015. private _lockstepMaxSteps;
  108016. private _timeStep;
  108017. protected get _supportsHardwareTextureRescaling(): boolean;
  108018. private _fps;
  108019. private _deltaTime;
  108020. /** @hidden */
  108021. _drawCalls: PerfCounter;
  108022. /** 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 */
  108023. canvasTabIndex: number;
  108024. /**
  108025. * Turn this value on if you want to pause FPS computation when in background
  108026. */
  108027. disablePerformanceMonitorInBackground: boolean;
  108028. private _performanceMonitor;
  108029. /**
  108030. * Gets the performance monitor attached to this engine
  108031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108032. */
  108033. get performanceMonitor(): PerformanceMonitor;
  108034. private _onFocus;
  108035. private _onBlur;
  108036. private _onCanvasPointerOut;
  108037. private _onCanvasBlur;
  108038. private _onCanvasFocus;
  108039. private _onFullscreenChange;
  108040. private _onPointerLockChange;
  108041. /**
  108042. * Gets the HTML element used to attach event listeners
  108043. * @returns a HTML element
  108044. */
  108045. getInputElement(): Nullable<HTMLElement>;
  108046. /**
  108047. * Creates a new engine
  108048. * @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
  108049. * @param antialias defines enable antialiasing (default: false)
  108050. * @param options defines further options to be sent to the getContext() function
  108051. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  108052. */
  108053. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  108054. /**
  108055. * Gets current aspect ratio
  108056. * @param viewportOwner defines the camera to use to get the aspect ratio
  108057. * @param useScreen defines if screen size must be used (or the current render target if any)
  108058. * @returns a number defining the aspect ratio
  108059. */
  108060. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  108061. /**
  108062. * Gets current screen aspect ratio
  108063. * @returns a number defining the aspect ratio
  108064. */
  108065. getScreenAspectRatio(): number;
  108066. /**
  108067. * Gets the client rect of the HTML canvas attached with the current webGL context
  108068. * @returns a client rectanglee
  108069. */
  108070. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  108071. /**
  108072. * Gets the client rect of the HTML element used for events
  108073. * @returns a client rectanglee
  108074. */
  108075. getInputElementClientRect(): Nullable<ClientRect>;
  108076. /**
  108077. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  108078. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108079. * @returns true if engine is in deterministic lock step mode
  108080. */
  108081. isDeterministicLockStep(): boolean;
  108082. /**
  108083. * Gets the max steps when engine is running in deterministic lock step
  108084. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108085. * @returns the max steps
  108086. */
  108087. getLockstepMaxSteps(): number;
  108088. /**
  108089. * Returns the time in ms between steps when using deterministic lock step.
  108090. * @returns time step in (ms)
  108091. */
  108092. getTimeStep(): number;
  108093. /**
  108094. * Force the mipmap generation for the given render target texture
  108095. * @param texture defines the render target texture to use
  108096. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  108097. */
  108098. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  108099. /** States */
  108100. /**
  108101. * Set various states to the webGL context
  108102. * @param culling defines backface culling state
  108103. * @param zOffset defines the value to apply to zOffset (0 by default)
  108104. * @param force defines if states must be applied even if cache is up to date
  108105. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  108106. */
  108107. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108108. /**
  108109. * Set the z offset to apply to current rendering
  108110. * @param value defines the offset to apply
  108111. */
  108112. setZOffset(value: number): void;
  108113. /**
  108114. * Gets the current value of the zOffset
  108115. * @returns the current zOffset state
  108116. */
  108117. getZOffset(): number;
  108118. /**
  108119. * Enable or disable depth buffering
  108120. * @param enable defines the state to set
  108121. */
  108122. setDepthBuffer(enable: boolean): void;
  108123. /**
  108124. * Gets a boolean indicating if depth writing is enabled
  108125. * @returns the current depth writing state
  108126. */
  108127. getDepthWrite(): boolean;
  108128. /**
  108129. * Enable or disable depth writing
  108130. * @param enable defines the state to set
  108131. */
  108132. setDepthWrite(enable: boolean): void;
  108133. /**
  108134. * Gets a boolean indicating if stencil buffer is enabled
  108135. * @returns the current stencil buffer state
  108136. */
  108137. getStencilBuffer(): boolean;
  108138. /**
  108139. * Enable or disable the stencil buffer
  108140. * @param enable defines if the stencil buffer must be enabled or disabled
  108141. */
  108142. setStencilBuffer(enable: boolean): void;
  108143. /**
  108144. * Gets the current stencil mask
  108145. * @returns a number defining the new stencil mask to use
  108146. */
  108147. getStencilMask(): number;
  108148. /**
  108149. * Sets the current stencil mask
  108150. * @param mask defines the new stencil mask to use
  108151. */
  108152. setStencilMask(mask: number): void;
  108153. /**
  108154. * Gets the current stencil function
  108155. * @returns a number defining the stencil function to use
  108156. */
  108157. getStencilFunction(): number;
  108158. /**
  108159. * Gets the current stencil reference value
  108160. * @returns a number defining the stencil reference value to use
  108161. */
  108162. getStencilFunctionReference(): number;
  108163. /**
  108164. * Gets the current stencil mask
  108165. * @returns a number defining the stencil mask to use
  108166. */
  108167. getStencilFunctionMask(): number;
  108168. /**
  108169. * Sets the current stencil function
  108170. * @param stencilFunc defines the new stencil function to use
  108171. */
  108172. setStencilFunction(stencilFunc: number): void;
  108173. /**
  108174. * Sets the current stencil reference
  108175. * @param reference defines the new stencil reference to use
  108176. */
  108177. setStencilFunctionReference(reference: number): void;
  108178. /**
  108179. * Sets the current stencil mask
  108180. * @param mask defines the new stencil mask to use
  108181. */
  108182. setStencilFunctionMask(mask: number): void;
  108183. /**
  108184. * Gets the current stencil operation when stencil fails
  108185. * @returns a number defining stencil operation to use when stencil fails
  108186. */
  108187. getStencilOperationFail(): number;
  108188. /**
  108189. * Gets the current stencil operation when depth fails
  108190. * @returns a number defining stencil operation to use when depth fails
  108191. */
  108192. getStencilOperationDepthFail(): number;
  108193. /**
  108194. * Gets the current stencil operation when stencil passes
  108195. * @returns a number defining stencil operation to use when stencil passes
  108196. */
  108197. getStencilOperationPass(): number;
  108198. /**
  108199. * Sets the stencil operation to use when stencil fails
  108200. * @param operation defines the stencil operation to use when stencil fails
  108201. */
  108202. setStencilOperationFail(operation: number): void;
  108203. /**
  108204. * Sets the stencil operation to use when depth fails
  108205. * @param operation defines the stencil operation to use when depth fails
  108206. */
  108207. setStencilOperationDepthFail(operation: number): void;
  108208. /**
  108209. * Sets the stencil operation to use when stencil passes
  108210. * @param operation defines the stencil operation to use when stencil passes
  108211. */
  108212. setStencilOperationPass(operation: number): void;
  108213. /**
  108214. * Sets a boolean indicating if the dithering state is enabled or disabled
  108215. * @param value defines the dithering state
  108216. */
  108217. setDitheringState(value: boolean): void;
  108218. /**
  108219. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  108220. * @param value defines the rasterizer state
  108221. */
  108222. setRasterizerState(value: boolean): void;
  108223. /**
  108224. * Gets the current depth function
  108225. * @returns a number defining the depth function
  108226. */
  108227. getDepthFunction(): Nullable<number>;
  108228. /**
  108229. * Sets the current depth function
  108230. * @param depthFunc defines the function to use
  108231. */
  108232. setDepthFunction(depthFunc: number): void;
  108233. /**
  108234. * Sets the current depth function to GREATER
  108235. */
  108236. setDepthFunctionToGreater(): void;
  108237. /**
  108238. * Sets the current depth function to GEQUAL
  108239. */
  108240. setDepthFunctionToGreaterOrEqual(): void;
  108241. /**
  108242. * Sets the current depth function to LESS
  108243. */
  108244. setDepthFunctionToLess(): void;
  108245. /**
  108246. * Sets the current depth function to LEQUAL
  108247. */
  108248. setDepthFunctionToLessOrEqual(): void;
  108249. private _cachedStencilBuffer;
  108250. private _cachedStencilFunction;
  108251. private _cachedStencilMask;
  108252. private _cachedStencilOperationPass;
  108253. private _cachedStencilOperationFail;
  108254. private _cachedStencilOperationDepthFail;
  108255. private _cachedStencilReference;
  108256. /**
  108257. * Caches the the state of the stencil buffer
  108258. */
  108259. cacheStencilState(): void;
  108260. /**
  108261. * Restores the state of the stencil buffer
  108262. */
  108263. restoreStencilState(): void;
  108264. /**
  108265. * Directly set the WebGL Viewport
  108266. * @param x defines the x coordinate of the viewport (in screen space)
  108267. * @param y defines the y coordinate of the viewport (in screen space)
  108268. * @param width defines the width of the viewport (in screen space)
  108269. * @param height defines the height of the viewport (in screen space)
  108270. * @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
  108271. */
  108272. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  108273. /**
  108274. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  108275. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108276. * @param y defines the y-coordinate of the corner of the clear rectangle
  108277. * @param width defines the width of the clear rectangle
  108278. * @param height defines the height of the clear rectangle
  108279. * @param clearColor defines the clear color
  108280. */
  108281. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  108282. /**
  108283. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  108284. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108285. * @param y defines the y-coordinate of the corner of the clear rectangle
  108286. * @param width defines the width of the clear rectangle
  108287. * @param height defines the height of the clear rectangle
  108288. */
  108289. enableScissor(x: number, y: number, width: number, height: number): void;
  108290. /**
  108291. * Disable previously set scissor test rectangle
  108292. */
  108293. disableScissor(): void;
  108294. protected _reportDrawCall(): void;
  108295. /**
  108296. * Initializes a webVR display and starts listening to display change events
  108297. * The onVRDisplayChangedObservable will be notified upon these changes
  108298. * @returns The onVRDisplayChangedObservable
  108299. */
  108300. initWebVR(): Observable<IDisplayChangedEventArgs>;
  108301. /** @hidden */
  108302. _prepareVRComponent(): void;
  108303. /** @hidden */
  108304. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  108305. /** @hidden */
  108306. _submitVRFrame(): void;
  108307. /**
  108308. * Call this function to leave webVR mode
  108309. * Will do nothing if webVR is not supported or if there is no webVR device
  108310. * @see http://doc.babylonjs.com/how_to/webvr_camera
  108311. */
  108312. disableVR(): void;
  108313. /**
  108314. * Gets a boolean indicating that the system is in VR mode and is presenting
  108315. * @returns true if VR mode is engaged
  108316. */
  108317. isVRPresenting(): boolean;
  108318. /** @hidden */
  108319. _requestVRFrame(): void;
  108320. /** @hidden */
  108321. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108322. /**
  108323. * Gets the source code of the vertex shader associated with a specific webGL program
  108324. * @param program defines the program to use
  108325. * @returns a string containing the source code of the vertex shader associated with the program
  108326. */
  108327. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  108328. /**
  108329. * Gets the source code of the fragment shader associated with a specific webGL program
  108330. * @param program defines the program to use
  108331. * @returns a string containing the source code of the fragment shader associated with the program
  108332. */
  108333. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  108334. /**
  108335. * Sets a depth stencil texture from a render target to the according uniform.
  108336. * @param channel The texture channel
  108337. * @param uniform The uniform to set
  108338. * @param texture The render target texture containing the depth stencil texture to apply
  108339. */
  108340. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  108341. /**
  108342. * Sets a texture to the webGL context from a postprocess
  108343. * @param channel defines the channel to use
  108344. * @param postProcess defines the source postprocess
  108345. */
  108346. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  108347. /**
  108348. * Binds the output of the passed in post process to the texture channel specified
  108349. * @param channel The channel the texture should be bound to
  108350. * @param postProcess The post process which's output should be bound
  108351. */
  108352. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  108353. /** @hidden */
  108354. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  108355. protected _rebuildBuffers(): void;
  108356. /** @hidden */
  108357. _renderFrame(): void;
  108358. _renderLoop(): void;
  108359. /** @hidden */
  108360. _renderViews(): boolean;
  108361. /**
  108362. * Toggle full screen mode
  108363. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108364. */
  108365. switchFullscreen(requestPointerLock: boolean): void;
  108366. /**
  108367. * Enters full screen mode
  108368. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108369. */
  108370. enterFullscreen(requestPointerLock: boolean): void;
  108371. /**
  108372. * Exits full screen mode
  108373. */
  108374. exitFullscreen(): void;
  108375. /**
  108376. * Enters Pointerlock mode
  108377. */
  108378. enterPointerlock(): void;
  108379. /**
  108380. * Exits Pointerlock mode
  108381. */
  108382. exitPointerlock(): void;
  108383. /**
  108384. * Begin a new frame
  108385. */
  108386. beginFrame(): void;
  108387. /**
  108388. * Enf the current frame
  108389. */
  108390. endFrame(): void;
  108391. resize(): void;
  108392. /**
  108393. * Force a specific size of the canvas
  108394. * @param width defines the new canvas' width
  108395. * @param height defines the new canvas' height
  108396. */
  108397. setSize(width: number, height: number): void;
  108398. /**
  108399. * Updates a dynamic vertex buffer.
  108400. * @param vertexBuffer the vertex buffer to update
  108401. * @param data the data used to update the vertex buffer
  108402. * @param byteOffset the byte offset of the data
  108403. * @param byteLength the byte length of the data
  108404. */
  108405. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  108406. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108407. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108408. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108409. _releaseTexture(texture: InternalTexture): void;
  108410. /**
  108411. * @hidden
  108412. * Rescales a texture
  108413. * @param source input texutre
  108414. * @param destination destination texture
  108415. * @param scene scene to use to render the resize
  108416. * @param internalFormat format to use when resizing
  108417. * @param onComplete callback to be called when resize has completed
  108418. */
  108419. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108420. /**
  108421. * Gets the current framerate
  108422. * @returns a number representing the framerate
  108423. */
  108424. getFps(): number;
  108425. /**
  108426. * Gets the time spent between current and previous frame
  108427. * @returns a number representing the delta time in ms
  108428. */
  108429. getDeltaTime(): number;
  108430. private _measureFps;
  108431. /** @hidden */
  108432. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  108433. /**
  108434. * Update a dynamic index buffer
  108435. * @param indexBuffer defines the target index buffer
  108436. * @param indices defines the data to update
  108437. * @param offset defines the offset in the target index buffer where update should start
  108438. */
  108439. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  108440. /**
  108441. * Updates the sample count of a render target texture
  108442. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108443. * @param texture defines the texture to update
  108444. * @param samples defines the sample count to set
  108445. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108446. */
  108447. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  108448. /**
  108449. * Updates a depth texture Comparison Mode and Function.
  108450. * If the comparison Function is equal to 0, the mode will be set to none.
  108451. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  108452. * @param texture The texture to set the comparison function for
  108453. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  108454. */
  108455. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  108456. /**
  108457. * Creates a webGL buffer to use with instanciation
  108458. * @param capacity defines the size of the buffer
  108459. * @returns the webGL buffer
  108460. */
  108461. createInstancesBuffer(capacity: number): DataBuffer;
  108462. /**
  108463. * Delete a webGL buffer used with instanciation
  108464. * @param buffer defines the webGL buffer to delete
  108465. */
  108466. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  108467. private _clientWaitAsync;
  108468. /** @hidden */
  108469. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  108470. /** @hidden */
  108471. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  108472. dispose(): void;
  108473. private _disableTouchAction;
  108474. /**
  108475. * Display the loading screen
  108476. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108477. */
  108478. displayLoadingUI(): void;
  108479. /**
  108480. * Hide the loading screen
  108481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108482. */
  108483. hideLoadingUI(): void;
  108484. /**
  108485. * Gets the current loading screen object
  108486. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108487. */
  108488. get loadingScreen(): ILoadingScreen;
  108489. /**
  108490. * Sets the current loading screen object
  108491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108492. */
  108493. set loadingScreen(loadingScreen: ILoadingScreen);
  108494. /**
  108495. * Sets the current loading screen text
  108496. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108497. */
  108498. set loadingUIText(text: string);
  108499. /**
  108500. * Sets the current loading screen background color
  108501. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108502. */
  108503. set loadingUIBackgroundColor(color: string);
  108504. /** Pointerlock and fullscreen */
  108505. /**
  108506. * Ask the browser to promote the current element to pointerlock mode
  108507. * @param element defines the DOM element to promote
  108508. */
  108509. static _RequestPointerlock(element: HTMLElement): void;
  108510. /**
  108511. * Asks the browser to exit pointerlock mode
  108512. */
  108513. static _ExitPointerlock(): void;
  108514. /**
  108515. * Ask the browser to promote the current element to fullscreen rendering mode
  108516. * @param element defines the DOM element to promote
  108517. */
  108518. static _RequestFullscreen(element: HTMLElement): void;
  108519. /**
  108520. * Asks the browser to exit fullscreen mode
  108521. */
  108522. static _ExitFullscreen(): void;
  108523. }
  108524. }
  108525. declare module BABYLON {
  108526. /**
  108527. * The engine store class is responsible to hold all the instances of Engine and Scene created
  108528. * during the life time of the application.
  108529. */
  108530. export class EngineStore {
  108531. /** Gets the list of created engines */
  108532. static Instances: Engine[];
  108533. /** @hidden */
  108534. static _LastCreatedScene: Nullable<Scene>;
  108535. /**
  108536. * Gets the latest created engine
  108537. */
  108538. static get LastCreatedEngine(): Nullable<Engine>;
  108539. /**
  108540. * Gets the latest created scene
  108541. */
  108542. static get LastCreatedScene(): Nullable<Scene>;
  108543. /**
  108544. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108545. * @ignorenaming
  108546. */
  108547. static UseFallbackTexture: boolean;
  108548. /**
  108549. * Texture content used if a texture cannot loaded
  108550. * @ignorenaming
  108551. */
  108552. static FallbackTexture: string;
  108553. }
  108554. }
  108555. declare module BABYLON {
  108556. /**
  108557. * Helper class that provides a small promise polyfill
  108558. */
  108559. export class PromisePolyfill {
  108560. /**
  108561. * Static function used to check if the polyfill is required
  108562. * If this is the case then the function will inject the polyfill to window.Promise
  108563. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  108564. */
  108565. static Apply(force?: boolean): void;
  108566. }
  108567. }
  108568. declare module BABYLON {
  108569. /**
  108570. * Interface for screenshot methods with describe argument called `size` as object with options
  108571. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  108572. */
  108573. export interface IScreenshotSize {
  108574. /**
  108575. * number in pixels for canvas height
  108576. */
  108577. height?: number;
  108578. /**
  108579. * multiplier allowing render at a higher or lower resolution
  108580. * If value is defined then height and width will be ignored and taken from camera
  108581. */
  108582. precision?: number;
  108583. /**
  108584. * number in pixels for canvas width
  108585. */
  108586. width?: number;
  108587. }
  108588. }
  108589. declare module BABYLON {
  108590. interface IColor4Like {
  108591. r: float;
  108592. g: float;
  108593. b: float;
  108594. a: float;
  108595. }
  108596. /**
  108597. * Class containing a set of static utilities functions
  108598. */
  108599. export class Tools {
  108600. /**
  108601. * Gets or sets the base URL to use to load assets
  108602. */
  108603. static get BaseUrl(): string;
  108604. static set BaseUrl(value: string);
  108605. /**
  108606. * Enable/Disable Custom HTTP Request Headers globally.
  108607. * default = false
  108608. * @see CustomRequestHeaders
  108609. */
  108610. static UseCustomRequestHeaders: boolean;
  108611. /**
  108612. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  108613. * i.e. when loading files, where the server/service expects an Authorization header
  108614. */
  108615. static CustomRequestHeaders: {
  108616. [key: string]: string;
  108617. };
  108618. /**
  108619. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  108620. */
  108621. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  108622. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  108623. /**
  108624. * Default behaviour for cors in the application.
  108625. * It can be a string if the expected behavior is identical in the entire app.
  108626. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  108627. */
  108628. static get CorsBehavior(): string | ((url: string | string[]) => string);
  108629. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  108630. /**
  108631. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108632. * @ignorenaming
  108633. */
  108634. static get UseFallbackTexture(): boolean;
  108635. static set UseFallbackTexture(value: boolean);
  108636. /**
  108637. * Use this object to register external classes like custom textures or material
  108638. * to allow the laoders to instantiate them
  108639. */
  108640. static get RegisteredExternalClasses(): {
  108641. [key: string]: Object;
  108642. };
  108643. static set RegisteredExternalClasses(classes: {
  108644. [key: string]: Object;
  108645. });
  108646. /**
  108647. * Texture content used if a texture cannot loaded
  108648. * @ignorenaming
  108649. */
  108650. static get fallbackTexture(): string;
  108651. static set fallbackTexture(value: string);
  108652. /**
  108653. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  108654. * @param u defines the coordinate on X axis
  108655. * @param v defines the coordinate on Y axis
  108656. * @param width defines the width of the source data
  108657. * @param height defines the height of the source data
  108658. * @param pixels defines the source byte array
  108659. * @param color defines the output color
  108660. */
  108661. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  108662. /**
  108663. * Interpolates between a and b via alpha
  108664. * @param a The lower value (returned when alpha = 0)
  108665. * @param b The upper value (returned when alpha = 1)
  108666. * @param alpha The interpolation-factor
  108667. * @return The mixed value
  108668. */
  108669. static Mix(a: number, b: number, alpha: number): number;
  108670. /**
  108671. * Tries to instantiate a new object from a given class name
  108672. * @param className defines the class name to instantiate
  108673. * @returns the new object or null if the system was not able to do the instantiation
  108674. */
  108675. static Instantiate(className: string): any;
  108676. /**
  108677. * Provides a slice function that will work even on IE
  108678. * @param data defines the array to slice
  108679. * @param start defines the start of the data (optional)
  108680. * @param end defines the end of the data (optional)
  108681. * @returns the new sliced array
  108682. */
  108683. static Slice<T>(data: T, start?: number, end?: number): T;
  108684. /**
  108685. * Polyfill for setImmediate
  108686. * @param action defines the action to execute after the current execution block
  108687. */
  108688. static SetImmediate(action: () => void): void;
  108689. /**
  108690. * Function indicating if a number is an exponent of 2
  108691. * @param value defines the value to test
  108692. * @returns true if the value is an exponent of 2
  108693. */
  108694. static IsExponentOfTwo(value: number): boolean;
  108695. private static _tmpFloatArray;
  108696. /**
  108697. * Returns the nearest 32-bit single precision float representation of a Number
  108698. * @param value A Number. If the parameter is of a different type, it will get converted
  108699. * to a number or to NaN if it cannot be converted
  108700. * @returns number
  108701. */
  108702. static FloatRound(value: number): number;
  108703. /**
  108704. * Extracts the filename from a path
  108705. * @param path defines the path to use
  108706. * @returns the filename
  108707. */
  108708. static GetFilename(path: string): string;
  108709. /**
  108710. * Extracts the "folder" part of a path (everything before the filename).
  108711. * @param uri The URI to extract the info from
  108712. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  108713. * @returns The "folder" part of the path
  108714. */
  108715. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  108716. /**
  108717. * Extracts text content from a DOM element hierarchy
  108718. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  108719. */
  108720. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  108721. /**
  108722. * Convert an angle in radians to degrees
  108723. * @param angle defines the angle to convert
  108724. * @returns the angle in degrees
  108725. */
  108726. static ToDegrees(angle: number): number;
  108727. /**
  108728. * Convert an angle in degrees to radians
  108729. * @param angle defines the angle to convert
  108730. * @returns the angle in radians
  108731. */
  108732. static ToRadians(angle: number): number;
  108733. /**
  108734. * Returns an array if obj is not an array
  108735. * @param obj defines the object to evaluate as an array
  108736. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  108737. * @returns either obj directly if obj is an array or a new array containing obj
  108738. */
  108739. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  108740. /**
  108741. * Gets the pointer prefix to use
  108742. * @returns "pointer" if touch is enabled. Else returns "mouse"
  108743. */
  108744. static GetPointerPrefix(): string;
  108745. /**
  108746. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  108747. * @param url define the url we are trying
  108748. * @param element define the dom element where to configure the cors policy
  108749. */
  108750. static SetCorsBehavior(url: string | string[], element: {
  108751. crossOrigin: string | null;
  108752. }): void;
  108753. /**
  108754. * Removes unwanted characters from an url
  108755. * @param url defines the url to clean
  108756. * @returns the cleaned url
  108757. */
  108758. static CleanUrl(url: string): string;
  108759. /**
  108760. * Gets or sets a function used to pre-process url before using them to load assets
  108761. */
  108762. static get PreprocessUrl(): (url: string) => string;
  108763. static set PreprocessUrl(processor: (url: string) => string);
  108764. /**
  108765. * Loads an image as an HTMLImageElement.
  108766. * @param input url string, ArrayBuffer, or Blob to load
  108767. * @param onLoad callback called when the image successfully loads
  108768. * @param onError callback called when the image fails to load
  108769. * @param offlineProvider offline provider for caching
  108770. * @param mimeType optional mime type
  108771. * @returns the HTMLImageElement of the loaded image
  108772. */
  108773. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108774. /**
  108775. * Loads a file from a url
  108776. * @param url url string, ArrayBuffer, or Blob to load
  108777. * @param onSuccess callback called when the file successfully loads
  108778. * @param onProgress callback called while file is loading (if the server supports this mode)
  108779. * @param offlineProvider defines the offline provider for caching
  108780. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108781. * @param onError callback called when the file fails to load
  108782. * @returns a file request object
  108783. */
  108784. 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;
  108785. /**
  108786. * Loads a file from a url
  108787. * @param url the file url to load
  108788. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108789. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  108790. */
  108791. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  108792. /**
  108793. * Load a script (identified by an url). When the url returns, the
  108794. * content of this file is added into a new script element, attached to the DOM (body element)
  108795. * @param scriptUrl defines the url of the script to laod
  108796. * @param onSuccess defines the callback called when the script is loaded
  108797. * @param onError defines the callback to call if an error occurs
  108798. * @param scriptId defines the id of the script element
  108799. */
  108800. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  108801. /**
  108802. * Load an asynchronous script (identified by an url). When the url returns, the
  108803. * content of this file is added into a new script element, attached to the DOM (body element)
  108804. * @param scriptUrl defines the url of the script to laod
  108805. * @param scriptId defines the id of the script element
  108806. * @returns a promise request object
  108807. */
  108808. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  108809. /**
  108810. * Loads a file from a blob
  108811. * @param fileToLoad defines the blob to use
  108812. * @param callback defines the callback to call when data is loaded
  108813. * @param progressCallback defines the callback to call during loading process
  108814. * @returns a file request object
  108815. */
  108816. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  108817. /**
  108818. * Reads a file from a File object
  108819. * @param file defines the file to load
  108820. * @param onSuccess defines the callback to call when data is loaded
  108821. * @param onProgress defines the callback to call during loading process
  108822. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  108823. * @param onError defines the callback to call when an error occurs
  108824. * @returns a file request object
  108825. */
  108826. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108827. /**
  108828. * Creates a data url from a given string content
  108829. * @param content defines the content to convert
  108830. * @returns the new data url link
  108831. */
  108832. static FileAsURL(content: string): string;
  108833. /**
  108834. * Format the given number to a specific decimal format
  108835. * @param value defines the number to format
  108836. * @param decimals defines the number of decimals to use
  108837. * @returns the formatted string
  108838. */
  108839. static Format(value: number, decimals?: number): string;
  108840. /**
  108841. * Tries to copy an object by duplicating every property
  108842. * @param source defines the source object
  108843. * @param destination defines the target object
  108844. * @param doNotCopyList defines a list of properties to avoid
  108845. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  108846. */
  108847. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  108848. /**
  108849. * Gets a boolean indicating if the given object has no own property
  108850. * @param obj defines the object to test
  108851. * @returns true if object has no own property
  108852. */
  108853. static IsEmpty(obj: any): boolean;
  108854. /**
  108855. * Function used to register events at window level
  108856. * @param windowElement defines the Window object to use
  108857. * @param events defines the events to register
  108858. */
  108859. static RegisterTopRootEvents(windowElement: Window, events: {
  108860. name: string;
  108861. handler: Nullable<(e: FocusEvent) => any>;
  108862. }[]): void;
  108863. /**
  108864. * Function used to unregister events from window level
  108865. * @param windowElement defines the Window object to use
  108866. * @param events defines the events to unregister
  108867. */
  108868. static UnregisterTopRootEvents(windowElement: Window, events: {
  108869. name: string;
  108870. handler: Nullable<(e: FocusEvent) => any>;
  108871. }[]): void;
  108872. /**
  108873. * @ignore
  108874. */
  108875. static _ScreenshotCanvas: HTMLCanvasElement;
  108876. /**
  108877. * Dumps the current bound framebuffer
  108878. * @param width defines the rendering width
  108879. * @param height defines the rendering height
  108880. * @param engine defines the hosting engine
  108881. * @param successCallback defines the callback triggered once the data are available
  108882. * @param mimeType defines the mime type of the result
  108883. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  108884. */
  108885. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108886. /**
  108887. * Converts the canvas data to blob.
  108888. * This acts as a polyfill for browsers not supporting the to blob function.
  108889. * @param canvas Defines the canvas to extract the data from
  108890. * @param successCallback Defines the callback triggered once the data are available
  108891. * @param mimeType Defines the mime type of the result
  108892. */
  108893. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  108894. /**
  108895. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  108896. * @param successCallback defines the callback triggered once the data are available
  108897. * @param mimeType defines the mime type of the result
  108898. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  108899. */
  108900. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108901. /**
  108902. * Downloads a blob in the browser
  108903. * @param blob defines the blob to download
  108904. * @param fileName defines the name of the downloaded file
  108905. */
  108906. static Download(blob: Blob, fileName: string): void;
  108907. /**
  108908. * Captures a screenshot of the current rendering
  108909. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108910. * @param engine defines the rendering engine
  108911. * @param camera defines the source camera
  108912. * @param size This parameter can be set to a single number or to an object with the
  108913. * following (optional) properties: precision, width, height. If a single number is passed,
  108914. * it will be used for both width and height. If an object is passed, the screenshot size
  108915. * will be derived from the parameters. The precision property is a multiplier allowing
  108916. * rendering at a higher or lower resolution
  108917. * @param successCallback defines the callback receives a single parameter which contains the
  108918. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108919. * src parameter of an <img> to display it
  108920. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108921. * Check your browser for supported MIME types
  108922. */
  108923. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  108924. /**
  108925. * Captures a screenshot of the current rendering
  108926. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108927. * @param engine defines the rendering engine
  108928. * @param camera defines the source camera
  108929. * @param size This parameter can be set to a single number or to an object with the
  108930. * following (optional) properties: precision, width, height. If a single number is passed,
  108931. * it will be used for both width and height. If an object is passed, the screenshot size
  108932. * will be derived from the parameters. The precision property is a multiplier allowing
  108933. * rendering at a higher or lower resolution
  108934. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108935. * Check your browser for supported MIME types
  108936. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108937. * to the src parameter of an <img> to display it
  108938. */
  108939. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108940. /**
  108941. * Generates an image screenshot from the specified camera.
  108942. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108943. * @param engine The engine to use for rendering
  108944. * @param camera The camera to use for rendering
  108945. * @param size This parameter can be set to a single number or to an object with the
  108946. * following (optional) properties: precision, width, height. If a single number is passed,
  108947. * it will be used for both width and height. If an object is passed, the screenshot size
  108948. * will be derived from the parameters. The precision property is a multiplier allowing
  108949. * rendering at a higher or lower resolution
  108950. * @param successCallback The callback receives a single parameter which contains the
  108951. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108952. * src parameter of an <img> to display it
  108953. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108954. * Check your browser for supported MIME types
  108955. * @param samples Texture samples (default: 1)
  108956. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108957. * @param fileName A name for for the downloaded file.
  108958. */
  108959. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108960. /**
  108961. * Generates an image screenshot from the specified camera.
  108962. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108963. * @param engine The engine to use for rendering
  108964. * @param camera The camera to use for rendering
  108965. * @param size This parameter can be set to a single number or to an object with the
  108966. * following (optional) properties: precision, width, height. If a single number is passed,
  108967. * it will be used for both width and height. If an object is passed, the screenshot size
  108968. * will be derived from the parameters. The precision property is a multiplier allowing
  108969. * rendering at a higher or lower resolution
  108970. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108971. * Check your browser for supported MIME types
  108972. * @param samples Texture samples (default: 1)
  108973. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108974. * @param fileName A name for for the downloaded file.
  108975. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108976. * to the src parameter of an <img> to display it
  108977. */
  108978. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108979. /**
  108980. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108981. * Be aware Math.random() could cause collisions, but:
  108982. * "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"
  108983. * @returns a pseudo random id
  108984. */
  108985. static RandomId(): string;
  108986. /**
  108987. * Test if the given uri is a base64 string
  108988. * @param uri The uri to test
  108989. * @return True if the uri is a base64 string or false otherwise
  108990. */
  108991. static IsBase64(uri: string): boolean;
  108992. /**
  108993. * Decode the given base64 uri.
  108994. * @param uri The uri to decode
  108995. * @return The decoded base64 data.
  108996. */
  108997. static DecodeBase64(uri: string): ArrayBuffer;
  108998. /**
  108999. * Gets the absolute url.
  109000. * @param url the input url
  109001. * @return the absolute url
  109002. */
  109003. static GetAbsoluteUrl(url: string): string;
  109004. /**
  109005. * No log
  109006. */
  109007. static readonly NoneLogLevel: number;
  109008. /**
  109009. * Only message logs
  109010. */
  109011. static readonly MessageLogLevel: number;
  109012. /**
  109013. * Only warning logs
  109014. */
  109015. static readonly WarningLogLevel: number;
  109016. /**
  109017. * Only error logs
  109018. */
  109019. static readonly ErrorLogLevel: number;
  109020. /**
  109021. * All logs
  109022. */
  109023. static readonly AllLogLevel: number;
  109024. /**
  109025. * Gets a value indicating the number of loading errors
  109026. * @ignorenaming
  109027. */
  109028. static get errorsCount(): number;
  109029. /**
  109030. * Callback called when a new log is added
  109031. */
  109032. static OnNewCacheEntry: (entry: string) => void;
  109033. /**
  109034. * Log a message to the console
  109035. * @param message defines the message to log
  109036. */
  109037. static Log(message: string): void;
  109038. /**
  109039. * Write a warning message to the console
  109040. * @param message defines the message to log
  109041. */
  109042. static Warn(message: string): void;
  109043. /**
  109044. * Write an error message to the console
  109045. * @param message defines the message to log
  109046. */
  109047. static Error(message: string): void;
  109048. /**
  109049. * Gets current log cache (list of logs)
  109050. */
  109051. static get LogCache(): string;
  109052. /**
  109053. * Clears the log cache
  109054. */
  109055. static ClearLogCache(): void;
  109056. /**
  109057. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  109058. */
  109059. static set LogLevels(level: number);
  109060. /**
  109061. * Checks if the window object exists
  109062. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  109063. */
  109064. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  109065. /**
  109066. * No performance log
  109067. */
  109068. static readonly PerformanceNoneLogLevel: number;
  109069. /**
  109070. * Use user marks to log performance
  109071. */
  109072. static readonly PerformanceUserMarkLogLevel: number;
  109073. /**
  109074. * Log performance to the console
  109075. */
  109076. static readonly PerformanceConsoleLogLevel: number;
  109077. private static _performance;
  109078. /**
  109079. * Sets the current performance log level
  109080. */
  109081. static set PerformanceLogLevel(level: number);
  109082. private static _StartPerformanceCounterDisabled;
  109083. private static _EndPerformanceCounterDisabled;
  109084. private static _StartUserMark;
  109085. private static _EndUserMark;
  109086. private static _StartPerformanceConsole;
  109087. private static _EndPerformanceConsole;
  109088. /**
  109089. * Starts a performance counter
  109090. */
  109091. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109092. /**
  109093. * Ends a specific performance coutner
  109094. */
  109095. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109096. /**
  109097. * Gets either window.performance.now() if supported or Date.now() else
  109098. */
  109099. static get Now(): number;
  109100. /**
  109101. * This method will return the name of the class used to create the instance of the given object.
  109102. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  109103. * @param object the object to get the class name from
  109104. * @param isType defines if the object is actually a type
  109105. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  109106. */
  109107. static GetClassName(object: any, isType?: boolean): string;
  109108. /**
  109109. * Gets the first element of an array satisfying a given predicate
  109110. * @param array defines the array to browse
  109111. * @param predicate defines the predicate to use
  109112. * @returns null if not found or the element
  109113. */
  109114. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  109115. /**
  109116. * This method will return the name of the full name of the class, including its owning module (if any).
  109117. * 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).
  109118. * @param object the object to get the class name from
  109119. * @param isType defines if the object is actually a type
  109120. * @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.
  109121. * @ignorenaming
  109122. */
  109123. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  109124. /**
  109125. * Returns a promise that resolves after the given amount of time.
  109126. * @param delay Number of milliseconds to delay
  109127. * @returns Promise that resolves after the given amount of time
  109128. */
  109129. static DelayAsync(delay: number): Promise<void>;
  109130. /**
  109131. * Utility function to detect if the current user agent is Safari
  109132. * @returns whether or not the current user agent is safari
  109133. */
  109134. static IsSafari(): boolean;
  109135. }
  109136. /**
  109137. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  109138. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  109139. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  109140. * @param name The name of the class, case should be preserved
  109141. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  109142. */
  109143. export function className(name: string, module?: string): (target: Object) => void;
  109144. /**
  109145. * An implementation of a loop for asynchronous functions.
  109146. */
  109147. export class AsyncLoop {
  109148. /**
  109149. * Defines the number of iterations for the loop
  109150. */
  109151. iterations: number;
  109152. /**
  109153. * Defines the current index of the loop.
  109154. */
  109155. index: number;
  109156. private _done;
  109157. private _fn;
  109158. private _successCallback;
  109159. /**
  109160. * Constructor.
  109161. * @param iterations the number of iterations.
  109162. * @param func the function to run each iteration
  109163. * @param successCallback the callback that will be called upon succesful execution
  109164. * @param offset starting offset.
  109165. */
  109166. constructor(
  109167. /**
  109168. * Defines the number of iterations for the loop
  109169. */
  109170. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  109171. /**
  109172. * Execute the next iteration. Must be called after the last iteration was finished.
  109173. */
  109174. executeNext(): void;
  109175. /**
  109176. * Break the loop and run the success callback.
  109177. */
  109178. breakLoop(): void;
  109179. /**
  109180. * Create and run an async loop.
  109181. * @param iterations the number of iterations.
  109182. * @param fn the function to run each iteration
  109183. * @param successCallback the callback that will be called upon succesful execution
  109184. * @param offset starting offset.
  109185. * @returns the created async loop object
  109186. */
  109187. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  109188. /**
  109189. * A for-loop that will run a given number of iterations synchronous and the rest async.
  109190. * @param iterations total number of iterations
  109191. * @param syncedIterations number of synchronous iterations in each async iteration.
  109192. * @param fn the function to call each iteration.
  109193. * @param callback a success call back that will be called when iterating stops.
  109194. * @param breakFunction a break condition (optional)
  109195. * @param timeout timeout settings for the setTimeout function. default - 0.
  109196. * @returns the created async loop object
  109197. */
  109198. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  109199. }
  109200. }
  109201. declare module BABYLON {
  109202. /**
  109203. * This class implement a typical dictionary using a string as key and the generic type T as value.
  109204. * The underlying implementation relies on an associative array to ensure the best performances.
  109205. * The value can be anything including 'null' but except 'undefined'
  109206. */
  109207. export class StringDictionary<T> {
  109208. /**
  109209. * This will clear this dictionary and copy the content from the 'source' one.
  109210. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  109211. * @param source the dictionary to take the content from and copy to this dictionary
  109212. */
  109213. copyFrom(source: StringDictionary<T>): void;
  109214. /**
  109215. * Get a value based from its key
  109216. * @param key the given key to get the matching value from
  109217. * @return the value if found, otherwise undefined is returned
  109218. */
  109219. get(key: string): T | undefined;
  109220. /**
  109221. * Get a value from its key or add it if it doesn't exist.
  109222. * This method will ensure you that a given key/data will be present in the dictionary.
  109223. * @param key the given key to get the matching value from
  109224. * @param factory the factory that will create the value if the key is not present in the dictionary.
  109225. * The factory will only be invoked if there's no data for the given key.
  109226. * @return the value corresponding to the key.
  109227. */
  109228. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  109229. /**
  109230. * Get a value from its key if present in the dictionary otherwise add it
  109231. * @param key the key to get the value from
  109232. * @param val if there's no such key/value pair in the dictionary add it with this value
  109233. * @return the value corresponding to the key
  109234. */
  109235. getOrAdd(key: string, val: T): T;
  109236. /**
  109237. * Check if there's a given key in the dictionary
  109238. * @param key the key to check for
  109239. * @return true if the key is present, false otherwise
  109240. */
  109241. contains(key: string): boolean;
  109242. /**
  109243. * Add a new key and its corresponding value
  109244. * @param key the key to add
  109245. * @param value the value corresponding to the key
  109246. * @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
  109247. */
  109248. add(key: string, value: T): boolean;
  109249. /**
  109250. * Update a specific value associated to a key
  109251. * @param key defines the key to use
  109252. * @param value defines the value to store
  109253. * @returns true if the value was updated (or false if the key was not found)
  109254. */
  109255. set(key: string, value: T): boolean;
  109256. /**
  109257. * Get the element of the given key and remove it from the dictionary
  109258. * @param key defines the key to search
  109259. * @returns the value associated with the key or null if not found
  109260. */
  109261. getAndRemove(key: string): Nullable<T>;
  109262. /**
  109263. * Remove a key/value from the dictionary.
  109264. * @param key the key to remove
  109265. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  109266. */
  109267. remove(key: string): boolean;
  109268. /**
  109269. * Clear the whole content of the dictionary
  109270. */
  109271. clear(): void;
  109272. /**
  109273. * Gets the current count
  109274. */
  109275. get count(): number;
  109276. /**
  109277. * Execute a callback on each key/val of the dictionary.
  109278. * Note that you can remove any element in this dictionary in the callback implementation
  109279. * @param callback the callback to execute on a given key/value pair
  109280. */
  109281. forEach(callback: (key: string, val: T) => void): void;
  109282. /**
  109283. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  109284. * If the callback returns null or undefined the method will iterate to the next key/value pair
  109285. * Note that you can remove any element in this dictionary in the callback implementation
  109286. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  109287. * @returns the first item
  109288. */
  109289. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  109290. private _count;
  109291. private _data;
  109292. }
  109293. }
  109294. declare module BABYLON {
  109295. /** @hidden */
  109296. export interface ICollisionCoordinator {
  109297. createCollider(): Collider;
  109298. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109299. init(scene: Scene): void;
  109300. }
  109301. /** @hidden */
  109302. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  109303. private _scene;
  109304. private _scaledPosition;
  109305. private _scaledVelocity;
  109306. private _finalPosition;
  109307. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109308. createCollider(): Collider;
  109309. init(scene: Scene): void;
  109310. private _collideWithWorld;
  109311. }
  109312. }
  109313. declare module BABYLON {
  109314. /**
  109315. * Class used to manage all inputs for the scene.
  109316. */
  109317. export class InputManager {
  109318. /** The distance in pixel that you have to move to prevent some events */
  109319. static DragMovementThreshold: number;
  109320. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  109321. static LongPressDelay: number;
  109322. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  109323. static DoubleClickDelay: number;
  109324. /** If you need to check double click without raising a single click at first click, enable this flag */
  109325. static ExclusiveDoubleClickMode: boolean;
  109326. private _wheelEventName;
  109327. private _onPointerMove;
  109328. private _onPointerDown;
  109329. private _onPointerUp;
  109330. private _initClickEvent;
  109331. private _initActionManager;
  109332. private _delayedSimpleClick;
  109333. private _delayedSimpleClickTimeout;
  109334. private _previousDelayedSimpleClickTimeout;
  109335. private _meshPickProceed;
  109336. private _previousButtonPressed;
  109337. private _currentPickResult;
  109338. private _previousPickResult;
  109339. private _totalPointersPressed;
  109340. private _doubleClickOccured;
  109341. private _pointerOverMesh;
  109342. private _pickedDownMesh;
  109343. private _pickedUpMesh;
  109344. private _pointerX;
  109345. private _pointerY;
  109346. private _unTranslatedPointerX;
  109347. private _unTranslatedPointerY;
  109348. private _startingPointerPosition;
  109349. private _previousStartingPointerPosition;
  109350. private _startingPointerTime;
  109351. private _previousStartingPointerTime;
  109352. private _pointerCaptures;
  109353. private _onKeyDown;
  109354. private _onKeyUp;
  109355. private _onCanvasFocusObserver;
  109356. private _onCanvasBlurObserver;
  109357. private _scene;
  109358. /**
  109359. * Creates a new InputManager
  109360. * @param scene defines the hosting scene
  109361. */
  109362. constructor(scene: Scene);
  109363. /**
  109364. * Gets the mesh that is currently under the pointer
  109365. */
  109366. get meshUnderPointer(): Nullable<AbstractMesh>;
  109367. /**
  109368. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  109369. */
  109370. get unTranslatedPointer(): Vector2;
  109371. /**
  109372. * Gets or sets the current on-screen X position of the pointer
  109373. */
  109374. get pointerX(): number;
  109375. set pointerX(value: number);
  109376. /**
  109377. * Gets or sets the current on-screen Y position of the pointer
  109378. */
  109379. get pointerY(): number;
  109380. set pointerY(value: number);
  109381. private _updatePointerPosition;
  109382. private _processPointerMove;
  109383. private _setRayOnPointerInfo;
  109384. private _checkPrePointerObservable;
  109385. /**
  109386. * Use this method to simulate a pointer move on a mesh
  109387. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109388. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109389. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109390. */
  109391. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109392. /**
  109393. * Use this method to simulate a pointer down on a mesh
  109394. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109395. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109396. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109397. */
  109398. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109399. private _processPointerDown;
  109400. /** @hidden */
  109401. _isPointerSwiping(): boolean;
  109402. /**
  109403. * Use this method to simulate a pointer up on a mesh
  109404. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109405. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109406. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109407. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109408. */
  109409. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  109410. private _processPointerUp;
  109411. /**
  109412. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109413. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109414. * @returns true if the pointer was captured
  109415. */
  109416. isPointerCaptured(pointerId?: number): boolean;
  109417. /**
  109418. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109419. * @param attachUp defines if you want to attach events to pointerup
  109420. * @param attachDown defines if you want to attach events to pointerdown
  109421. * @param attachMove defines if you want to attach events to pointermove
  109422. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  109423. */
  109424. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  109425. /**
  109426. * Detaches all event handlers
  109427. */
  109428. detachControl(): void;
  109429. /**
  109430. * Force the value of meshUnderPointer
  109431. * @param mesh defines the mesh to use
  109432. */
  109433. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109434. /**
  109435. * Gets the mesh under the pointer
  109436. * @returns a Mesh or null if no mesh is under the pointer
  109437. */
  109438. getPointerOverMesh(): Nullable<AbstractMesh>;
  109439. }
  109440. }
  109441. declare module BABYLON {
  109442. /**
  109443. * Helper class used to generate session unique ID
  109444. */
  109445. export class UniqueIdGenerator {
  109446. private static _UniqueIdCounter;
  109447. /**
  109448. * Gets an unique (relatively to the current scene) Id
  109449. */
  109450. static get UniqueId(): number;
  109451. }
  109452. }
  109453. declare module BABYLON {
  109454. /**
  109455. * This class defines the direct association between an animation and a target
  109456. */
  109457. export class TargetedAnimation {
  109458. /**
  109459. * Animation to perform
  109460. */
  109461. animation: Animation;
  109462. /**
  109463. * Target to animate
  109464. */
  109465. target: any;
  109466. /**
  109467. * Serialize the object
  109468. * @returns the JSON object representing the current entity
  109469. */
  109470. serialize(): any;
  109471. }
  109472. /**
  109473. * Use this class to create coordinated animations on multiple targets
  109474. */
  109475. export class AnimationGroup implements IDisposable {
  109476. /** The name of the animation group */
  109477. name: string;
  109478. private _scene;
  109479. private _targetedAnimations;
  109480. private _animatables;
  109481. private _from;
  109482. private _to;
  109483. private _isStarted;
  109484. private _isPaused;
  109485. private _speedRatio;
  109486. private _loopAnimation;
  109487. private _isAdditive;
  109488. /**
  109489. * Gets or sets the unique id of the node
  109490. */
  109491. uniqueId: number;
  109492. /**
  109493. * This observable will notify when one animation have ended
  109494. */
  109495. onAnimationEndObservable: Observable<TargetedAnimation>;
  109496. /**
  109497. * Observer raised when one animation loops
  109498. */
  109499. onAnimationLoopObservable: Observable<TargetedAnimation>;
  109500. /**
  109501. * Observer raised when all animations have looped
  109502. */
  109503. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  109504. /**
  109505. * This observable will notify when all animations have ended.
  109506. */
  109507. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  109508. /**
  109509. * This observable will notify when all animations have paused.
  109510. */
  109511. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  109512. /**
  109513. * This observable will notify when all animations are playing.
  109514. */
  109515. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  109516. /**
  109517. * Gets the first frame
  109518. */
  109519. get from(): number;
  109520. /**
  109521. * Gets the last frame
  109522. */
  109523. get to(): number;
  109524. /**
  109525. * Define if the animations are started
  109526. */
  109527. get isStarted(): boolean;
  109528. /**
  109529. * Gets a value indicating that the current group is playing
  109530. */
  109531. get isPlaying(): boolean;
  109532. /**
  109533. * Gets or sets the speed ratio to use for all animations
  109534. */
  109535. get speedRatio(): number;
  109536. /**
  109537. * Gets or sets the speed ratio to use for all animations
  109538. */
  109539. set speedRatio(value: number);
  109540. /**
  109541. * Gets or sets if all animations should loop or not
  109542. */
  109543. get loopAnimation(): boolean;
  109544. set loopAnimation(value: boolean);
  109545. /**
  109546. * Gets or sets if all animations should be evaluated additively
  109547. */
  109548. get isAdditive(): boolean;
  109549. set isAdditive(value: boolean);
  109550. /**
  109551. * Gets the targeted animations for this animation group
  109552. */
  109553. get targetedAnimations(): Array<TargetedAnimation>;
  109554. /**
  109555. * returning the list of animatables controlled by this animation group.
  109556. */
  109557. get animatables(): Array<Animatable>;
  109558. /**
  109559. * Instantiates a new Animation Group.
  109560. * This helps managing several animations at once.
  109561. * @see http://doc.babylonjs.com/how_to/group
  109562. * @param name Defines the name of the group
  109563. * @param scene Defines the scene the group belongs to
  109564. */
  109565. constructor(
  109566. /** The name of the animation group */
  109567. name: string, scene?: Nullable<Scene>);
  109568. /**
  109569. * Add an animation (with its target) in the group
  109570. * @param animation defines the animation we want to add
  109571. * @param target defines the target of the animation
  109572. * @returns the TargetedAnimation object
  109573. */
  109574. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  109575. /**
  109576. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  109577. * It can add constant keys at begin or end
  109578. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  109579. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  109580. * @returns the animation group
  109581. */
  109582. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  109583. private _animationLoopCount;
  109584. private _animationLoopFlags;
  109585. private _processLoop;
  109586. /**
  109587. * Start all animations on given targets
  109588. * @param loop defines if animations must loop
  109589. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  109590. * @param from defines the from key (optional)
  109591. * @param to defines the to key (optional)
  109592. * @param isAdditive defines the additive state for the resulting animatables (optional)
  109593. * @returns the current animation group
  109594. */
  109595. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  109596. /**
  109597. * Pause all animations
  109598. * @returns the animation group
  109599. */
  109600. pause(): AnimationGroup;
  109601. /**
  109602. * Play all animations to initial state
  109603. * This function will start() the animations if they were not started or will restart() them if they were paused
  109604. * @param loop defines if animations must loop
  109605. * @returns the animation group
  109606. */
  109607. play(loop?: boolean): AnimationGroup;
  109608. /**
  109609. * Reset all animations to initial state
  109610. * @returns the animation group
  109611. */
  109612. reset(): AnimationGroup;
  109613. /**
  109614. * Restart animations from key 0
  109615. * @returns the animation group
  109616. */
  109617. restart(): AnimationGroup;
  109618. /**
  109619. * Stop all animations
  109620. * @returns the animation group
  109621. */
  109622. stop(): AnimationGroup;
  109623. /**
  109624. * Set animation weight for all animatables
  109625. * @param weight defines the weight to use
  109626. * @return the animationGroup
  109627. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109628. */
  109629. setWeightForAllAnimatables(weight: number): AnimationGroup;
  109630. /**
  109631. * Synchronize and normalize all animatables with a source animatable
  109632. * @param root defines the root animatable to synchronize with
  109633. * @return the animationGroup
  109634. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109635. */
  109636. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  109637. /**
  109638. * Goes to a specific frame in this animation group
  109639. * @param frame the frame number to go to
  109640. * @return the animationGroup
  109641. */
  109642. goToFrame(frame: number): AnimationGroup;
  109643. /**
  109644. * Dispose all associated resources
  109645. */
  109646. dispose(): void;
  109647. private _checkAnimationGroupEnded;
  109648. /**
  109649. * Clone the current animation group and returns a copy
  109650. * @param newName defines the name of the new group
  109651. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  109652. * @returns the new aniamtion group
  109653. */
  109654. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  109655. /**
  109656. * Serializes the animationGroup to an object
  109657. * @returns Serialized object
  109658. */
  109659. serialize(): any;
  109660. /**
  109661. * Returns a new AnimationGroup object parsed from the source provided.
  109662. * @param parsedAnimationGroup defines the source
  109663. * @param scene defines the scene that will receive the animationGroup
  109664. * @returns a new AnimationGroup
  109665. */
  109666. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  109667. /**
  109668. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109669. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  109670. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109671. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  109672. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  109673. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  109674. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  109675. */
  109676. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  109677. /**
  109678. * Returns the string "AnimationGroup"
  109679. * @returns "AnimationGroup"
  109680. */
  109681. getClassName(): string;
  109682. /**
  109683. * Creates a detailled string about the object
  109684. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  109685. * @returns a string representing the object
  109686. */
  109687. toString(fullDetails?: boolean): string;
  109688. }
  109689. }
  109690. declare module BABYLON {
  109691. /**
  109692. * Define an interface for all classes that will hold resources
  109693. */
  109694. export interface IDisposable {
  109695. /**
  109696. * Releases all held resources
  109697. */
  109698. dispose(): void;
  109699. }
  109700. /** Interface defining initialization parameters for Scene class */
  109701. export interface SceneOptions {
  109702. /**
  109703. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  109704. * It will improve performance when the number of geometries becomes important.
  109705. */
  109706. useGeometryUniqueIdsMap?: boolean;
  109707. /**
  109708. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  109709. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109710. */
  109711. useMaterialMeshMap?: boolean;
  109712. /**
  109713. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  109714. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109715. */
  109716. useClonedMeshMap?: boolean;
  109717. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  109718. virtual?: boolean;
  109719. }
  109720. /**
  109721. * Represents a scene to be rendered by the engine.
  109722. * @see http://doc.babylonjs.com/features/scene
  109723. */
  109724. export class Scene extends AbstractScene implements IAnimatable {
  109725. /** The fog is deactivated */
  109726. static readonly FOGMODE_NONE: number;
  109727. /** The fog density is following an exponential function */
  109728. static readonly FOGMODE_EXP: number;
  109729. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  109730. static readonly FOGMODE_EXP2: number;
  109731. /** The fog density is following a linear function. */
  109732. static readonly FOGMODE_LINEAR: number;
  109733. /**
  109734. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  109735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109736. */
  109737. static MinDeltaTime: number;
  109738. /**
  109739. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  109740. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109741. */
  109742. static MaxDeltaTime: number;
  109743. /**
  109744. * Factory used to create the default material.
  109745. * @param name The name of the material to create
  109746. * @param scene The scene to create the material for
  109747. * @returns The default material
  109748. */
  109749. static DefaultMaterialFactory(scene: Scene): Material;
  109750. /**
  109751. * Factory used to create the a collision coordinator.
  109752. * @returns The collision coordinator
  109753. */
  109754. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  109755. /** @hidden */
  109756. _inputManager: InputManager;
  109757. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  109758. cameraToUseForPointers: Nullable<Camera>;
  109759. /** @hidden */
  109760. readonly _isScene: boolean;
  109761. /** @hidden */
  109762. _blockEntityCollection: boolean;
  109763. /**
  109764. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  109765. */
  109766. autoClear: boolean;
  109767. /**
  109768. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  109769. */
  109770. autoClearDepthAndStencil: boolean;
  109771. /**
  109772. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  109773. */
  109774. clearColor: Color4;
  109775. /**
  109776. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  109777. */
  109778. ambientColor: Color3;
  109779. /**
  109780. * This is use to store the default BRDF lookup for PBR materials in your scene.
  109781. * It should only be one of the following (if not the default embedded one):
  109782. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109783. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  109784. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109785. * The material properties need to be setup according to the type of texture in use.
  109786. */
  109787. environmentBRDFTexture: BaseTexture;
  109788. /** @hidden */
  109789. protected _environmentTexture: Nullable<BaseTexture>;
  109790. /**
  109791. * Texture used in all pbr material as the reflection texture.
  109792. * As in the majority of the scene they are the same (exception for multi room and so on),
  109793. * this is easier to reference from here than from all the materials.
  109794. */
  109795. get environmentTexture(): Nullable<BaseTexture>;
  109796. /**
  109797. * Texture used in all pbr material as the reflection texture.
  109798. * As in the majority of the scene they are the same (exception for multi room and so on),
  109799. * this is easier to set here than in all the materials.
  109800. */
  109801. set environmentTexture(value: Nullable<BaseTexture>);
  109802. /** @hidden */
  109803. protected _environmentIntensity: number;
  109804. /**
  109805. * Intensity of the environment in all pbr material.
  109806. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109807. * As in the majority of the scene they are the same (exception for multi room and so on),
  109808. * this is easier to reference from here than from all the materials.
  109809. */
  109810. get environmentIntensity(): number;
  109811. /**
  109812. * Intensity of the environment in all pbr material.
  109813. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109814. * As in the majority of the scene they are the same (exception for multi room and so on),
  109815. * this is easier to set here than in all the materials.
  109816. */
  109817. set environmentIntensity(value: number);
  109818. /** @hidden */
  109819. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109820. /**
  109821. * Default image processing configuration used either in the rendering
  109822. * Forward main pass or through the imageProcessingPostProcess if present.
  109823. * As in the majority of the scene they are the same (exception for multi camera),
  109824. * this is easier to reference from here than from all the materials and post process.
  109825. *
  109826. * No setter as we it is a shared configuration, you can set the values instead.
  109827. */
  109828. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109829. private _forceWireframe;
  109830. /**
  109831. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  109832. */
  109833. set forceWireframe(value: boolean);
  109834. get forceWireframe(): boolean;
  109835. private _skipFrustumClipping;
  109836. /**
  109837. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  109838. */
  109839. set skipFrustumClipping(value: boolean);
  109840. get skipFrustumClipping(): boolean;
  109841. private _forcePointsCloud;
  109842. /**
  109843. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  109844. */
  109845. set forcePointsCloud(value: boolean);
  109846. get forcePointsCloud(): boolean;
  109847. /**
  109848. * Gets or sets the active clipplane 1
  109849. */
  109850. clipPlane: Nullable<Plane>;
  109851. /**
  109852. * Gets or sets the active clipplane 2
  109853. */
  109854. clipPlane2: Nullable<Plane>;
  109855. /**
  109856. * Gets or sets the active clipplane 3
  109857. */
  109858. clipPlane3: Nullable<Plane>;
  109859. /**
  109860. * Gets or sets the active clipplane 4
  109861. */
  109862. clipPlane4: Nullable<Plane>;
  109863. /**
  109864. * Gets or sets the active clipplane 5
  109865. */
  109866. clipPlane5: Nullable<Plane>;
  109867. /**
  109868. * Gets or sets the active clipplane 6
  109869. */
  109870. clipPlane6: Nullable<Plane>;
  109871. /**
  109872. * Gets or sets a boolean indicating if animations are enabled
  109873. */
  109874. animationsEnabled: boolean;
  109875. private _animationPropertiesOverride;
  109876. /**
  109877. * Gets or sets the animation properties override
  109878. */
  109879. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109880. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109881. /**
  109882. * Gets or sets a boolean indicating if a constant deltatime has to be used
  109883. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  109884. */
  109885. useConstantAnimationDeltaTime: boolean;
  109886. /**
  109887. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  109888. * Please note that it requires to run a ray cast through the scene on every frame
  109889. */
  109890. constantlyUpdateMeshUnderPointer: boolean;
  109891. /**
  109892. * Defines the HTML cursor to use when hovering over interactive elements
  109893. */
  109894. hoverCursor: string;
  109895. /**
  109896. * Defines the HTML default cursor to use (empty by default)
  109897. */
  109898. defaultCursor: string;
  109899. /**
  109900. * Defines whether cursors are handled by the scene.
  109901. */
  109902. doNotHandleCursors: boolean;
  109903. /**
  109904. * This is used to call preventDefault() on pointer down
  109905. * in order to block unwanted artifacts like system double clicks
  109906. */
  109907. preventDefaultOnPointerDown: boolean;
  109908. /**
  109909. * This is used to call preventDefault() on pointer up
  109910. * in order to block unwanted artifacts like system double clicks
  109911. */
  109912. preventDefaultOnPointerUp: boolean;
  109913. /**
  109914. * Gets or sets user defined metadata
  109915. */
  109916. metadata: any;
  109917. /**
  109918. * For internal use only. Please do not use.
  109919. */
  109920. reservedDataStore: any;
  109921. /**
  109922. * Gets the name of the plugin used to load this scene (null by default)
  109923. */
  109924. loadingPluginName: string;
  109925. /**
  109926. * Use this array to add regular expressions used to disable offline support for specific urls
  109927. */
  109928. disableOfflineSupportExceptionRules: RegExp[];
  109929. /**
  109930. * An event triggered when the scene is disposed.
  109931. */
  109932. onDisposeObservable: Observable<Scene>;
  109933. private _onDisposeObserver;
  109934. /** Sets a function to be executed when this scene is disposed. */
  109935. set onDispose(callback: () => void);
  109936. /**
  109937. * An event triggered before rendering the scene (right after animations and physics)
  109938. */
  109939. onBeforeRenderObservable: Observable<Scene>;
  109940. private _onBeforeRenderObserver;
  109941. /** Sets a function to be executed before rendering this scene */
  109942. set beforeRender(callback: Nullable<() => void>);
  109943. /**
  109944. * An event triggered after rendering the scene
  109945. */
  109946. onAfterRenderObservable: Observable<Scene>;
  109947. /**
  109948. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109949. */
  109950. onAfterRenderCameraObservable: Observable<Camera>;
  109951. private _onAfterRenderObserver;
  109952. /** Sets a function to be executed after rendering this scene */
  109953. set afterRender(callback: Nullable<() => void>);
  109954. /**
  109955. * An event triggered before animating the scene
  109956. */
  109957. onBeforeAnimationsObservable: Observable<Scene>;
  109958. /**
  109959. * An event triggered after animations processing
  109960. */
  109961. onAfterAnimationsObservable: Observable<Scene>;
  109962. /**
  109963. * An event triggered before draw calls are ready to be sent
  109964. */
  109965. onBeforeDrawPhaseObservable: Observable<Scene>;
  109966. /**
  109967. * An event triggered after draw calls have been sent
  109968. */
  109969. onAfterDrawPhaseObservable: Observable<Scene>;
  109970. /**
  109971. * An event triggered when the scene is ready
  109972. */
  109973. onReadyObservable: Observable<Scene>;
  109974. /**
  109975. * An event triggered before rendering a camera
  109976. */
  109977. onBeforeCameraRenderObservable: Observable<Camera>;
  109978. private _onBeforeCameraRenderObserver;
  109979. /** Sets a function to be executed before rendering a camera*/
  109980. set beforeCameraRender(callback: () => void);
  109981. /**
  109982. * An event triggered after rendering a camera
  109983. */
  109984. onAfterCameraRenderObservable: Observable<Camera>;
  109985. private _onAfterCameraRenderObserver;
  109986. /** Sets a function to be executed after rendering a camera*/
  109987. set afterCameraRender(callback: () => void);
  109988. /**
  109989. * An event triggered when active meshes evaluation is about to start
  109990. */
  109991. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  109992. /**
  109993. * An event triggered when active meshes evaluation is done
  109994. */
  109995. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  109996. /**
  109997. * An event triggered when particles rendering is about to start
  109998. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  109999. */
  110000. onBeforeParticlesRenderingObservable: Observable<Scene>;
  110001. /**
  110002. * An event triggered when particles rendering is done
  110003. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110004. */
  110005. onAfterParticlesRenderingObservable: Observable<Scene>;
  110006. /**
  110007. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  110008. */
  110009. onDataLoadedObservable: Observable<Scene>;
  110010. /**
  110011. * An event triggered when a camera is created
  110012. */
  110013. onNewCameraAddedObservable: Observable<Camera>;
  110014. /**
  110015. * An event triggered when a camera is removed
  110016. */
  110017. onCameraRemovedObservable: Observable<Camera>;
  110018. /**
  110019. * An event triggered when a light is created
  110020. */
  110021. onNewLightAddedObservable: Observable<Light>;
  110022. /**
  110023. * An event triggered when a light is removed
  110024. */
  110025. onLightRemovedObservable: Observable<Light>;
  110026. /**
  110027. * An event triggered when a geometry is created
  110028. */
  110029. onNewGeometryAddedObservable: Observable<Geometry>;
  110030. /**
  110031. * An event triggered when a geometry is removed
  110032. */
  110033. onGeometryRemovedObservable: Observable<Geometry>;
  110034. /**
  110035. * An event triggered when a transform node is created
  110036. */
  110037. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  110038. /**
  110039. * An event triggered when a transform node is removed
  110040. */
  110041. onTransformNodeRemovedObservable: Observable<TransformNode>;
  110042. /**
  110043. * An event triggered when a mesh is created
  110044. */
  110045. onNewMeshAddedObservable: Observable<AbstractMesh>;
  110046. /**
  110047. * An event triggered when a mesh is removed
  110048. */
  110049. onMeshRemovedObservable: Observable<AbstractMesh>;
  110050. /**
  110051. * An event triggered when a skeleton is created
  110052. */
  110053. onNewSkeletonAddedObservable: Observable<Skeleton>;
  110054. /**
  110055. * An event triggered when a skeleton is removed
  110056. */
  110057. onSkeletonRemovedObservable: Observable<Skeleton>;
  110058. /**
  110059. * An event triggered when a material is created
  110060. */
  110061. onNewMaterialAddedObservable: Observable<Material>;
  110062. /**
  110063. * An event triggered when a material is removed
  110064. */
  110065. onMaterialRemovedObservable: Observable<Material>;
  110066. /**
  110067. * An event triggered when a texture is created
  110068. */
  110069. onNewTextureAddedObservable: Observable<BaseTexture>;
  110070. /**
  110071. * An event triggered when a texture is removed
  110072. */
  110073. onTextureRemovedObservable: Observable<BaseTexture>;
  110074. /**
  110075. * An event triggered when render targets are about to be rendered
  110076. * Can happen multiple times per frame.
  110077. */
  110078. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  110079. /**
  110080. * An event triggered when render targets were rendered.
  110081. * Can happen multiple times per frame.
  110082. */
  110083. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  110084. /**
  110085. * An event triggered before calculating deterministic simulation step
  110086. */
  110087. onBeforeStepObservable: Observable<Scene>;
  110088. /**
  110089. * An event triggered after calculating deterministic simulation step
  110090. */
  110091. onAfterStepObservable: Observable<Scene>;
  110092. /**
  110093. * An event triggered when the activeCamera property is updated
  110094. */
  110095. onActiveCameraChanged: Observable<Scene>;
  110096. /**
  110097. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  110098. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110099. * 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)
  110100. */
  110101. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110102. /**
  110103. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  110104. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110105. * 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)
  110106. */
  110107. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110108. /**
  110109. * This Observable will when a mesh has been imported into the scene.
  110110. */
  110111. onMeshImportedObservable: Observable<AbstractMesh>;
  110112. /**
  110113. * This Observable will when an animation file has been imported into the scene.
  110114. */
  110115. onAnimationFileImportedObservable: Observable<Scene>;
  110116. /**
  110117. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  110118. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  110119. */
  110120. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  110121. /** @hidden */
  110122. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  110123. /**
  110124. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  110125. */
  110126. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  110127. /**
  110128. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  110129. */
  110130. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  110131. /**
  110132. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  110133. */
  110134. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  110135. /** Callback called when a pointer move is detected */
  110136. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110137. /** Callback called when a pointer down is detected */
  110138. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110139. /** Callback called when a pointer up is detected */
  110140. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  110141. /** Callback called when a pointer pick is detected */
  110142. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  110143. /**
  110144. * 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).
  110145. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  110146. */
  110147. onPrePointerObservable: Observable<PointerInfoPre>;
  110148. /**
  110149. * Observable event triggered each time an input event is received from the rendering canvas
  110150. */
  110151. onPointerObservable: Observable<PointerInfo>;
  110152. /**
  110153. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  110154. */
  110155. get unTranslatedPointer(): Vector2;
  110156. /**
  110157. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  110158. */
  110159. static get DragMovementThreshold(): number;
  110160. static set DragMovementThreshold(value: number);
  110161. /**
  110162. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  110163. */
  110164. static get LongPressDelay(): number;
  110165. static set LongPressDelay(value: number);
  110166. /**
  110167. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  110168. */
  110169. static get DoubleClickDelay(): number;
  110170. static set DoubleClickDelay(value: number);
  110171. /** If you need to check double click without raising a single click at first click, enable this flag */
  110172. static get ExclusiveDoubleClickMode(): boolean;
  110173. static set ExclusiveDoubleClickMode(value: boolean);
  110174. /** @hidden */
  110175. _mirroredCameraPosition: Nullable<Vector3>;
  110176. /**
  110177. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  110178. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  110179. */
  110180. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  110181. /**
  110182. * Observable event triggered each time an keyboard event is received from the hosting window
  110183. */
  110184. onKeyboardObservable: Observable<KeyboardInfo>;
  110185. private _useRightHandedSystem;
  110186. /**
  110187. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  110188. */
  110189. set useRightHandedSystem(value: boolean);
  110190. get useRightHandedSystem(): boolean;
  110191. private _timeAccumulator;
  110192. private _currentStepId;
  110193. private _currentInternalStep;
  110194. /**
  110195. * Sets the step Id used by deterministic lock step
  110196. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110197. * @param newStepId defines the step Id
  110198. */
  110199. setStepId(newStepId: number): void;
  110200. /**
  110201. * Gets the step Id used by deterministic lock step
  110202. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110203. * @returns the step Id
  110204. */
  110205. getStepId(): number;
  110206. /**
  110207. * Gets the internal step used by deterministic lock step
  110208. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110209. * @returns the internal step
  110210. */
  110211. getInternalStep(): number;
  110212. private _fogEnabled;
  110213. /**
  110214. * Gets or sets a boolean indicating if fog is enabled on this scene
  110215. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110216. * (Default is true)
  110217. */
  110218. set fogEnabled(value: boolean);
  110219. get fogEnabled(): boolean;
  110220. private _fogMode;
  110221. /**
  110222. * Gets or sets the fog mode to use
  110223. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110224. * | mode | value |
  110225. * | --- | --- |
  110226. * | FOGMODE_NONE | 0 |
  110227. * | FOGMODE_EXP | 1 |
  110228. * | FOGMODE_EXP2 | 2 |
  110229. * | FOGMODE_LINEAR | 3 |
  110230. */
  110231. set fogMode(value: number);
  110232. get fogMode(): number;
  110233. /**
  110234. * Gets or sets the fog color to use
  110235. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110236. * (Default is Color3(0.2, 0.2, 0.3))
  110237. */
  110238. fogColor: Color3;
  110239. /**
  110240. * Gets or sets the fog density to use
  110241. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110242. * (Default is 0.1)
  110243. */
  110244. fogDensity: number;
  110245. /**
  110246. * Gets or sets the fog start distance to use
  110247. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110248. * (Default is 0)
  110249. */
  110250. fogStart: number;
  110251. /**
  110252. * Gets or sets the fog end distance to use
  110253. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110254. * (Default is 1000)
  110255. */
  110256. fogEnd: number;
  110257. private _shadowsEnabled;
  110258. /**
  110259. * Gets or sets a boolean indicating if shadows are enabled on this scene
  110260. */
  110261. set shadowsEnabled(value: boolean);
  110262. get shadowsEnabled(): boolean;
  110263. private _lightsEnabled;
  110264. /**
  110265. * Gets or sets a boolean indicating if lights are enabled on this scene
  110266. */
  110267. set lightsEnabled(value: boolean);
  110268. get lightsEnabled(): boolean;
  110269. /** All of the active cameras added to this scene. */
  110270. activeCameras: Camera[];
  110271. /** @hidden */
  110272. _activeCamera: Nullable<Camera>;
  110273. /** Gets or sets the current active camera */
  110274. get activeCamera(): Nullable<Camera>;
  110275. set activeCamera(value: Nullable<Camera>);
  110276. private _defaultMaterial;
  110277. /** The default material used on meshes when no material is affected */
  110278. get defaultMaterial(): Material;
  110279. /** The default material used on meshes when no material is affected */
  110280. set defaultMaterial(value: Material);
  110281. private _texturesEnabled;
  110282. /**
  110283. * Gets or sets a boolean indicating if textures are enabled on this scene
  110284. */
  110285. set texturesEnabled(value: boolean);
  110286. get texturesEnabled(): boolean;
  110287. /**
  110288. * Gets or sets a boolean indicating if particles are enabled on this scene
  110289. */
  110290. particlesEnabled: boolean;
  110291. /**
  110292. * Gets or sets a boolean indicating if sprites are enabled on this scene
  110293. */
  110294. spritesEnabled: boolean;
  110295. private _skeletonsEnabled;
  110296. /**
  110297. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  110298. */
  110299. set skeletonsEnabled(value: boolean);
  110300. get skeletonsEnabled(): boolean;
  110301. /**
  110302. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  110303. */
  110304. lensFlaresEnabled: boolean;
  110305. /**
  110306. * Gets or sets a boolean indicating if collisions are enabled on this scene
  110307. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110308. */
  110309. collisionsEnabled: boolean;
  110310. private _collisionCoordinator;
  110311. /** @hidden */
  110312. get collisionCoordinator(): ICollisionCoordinator;
  110313. /**
  110314. * Defines the gravity applied to this scene (used only for collisions)
  110315. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110316. */
  110317. gravity: Vector3;
  110318. /**
  110319. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  110320. */
  110321. postProcessesEnabled: boolean;
  110322. /**
  110323. * The list of postprocesses added to the scene
  110324. */
  110325. postProcesses: PostProcess[];
  110326. /**
  110327. * Gets the current postprocess manager
  110328. */
  110329. postProcessManager: PostProcessManager;
  110330. /**
  110331. * Gets or sets a boolean indicating if render targets are enabled on this scene
  110332. */
  110333. renderTargetsEnabled: boolean;
  110334. /**
  110335. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  110336. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  110337. */
  110338. dumpNextRenderTargets: boolean;
  110339. /**
  110340. * The list of user defined render targets added to the scene
  110341. */
  110342. customRenderTargets: RenderTargetTexture[];
  110343. /**
  110344. * Defines if texture loading must be delayed
  110345. * If true, textures will only be loaded when they need to be rendered
  110346. */
  110347. useDelayedTextureLoading: boolean;
  110348. /**
  110349. * Gets the list of meshes imported to the scene through SceneLoader
  110350. */
  110351. importedMeshesFiles: String[];
  110352. /**
  110353. * Gets or sets a boolean indicating if probes are enabled on this scene
  110354. */
  110355. probesEnabled: boolean;
  110356. /**
  110357. * Gets or sets the current offline provider to use to store scene data
  110358. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110359. */
  110360. offlineProvider: IOfflineProvider;
  110361. /**
  110362. * Gets or sets the action manager associated with the scene
  110363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110364. */
  110365. actionManager: AbstractActionManager;
  110366. private _meshesForIntersections;
  110367. /**
  110368. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  110369. */
  110370. proceduralTexturesEnabled: boolean;
  110371. private _engine;
  110372. private _totalVertices;
  110373. /** @hidden */
  110374. _activeIndices: PerfCounter;
  110375. /** @hidden */
  110376. _activeParticles: PerfCounter;
  110377. /** @hidden */
  110378. _activeBones: PerfCounter;
  110379. private _animationRatio;
  110380. /** @hidden */
  110381. _animationTimeLast: number;
  110382. /** @hidden */
  110383. _animationTime: number;
  110384. /**
  110385. * Gets or sets a general scale for animation speed
  110386. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  110387. */
  110388. animationTimeScale: number;
  110389. /** @hidden */
  110390. _cachedMaterial: Nullable<Material>;
  110391. /** @hidden */
  110392. _cachedEffect: Nullable<Effect>;
  110393. /** @hidden */
  110394. _cachedVisibility: Nullable<number>;
  110395. private _renderId;
  110396. private _frameId;
  110397. private _executeWhenReadyTimeoutId;
  110398. private _intermediateRendering;
  110399. private _viewUpdateFlag;
  110400. private _projectionUpdateFlag;
  110401. /** @hidden */
  110402. _toBeDisposed: Nullable<IDisposable>[];
  110403. private _activeRequests;
  110404. /** @hidden */
  110405. _pendingData: any[];
  110406. private _isDisposed;
  110407. /**
  110408. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  110409. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  110410. */
  110411. dispatchAllSubMeshesOfActiveMeshes: boolean;
  110412. private _activeMeshes;
  110413. private _processedMaterials;
  110414. private _renderTargets;
  110415. /** @hidden */
  110416. _activeParticleSystems: SmartArray<IParticleSystem>;
  110417. private _activeSkeletons;
  110418. private _softwareSkinnedMeshes;
  110419. private _renderingManager;
  110420. /** @hidden */
  110421. _activeAnimatables: Animatable[];
  110422. private _transformMatrix;
  110423. private _sceneUbo;
  110424. /** @hidden */
  110425. _viewMatrix: Matrix;
  110426. private _projectionMatrix;
  110427. /** @hidden */
  110428. _forcedViewPosition: Nullable<Vector3>;
  110429. /** @hidden */
  110430. _frustumPlanes: Plane[];
  110431. /**
  110432. * Gets the list of frustum planes (built from the active camera)
  110433. */
  110434. get frustumPlanes(): Plane[];
  110435. /**
  110436. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  110437. * This is useful if there are more lights that the maximum simulteanous authorized
  110438. */
  110439. requireLightSorting: boolean;
  110440. /** @hidden */
  110441. readonly useMaterialMeshMap: boolean;
  110442. /** @hidden */
  110443. readonly useClonedMeshMap: boolean;
  110444. private _externalData;
  110445. private _uid;
  110446. /**
  110447. * @hidden
  110448. * Backing store of defined scene components.
  110449. */
  110450. _components: ISceneComponent[];
  110451. /**
  110452. * @hidden
  110453. * Backing store of defined scene components.
  110454. */
  110455. _serializableComponents: ISceneSerializableComponent[];
  110456. /**
  110457. * List of components to register on the next registration step.
  110458. */
  110459. private _transientComponents;
  110460. /**
  110461. * Registers the transient components if needed.
  110462. */
  110463. private _registerTransientComponents;
  110464. /**
  110465. * @hidden
  110466. * Add a component to the scene.
  110467. * Note that the ccomponent could be registered on th next frame if this is called after
  110468. * the register component stage.
  110469. * @param component Defines the component to add to the scene
  110470. */
  110471. _addComponent(component: ISceneComponent): void;
  110472. /**
  110473. * @hidden
  110474. * Gets a component from the scene.
  110475. * @param name defines the name of the component to retrieve
  110476. * @returns the component or null if not present
  110477. */
  110478. _getComponent(name: string): Nullable<ISceneComponent>;
  110479. /**
  110480. * @hidden
  110481. * Defines the actions happening before camera updates.
  110482. */
  110483. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  110484. /**
  110485. * @hidden
  110486. * Defines the actions happening before clear the canvas.
  110487. */
  110488. _beforeClearStage: Stage<SimpleStageAction>;
  110489. /**
  110490. * @hidden
  110491. * Defines the actions when collecting render targets for the frame.
  110492. */
  110493. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110494. /**
  110495. * @hidden
  110496. * Defines the actions happening for one camera in the frame.
  110497. */
  110498. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110499. /**
  110500. * @hidden
  110501. * Defines the actions happening during the per mesh ready checks.
  110502. */
  110503. _isReadyForMeshStage: Stage<MeshStageAction>;
  110504. /**
  110505. * @hidden
  110506. * Defines the actions happening before evaluate active mesh checks.
  110507. */
  110508. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  110509. /**
  110510. * @hidden
  110511. * Defines the actions happening during the evaluate sub mesh checks.
  110512. */
  110513. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  110514. /**
  110515. * @hidden
  110516. * Defines the actions happening during the active mesh stage.
  110517. */
  110518. _activeMeshStage: Stage<ActiveMeshStageAction>;
  110519. /**
  110520. * @hidden
  110521. * Defines the actions happening during the per camera render target step.
  110522. */
  110523. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  110524. /**
  110525. * @hidden
  110526. * Defines the actions happening just before the active camera is drawing.
  110527. */
  110528. _beforeCameraDrawStage: Stage<CameraStageAction>;
  110529. /**
  110530. * @hidden
  110531. * Defines the actions happening just before a render target is drawing.
  110532. */
  110533. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110534. /**
  110535. * @hidden
  110536. * Defines the actions happening just before a rendering group is drawing.
  110537. */
  110538. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110539. /**
  110540. * @hidden
  110541. * Defines the actions happening just before a mesh is drawing.
  110542. */
  110543. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110544. /**
  110545. * @hidden
  110546. * Defines the actions happening just after a mesh has been drawn.
  110547. */
  110548. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110549. /**
  110550. * @hidden
  110551. * Defines the actions happening just after a rendering group has been drawn.
  110552. */
  110553. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110554. /**
  110555. * @hidden
  110556. * Defines the actions happening just after the active camera has been drawn.
  110557. */
  110558. _afterCameraDrawStage: Stage<CameraStageAction>;
  110559. /**
  110560. * @hidden
  110561. * Defines the actions happening just after a render target has been drawn.
  110562. */
  110563. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110564. /**
  110565. * @hidden
  110566. * Defines the actions happening just after rendering all cameras and computing intersections.
  110567. */
  110568. _afterRenderStage: Stage<SimpleStageAction>;
  110569. /**
  110570. * @hidden
  110571. * Defines the actions happening when a pointer move event happens.
  110572. */
  110573. _pointerMoveStage: Stage<PointerMoveStageAction>;
  110574. /**
  110575. * @hidden
  110576. * Defines the actions happening when a pointer down event happens.
  110577. */
  110578. _pointerDownStage: Stage<PointerUpDownStageAction>;
  110579. /**
  110580. * @hidden
  110581. * Defines the actions happening when a pointer up event happens.
  110582. */
  110583. _pointerUpStage: Stage<PointerUpDownStageAction>;
  110584. /**
  110585. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  110586. */
  110587. private geometriesByUniqueId;
  110588. /**
  110589. * Creates a new Scene
  110590. * @param engine defines the engine to use to render this scene
  110591. * @param options defines the scene options
  110592. */
  110593. constructor(engine: Engine, options?: SceneOptions);
  110594. /**
  110595. * Gets a string idenfifying the name of the class
  110596. * @returns "Scene" string
  110597. */
  110598. getClassName(): string;
  110599. private _defaultMeshCandidates;
  110600. /**
  110601. * @hidden
  110602. */
  110603. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110604. private _defaultSubMeshCandidates;
  110605. /**
  110606. * @hidden
  110607. */
  110608. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110609. /**
  110610. * Sets the default candidate providers for the scene.
  110611. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  110612. * and getCollidingSubMeshCandidates to their default function
  110613. */
  110614. setDefaultCandidateProviders(): void;
  110615. /**
  110616. * Gets the mesh that is currently under the pointer
  110617. */
  110618. get meshUnderPointer(): Nullable<AbstractMesh>;
  110619. /**
  110620. * Gets or sets the current on-screen X position of the pointer
  110621. */
  110622. get pointerX(): number;
  110623. set pointerX(value: number);
  110624. /**
  110625. * Gets or sets the current on-screen Y position of the pointer
  110626. */
  110627. get pointerY(): number;
  110628. set pointerY(value: number);
  110629. /**
  110630. * Gets the cached material (ie. the latest rendered one)
  110631. * @returns the cached material
  110632. */
  110633. getCachedMaterial(): Nullable<Material>;
  110634. /**
  110635. * Gets the cached effect (ie. the latest rendered one)
  110636. * @returns the cached effect
  110637. */
  110638. getCachedEffect(): Nullable<Effect>;
  110639. /**
  110640. * Gets the cached visibility state (ie. the latest rendered one)
  110641. * @returns the cached visibility state
  110642. */
  110643. getCachedVisibility(): Nullable<number>;
  110644. /**
  110645. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  110646. * @param material defines the current material
  110647. * @param effect defines the current effect
  110648. * @param visibility defines the current visibility state
  110649. * @returns true if one parameter is not cached
  110650. */
  110651. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  110652. /**
  110653. * Gets the engine associated with the scene
  110654. * @returns an Engine
  110655. */
  110656. getEngine(): Engine;
  110657. /**
  110658. * Gets the total number of vertices rendered per frame
  110659. * @returns the total number of vertices rendered per frame
  110660. */
  110661. getTotalVertices(): number;
  110662. /**
  110663. * Gets the performance counter for total vertices
  110664. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110665. */
  110666. get totalVerticesPerfCounter(): PerfCounter;
  110667. /**
  110668. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  110669. * @returns the total number of active indices rendered per frame
  110670. */
  110671. getActiveIndices(): number;
  110672. /**
  110673. * Gets the performance counter for active indices
  110674. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110675. */
  110676. get totalActiveIndicesPerfCounter(): PerfCounter;
  110677. /**
  110678. * Gets the total number of active particles rendered per frame
  110679. * @returns the total number of active particles rendered per frame
  110680. */
  110681. getActiveParticles(): number;
  110682. /**
  110683. * Gets the performance counter for active particles
  110684. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110685. */
  110686. get activeParticlesPerfCounter(): PerfCounter;
  110687. /**
  110688. * Gets the total number of active bones rendered per frame
  110689. * @returns the total number of active bones rendered per frame
  110690. */
  110691. getActiveBones(): number;
  110692. /**
  110693. * Gets the performance counter for active bones
  110694. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110695. */
  110696. get activeBonesPerfCounter(): PerfCounter;
  110697. /**
  110698. * Gets the array of active meshes
  110699. * @returns an array of AbstractMesh
  110700. */
  110701. getActiveMeshes(): SmartArray<AbstractMesh>;
  110702. /**
  110703. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  110704. * @returns a number
  110705. */
  110706. getAnimationRatio(): number;
  110707. /**
  110708. * Gets an unique Id for the current render phase
  110709. * @returns a number
  110710. */
  110711. getRenderId(): number;
  110712. /**
  110713. * Gets an unique Id for the current frame
  110714. * @returns a number
  110715. */
  110716. getFrameId(): number;
  110717. /** Call this function if you want to manually increment the render Id*/
  110718. incrementRenderId(): void;
  110719. private _createUbo;
  110720. /**
  110721. * Use this method to simulate a pointer move on a mesh
  110722. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110723. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110724. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110725. * @returns the current scene
  110726. */
  110727. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110728. /**
  110729. * Use this method to simulate a pointer down on a mesh
  110730. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110731. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110732. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110733. * @returns the current scene
  110734. */
  110735. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110736. /**
  110737. * Use this method to simulate a pointer up on a mesh
  110738. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110739. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110740. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110741. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  110742. * @returns the current scene
  110743. */
  110744. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  110745. /**
  110746. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  110747. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  110748. * @returns true if the pointer was captured
  110749. */
  110750. isPointerCaptured(pointerId?: number): boolean;
  110751. /**
  110752. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  110753. * @param attachUp defines if you want to attach events to pointerup
  110754. * @param attachDown defines if you want to attach events to pointerdown
  110755. * @param attachMove defines if you want to attach events to pointermove
  110756. */
  110757. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  110758. /** Detaches all event handlers*/
  110759. detachControl(): void;
  110760. /**
  110761. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  110762. * Delay loaded resources are not taking in account
  110763. * @return true if all required resources are ready
  110764. */
  110765. isReady(): boolean;
  110766. /** Resets all cached information relative to material (including effect and visibility) */
  110767. resetCachedMaterial(): void;
  110768. /**
  110769. * Registers a function to be called before every frame render
  110770. * @param func defines the function to register
  110771. */
  110772. registerBeforeRender(func: () => void): void;
  110773. /**
  110774. * Unregisters a function called before every frame render
  110775. * @param func defines the function to unregister
  110776. */
  110777. unregisterBeforeRender(func: () => void): void;
  110778. /**
  110779. * Registers a function to be called after every frame render
  110780. * @param func defines the function to register
  110781. */
  110782. registerAfterRender(func: () => void): void;
  110783. /**
  110784. * Unregisters a function called after every frame render
  110785. * @param func defines the function to unregister
  110786. */
  110787. unregisterAfterRender(func: () => void): void;
  110788. private _executeOnceBeforeRender;
  110789. /**
  110790. * The provided function will run before render once and will be disposed afterwards.
  110791. * A timeout delay can be provided so that the function will be executed in N ms.
  110792. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  110793. * @param func The function to be executed.
  110794. * @param timeout optional delay in ms
  110795. */
  110796. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  110797. /** @hidden */
  110798. _addPendingData(data: any): void;
  110799. /** @hidden */
  110800. _removePendingData(data: any): void;
  110801. /**
  110802. * Returns the number of items waiting to be loaded
  110803. * @returns the number of items waiting to be loaded
  110804. */
  110805. getWaitingItemsCount(): number;
  110806. /**
  110807. * Returns a boolean indicating if the scene is still loading data
  110808. */
  110809. get isLoading(): boolean;
  110810. /**
  110811. * Registers a function to be executed when the scene is ready
  110812. * @param {Function} func - the function to be executed
  110813. */
  110814. executeWhenReady(func: () => void): void;
  110815. /**
  110816. * Returns a promise that resolves when the scene is ready
  110817. * @returns A promise that resolves when the scene is ready
  110818. */
  110819. whenReadyAsync(): Promise<void>;
  110820. /** @hidden */
  110821. _checkIsReady(): void;
  110822. /**
  110823. * Gets all animatable attached to the scene
  110824. */
  110825. get animatables(): Animatable[];
  110826. /**
  110827. * Resets the last animation time frame.
  110828. * Useful to override when animations start running when loading a scene for the first time.
  110829. */
  110830. resetLastAnimationTimeFrame(): void;
  110831. /**
  110832. * Gets the current view matrix
  110833. * @returns a Matrix
  110834. */
  110835. getViewMatrix(): Matrix;
  110836. /**
  110837. * Gets the current projection matrix
  110838. * @returns a Matrix
  110839. */
  110840. getProjectionMatrix(): Matrix;
  110841. /**
  110842. * Gets the current transform matrix
  110843. * @returns a Matrix made of View * Projection
  110844. */
  110845. getTransformMatrix(): Matrix;
  110846. /**
  110847. * Sets the current transform matrix
  110848. * @param viewL defines the View matrix to use
  110849. * @param projectionL defines the Projection matrix to use
  110850. * @param viewR defines the right View matrix to use (if provided)
  110851. * @param projectionR defines the right Projection matrix to use (if provided)
  110852. */
  110853. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  110854. /**
  110855. * Gets the uniform buffer used to store scene data
  110856. * @returns a UniformBuffer
  110857. */
  110858. getSceneUniformBuffer(): UniformBuffer;
  110859. /**
  110860. * Gets an unique (relatively to the current scene) Id
  110861. * @returns an unique number for the scene
  110862. */
  110863. getUniqueId(): number;
  110864. /**
  110865. * Add a mesh to the list of scene's meshes
  110866. * @param newMesh defines the mesh to add
  110867. * @param recursive if all child meshes should also be added to the scene
  110868. */
  110869. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  110870. /**
  110871. * Remove a mesh for the list of scene's meshes
  110872. * @param toRemove defines the mesh to remove
  110873. * @param recursive if all child meshes should also be removed from the scene
  110874. * @returns the index where the mesh was in the mesh list
  110875. */
  110876. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  110877. /**
  110878. * Add a transform node to the list of scene's transform nodes
  110879. * @param newTransformNode defines the transform node to add
  110880. */
  110881. addTransformNode(newTransformNode: TransformNode): void;
  110882. /**
  110883. * Remove a transform node for the list of scene's transform nodes
  110884. * @param toRemove defines the transform node to remove
  110885. * @returns the index where the transform node was in the transform node list
  110886. */
  110887. removeTransformNode(toRemove: TransformNode): number;
  110888. /**
  110889. * Remove a skeleton for the list of scene's skeletons
  110890. * @param toRemove defines the skeleton to remove
  110891. * @returns the index where the skeleton was in the skeleton list
  110892. */
  110893. removeSkeleton(toRemove: Skeleton): number;
  110894. /**
  110895. * Remove a morph target for the list of scene's morph targets
  110896. * @param toRemove defines the morph target to remove
  110897. * @returns the index where the morph target was in the morph target list
  110898. */
  110899. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  110900. /**
  110901. * Remove a light for the list of scene's lights
  110902. * @param toRemove defines the light to remove
  110903. * @returns the index where the light was in the light list
  110904. */
  110905. removeLight(toRemove: Light): number;
  110906. /**
  110907. * Remove a camera for the list of scene's cameras
  110908. * @param toRemove defines the camera to remove
  110909. * @returns the index where the camera was in the camera list
  110910. */
  110911. removeCamera(toRemove: Camera): number;
  110912. /**
  110913. * Remove a particle system for the list of scene's particle systems
  110914. * @param toRemove defines the particle system to remove
  110915. * @returns the index where the particle system was in the particle system list
  110916. */
  110917. removeParticleSystem(toRemove: IParticleSystem): number;
  110918. /**
  110919. * Remove a animation for the list of scene's animations
  110920. * @param toRemove defines the animation to remove
  110921. * @returns the index where the animation was in the animation list
  110922. */
  110923. removeAnimation(toRemove: Animation): number;
  110924. /**
  110925. * Will stop the animation of the given target
  110926. * @param target - the target
  110927. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110928. * @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)
  110929. */
  110930. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110931. /**
  110932. * Removes the given animation group from this scene.
  110933. * @param toRemove The animation group to remove
  110934. * @returns The index of the removed animation group
  110935. */
  110936. removeAnimationGroup(toRemove: AnimationGroup): number;
  110937. /**
  110938. * Removes the given multi-material from this scene.
  110939. * @param toRemove The multi-material to remove
  110940. * @returns The index of the removed multi-material
  110941. */
  110942. removeMultiMaterial(toRemove: MultiMaterial): number;
  110943. /**
  110944. * Removes the given material from this scene.
  110945. * @param toRemove The material to remove
  110946. * @returns The index of the removed material
  110947. */
  110948. removeMaterial(toRemove: Material): number;
  110949. /**
  110950. * Removes the given action manager from this scene.
  110951. * @param toRemove The action manager to remove
  110952. * @returns The index of the removed action manager
  110953. */
  110954. removeActionManager(toRemove: AbstractActionManager): number;
  110955. /**
  110956. * Removes the given texture from this scene.
  110957. * @param toRemove The texture to remove
  110958. * @returns The index of the removed texture
  110959. */
  110960. removeTexture(toRemove: BaseTexture): number;
  110961. /**
  110962. * Adds the given light to this scene
  110963. * @param newLight The light to add
  110964. */
  110965. addLight(newLight: Light): void;
  110966. /**
  110967. * Sorts the list list based on light priorities
  110968. */
  110969. sortLightsByPriority(): void;
  110970. /**
  110971. * Adds the given camera to this scene
  110972. * @param newCamera The camera to add
  110973. */
  110974. addCamera(newCamera: Camera): void;
  110975. /**
  110976. * Adds the given skeleton to this scene
  110977. * @param newSkeleton The skeleton to add
  110978. */
  110979. addSkeleton(newSkeleton: Skeleton): void;
  110980. /**
  110981. * Adds the given particle system to this scene
  110982. * @param newParticleSystem The particle system to add
  110983. */
  110984. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110985. /**
  110986. * Adds the given animation to this scene
  110987. * @param newAnimation The animation to add
  110988. */
  110989. addAnimation(newAnimation: Animation): void;
  110990. /**
  110991. * Adds the given animation group to this scene.
  110992. * @param newAnimationGroup The animation group to add
  110993. */
  110994. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  110995. /**
  110996. * Adds the given multi-material to this scene
  110997. * @param newMultiMaterial The multi-material to add
  110998. */
  110999. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  111000. /**
  111001. * Adds the given material to this scene
  111002. * @param newMaterial The material to add
  111003. */
  111004. addMaterial(newMaterial: Material): void;
  111005. /**
  111006. * Adds the given morph target to this scene
  111007. * @param newMorphTargetManager The morph target to add
  111008. */
  111009. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  111010. /**
  111011. * Adds the given geometry to this scene
  111012. * @param newGeometry The geometry to add
  111013. */
  111014. addGeometry(newGeometry: Geometry): void;
  111015. /**
  111016. * Adds the given action manager to this scene
  111017. * @param newActionManager The action manager to add
  111018. */
  111019. addActionManager(newActionManager: AbstractActionManager): void;
  111020. /**
  111021. * Adds the given texture to this scene.
  111022. * @param newTexture The texture to add
  111023. */
  111024. addTexture(newTexture: BaseTexture): void;
  111025. /**
  111026. * Switch active camera
  111027. * @param newCamera defines the new active camera
  111028. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  111029. */
  111030. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  111031. /**
  111032. * sets the active camera of the scene using its ID
  111033. * @param id defines the camera's ID
  111034. * @return the new active camera or null if none found.
  111035. */
  111036. setActiveCameraByID(id: string): Nullable<Camera>;
  111037. /**
  111038. * sets the active camera of the scene using its name
  111039. * @param name defines the camera's name
  111040. * @returns the new active camera or null if none found.
  111041. */
  111042. setActiveCameraByName(name: string): Nullable<Camera>;
  111043. /**
  111044. * get an animation group using its name
  111045. * @param name defines the material's name
  111046. * @return the animation group or null if none found.
  111047. */
  111048. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  111049. /**
  111050. * Get a material using its unique id
  111051. * @param uniqueId defines the material's unique id
  111052. * @return the material or null if none found.
  111053. */
  111054. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  111055. /**
  111056. * get a material using its id
  111057. * @param id defines the material's ID
  111058. * @return the material or null if none found.
  111059. */
  111060. getMaterialByID(id: string): Nullable<Material>;
  111061. /**
  111062. * Gets a the last added material using a given id
  111063. * @param id defines the material's ID
  111064. * @return the last material with the given id or null if none found.
  111065. */
  111066. getLastMaterialByID(id: string): Nullable<Material>;
  111067. /**
  111068. * Gets a material using its name
  111069. * @param name defines the material's name
  111070. * @return the material or null if none found.
  111071. */
  111072. getMaterialByName(name: string): Nullable<Material>;
  111073. /**
  111074. * Get a texture using its unique id
  111075. * @param uniqueId defines the texture's unique id
  111076. * @return the texture or null if none found.
  111077. */
  111078. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  111079. /**
  111080. * Gets a camera using its id
  111081. * @param id defines the id to look for
  111082. * @returns the camera or null if not found
  111083. */
  111084. getCameraByID(id: string): Nullable<Camera>;
  111085. /**
  111086. * Gets a camera using its unique id
  111087. * @param uniqueId defines the unique id to look for
  111088. * @returns the camera or null if not found
  111089. */
  111090. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  111091. /**
  111092. * Gets a camera using its name
  111093. * @param name defines the camera's name
  111094. * @return the camera or null if none found.
  111095. */
  111096. getCameraByName(name: string): Nullable<Camera>;
  111097. /**
  111098. * Gets a bone using its id
  111099. * @param id defines the bone's id
  111100. * @return the bone or null if not found
  111101. */
  111102. getBoneByID(id: string): Nullable<Bone>;
  111103. /**
  111104. * Gets a bone using its id
  111105. * @param name defines the bone's name
  111106. * @return the bone or null if not found
  111107. */
  111108. getBoneByName(name: string): Nullable<Bone>;
  111109. /**
  111110. * Gets a light node using its name
  111111. * @param name defines the the light's name
  111112. * @return the light or null if none found.
  111113. */
  111114. getLightByName(name: string): Nullable<Light>;
  111115. /**
  111116. * Gets a light node using its id
  111117. * @param id defines the light's id
  111118. * @return the light or null if none found.
  111119. */
  111120. getLightByID(id: string): Nullable<Light>;
  111121. /**
  111122. * Gets a light node using its scene-generated unique ID
  111123. * @param uniqueId defines the light's unique id
  111124. * @return the light or null if none found.
  111125. */
  111126. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  111127. /**
  111128. * Gets a particle system by id
  111129. * @param id defines the particle system id
  111130. * @return the corresponding system or null if none found
  111131. */
  111132. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  111133. /**
  111134. * Gets a geometry using its ID
  111135. * @param id defines the geometry's id
  111136. * @return the geometry or null if none found.
  111137. */
  111138. getGeometryByID(id: string): Nullable<Geometry>;
  111139. private _getGeometryByUniqueID;
  111140. /**
  111141. * Add a new geometry to this scene
  111142. * @param geometry defines the geometry to be added to the scene.
  111143. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  111144. * @return a boolean defining if the geometry was added or not
  111145. */
  111146. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  111147. /**
  111148. * Removes an existing geometry
  111149. * @param geometry defines the geometry to be removed from the scene
  111150. * @return a boolean defining if the geometry was removed or not
  111151. */
  111152. removeGeometry(geometry: Geometry): boolean;
  111153. /**
  111154. * Gets the list of geometries attached to the scene
  111155. * @returns an array of Geometry
  111156. */
  111157. getGeometries(): Geometry[];
  111158. /**
  111159. * Gets the first added mesh found of a given ID
  111160. * @param id defines the id to search for
  111161. * @return the mesh found or null if not found at all
  111162. */
  111163. getMeshByID(id: string): Nullable<AbstractMesh>;
  111164. /**
  111165. * Gets a list of meshes using their id
  111166. * @param id defines the id to search for
  111167. * @returns a list of meshes
  111168. */
  111169. getMeshesByID(id: string): Array<AbstractMesh>;
  111170. /**
  111171. * Gets the first added transform node found of a given ID
  111172. * @param id defines the id to search for
  111173. * @return the found transform node or null if not found at all.
  111174. */
  111175. getTransformNodeByID(id: string): Nullable<TransformNode>;
  111176. /**
  111177. * Gets a transform node with its auto-generated unique id
  111178. * @param uniqueId efines the unique id to search for
  111179. * @return the found transform node or null if not found at all.
  111180. */
  111181. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  111182. /**
  111183. * Gets a list of transform nodes using their id
  111184. * @param id defines the id to search for
  111185. * @returns a list of transform nodes
  111186. */
  111187. getTransformNodesByID(id: string): Array<TransformNode>;
  111188. /**
  111189. * Gets a mesh with its auto-generated unique id
  111190. * @param uniqueId defines the unique id to search for
  111191. * @return the found mesh or null if not found at all.
  111192. */
  111193. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  111194. /**
  111195. * Gets a the last added mesh using a given id
  111196. * @param id defines the id to search for
  111197. * @return the found mesh or null if not found at all.
  111198. */
  111199. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  111200. /**
  111201. * Gets a the last added node (Mesh, Camera, Light) using a given id
  111202. * @param id defines the id to search for
  111203. * @return the found node or null if not found at all
  111204. */
  111205. getLastEntryByID(id: string): Nullable<Node>;
  111206. /**
  111207. * Gets a node (Mesh, Camera, Light) using a given id
  111208. * @param id defines the id to search for
  111209. * @return the found node or null if not found at all
  111210. */
  111211. getNodeByID(id: string): Nullable<Node>;
  111212. /**
  111213. * Gets a node (Mesh, Camera, Light) using a given name
  111214. * @param name defines the name to search for
  111215. * @return the found node or null if not found at all.
  111216. */
  111217. getNodeByName(name: string): Nullable<Node>;
  111218. /**
  111219. * Gets a mesh using a given name
  111220. * @param name defines the name to search for
  111221. * @return the found mesh or null if not found at all.
  111222. */
  111223. getMeshByName(name: string): Nullable<AbstractMesh>;
  111224. /**
  111225. * Gets a transform node using a given name
  111226. * @param name defines the name to search for
  111227. * @return the found transform node or null if not found at all.
  111228. */
  111229. getTransformNodeByName(name: string): Nullable<TransformNode>;
  111230. /**
  111231. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  111232. * @param id defines the id to search for
  111233. * @return the found skeleton or null if not found at all.
  111234. */
  111235. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  111236. /**
  111237. * Gets a skeleton using a given auto generated unique id
  111238. * @param uniqueId defines the unique id to search for
  111239. * @return the found skeleton or null if not found at all.
  111240. */
  111241. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  111242. /**
  111243. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  111244. * @param id defines the id to search for
  111245. * @return the found skeleton or null if not found at all.
  111246. */
  111247. getSkeletonById(id: string): Nullable<Skeleton>;
  111248. /**
  111249. * Gets a skeleton using a given name
  111250. * @param name defines the name to search for
  111251. * @return the found skeleton or null if not found at all.
  111252. */
  111253. getSkeletonByName(name: string): Nullable<Skeleton>;
  111254. /**
  111255. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  111256. * @param id defines the id to search for
  111257. * @return the found morph target manager or null if not found at all.
  111258. */
  111259. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  111260. /**
  111261. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  111262. * @param id defines the id to search for
  111263. * @return the found morph target or null if not found at all.
  111264. */
  111265. getMorphTargetById(id: string): Nullable<MorphTarget>;
  111266. /**
  111267. * Gets a boolean indicating if the given mesh is active
  111268. * @param mesh defines the mesh to look for
  111269. * @returns true if the mesh is in the active list
  111270. */
  111271. isActiveMesh(mesh: AbstractMesh): boolean;
  111272. /**
  111273. * Return a unique id as a string which can serve as an identifier for the scene
  111274. */
  111275. get uid(): string;
  111276. /**
  111277. * Add an externaly attached data from its key.
  111278. * This method call will fail and return false, if such key already exists.
  111279. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  111280. * @param key the unique key that identifies the data
  111281. * @param data the data object to associate to the key for this Engine instance
  111282. * @return true if no such key were already present and the data was added successfully, false otherwise
  111283. */
  111284. addExternalData<T>(key: string, data: T): boolean;
  111285. /**
  111286. * Get an externaly attached data from its key
  111287. * @param key the unique key that identifies the data
  111288. * @return the associated data, if present (can be null), or undefined if not present
  111289. */
  111290. getExternalData<T>(key: string): Nullable<T>;
  111291. /**
  111292. * Get an externaly attached data from its key, create it using a factory if it's not already present
  111293. * @param key the unique key that identifies the data
  111294. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  111295. * @return the associated data, can be null if the factory returned null.
  111296. */
  111297. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  111298. /**
  111299. * Remove an externaly attached data from the Engine instance
  111300. * @param key the unique key that identifies the data
  111301. * @return true if the data was successfully removed, false if it doesn't exist
  111302. */
  111303. removeExternalData(key: string): boolean;
  111304. private _evaluateSubMesh;
  111305. /**
  111306. * Clear the processed materials smart array preventing retention point in material dispose.
  111307. */
  111308. freeProcessedMaterials(): void;
  111309. private _preventFreeActiveMeshesAndRenderingGroups;
  111310. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  111311. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  111312. * when disposing several meshes in a row or a hierarchy of meshes.
  111313. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  111314. */
  111315. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  111316. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  111317. /**
  111318. * Clear the active meshes smart array preventing retention point in mesh dispose.
  111319. */
  111320. freeActiveMeshes(): void;
  111321. /**
  111322. * Clear the info related to rendering groups preventing retention points during dispose.
  111323. */
  111324. freeRenderingGroups(): void;
  111325. /** @hidden */
  111326. _isInIntermediateRendering(): boolean;
  111327. /**
  111328. * Lambda returning the list of potentially active meshes.
  111329. */
  111330. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  111331. /**
  111332. * Lambda returning the list of potentially active sub meshes.
  111333. */
  111334. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  111335. /**
  111336. * Lambda returning the list of potentially intersecting sub meshes.
  111337. */
  111338. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  111339. /**
  111340. * Lambda returning the list of potentially colliding sub meshes.
  111341. */
  111342. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  111343. private _activeMeshesFrozen;
  111344. private _skipEvaluateActiveMeshesCompletely;
  111345. /**
  111346. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  111347. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  111348. * @returns the current scene
  111349. */
  111350. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  111351. /**
  111352. * Use this function to restart evaluating active meshes on every frame
  111353. * @returns the current scene
  111354. */
  111355. unfreezeActiveMeshes(): Scene;
  111356. private _evaluateActiveMeshes;
  111357. private _activeMesh;
  111358. /**
  111359. * Update the transform matrix to update from the current active camera
  111360. * @param force defines a boolean used to force the update even if cache is up to date
  111361. */
  111362. updateTransformMatrix(force?: boolean): void;
  111363. private _bindFrameBuffer;
  111364. /** @hidden */
  111365. _allowPostProcessClearColor: boolean;
  111366. /** @hidden */
  111367. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  111368. private _processSubCameras;
  111369. private _checkIntersections;
  111370. /** @hidden */
  111371. _advancePhysicsEngineStep(step: number): void;
  111372. /**
  111373. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  111374. */
  111375. getDeterministicFrameTime: () => number;
  111376. /** @hidden */
  111377. _animate(): void;
  111378. /** Execute all animations (for a frame) */
  111379. animate(): void;
  111380. /**
  111381. * Render the scene
  111382. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  111383. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  111384. */
  111385. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  111386. /**
  111387. * Freeze all materials
  111388. * A frozen material will not be updatable but should be faster to render
  111389. */
  111390. freezeMaterials(): void;
  111391. /**
  111392. * Unfreeze all materials
  111393. * A frozen material will not be updatable but should be faster to render
  111394. */
  111395. unfreezeMaterials(): void;
  111396. /**
  111397. * Releases all held ressources
  111398. */
  111399. dispose(): void;
  111400. /**
  111401. * Gets if the scene is already disposed
  111402. */
  111403. get isDisposed(): boolean;
  111404. /**
  111405. * Call this function to reduce memory footprint of the scene.
  111406. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  111407. */
  111408. clearCachedVertexData(): void;
  111409. /**
  111410. * This function will remove the local cached buffer data from texture.
  111411. * It will save memory but will prevent the texture from being rebuilt
  111412. */
  111413. cleanCachedTextureBuffer(): void;
  111414. /**
  111415. * Get the world extend vectors with an optional filter
  111416. *
  111417. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  111418. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  111419. */
  111420. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  111421. min: Vector3;
  111422. max: Vector3;
  111423. };
  111424. /**
  111425. * Creates a ray that can be used to pick in the scene
  111426. * @param x defines the x coordinate of the origin (on-screen)
  111427. * @param y defines the y coordinate of the origin (on-screen)
  111428. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111429. * @param camera defines the camera to use for the picking
  111430. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111431. * @returns a Ray
  111432. */
  111433. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  111434. /**
  111435. * Creates a ray that can be used to pick in the scene
  111436. * @param x defines the x coordinate of the origin (on-screen)
  111437. * @param y defines the y coordinate of the origin (on-screen)
  111438. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111439. * @param result defines the ray where to store the picking ray
  111440. * @param camera defines the camera to use for the picking
  111441. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111442. * @returns the current scene
  111443. */
  111444. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  111445. /**
  111446. * Creates a ray that can be used to pick in the scene
  111447. * @param x defines the x coordinate of the origin (on-screen)
  111448. * @param y defines the y coordinate of the origin (on-screen)
  111449. * @param camera defines the camera to use for the picking
  111450. * @returns a Ray
  111451. */
  111452. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  111453. /**
  111454. * Creates a ray that can be used to pick in the scene
  111455. * @param x defines the x coordinate of the origin (on-screen)
  111456. * @param y defines the y coordinate of the origin (on-screen)
  111457. * @param result defines the ray where to store the picking ray
  111458. * @param camera defines the camera to use for the picking
  111459. * @returns the current scene
  111460. */
  111461. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  111462. /** Launch a ray to try to pick a mesh in the scene
  111463. * @param x position on screen
  111464. * @param y position on screen
  111465. * @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
  111466. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  111467. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111468. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111469. * @returns a PickingInfo
  111470. */
  111471. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111472. /** Use the given ray to pick a mesh in the scene
  111473. * @param ray The ray to use to pick meshes
  111474. * @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
  111475. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  111476. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111477. * @returns a PickingInfo
  111478. */
  111479. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111480. /**
  111481. * Launch a ray to try to pick a mesh in the scene
  111482. * @param x X position on screen
  111483. * @param y Y position on screen
  111484. * @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
  111485. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111486. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111487. * @returns an array of PickingInfo
  111488. */
  111489. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111490. /**
  111491. * Launch a ray to try to pick a mesh in the scene
  111492. * @param ray Ray to use
  111493. * @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
  111494. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111495. * @returns an array of PickingInfo
  111496. */
  111497. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111498. /**
  111499. * Force the value of meshUnderPointer
  111500. * @param mesh defines the mesh to use
  111501. */
  111502. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111503. /**
  111504. * Gets the mesh under the pointer
  111505. * @returns a Mesh or null if no mesh is under the pointer
  111506. */
  111507. getPointerOverMesh(): Nullable<AbstractMesh>;
  111508. /** @hidden */
  111509. _rebuildGeometries(): void;
  111510. /** @hidden */
  111511. _rebuildTextures(): void;
  111512. private _getByTags;
  111513. /**
  111514. * Get a list of meshes by tags
  111515. * @param tagsQuery defines the tags query to use
  111516. * @param forEach defines a predicate used to filter results
  111517. * @returns an array of Mesh
  111518. */
  111519. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  111520. /**
  111521. * Get a list of cameras by tags
  111522. * @param tagsQuery defines the tags query to use
  111523. * @param forEach defines a predicate used to filter results
  111524. * @returns an array of Camera
  111525. */
  111526. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  111527. /**
  111528. * Get a list of lights by tags
  111529. * @param tagsQuery defines the tags query to use
  111530. * @param forEach defines a predicate used to filter results
  111531. * @returns an array of Light
  111532. */
  111533. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  111534. /**
  111535. * Get a list of materials by tags
  111536. * @param tagsQuery defines the tags query to use
  111537. * @param forEach defines a predicate used to filter results
  111538. * @returns an array of Material
  111539. */
  111540. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  111541. /**
  111542. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  111543. * This allowed control for front to back rendering or reversly depending of the special needs.
  111544. *
  111545. * @param renderingGroupId The rendering group id corresponding to its index
  111546. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  111547. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  111548. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  111549. */
  111550. 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;
  111551. /**
  111552. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  111553. *
  111554. * @param renderingGroupId The rendering group id corresponding to its index
  111555. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111556. * @param depth Automatically clears depth between groups if true and autoClear is true.
  111557. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  111558. */
  111559. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  111560. /**
  111561. * Gets the current auto clear configuration for one rendering group of the rendering
  111562. * manager.
  111563. * @param index the rendering group index to get the information for
  111564. * @returns The auto clear setup for the requested rendering group
  111565. */
  111566. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  111567. private _blockMaterialDirtyMechanism;
  111568. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  111569. get blockMaterialDirtyMechanism(): boolean;
  111570. set blockMaterialDirtyMechanism(value: boolean);
  111571. /**
  111572. * Will flag all materials as dirty to trigger new shader compilation
  111573. * @param flag defines the flag used to specify which material part must be marked as dirty
  111574. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  111575. */
  111576. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  111577. /** @hidden */
  111578. _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;
  111579. /** @hidden */
  111580. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111581. /** @hidden */
  111582. _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;
  111583. /** @hidden */
  111584. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  111585. /** @hidden */
  111586. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  111587. /** @hidden */
  111588. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111589. }
  111590. }
  111591. declare module BABYLON {
  111592. /**
  111593. * Set of assets to keep when moving a scene into an asset container.
  111594. */
  111595. export class KeepAssets extends AbstractScene {
  111596. }
  111597. /**
  111598. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  111599. */
  111600. export class InstantiatedEntries {
  111601. /**
  111602. * List of new root nodes (eg. nodes with no parent)
  111603. */
  111604. rootNodes: TransformNode[];
  111605. /**
  111606. * List of new skeletons
  111607. */
  111608. skeletons: Skeleton[];
  111609. /**
  111610. * List of new animation groups
  111611. */
  111612. animationGroups: AnimationGroup[];
  111613. }
  111614. /**
  111615. * Container with a set of assets that can be added or removed from a scene.
  111616. */
  111617. export class AssetContainer extends AbstractScene {
  111618. private _wasAddedToScene;
  111619. /**
  111620. * The scene the AssetContainer belongs to.
  111621. */
  111622. scene: Scene;
  111623. /**
  111624. * Instantiates an AssetContainer.
  111625. * @param scene The scene the AssetContainer belongs to.
  111626. */
  111627. constructor(scene: Scene);
  111628. /**
  111629. * Instantiate or clone all meshes and add the new ones to the scene.
  111630. * Skeletons and animation groups will all be cloned
  111631. * @param nameFunction defines an optional function used to get new names for clones
  111632. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  111633. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  111634. */
  111635. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  111636. /**
  111637. * Adds all the assets from the container to the scene.
  111638. */
  111639. addAllToScene(): void;
  111640. /**
  111641. * Removes all the assets in the container from the scene
  111642. */
  111643. removeAllFromScene(): void;
  111644. /**
  111645. * Disposes all the assets in the container
  111646. */
  111647. dispose(): void;
  111648. private _moveAssets;
  111649. /**
  111650. * Removes all the assets contained in the scene and adds them to the container.
  111651. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  111652. */
  111653. moveAllFromScene(keepAssets?: KeepAssets): void;
  111654. /**
  111655. * 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.
  111656. * @returns the root mesh
  111657. */
  111658. createRootMesh(): Mesh;
  111659. /**
  111660. * Merge animations from this asset container into a scene
  111661. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111662. * @param animatables set of animatables to retarget to a node from the scene
  111663. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  111664. */
  111665. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  111666. }
  111667. }
  111668. declare module BABYLON {
  111669. /**
  111670. * Defines how the parser contract is defined.
  111671. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  111672. */
  111673. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  111674. /**
  111675. * Defines how the individual parser contract is defined.
  111676. * These parser can parse an individual asset
  111677. */
  111678. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  111679. /**
  111680. * Base class of the scene acting as a container for the different elements composing a scene.
  111681. * This class is dynamically extended by the different components of the scene increasing
  111682. * flexibility and reducing coupling
  111683. */
  111684. export abstract class AbstractScene {
  111685. /**
  111686. * Stores the list of available parsers in the application.
  111687. */
  111688. private static _BabylonFileParsers;
  111689. /**
  111690. * Stores the list of available individual parsers in the application.
  111691. */
  111692. private static _IndividualBabylonFileParsers;
  111693. /**
  111694. * Adds a parser in the list of available ones
  111695. * @param name Defines the name of the parser
  111696. * @param parser Defines the parser to add
  111697. */
  111698. static AddParser(name: string, parser: BabylonFileParser): void;
  111699. /**
  111700. * Gets a general parser from the list of avaialble ones
  111701. * @param name Defines the name of the parser
  111702. * @returns the requested parser or null
  111703. */
  111704. static GetParser(name: string): Nullable<BabylonFileParser>;
  111705. /**
  111706. * Adds n individual parser in the list of available ones
  111707. * @param name Defines the name of the parser
  111708. * @param parser Defines the parser to add
  111709. */
  111710. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  111711. /**
  111712. * Gets an individual parser from the list of avaialble ones
  111713. * @param name Defines the name of the parser
  111714. * @returns the requested parser or null
  111715. */
  111716. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  111717. /**
  111718. * Parser json data and populate both a scene and its associated container object
  111719. * @param jsonData Defines the data to parse
  111720. * @param scene Defines the scene to parse the data for
  111721. * @param container Defines the container attached to the parsing sequence
  111722. * @param rootUrl Defines the root url of the data
  111723. */
  111724. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  111725. /**
  111726. * Gets the list of root nodes (ie. nodes with no parent)
  111727. */
  111728. rootNodes: Node[];
  111729. /** All of the cameras added to this scene
  111730. * @see http://doc.babylonjs.com/babylon101/cameras
  111731. */
  111732. cameras: Camera[];
  111733. /**
  111734. * All of the lights added to this scene
  111735. * @see http://doc.babylonjs.com/babylon101/lights
  111736. */
  111737. lights: Light[];
  111738. /**
  111739. * All of the (abstract) meshes added to this scene
  111740. */
  111741. meshes: AbstractMesh[];
  111742. /**
  111743. * The list of skeletons added to the scene
  111744. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111745. */
  111746. skeletons: Skeleton[];
  111747. /**
  111748. * All of the particle systems added to this scene
  111749. * @see http://doc.babylonjs.com/babylon101/particles
  111750. */
  111751. particleSystems: IParticleSystem[];
  111752. /**
  111753. * Gets a list of Animations associated with the scene
  111754. */
  111755. animations: Animation[];
  111756. /**
  111757. * All of the animation groups added to this scene
  111758. * @see http://doc.babylonjs.com/how_to/group
  111759. */
  111760. animationGroups: AnimationGroup[];
  111761. /**
  111762. * All of the multi-materials added to this scene
  111763. * @see http://doc.babylonjs.com/how_to/multi_materials
  111764. */
  111765. multiMaterials: MultiMaterial[];
  111766. /**
  111767. * All of the materials added to this scene
  111768. * In the context of a Scene, it is not supposed to be modified manually.
  111769. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  111770. * Note also that the order of the Material within the array is not significant and might change.
  111771. * @see http://doc.babylonjs.com/babylon101/materials
  111772. */
  111773. materials: Material[];
  111774. /**
  111775. * The list of morph target managers added to the scene
  111776. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  111777. */
  111778. morphTargetManagers: MorphTargetManager[];
  111779. /**
  111780. * The list of geometries used in the scene.
  111781. */
  111782. geometries: Geometry[];
  111783. /**
  111784. * All of the tranform nodes added to this scene
  111785. * In the context of a Scene, it is not supposed to be modified manually.
  111786. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  111787. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  111788. * @see http://doc.babylonjs.com/how_to/transformnode
  111789. */
  111790. transformNodes: TransformNode[];
  111791. /**
  111792. * ActionManagers available on the scene.
  111793. */
  111794. actionManagers: AbstractActionManager[];
  111795. /**
  111796. * Textures to keep.
  111797. */
  111798. textures: BaseTexture[];
  111799. /**
  111800. * Environment texture for the scene
  111801. */
  111802. environmentTexture: Nullable<BaseTexture>;
  111803. /**
  111804. * @returns all meshes, lights, cameras, transformNodes and bones
  111805. */
  111806. getNodes(): Array<Node>;
  111807. }
  111808. }
  111809. declare module BABYLON {
  111810. /**
  111811. * Interface used to define options for Sound class
  111812. */
  111813. export interface ISoundOptions {
  111814. /**
  111815. * Does the sound autoplay once loaded.
  111816. */
  111817. autoplay?: boolean;
  111818. /**
  111819. * Does the sound loop after it finishes playing once.
  111820. */
  111821. loop?: boolean;
  111822. /**
  111823. * Sound's volume
  111824. */
  111825. volume?: number;
  111826. /**
  111827. * Is it a spatial sound?
  111828. */
  111829. spatialSound?: boolean;
  111830. /**
  111831. * Maximum distance to hear that sound
  111832. */
  111833. maxDistance?: number;
  111834. /**
  111835. * Uses user defined attenuation function
  111836. */
  111837. useCustomAttenuation?: boolean;
  111838. /**
  111839. * Define the roll off factor of spatial sounds.
  111840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111841. */
  111842. rolloffFactor?: number;
  111843. /**
  111844. * Define the reference distance the sound should be heard perfectly.
  111845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111846. */
  111847. refDistance?: number;
  111848. /**
  111849. * Define the distance attenuation model the sound will follow.
  111850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111851. */
  111852. distanceModel?: string;
  111853. /**
  111854. * Defines the playback speed (1 by default)
  111855. */
  111856. playbackRate?: number;
  111857. /**
  111858. * Defines if the sound is from a streaming source
  111859. */
  111860. streaming?: boolean;
  111861. /**
  111862. * Defines an optional length (in seconds) inside the sound file
  111863. */
  111864. length?: number;
  111865. /**
  111866. * Defines an optional offset (in seconds) inside the sound file
  111867. */
  111868. offset?: number;
  111869. /**
  111870. * If true, URLs will not be required to state the audio file codec to use.
  111871. */
  111872. skipCodecCheck?: boolean;
  111873. }
  111874. /**
  111875. * Defines a sound that can be played in the application.
  111876. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  111877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111878. */
  111879. export class Sound {
  111880. /**
  111881. * The name of the sound in the scene.
  111882. */
  111883. name: string;
  111884. /**
  111885. * Does the sound autoplay once loaded.
  111886. */
  111887. autoplay: boolean;
  111888. /**
  111889. * Does the sound loop after it finishes playing once.
  111890. */
  111891. loop: boolean;
  111892. /**
  111893. * Does the sound use a custom attenuation curve to simulate the falloff
  111894. * happening when the source gets further away from the camera.
  111895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111896. */
  111897. useCustomAttenuation: boolean;
  111898. /**
  111899. * The sound track id this sound belongs to.
  111900. */
  111901. soundTrackId: number;
  111902. /**
  111903. * Is this sound currently played.
  111904. */
  111905. isPlaying: boolean;
  111906. /**
  111907. * Is this sound currently paused.
  111908. */
  111909. isPaused: boolean;
  111910. /**
  111911. * Does this sound enables spatial sound.
  111912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111913. */
  111914. spatialSound: boolean;
  111915. /**
  111916. * Define the reference distance the sound should be heard perfectly.
  111917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111918. */
  111919. refDistance: number;
  111920. /**
  111921. * Define the roll off factor of spatial sounds.
  111922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111923. */
  111924. rolloffFactor: number;
  111925. /**
  111926. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111928. */
  111929. maxDistance: number;
  111930. /**
  111931. * Define the distance attenuation model the sound will follow.
  111932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111933. */
  111934. distanceModel: string;
  111935. /**
  111936. * @hidden
  111937. * Back Compat
  111938. **/
  111939. onended: () => any;
  111940. /**
  111941. * Observable event when the current playing sound finishes.
  111942. */
  111943. onEndedObservable: Observable<Sound>;
  111944. private _panningModel;
  111945. private _playbackRate;
  111946. private _streaming;
  111947. private _startTime;
  111948. private _startOffset;
  111949. private _position;
  111950. /** @hidden */
  111951. _positionInEmitterSpace: boolean;
  111952. private _localDirection;
  111953. private _volume;
  111954. private _isReadyToPlay;
  111955. private _isDirectional;
  111956. private _readyToPlayCallback;
  111957. private _audioBuffer;
  111958. private _soundSource;
  111959. private _streamingSource;
  111960. private _soundPanner;
  111961. private _soundGain;
  111962. private _inputAudioNode;
  111963. private _outputAudioNode;
  111964. private _coneInnerAngle;
  111965. private _coneOuterAngle;
  111966. private _coneOuterGain;
  111967. private _scene;
  111968. private _connectedTransformNode;
  111969. private _customAttenuationFunction;
  111970. private _registerFunc;
  111971. private _isOutputConnected;
  111972. private _htmlAudioElement;
  111973. private _urlType;
  111974. private _length?;
  111975. private _offset?;
  111976. /** @hidden */
  111977. static _SceneComponentInitialization: (scene: Scene) => void;
  111978. /**
  111979. * Create a sound and attach it to a scene
  111980. * @param name Name of your sound
  111981. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111982. * @param scene defines the scene the sound belongs to
  111983. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  111984. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  111985. */
  111986. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  111987. /**
  111988. * Release the sound and its associated resources
  111989. */
  111990. dispose(): void;
  111991. /**
  111992. * Gets if the sounds is ready to be played or not.
  111993. * @returns true if ready, otherwise false
  111994. */
  111995. isReady(): boolean;
  111996. private _soundLoaded;
  111997. /**
  111998. * Sets the data of the sound from an audiobuffer
  111999. * @param audioBuffer The audioBuffer containing the data
  112000. */
  112001. setAudioBuffer(audioBuffer: AudioBuffer): void;
  112002. /**
  112003. * Updates the current sounds options such as maxdistance, loop...
  112004. * @param options A JSON object containing values named as the object properties
  112005. */
  112006. updateOptions(options: ISoundOptions): void;
  112007. private _createSpatialParameters;
  112008. private _updateSpatialParameters;
  112009. /**
  112010. * Switch the panning model to HRTF:
  112011. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112013. */
  112014. switchPanningModelToHRTF(): void;
  112015. /**
  112016. * Switch the panning model to Equal Power:
  112017. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112019. */
  112020. switchPanningModelToEqualPower(): void;
  112021. private _switchPanningModel;
  112022. /**
  112023. * Connect this sound to a sound track audio node like gain...
  112024. * @param soundTrackAudioNode the sound track audio node to connect to
  112025. */
  112026. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  112027. /**
  112028. * Transform this sound into a directional source
  112029. * @param coneInnerAngle Size of the inner cone in degree
  112030. * @param coneOuterAngle Size of the outer cone in degree
  112031. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  112032. */
  112033. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  112034. /**
  112035. * Gets or sets the inner angle for the directional cone.
  112036. */
  112037. get directionalConeInnerAngle(): number;
  112038. /**
  112039. * Gets or sets the inner angle for the directional cone.
  112040. */
  112041. set directionalConeInnerAngle(value: number);
  112042. /**
  112043. * Gets or sets the outer angle for the directional cone.
  112044. */
  112045. get directionalConeOuterAngle(): number;
  112046. /**
  112047. * Gets or sets the outer angle for the directional cone.
  112048. */
  112049. set directionalConeOuterAngle(value: number);
  112050. /**
  112051. * Sets the position of the emitter if spatial sound is enabled
  112052. * @param newPosition Defines the new posisiton
  112053. */
  112054. setPosition(newPosition: Vector3): void;
  112055. /**
  112056. * Sets the local direction of the emitter if spatial sound is enabled
  112057. * @param newLocalDirection Defines the new local direction
  112058. */
  112059. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  112060. private _updateDirection;
  112061. /** @hidden */
  112062. updateDistanceFromListener(): void;
  112063. /**
  112064. * Sets a new custom attenuation function for the sound.
  112065. * @param callback Defines the function used for the attenuation
  112066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  112067. */
  112068. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  112069. /**
  112070. * Play the sound
  112071. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  112072. * @param offset (optional) Start the sound at a specific time in seconds
  112073. * @param length (optional) Sound duration (in seconds)
  112074. */
  112075. play(time?: number, offset?: number, length?: number): void;
  112076. private _onended;
  112077. /**
  112078. * Stop the sound
  112079. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  112080. */
  112081. stop(time?: number): void;
  112082. /**
  112083. * Put the sound in pause
  112084. */
  112085. pause(): void;
  112086. /**
  112087. * Sets a dedicated volume for this sounds
  112088. * @param newVolume Define the new volume of the sound
  112089. * @param time Define time for gradual change to new volume
  112090. */
  112091. setVolume(newVolume: number, time?: number): void;
  112092. /**
  112093. * Set the sound play back rate
  112094. * @param newPlaybackRate Define the playback rate the sound should be played at
  112095. */
  112096. setPlaybackRate(newPlaybackRate: number): void;
  112097. /**
  112098. * Gets the volume of the sound.
  112099. * @returns the volume of the sound
  112100. */
  112101. getVolume(): number;
  112102. /**
  112103. * Attach the sound to a dedicated mesh
  112104. * @param transformNode The transform node to connect the sound with
  112105. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112106. */
  112107. attachToMesh(transformNode: TransformNode): void;
  112108. /**
  112109. * Detach the sound from the previously attached mesh
  112110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112111. */
  112112. detachFromMesh(): void;
  112113. private _onRegisterAfterWorldMatrixUpdate;
  112114. /**
  112115. * Clone the current sound in the scene.
  112116. * @returns the new sound clone
  112117. */
  112118. clone(): Nullable<Sound>;
  112119. /**
  112120. * Gets the current underlying audio buffer containing the data
  112121. * @returns the audio buffer
  112122. */
  112123. getAudioBuffer(): Nullable<AudioBuffer>;
  112124. /**
  112125. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  112126. * @returns the source node
  112127. */
  112128. getSoundSource(): Nullable<AudioBufferSourceNode>;
  112129. /**
  112130. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  112131. * @returns the gain node
  112132. */
  112133. getSoundGain(): Nullable<GainNode>;
  112134. /**
  112135. * Serializes the Sound in a JSON representation
  112136. * @returns the JSON representation of the sound
  112137. */
  112138. serialize(): any;
  112139. /**
  112140. * Parse a JSON representation of a sound to innstantiate in a given scene
  112141. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  112142. * @param scene Define the scene the new parsed sound should be created in
  112143. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  112144. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  112145. * @returns the newly parsed sound
  112146. */
  112147. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  112148. }
  112149. }
  112150. declare module BABYLON {
  112151. /**
  112152. * This defines an action helpful to play a defined sound on a triggered action.
  112153. */
  112154. export class PlaySoundAction extends Action {
  112155. private _sound;
  112156. /**
  112157. * Instantiate the action
  112158. * @param triggerOptions defines the trigger options
  112159. * @param sound defines the sound to play
  112160. * @param condition defines the trigger related conditions
  112161. */
  112162. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112163. /** @hidden */
  112164. _prepare(): void;
  112165. /**
  112166. * Execute the action and play the sound.
  112167. */
  112168. execute(): void;
  112169. /**
  112170. * Serializes the actions and its related information.
  112171. * @param parent defines the object to serialize in
  112172. * @returns the serialized object
  112173. */
  112174. serialize(parent: any): any;
  112175. }
  112176. /**
  112177. * This defines an action helpful to stop a defined sound on a triggered action.
  112178. */
  112179. export class StopSoundAction extends Action {
  112180. private _sound;
  112181. /**
  112182. * Instantiate the action
  112183. * @param triggerOptions defines the trigger options
  112184. * @param sound defines the sound to stop
  112185. * @param condition defines the trigger related conditions
  112186. */
  112187. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112188. /** @hidden */
  112189. _prepare(): void;
  112190. /**
  112191. * Execute the action and stop the sound.
  112192. */
  112193. execute(): void;
  112194. /**
  112195. * Serializes the actions and its related information.
  112196. * @param parent defines the object to serialize in
  112197. * @returns the serialized object
  112198. */
  112199. serialize(parent: any): any;
  112200. }
  112201. }
  112202. declare module BABYLON {
  112203. /**
  112204. * This defines an action responsible to change the value of a property
  112205. * by interpolating between its current value and the newly set one once triggered.
  112206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112207. */
  112208. export class InterpolateValueAction extends Action {
  112209. /**
  112210. * Defines the path of the property where the value should be interpolated
  112211. */
  112212. propertyPath: string;
  112213. /**
  112214. * Defines the target value at the end of the interpolation.
  112215. */
  112216. value: any;
  112217. /**
  112218. * Defines the time it will take for the property to interpolate to the value.
  112219. */
  112220. duration: number;
  112221. /**
  112222. * Defines if the other scene animations should be stopped when the action has been triggered
  112223. */
  112224. stopOtherAnimations?: boolean;
  112225. /**
  112226. * Defines a callback raised once the interpolation animation has been done.
  112227. */
  112228. onInterpolationDone?: () => void;
  112229. /**
  112230. * Observable triggered once the interpolation animation has been done.
  112231. */
  112232. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  112233. private _target;
  112234. private _effectiveTarget;
  112235. private _property;
  112236. /**
  112237. * Instantiate the action
  112238. * @param triggerOptions defines the trigger options
  112239. * @param target defines the object containing the value to interpolate
  112240. * @param propertyPath defines the path to the property in the target object
  112241. * @param value defines the target value at the end of the interpolation
  112242. * @param duration deines the time it will take for the property to interpolate to the value.
  112243. * @param condition defines the trigger related conditions
  112244. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  112245. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  112246. */
  112247. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  112248. /** @hidden */
  112249. _prepare(): void;
  112250. /**
  112251. * Execute the action starts the value interpolation.
  112252. */
  112253. execute(): void;
  112254. /**
  112255. * Serializes the actions and its related information.
  112256. * @param parent defines the object to serialize in
  112257. * @returns the serialized object
  112258. */
  112259. serialize(parent: any): any;
  112260. }
  112261. }
  112262. declare module BABYLON {
  112263. /**
  112264. * Options allowed during the creation of a sound track.
  112265. */
  112266. export interface ISoundTrackOptions {
  112267. /**
  112268. * The volume the sound track should take during creation
  112269. */
  112270. volume?: number;
  112271. /**
  112272. * Define if the sound track is the main sound track of the scene
  112273. */
  112274. mainTrack?: boolean;
  112275. }
  112276. /**
  112277. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  112278. * It will be also used in a future release to apply effects on a specific track.
  112279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112280. */
  112281. export class SoundTrack {
  112282. /**
  112283. * The unique identifier of the sound track in the scene.
  112284. */
  112285. id: number;
  112286. /**
  112287. * The list of sounds included in the sound track.
  112288. */
  112289. soundCollection: Array<Sound>;
  112290. private _outputAudioNode;
  112291. private _scene;
  112292. private _connectedAnalyser;
  112293. private _options;
  112294. private _isInitialized;
  112295. /**
  112296. * Creates a new sound track.
  112297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112298. * @param scene Define the scene the sound track belongs to
  112299. * @param options
  112300. */
  112301. constructor(scene: Scene, options?: ISoundTrackOptions);
  112302. private _initializeSoundTrackAudioGraph;
  112303. /**
  112304. * Release the sound track and its associated resources
  112305. */
  112306. dispose(): void;
  112307. /**
  112308. * Adds a sound to this sound track
  112309. * @param sound define the cound to add
  112310. * @ignoreNaming
  112311. */
  112312. AddSound(sound: Sound): void;
  112313. /**
  112314. * Removes a sound to this sound track
  112315. * @param sound define the cound to remove
  112316. * @ignoreNaming
  112317. */
  112318. RemoveSound(sound: Sound): void;
  112319. /**
  112320. * Set a global volume for the full sound track.
  112321. * @param newVolume Define the new volume of the sound track
  112322. */
  112323. setVolume(newVolume: number): void;
  112324. /**
  112325. * Switch the panning model to HRTF:
  112326. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112328. */
  112329. switchPanningModelToHRTF(): void;
  112330. /**
  112331. * Switch the panning model to Equal Power:
  112332. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112334. */
  112335. switchPanningModelToEqualPower(): void;
  112336. /**
  112337. * Connect the sound track to an audio analyser allowing some amazing
  112338. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112339. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112340. * @param analyser The analyser to connect to the engine
  112341. */
  112342. connectToAnalyser(analyser: Analyser): void;
  112343. }
  112344. }
  112345. declare module BABYLON {
  112346. interface AbstractScene {
  112347. /**
  112348. * The list of sounds used in the scene.
  112349. */
  112350. sounds: Nullable<Array<Sound>>;
  112351. }
  112352. interface Scene {
  112353. /**
  112354. * @hidden
  112355. * Backing field
  112356. */
  112357. _mainSoundTrack: SoundTrack;
  112358. /**
  112359. * The main sound track played by the scene.
  112360. * It cotains your primary collection of sounds.
  112361. */
  112362. mainSoundTrack: SoundTrack;
  112363. /**
  112364. * The list of sound tracks added to the scene
  112365. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112366. */
  112367. soundTracks: Nullable<Array<SoundTrack>>;
  112368. /**
  112369. * Gets a sound using a given name
  112370. * @param name defines the name to search for
  112371. * @return the found sound or null if not found at all.
  112372. */
  112373. getSoundByName(name: string): Nullable<Sound>;
  112374. /**
  112375. * Gets or sets if audio support is enabled
  112376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112377. */
  112378. audioEnabled: boolean;
  112379. /**
  112380. * Gets or sets if audio will be output to headphones
  112381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112382. */
  112383. headphone: boolean;
  112384. /**
  112385. * Gets or sets custom audio listener position provider
  112386. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112387. */
  112388. audioListenerPositionProvider: Nullable<() => Vector3>;
  112389. /**
  112390. * Gets or sets a refresh rate when using 3D audio positioning
  112391. */
  112392. audioPositioningRefreshRate: number;
  112393. }
  112394. /**
  112395. * Defines the sound scene component responsible to manage any sounds
  112396. * in a given scene.
  112397. */
  112398. export class AudioSceneComponent implements ISceneSerializableComponent {
  112399. /**
  112400. * The component name helpfull to identify the component in the list of scene components.
  112401. */
  112402. readonly name: string;
  112403. /**
  112404. * The scene the component belongs to.
  112405. */
  112406. scene: Scene;
  112407. private _audioEnabled;
  112408. /**
  112409. * Gets whether audio is enabled or not.
  112410. * Please use related enable/disable method to switch state.
  112411. */
  112412. get audioEnabled(): boolean;
  112413. private _headphone;
  112414. /**
  112415. * Gets whether audio is outputing to headphone or not.
  112416. * Please use the according Switch methods to change output.
  112417. */
  112418. get headphone(): boolean;
  112419. /**
  112420. * Gets or sets a refresh rate when using 3D audio positioning
  112421. */
  112422. audioPositioningRefreshRate: number;
  112423. private _audioListenerPositionProvider;
  112424. /**
  112425. * Gets the current audio listener position provider
  112426. */
  112427. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  112428. /**
  112429. * Sets a custom listener position for all sounds in the scene
  112430. * By default, this is the position of the first active camera
  112431. */
  112432. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  112433. /**
  112434. * Creates a new instance of the component for the given scene
  112435. * @param scene Defines the scene to register the component in
  112436. */
  112437. constructor(scene: Scene);
  112438. /**
  112439. * Registers the component in a given scene
  112440. */
  112441. register(): void;
  112442. /**
  112443. * Rebuilds the elements related to this component in case of
  112444. * context lost for instance.
  112445. */
  112446. rebuild(): void;
  112447. /**
  112448. * Serializes the component data to the specified json object
  112449. * @param serializationObject The object to serialize to
  112450. */
  112451. serialize(serializationObject: any): void;
  112452. /**
  112453. * Adds all the elements from the container to the scene
  112454. * @param container the container holding the elements
  112455. */
  112456. addFromContainer(container: AbstractScene): void;
  112457. /**
  112458. * Removes all the elements in the container from the scene
  112459. * @param container contains the elements to remove
  112460. * @param dispose if the removed element should be disposed (default: false)
  112461. */
  112462. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112463. /**
  112464. * Disposes the component and the associated ressources.
  112465. */
  112466. dispose(): void;
  112467. /**
  112468. * Disables audio in the associated scene.
  112469. */
  112470. disableAudio(): void;
  112471. /**
  112472. * Enables audio in the associated scene.
  112473. */
  112474. enableAudio(): void;
  112475. /**
  112476. * Switch audio to headphone output.
  112477. */
  112478. switchAudioModeForHeadphones(): void;
  112479. /**
  112480. * Switch audio to normal speakers.
  112481. */
  112482. switchAudioModeForNormalSpeakers(): void;
  112483. private _cachedCameraDirection;
  112484. private _cachedCameraPosition;
  112485. private _lastCheck;
  112486. private _afterRender;
  112487. }
  112488. }
  112489. declare module BABYLON {
  112490. /**
  112491. * Wraps one or more Sound objects and selects one with random weight for playback.
  112492. */
  112493. export class WeightedSound {
  112494. /** When true a Sound will be selected and played when the current playing Sound completes. */
  112495. loop: boolean;
  112496. private _coneInnerAngle;
  112497. private _coneOuterAngle;
  112498. private _volume;
  112499. /** A Sound is currently playing. */
  112500. isPlaying: boolean;
  112501. /** A Sound is currently paused. */
  112502. isPaused: boolean;
  112503. private _sounds;
  112504. private _weights;
  112505. private _currentIndex?;
  112506. /**
  112507. * Creates a new WeightedSound from the list of sounds given.
  112508. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  112509. * @param sounds Array of Sounds that will be selected from.
  112510. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  112511. */
  112512. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  112513. /**
  112514. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  112515. */
  112516. get directionalConeInnerAngle(): number;
  112517. /**
  112518. * The size of cone in degress for a directional sound in which there will be no attenuation.
  112519. */
  112520. set directionalConeInnerAngle(value: number);
  112521. /**
  112522. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112523. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112524. */
  112525. get directionalConeOuterAngle(): number;
  112526. /**
  112527. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112528. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112529. */
  112530. set directionalConeOuterAngle(value: number);
  112531. /**
  112532. * Playback volume.
  112533. */
  112534. get volume(): number;
  112535. /**
  112536. * Playback volume.
  112537. */
  112538. set volume(value: number);
  112539. private _onended;
  112540. /**
  112541. * Suspend playback
  112542. */
  112543. pause(): void;
  112544. /**
  112545. * Stop playback
  112546. */
  112547. stop(): void;
  112548. /**
  112549. * Start playback.
  112550. * @param startOffset Position the clip head at a specific time in seconds.
  112551. */
  112552. play(startOffset?: number): void;
  112553. }
  112554. }
  112555. declare module BABYLON {
  112556. /**
  112557. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  112558. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112559. */
  112560. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  112561. /**
  112562. * Gets the name of the behavior.
  112563. */
  112564. get name(): string;
  112565. /**
  112566. * The easing function used by animations
  112567. */
  112568. static EasingFunction: BackEase;
  112569. /**
  112570. * The easing mode used by animations
  112571. */
  112572. static EasingMode: number;
  112573. /**
  112574. * The duration of the animation, in milliseconds
  112575. */
  112576. transitionDuration: number;
  112577. /**
  112578. * Length of the distance animated by the transition when lower radius is reached
  112579. */
  112580. lowerRadiusTransitionRange: number;
  112581. /**
  112582. * Length of the distance animated by the transition when upper radius is reached
  112583. */
  112584. upperRadiusTransitionRange: number;
  112585. private _autoTransitionRange;
  112586. /**
  112587. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112588. */
  112589. get autoTransitionRange(): boolean;
  112590. /**
  112591. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112592. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  112593. */
  112594. set autoTransitionRange(value: boolean);
  112595. private _attachedCamera;
  112596. private _onAfterCheckInputsObserver;
  112597. private _onMeshTargetChangedObserver;
  112598. /**
  112599. * Initializes the behavior.
  112600. */
  112601. init(): void;
  112602. /**
  112603. * Attaches the behavior to its arc rotate camera.
  112604. * @param camera Defines the camera to attach the behavior to
  112605. */
  112606. attach(camera: ArcRotateCamera): void;
  112607. /**
  112608. * Detaches the behavior from its current arc rotate camera.
  112609. */
  112610. detach(): void;
  112611. private _radiusIsAnimating;
  112612. private _radiusBounceTransition;
  112613. private _animatables;
  112614. private _cachedWheelPrecision;
  112615. /**
  112616. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  112617. * @param radiusLimit The limit to check against.
  112618. * @return Bool to indicate if at limit.
  112619. */
  112620. private _isRadiusAtLimit;
  112621. /**
  112622. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  112623. * @param radiusDelta The delta by which to animate to. Can be negative.
  112624. */
  112625. private _applyBoundRadiusAnimation;
  112626. /**
  112627. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  112628. */
  112629. protected _clearAnimationLocks(): void;
  112630. /**
  112631. * Stops and removes all animations that have been applied to the camera
  112632. */
  112633. stopAllAnimations(): void;
  112634. }
  112635. }
  112636. declare module BABYLON {
  112637. /**
  112638. * 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.
  112639. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112640. */
  112641. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  112642. /**
  112643. * Gets the name of the behavior.
  112644. */
  112645. get name(): string;
  112646. private _mode;
  112647. private _radiusScale;
  112648. private _positionScale;
  112649. private _defaultElevation;
  112650. private _elevationReturnTime;
  112651. private _elevationReturnWaitTime;
  112652. private _zoomStopsAnimation;
  112653. private _framingTime;
  112654. /**
  112655. * The easing function used by animations
  112656. */
  112657. static EasingFunction: ExponentialEase;
  112658. /**
  112659. * The easing mode used by animations
  112660. */
  112661. static EasingMode: number;
  112662. /**
  112663. * Sets the current mode used by the behavior
  112664. */
  112665. set mode(mode: number);
  112666. /**
  112667. * Gets current mode used by the behavior.
  112668. */
  112669. get mode(): number;
  112670. /**
  112671. * Sets the scale applied to the radius (1 by default)
  112672. */
  112673. set radiusScale(radius: number);
  112674. /**
  112675. * Gets the scale applied to the radius
  112676. */
  112677. get radiusScale(): number;
  112678. /**
  112679. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112680. */
  112681. set positionScale(scale: number);
  112682. /**
  112683. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112684. */
  112685. get positionScale(): number;
  112686. /**
  112687. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112688. * behaviour is triggered, in radians.
  112689. */
  112690. set defaultElevation(elevation: number);
  112691. /**
  112692. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112693. * behaviour is triggered, in radians.
  112694. */
  112695. get defaultElevation(): number;
  112696. /**
  112697. * Sets the time (in milliseconds) taken to return to the default beta position.
  112698. * Negative value indicates camera should not return to default.
  112699. */
  112700. set elevationReturnTime(speed: number);
  112701. /**
  112702. * Gets the time (in milliseconds) taken to return to the default beta position.
  112703. * Negative value indicates camera should not return to default.
  112704. */
  112705. get elevationReturnTime(): number;
  112706. /**
  112707. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112708. */
  112709. set elevationReturnWaitTime(time: number);
  112710. /**
  112711. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112712. */
  112713. get elevationReturnWaitTime(): number;
  112714. /**
  112715. * Sets the flag that indicates if user zooming should stop animation.
  112716. */
  112717. set zoomStopsAnimation(flag: boolean);
  112718. /**
  112719. * Gets the flag that indicates if user zooming should stop animation.
  112720. */
  112721. get zoomStopsAnimation(): boolean;
  112722. /**
  112723. * Sets the transition time when framing the mesh, in milliseconds
  112724. */
  112725. set framingTime(time: number);
  112726. /**
  112727. * Gets the transition time when framing the mesh, in milliseconds
  112728. */
  112729. get framingTime(): number;
  112730. /**
  112731. * Define if the behavior should automatically change the configured
  112732. * camera limits and sensibilities.
  112733. */
  112734. autoCorrectCameraLimitsAndSensibility: boolean;
  112735. private _onPrePointerObservableObserver;
  112736. private _onAfterCheckInputsObserver;
  112737. private _onMeshTargetChangedObserver;
  112738. private _attachedCamera;
  112739. private _isPointerDown;
  112740. private _lastInteractionTime;
  112741. /**
  112742. * Initializes the behavior.
  112743. */
  112744. init(): void;
  112745. /**
  112746. * Attaches the behavior to its arc rotate camera.
  112747. * @param camera Defines the camera to attach the behavior to
  112748. */
  112749. attach(camera: ArcRotateCamera): void;
  112750. /**
  112751. * Detaches the behavior from its current arc rotate camera.
  112752. */
  112753. detach(): void;
  112754. private _animatables;
  112755. private _betaIsAnimating;
  112756. private _betaTransition;
  112757. private _radiusTransition;
  112758. private _vectorTransition;
  112759. /**
  112760. * Targets the given mesh and updates zoom level accordingly.
  112761. * @param mesh The mesh to target.
  112762. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112763. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112764. */
  112765. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112766. /**
  112767. * Targets the given mesh with its children and updates zoom level accordingly.
  112768. * @param mesh The mesh to target.
  112769. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112770. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112771. */
  112772. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112773. /**
  112774. * Targets the given meshes with their children and updates zoom level accordingly.
  112775. * @param meshes The mesh to target.
  112776. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112777. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112778. */
  112779. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112780. /**
  112781. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  112782. * @param minimumWorld Determines the smaller position of the bounding box extend
  112783. * @param maximumWorld Determines the bigger position of the bounding box extend
  112784. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112785. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112786. */
  112787. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112788. /**
  112789. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  112790. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  112791. * frustum width.
  112792. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  112793. * to fully enclose the mesh in the viewing frustum.
  112794. */
  112795. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  112796. /**
  112797. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  112798. * is automatically returned to its default position (expected to be above ground plane).
  112799. */
  112800. private _maintainCameraAboveGround;
  112801. /**
  112802. * Returns the frustum slope based on the canvas ratio and camera FOV
  112803. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  112804. */
  112805. private _getFrustumSlope;
  112806. /**
  112807. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  112808. */
  112809. private _clearAnimationLocks;
  112810. /**
  112811. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112812. */
  112813. private _applyUserInteraction;
  112814. /**
  112815. * Stops and removes all animations that have been applied to the camera
  112816. */
  112817. stopAllAnimations(): void;
  112818. /**
  112819. * Gets a value indicating if the user is moving the camera
  112820. */
  112821. get isUserIsMoving(): boolean;
  112822. /**
  112823. * The camera can move all the way towards the mesh.
  112824. */
  112825. static IgnoreBoundsSizeMode: number;
  112826. /**
  112827. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  112828. */
  112829. static FitFrustumSidesMode: number;
  112830. }
  112831. }
  112832. declare module BABYLON {
  112833. /**
  112834. * Base class for Camera Pointer Inputs.
  112835. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  112836. * for example usage.
  112837. */
  112838. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  112839. /**
  112840. * Defines the camera the input is attached to.
  112841. */
  112842. abstract camera: Camera;
  112843. /**
  112844. * Whether keyboard modifier keys are pressed at time of last mouse event.
  112845. */
  112846. protected _altKey: boolean;
  112847. protected _ctrlKey: boolean;
  112848. protected _metaKey: boolean;
  112849. protected _shiftKey: boolean;
  112850. /**
  112851. * Which mouse buttons were pressed at time of last mouse event.
  112852. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  112853. */
  112854. protected _buttonsPressed: number;
  112855. /**
  112856. * Defines the buttons associated with the input to handle camera move.
  112857. */
  112858. buttons: number[];
  112859. /**
  112860. * Attach the input controls to a specific dom element to get the input from.
  112861. * @param element Defines the element the controls should be listened from
  112862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112863. */
  112864. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112865. /**
  112866. * Detach the current controls from the specified dom element.
  112867. * @param element Defines the element to stop listening the inputs from
  112868. */
  112869. detachControl(element: Nullable<HTMLElement>): void;
  112870. /**
  112871. * Gets the class name of the current input.
  112872. * @returns the class name
  112873. */
  112874. getClassName(): string;
  112875. /**
  112876. * Get the friendly name associated with the input class.
  112877. * @returns the input friendly name
  112878. */
  112879. getSimpleName(): string;
  112880. /**
  112881. * Called on pointer POINTERDOUBLETAP event.
  112882. * Override this method to provide functionality on POINTERDOUBLETAP event.
  112883. */
  112884. protected onDoubleTap(type: string): void;
  112885. /**
  112886. * Called on pointer POINTERMOVE event if only a single touch is active.
  112887. * Override this method to provide functionality.
  112888. */
  112889. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112890. /**
  112891. * Called on pointer POINTERMOVE event if multiple touches are active.
  112892. * Override this method to provide functionality.
  112893. */
  112894. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112895. /**
  112896. * Called on JS contextmenu event.
  112897. * Override this method to provide functionality.
  112898. */
  112899. protected onContextMenu(evt: PointerEvent): void;
  112900. /**
  112901. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112902. * press.
  112903. * Override this method to provide functionality.
  112904. */
  112905. protected onButtonDown(evt: PointerEvent): void;
  112906. /**
  112907. * Called each time a new POINTERUP event occurs. Ie, for each button
  112908. * release.
  112909. * Override this method to provide functionality.
  112910. */
  112911. protected onButtonUp(evt: PointerEvent): void;
  112912. /**
  112913. * Called when window becomes inactive.
  112914. * Override this method to provide functionality.
  112915. */
  112916. protected onLostFocus(): void;
  112917. private _pointerInput;
  112918. private _observer;
  112919. private _onLostFocus;
  112920. private pointA;
  112921. private pointB;
  112922. }
  112923. }
  112924. declare module BABYLON {
  112925. /**
  112926. * Manage the pointers inputs to control an arc rotate camera.
  112927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112928. */
  112929. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112930. /**
  112931. * Defines the camera the input is attached to.
  112932. */
  112933. camera: ArcRotateCamera;
  112934. /**
  112935. * Gets the class name of the current input.
  112936. * @returns the class name
  112937. */
  112938. getClassName(): string;
  112939. /**
  112940. * Defines the buttons associated with the input to handle camera move.
  112941. */
  112942. buttons: number[];
  112943. /**
  112944. * Defines the pointer angular sensibility along the X axis or how fast is
  112945. * the camera rotating.
  112946. */
  112947. angularSensibilityX: number;
  112948. /**
  112949. * Defines the pointer angular sensibility along the Y axis or how fast is
  112950. * the camera rotating.
  112951. */
  112952. angularSensibilityY: number;
  112953. /**
  112954. * Defines the pointer pinch precision or how fast is the camera zooming.
  112955. */
  112956. pinchPrecision: number;
  112957. /**
  112958. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112959. * from 0.
  112960. * It defines the percentage of current camera.radius to use as delta when
  112961. * pinch zoom is used.
  112962. */
  112963. pinchDeltaPercentage: number;
  112964. /**
  112965. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112966. * that any object in the plane at the camera's target point will scale
  112967. * perfectly with finger motion.
  112968. * Overrides pinchDeltaPercentage and pinchPrecision.
  112969. */
  112970. useNaturalPinchZoom: boolean;
  112971. /**
  112972. * Defines the pointer panning sensibility or how fast is the camera moving.
  112973. */
  112974. panningSensibility: number;
  112975. /**
  112976. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112977. */
  112978. multiTouchPanning: boolean;
  112979. /**
  112980. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112981. * zoom (pinch) through multitouch.
  112982. */
  112983. multiTouchPanAndZoom: boolean;
  112984. /**
  112985. * Revers pinch action direction.
  112986. */
  112987. pinchInwards: boolean;
  112988. private _isPanClick;
  112989. private _twoFingerActivityCount;
  112990. private _isPinching;
  112991. /**
  112992. * Called on pointer POINTERMOVE event if only a single touch is active.
  112993. */
  112994. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112995. /**
  112996. * Called on pointer POINTERDOUBLETAP event.
  112997. */
  112998. protected onDoubleTap(type: string): void;
  112999. /**
  113000. * Called on pointer POINTERMOVE event if multiple touches are active.
  113001. */
  113002. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113003. /**
  113004. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  113005. * press.
  113006. */
  113007. protected onButtonDown(evt: PointerEvent): void;
  113008. /**
  113009. * Called each time a new POINTERUP event occurs. Ie, for each button
  113010. * release.
  113011. */
  113012. protected onButtonUp(evt: PointerEvent): void;
  113013. /**
  113014. * Called when window becomes inactive.
  113015. */
  113016. protected onLostFocus(): void;
  113017. }
  113018. }
  113019. declare module BABYLON {
  113020. /**
  113021. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  113022. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113023. */
  113024. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  113025. /**
  113026. * Defines the camera the input is attached to.
  113027. */
  113028. camera: ArcRotateCamera;
  113029. /**
  113030. * Defines the list of key codes associated with the up action (increase alpha)
  113031. */
  113032. keysUp: number[];
  113033. /**
  113034. * Defines the list of key codes associated with the down action (decrease alpha)
  113035. */
  113036. keysDown: number[];
  113037. /**
  113038. * Defines the list of key codes associated with the left action (increase beta)
  113039. */
  113040. keysLeft: number[];
  113041. /**
  113042. * Defines the list of key codes associated with the right action (decrease beta)
  113043. */
  113044. keysRight: number[];
  113045. /**
  113046. * Defines the list of key codes associated with the reset action.
  113047. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  113048. */
  113049. keysReset: number[];
  113050. /**
  113051. * Defines the panning sensibility of the inputs.
  113052. * (How fast is the camera panning)
  113053. */
  113054. panningSensibility: number;
  113055. /**
  113056. * Defines the zooming sensibility of the inputs.
  113057. * (How fast is the camera zooming)
  113058. */
  113059. zoomingSensibility: number;
  113060. /**
  113061. * Defines whether maintaining the alt key down switch the movement mode from
  113062. * orientation to zoom.
  113063. */
  113064. useAltToZoom: boolean;
  113065. /**
  113066. * Rotation speed of the camera
  113067. */
  113068. angularSpeed: number;
  113069. private _keys;
  113070. private _ctrlPressed;
  113071. private _altPressed;
  113072. private _onCanvasBlurObserver;
  113073. private _onKeyboardObserver;
  113074. private _engine;
  113075. private _scene;
  113076. /**
  113077. * Attach the input controls to a specific dom element to get the input from.
  113078. * @param element Defines the element the controls should be listened from
  113079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113080. */
  113081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113082. /**
  113083. * Detach the current controls from the specified dom element.
  113084. * @param element Defines the element to stop listening the inputs from
  113085. */
  113086. detachControl(element: Nullable<HTMLElement>): void;
  113087. /**
  113088. * Update the current camera state depending on the inputs that have been used this frame.
  113089. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113090. */
  113091. checkInputs(): void;
  113092. /**
  113093. * Gets the class name of the current intput.
  113094. * @returns the class name
  113095. */
  113096. getClassName(): string;
  113097. /**
  113098. * Get the friendly name associated with the input class.
  113099. * @returns the input friendly name
  113100. */
  113101. getSimpleName(): string;
  113102. }
  113103. }
  113104. declare module BABYLON {
  113105. /**
  113106. * Manage the mouse wheel inputs to control an arc rotate camera.
  113107. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113108. */
  113109. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  113110. /**
  113111. * Defines the camera the input is attached to.
  113112. */
  113113. camera: ArcRotateCamera;
  113114. /**
  113115. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113116. */
  113117. wheelPrecision: number;
  113118. /**
  113119. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113120. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113121. */
  113122. wheelDeltaPercentage: number;
  113123. private _wheel;
  113124. private _observer;
  113125. private computeDeltaFromMouseWheelLegacyEvent;
  113126. /**
  113127. * Attach the input controls to a specific dom element to get the input from.
  113128. * @param element Defines the element the controls should be listened from
  113129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113130. */
  113131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113132. /**
  113133. * Detach the current controls from the specified dom element.
  113134. * @param element Defines the element to stop listening the inputs from
  113135. */
  113136. detachControl(element: Nullable<HTMLElement>): void;
  113137. /**
  113138. * Gets the class name of the current intput.
  113139. * @returns the class name
  113140. */
  113141. getClassName(): string;
  113142. /**
  113143. * Get the friendly name associated with the input class.
  113144. * @returns the input friendly name
  113145. */
  113146. getSimpleName(): string;
  113147. }
  113148. }
  113149. declare module BABYLON {
  113150. /**
  113151. * Default Inputs manager for the ArcRotateCamera.
  113152. * It groups all the default supported inputs for ease of use.
  113153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113154. */
  113155. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  113156. /**
  113157. * Instantiates a new ArcRotateCameraInputsManager.
  113158. * @param camera Defines the camera the inputs belong to
  113159. */
  113160. constructor(camera: ArcRotateCamera);
  113161. /**
  113162. * Add mouse wheel input support to the input manager.
  113163. * @returns the current input manager
  113164. */
  113165. addMouseWheel(): ArcRotateCameraInputsManager;
  113166. /**
  113167. * Add pointers input support to the input manager.
  113168. * @returns the current input manager
  113169. */
  113170. addPointers(): ArcRotateCameraInputsManager;
  113171. /**
  113172. * Add keyboard input support to the input manager.
  113173. * @returns the current input manager
  113174. */
  113175. addKeyboard(): ArcRotateCameraInputsManager;
  113176. }
  113177. }
  113178. declare module BABYLON {
  113179. /**
  113180. * This represents an orbital type of camera.
  113181. *
  113182. * 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.
  113183. * 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.
  113184. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  113185. */
  113186. export class ArcRotateCamera extends TargetCamera {
  113187. /**
  113188. * Defines the rotation angle of the camera along the longitudinal axis.
  113189. */
  113190. alpha: number;
  113191. /**
  113192. * Defines the rotation angle of the camera along the latitudinal axis.
  113193. */
  113194. beta: number;
  113195. /**
  113196. * Defines the radius of the camera from it s target point.
  113197. */
  113198. radius: number;
  113199. protected _target: Vector3;
  113200. protected _targetHost: Nullable<AbstractMesh>;
  113201. /**
  113202. * Defines the target point of the camera.
  113203. * The camera looks towards it form the radius distance.
  113204. */
  113205. get target(): Vector3;
  113206. set target(value: Vector3);
  113207. /**
  113208. * Define the current local position of the camera in the scene
  113209. */
  113210. get position(): Vector3;
  113211. set position(newPosition: Vector3);
  113212. protected _upVector: Vector3;
  113213. protected _upToYMatrix: Matrix;
  113214. protected _YToUpMatrix: Matrix;
  113215. /**
  113216. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  113217. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  113218. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  113219. */
  113220. set upVector(vec: Vector3);
  113221. get upVector(): Vector3;
  113222. /**
  113223. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  113224. */
  113225. setMatUp(): void;
  113226. /**
  113227. * Current inertia value on the longitudinal axis.
  113228. * The bigger this number the longer it will take for the camera to stop.
  113229. */
  113230. inertialAlphaOffset: number;
  113231. /**
  113232. * Current inertia value on the latitudinal axis.
  113233. * The bigger this number the longer it will take for the camera to stop.
  113234. */
  113235. inertialBetaOffset: number;
  113236. /**
  113237. * Current inertia value on the radius axis.
  113238. * The bigger this number the longer it will take for the camera to stop.
  113239. */
  113240. inertialRadiusOffset: number;
  113241. /**
  113242. * Minimum allowed angle on the longitudinal axis.
  113243. * This can help limiting how the Camera is able to move in the scene.
  113244. */
  113245. lowerAlphaLimit: Nullable<number>;
  113246. /**
  113247. * Maximum allowed angle on the longitudinal axis.
  113248. * This can help limiting how the Camera is able to move in the scene.
  113249. */
  113250. upperAlphaLimit: Nullable<number>;
  113251. /**
  113252. * Minimum allowed angle on the latitudinal axis.
  113253. * This can help limiting how the Camera is able to move in the scene.
  113254. */
  113255. lowerBetaLimit: number;
  113256. /**
  113257. * Maximum allowed angle on the latitudinal axis.
  113258. * This can help limiting how the Camera is able to move in the scene.
  113259. */
  113260. upperBetaLimit: number;
  113261. /**
  113262. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  113263. * This can help limiting how the Camera is able to move in the scene.
  113264. */
  113265. lowerRadiusLimit: Nullable<number>;
  113266. /**
  113267. * Maximum allowed distance of the camera to the target (The camera can not get further).
  113268. * This can help limiting how the Camera is able to move in the scene.
  113269. */
  113270. upperRadiusLimit: Nullable<number>;
  113271. /**
  113272. * Defines the current inertia value used during panning of the camera along the X axis.
  113273. */
  113274. inertialPanningX: number;
  113275. /**
  113276. * Defines the current inertia value used during panning of the camera along the Y axis.
  113277. */
  113278. inertialPanningY: number;
  113279. /**
  113280. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  113281. * Basically if your fingers moves away from more than this distance you will be considered
  113282. * in pinch mode.
  113283. */
  113284. pinchToPanMaxDistance: number;
  113285. /**
  113286. * Defines the maximum distance the camera can pan.
  113287. * This could help keeping the cammera always in your scene.
  113288. */
  113289. panningDistanceLimit: Nullable<number>;
  113290. /**
  113291. * Defines the target of the camera before paning.
  113292. */
  113293. panningOriginTarget: Vector3;
  113294. /**
  113295. * Defines the value of the inertia used during panning.
  113296. * 0 would mean stop inertia and one would mean no decelleration at all.
  113297. */
  113298. panningInertia: number;
  113299. /**
  113300. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  113301. */
  113302. get angularSensibilityX(): number;
  113303. set angularSensibilityX(value: number);
  113304. /**
  113305. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  113306. */
  113307. get angularSensibilityY(): number;
  113308. set angularSensibilityY(value: number);
  113309. /**
  113310. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  113311. */
  113312. get pinchPrecision(): number;
  113313. set pinchPrecision(value: number);
  113314. /**
  113315. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  113316. * It will be used instead of pinchDeltaPrecision if different from 0.
  113317. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113318. */
  113319. get pinchDeltaPercentage(): number;
  113320. set pinchDeltaPercentage(value: number);
  113321. /**
  113322. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  113323. * and pinch delta percentage.
  113324. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113325. * that any object in the plane at the camera's target point will scale
  113326. * perfectly with finger motion.
  113327. */
  113328. get useNaturalPinchZoom(): boolean;
  113329. set useNaturalPinchZoom(value: boolean);
  113330. /**
  113331. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  113332. */
  113333. get panningSensibility(): number;
  113334. set panningSensibility(value: number);
  113335. /**
  113336. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  113337. */
  113338. get keysUp(): number[];
  113339. set keysUp(value: number[]);
  113340. /**
  113341. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  113342. */
  113343. get keysDown(): number[];
  113344. set keysDown(value: number[]);
  113345. /**
  113346. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  113347. */
  113348. get keysLeft(): number[];
  113349. set keysLeft(value: number[]);
  113350. /**
  113351. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  113352. */
  113353. get keysRight(): number[];
  113354. set keysRight(value: number[]);
  113355. /**
  113356. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113357. */
  113358. get wheelPrecision(): number;
  113359. set wheelPrecision(value: number);
  113360. /**
  113361. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  113362. * It will be used instead of pinchDeltaPrecision if different from 0.
  113363. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113364. */
  113365. get wheelDeltaPercentage(): number;
  113366. set wheelDeltaPercentage(value: number);
  113367. /**
  113368. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  113369. */
  113370. zoomOnFactor: number;
  113371. /**
  113372. * Defines a screen offset for the camera position.
  113373. */
  113374. targetScreenOffset: Vector2;
  113375. /**
  113376. * Allows the camera to be completely reversed.
  113377. * If false the camera can not arrive upside down.
  113378. */
  113379. allowUpsideDown: boolean;
  113380. /**
  113381. * Define if double tap/click is used to restore the previously saved state of the camera.
  113382. */
  113383. useInputToRestoreState: boolean;
  113384. /** @hidden */
  113385. _viewMatrix: Matrix;
  113386. /** @hidden */
  113387. _useCtrlForPanning: boolean;
  113388. /** @hidden */
  113389. _panningMouseButton: number;
  113390. /**
  113391. * Defines the input associated to the camera.
  113392. */
  113393. inputs: ArcRotateCameraInputsManager;
  113394. /** @hidden */
  113395. _reset: () => void;
  113396. /**
  113397. * Defines the allowed panning axis.
  113398. */
  113399. panningAxis: Vector3;
  113400. protected _localDirection: Vector3;
  113401. protected _transformedDirection: Vector3;
  113402. private _bouncingBehavior;
  113403. /**
  113404. * Gets the bouncing behavior of the camera if it has been enabled.
  113405. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113406. */
  113407. get bouncingBehavior(): Nullable<BouncingBehavior>;
  113408. /**
  113409. * Defines if the bouncing behavior of the camera is enabled on the camera.
  113410. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113411. */
  113412. get useBouncingBehavior(): boolean;
  113413. set useBouncingBehavior(value: boolean);
  113414. private _framingBehavior;
  113415. /**
  113416. * Gets the framing behavior of the camera if it has been enabled.
  113417. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113418. */
  113419. get framingBehavior(): Nullable<FramingBehavior>;
  113420. /**
  113421. * Defines if the framing behavior of the camera is enabled on the camera.
  113422. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113423. */
  113424. get useFramingBehavior(): boolean;
  113425. set useFramingBehavior(value: boolean);
  113426. private _autoRotationBehavior;
  113427. /**
  113428. * Gets the auto rotation behavior of the camera if it has been enabled.
  113429. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113430. */
  113431. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  113432. /**
  113433. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  113434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113435. */
  113436. get useAutoRotationBehavior(): boolean;
  113437. set useAutoRotationBehavior(value: boolean);
  113438. /**
  113439. * Observable triggered when the mesh target has been changed on the camera.
  113440. */
  113441. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  113442. /**
  113443. * Event raised when the camera is colliding with a mesh.
  113444. */
  113445. onCollide: (collidedMesh: AbstractMesh) => void;
  113446. /**
  113447. * Defines whether the camera should check collision with the objects oh the scene.
  113448. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  113449. */
  113450. checkCollisions: boolean;
  113451. /**
  113452. * Defines the collision radius of the camera.
  113453. * This simulates a sphere around the camera.
  113454. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113455. */
  113456. collisionRadius: Vector3;
  113457. protected _collider: Collider;
  113458. protected _previousPosition: Vector3;
  113459. protected _collisionVelocity: Vector3;
  113460. protected _newPosition: Vector3;
  113461. protected _previousAlpha: number;
  113462. protected _previousBeta: number;
  113463. protected _previousRadius: number;
  113464. protected _collisionTriggered: boolean;
  113465. protected _targetBoundingCenter: Nullable<Vector3>;
  113466. private _computationVector;
  113467. /**
  113468. * Instantiates a new ArcRotateCamera in a given scene
  113469. * @param name Defines the name of the camera
  113470. * @param alpha Defines the camera rotation along the logitudinal axis
  113471. * @param beta Defines the camera rotation along the latitudinal axis
  113472. * @param radius Defines the camera distance from its target
  113473. * @param target Defines the camera target
  113474. * @param scene Defines the scene the camera belongs to
  113475. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  113476. */
  113477. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113478. /** @hidden */
  113479. _initCache(): void;
  113480. /** @hidden */
  113481. _updateCache(ignoreParentClass?: boolean): void;
  113482. protected _getTargetPosition(): Vector3;
  113483. private _storedAlpha;
  113484. private _storedBeta;
  113485. private _storedRadius;
  113486. private _storedTarget;
  113487. private _storedTargetScreenOffset;
  113488. /**
  113489. * Stores the current state of the camera (alpha, beta, radius and target)
  113490. * @returns the camera itself
  113491. */
  113492. storeState(): Camera;
  113493. /**
  113494. * @hidden
  113495. * Restored camera state. You must call storeState() first
  113496. */
  113497. _restoreStateValues(): boolean;
  113498. /** @hidden */
  113499. _isSynchronizedViewMatrix(): boolean;
  113500. /**
  113501. * Attached controls to the current camera.
  113502. * @param element Defines the element the controls should be listened from
  113503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113504. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  113505. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  113506. */
  113507. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  113508. /**
  113509. * Detach the current controls from the camera.
  113510. * The camera will stop reacting to inputs.
  113511. * @param element Defines the element to stop listening the inputs from
  113512. */
  113513. detachControl(element: HTMLElement): void;
  113514. /** @hidden */
  113515. _checkInputs(): void;
  113516. protected _checkLimits(): void;
  113517. /**
  113518. * Rebuilds angles (alpha, beta) and radius from the give position and target
  113519. */
  113520. rebuildAnglesAndRadius(): void;
  113521. /**
  113522. * Use a position to define the current camera related information like alpha, beta and radius
  113523. * @param position Defines the position to set the camera at
  113524. */
  113525. setPosition(position: Vector3): void;
  113526. /**
  113527. * Defines the target the camera should look at.
  113528. * This will automatically adapt alpha beta and radius to fit within the new target.
  113529. * @param target Defines the new target as a Vector or a mesh
  113530. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  113531. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  113532. */
  113533. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  113534. /** @hidden */
  113535. _getViewMatrix(): Matrix;
  113536. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  113537. /**
  113538. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  113539. * @param meshes Defines the mesh to zoom on
  113540. * @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)
  113541. */
  113542. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  113543. /**
  113544. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  113545. * The target will be changed but the radius
  113546. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  113547. * @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)
  113548. */
  113549. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  113550. min: Vector3;
  113551. max: Vector3;
  113552. distance: number;
  113553. }, doNotUpdateMaxZ?: boolean): void;
  113554. /**
  113555. * @override
  113556. * Override Camera.createRigCamera
  113557. */
  113558. createRigCamera(name: string, cameraIndex: number): Camera;
  113559. /**
  113560. * @hidden
  113561. * @override
  113562. * Override Camera._updateRigCameras
  113563. */
  113564. _updateRigCameras(): void;
  113565. /**
  113566. * Destroy the camera and release the current resources hold by it.
  113567. */
  113568. dispose(): void;
  113569. /**
  113570. * Gets the current object class name.
  113571. * @return the class name
  113572. */
  113573. getClassName(): string;
  113574. }
  113575. }
  113576. declare module BABYLON {
  113577. /**
  113578. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  113579. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113580. */
  113581. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  113582. /**
  113583. * Gets the name of the behavior.
  113584. */
  113585. get name(): string;
  113586. private _zoomStopsAnimation;
  113587. private _idleRotationSpeed;
  113588. private _idleRotationWaitTime;
  113589. private _idleRotationSpinupTime;
  113590. /**
  113591. * Sets the flag that indicates if user zooming should stop animation.
  113592. */
  113593. set zoomStopsAnimation(flag: boolean);
  113594. /**
  113595. * Gets the flag that indicates if user zooming should stop animation.
  113596. */
  113597. get zoomStopsAnimation(): boolean;
  113598. /**
  113599. * Sets the default speed at which the camera rotates around the model.
  113600. */
  113601. set idleRotationSpeed(speed: number);
  113602. /**
  113603. * Gets the default speed at which the camera rotates around the model.
  113604. */
  113605. get idleRotationSpeed(): number;
  113606. /**
  113607. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  113608. */
  113609. set idleRotationWaitTime(time: number);
  113610. /**
  113611. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  113612. */
  113613. get idleRotationWaitTime(): number;
  113614. /**
  113615. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113616. */
  113617. set idleRotationSpinupTime(time: number);
  113618. /**
  113619. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113620. */
  113621. get idleRotationSpinupTime(): number;
  113622. /**
  113623. * Gets a value indicating if the camera is currently rotating because of this behavior
  113624. */
  113625. get rotationInProgress(): boolean;
  113626. private _onPrePointerObservableObserver;
  113627. private _onAfterCheckInputsObserver;
  113628. private _attachedCamera;
  113629. private _isPointerDown;
  113630. private _lastFrameTime;
  113631. private _lastInteractionTime;
  113632. private _cameraRotationSpeed;
  113633. /**
  113634. * Initializes the behavior.
  113635. */
  113636. init(): void;
  113637. /**
  113638. * Attaches the behavior to its arc rotate camera.
  113639. * @param camera Defines the camera to attach the behavior to
  113640. */
  113641. attach(camera: ArcRotateCamera): void;
  113642. /**
  113643. * Detaches the behavior from its current arc rotate camera.
  113644. */
  113645. detach(): void;
  113646. /**
  113647. * Returns true if user is scrolling.
  113648. * @return true if user is scrolling.
  113649. */
  113650. private _userIsZooming;
  113651. private _lastFrameRadius;
  113652. private _shouldAnimationStopForInteraction;
  113653. /**
  113654. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  113655. */
  113656. private _applyUserInteraction;
  113657. private _userIsMoving;
  113658. }
  113659. }
  113660. declare module BABYLON {
  113661. /**
  113662. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  113663. */
  113664. export class AttachToBoxBehavior implements Behavior<Mesh> {
  113665. private ui;
  113666. /**
  113667. * The name of the behavior
  113668. */
  113669. name: string;
  113670. /**
  113671. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  113672. */
  113673. distanceAwayFromFace: number;
  113674. /**
  113675. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  113676. */
  113677. distanceAwayFromBottomOfFace: number;
  113678. private _faceVectors;
  113679. private _target;
  113680. private _scene;
  113681. private _onRenderObserver;
  113682. private _tmpMatrix;
  113683. private _tmpVector;
  113684. /**
  113685. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  113686. * @param ui The transform node that should be attched to the mesh
  113687. */
  113688. constructor(ui: TransformNode);
  113689. /**
  113690. * Initializes the behavior
  113691. */
  113692. init(): void;
  113693. private _closestFace;
  113694. private _zeroVector;
  113695. private _lookAtTmpMatrix;
  113696. private _lookAtToRef;
  113697. /**
  113698. * Attaches the AttachToBoxBehavior to the passed in mesh
  113699. * @param target The mesh that the specified node will be attached to
  113700. */
  113701. attach(target: Mesh): void;
  113702. /**
  113703. * Detaches the behavior from the mesh
  113704. */
  113705. detach(): void;
  113706. }
  113707. }
  113708. declare module BABYLON {
  113709. /**
  113710. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  113711. */
  113712. export class FadeInOutBehavior implements Behavior<Mesh> {
  113713. /**
  113714. * Time in milliseconds to delay before fading in (Default: 0)
  113715. */
  113716. delay: number;
  113717. /**
  113718. * Time in milliseconds for the mesh to fade in (Default: 300)
  113719. */
  113720. fadeInTime: number;
  113721. private _millisecondsPerFrame;
  113722. private _hovered;
  113723. private _hoverValue;
  113724. private _ownerNode;
  113725. /**
  113726. * Instatiates the FadeInOutBehavior
  113727. */
  113728. constructor();
  113729. /**
  113730. * The name of the behavior
  113731. */
  113732. get name(): string;
  113733. /**
  113734. * Initializes the behavior
  113735. */
  113736. init(): void;
  113737. /**
  113738. * Attaches the fade behavior on the passed in mesh
  113739. * @param ownerNode The mesh that will be faded in/out once attached
  113740. */
  113741. attach(ownerNode: Mesh): void;
  113742. /**
  113743. * Detaches the behavior from the mesh
  113744. */
  113745. detach(): void;
  113746. /**
  113747. * Triggers the mesh to begin fading in or out
  113748. * @param value if the object should fade in or out (true to fade in)
  113749. */
  113750. fadeIn(value: boolean): void;
  113751. private _update;
  113752. private _setAllVisibility;
  113753. }
  113754. }
  113755. declare module BABYLON {
  113756. /**
  113757. * Class containing a set of static utilities functions for managing Pivots
  113758. * @hidden
  113759. */
  113760. export class PivotTools {
  113761. private static _PivotCached;
  113762. private static _OldPivotPoint;
  113763. private static _PivotTranslation;
  113764. private static _PivotTmpVector;
  113765. /** @hidden */
  113766. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  113767. /** @hidden */
  113768. static _RestorePivotPoint(mesh: AbstractMesh): void;
  113769. }
  113770. }
  113771. declare module BABYLON {
  113772. /**
  113773. * Class containing static functions to help procedurally build meshes
  113774. */
  113775. export class PlaneBuilder {
  113776. /**
  113777. * Creates a plane mesh
  113778. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  113779. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  113780. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  113781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113784. * @param name defines the name of the mesh
  113785. * @param options defines the options used to create the mesh
  113786. * @param scene defines the hosting scene
  113787. * @returns the plane mesh
  113788. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  113789. */
  113790. static CreatePlane(name: string, options: {
  113791. size?: number;
  113792. width?: number;
  113793. height?: number;
  113794. sideOrientation?: number;
  113795. frontUVs?: Vector4;
  113796. backUVs?: Vector4;
  113797. updatable?: boolean;
  113798. sourcePlane?: Plane;
  113799. }, scene?: Nullable<Scene>): Mesh;
  113800. }
  113801. }
  113802. declare module BABYLON {
  113803. /**
  113804. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  113805. */
  113806. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  113807. private static _AnyMouseID;
  113808. /**
  113809. * Abstract mesh the behavior is set on
  113810. */
  113811. attachedNode: AbstractMesh;
  113812. private _dragPlane;
  113813. private _scene;
  113814. private _pointerObserver;
  113815. private _beforeRenderObserver;
  113816. private static _planeScene;
  113817. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  113818. /**
  113819. * 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)
  113820. */
  113821. maxDragAngle: number;
  113822. /**
  113823. * @hidden
  113824. */
  113825. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  113826. /**
  113827. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113828. */
  113829. currentDraggingPointerID: number;
  113830. /**
  113831. * The last position where the pointer hit the drag plane in world space
  113832. */
  113833. lastDragPosition: Vector3;
  113834. /**
  113835. * If the behavior is currently in a dragging state
  113836. */
  113837. dragging: boolean;
  113838. /**
  113839. * 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)
  113840. */
  113841. dragDeltaRatio: number;
  113842. /**
  113843. * If the drag plane orientation should be updated during the dragging (Default: true)
  113844. */
  113845. updateDragPlane: boolean;
  113846. private _debugMode;
  113847. private _moving;
  113848. /**
  113849. * Fires each time the attached mesh is dragged with the pointer
  113850. * * delta between last drag position and current drag position in world space
  113851. * * dragDistance along the drag axis
  113852. * * dragPlaneNormal normal of the current drag plane used during the drag
  113853. * * dragPlanePoint in world space where the drag intersects the drag plane
  113854. */
  113855. onDragObservable: Observable<{
  113856. delta: Vector3;
  113857. dragPlanePoint: Vector3;
  113858. dragPlaneNormal: Vector3;
  113859. dragDistance: number;
  113860. pointerId: number;
  113861. }>;
  113862. /**
  113863. * Fires each time a drag begins (eg. mouse down on mesh)
  113864. */
  113865. onDragStartObservable: Observable<{
  113866. dragPlanePoint: Vector3;
  113867. pointerId: number;
  113868. }>;
  113869. /**
  113870. * Fires each time a drag ends (eg. mouse release after drag)
  113871. */
  113872. onDragEndObservable: Observable<{
  113873. dragPlanePoint: Vector3;
  113874. pointerId: number;
  113875. }>;
  113876. /**
  113877. * If the attached mesh should be moved when dragged
  113878. */
  113879. moveAttached: boolean;
  113880. /**
  113881. * If the drag behavior will react to drag events (Default: true)
  113882. */
  113883. enabled: boolean;
  113884. /**
  113885. * If pointer events should start and release the drag (Default: true)
  113886. */
  113887. startAndReleaseDragOnPointerEvents: boolean;
  113888. /**
  113889. * If camera controls should be detached during the drag
  113890. */
  113891. detachCameraControls: boolean;
  113892. /**
  113893. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  113894. */
  113895. useObjectOrientationForDragging: boolean;
  113896. private _options;
  113897. /**
  113898. * Gets the options used by the behavior
  113899. */
  113900. get options(): {
  113901. dragAxis?: Vector3;
  113902. dragPlaneNormal?: Vector3;
  113903. };
  113904. /**
  113905. * Sets the options used by the behavior
  113906. */
  113907. set options(options: {
  113908. dragAxis?: Vector3;
  113909. dragPlaneNormal?: Vector3;
  113910. });
  113911. /**
  113912. * Creates a pointer drag behavior that can be attached to a mesh
  113913. * @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)
  113914. */
  113915. constructor(options?: {
  113916. dragAxis?: Vector3;
  113917. dragPlaneNormal?: Vector3;
  113918. });
  113919. /**
  113920. * Predicate to determine if it is valid to move the object to a new position when it is moved
  113921. */
  113922. validateDrag: (targetPosition: Vector3) => boolean;
  113923. /**
  113924. * The name of the behavior
  113925. */
  113926. get name(): string;
  113927. /**
  113928. * Initializes the behavior
  113929. */
  113930. init(): void;
  113931. private _tmpVector;
  113932. private _alternatePickedPoint;
  113933. private _worldDragAxis;
  113934. private _targetPosition;
  113935. private _attachedElement;
  113936. /**
  113937. * Attaches the drag behavior the passed in mesh
  113938. * @param ownerNode The mesh that will be dragged around once attached
  113939. * @param predicate Predicate to use for pick filtering
  113940. */
  113941. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113942. /**
  113943. * Force relase the drag action by code.
  113944. */
  113945. releaseDrag(): void;
  113946. private _startDragRay;
  113947. private _lastPointerRay;
  113948. /**
  113949. * Simulates the start of a pointer drag event on the behavior
  113950. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113951. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113952. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113953. */
  113954. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113955. private _startDrag;
  113956. private _dragDelta;
  113957. private _moveDrag;
  113958. private _pickWithRayOnDragPlane;
  113959. private _pointA;
  113960. private _pointB;
  113961. private _pointC;
  113962. private _lineA;
  113963. private _lineB;
  113964. private _localAxis;
  113965. private _lookAt;
  113966. private _updateDragPlanePosition;
  113967. /**
  113968. * Detaches the behavior from the mesh
  113969. */
  113970. detach(): void;
  113971. }
  113972. }
  113973. declare module BABYLON {
  113974. /**
  113975. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113976. */
  113977. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113978. private _dragBehaviorA;
  113979. private _dragBehaviorB;
  113980. private _startDistance;
  113981. private _initialScale;
  113982. private _targetScale;
  113983. private _ownerNode;
  113984. private _sceneRenderObserver;
  113985. /**
  113986. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  113987. */
  113988. constructor();
  113989. /**
  113990. * The name of the behavior
  113991. */
  113992. get name(): string;
  113993. /**
  113994. * Initializes the behavior
  113995. */
  113996. init(): void;
  113997. private _getCurrentDistance;
  113998. /**
  113999. * Attaches the scale behavior the passed in mesh
  114000. * @param ownerNode The mesh that will be scaled around once attached
  114001. */
  114002. attach(ownerNode: Mesh): void;
  114003. /**
  114004. * Detaches the behavior from the mesh
  114005. */
  114006. detach(): void;
  114007. }
  114008. }
  114009. declare module BABYLON {
  114010. /**
  114011. * 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
  114012. */
  114013. export class SixDofDragBehavior implements Behavior<Mesh> {
  114014. private static _virtualScene;
  114015. private _ownerNode;
  114016. private _sceneRenderObserver;
  114017. private _scene;
  114018. private _targetPosition;
  114019. private _virtualOriginMesh;
  114020. private _virtualDragMesh;
  114021. private _pointerObserver;
  114022. private _moving;
  114023. private _startingOrientation;
  114024. private _attachedElement;
  114025. /**
  114026. * 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)
  114027. */
  114028. private zDragFactor;
  114029. /**
  114030. * If the object should rotate to face the drag origin
  114031. */
  114032. rotateDraggedObject: boolean;
  114033. /**
  114034. * If the behavior is currently in a dragging state
  114035. */
  114036. dragging: boolean;
  114037. /**
  114038. * 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)
  114039. */
  114040. dragDeltaRatio: number;
  114041. /**
  114042. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  114043. */
  114044. currentDraggingPointerID: number;
  114045. /**
  114046. * If camera controls should be detached during the drag
  114047. */
  114048. detachCameraControls: boolean;
  114049. /**
  114050. * Fires each time a drag starts
  114051. */
  114052. onDragStartObservable: Observable<{}>;
  114053. /**
  114054. * Fires each time a drag ends (eg. mouse release after drag)
  114055. */
  114056. onDragEndObservable: Observable<{}>;
  114057. /**
  114058. * 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
  114059. */
  114060. constructor();
  114061. /**
  114062. * The name of the behavior
  114063. */
  114064. get name(): string;
  114065. /**
  114066. * Initializes the behavior
  114067. */
  114068. init(): void;
  114069. /**
  114070. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  114071. */
  114072. private get _pointerCamera();
  114073. /**
  114074. * Attaches the scale behavior the passed in mesh
  114075. * @param ownerNode The mesh that will be scaled around once attached
  114076. */
  114077. attach(ownerNode: Mesh): void;
  114078. /**
  114079. * Detaches the behavior from the mesh
  114080. */
  114081. detach(): void;
  114082. }
  114083. }
  114084. declare module BABYLON {
  114085. /**
  114086. * Class used to apply inverse kinematics to bones
  114087. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  114088. */
  114089. export class BoneIKController {
  114090. private static _tmpVecs;
  114091. private static _tmpQuat;
  114092. private static _tmpMats;
  114093. /**
  114094. * Gets or sets the target mesh
  114095. */
  114096. targetMesh: AbstractMesh;
  114097. /** Gets or sets the mesh used as pole */
  114098. poleTargetMesh: AbstractMesh;
  114099. /**
  114100. * Gets or sets the bone used as pole
  114101. */
  114102. poleTargetBone: Nullable<Bone>;
  114103. /**
  114104. * Gets or sets the target position
  114105. */
  114106. targetPosition: Vector3;
  114107. /**
  114108. * Gets or sets the pole target position
  114109. */
  114110. poleTargetPosition: Vector3;
  114111. /**
  114112. * Gets or sets the pole target local offset
  114113. */
  114114. poleTargetLocalOffset: Vector3;
  114115. /**
  114116. * Gets or sets the pole angle
  114117. */
  114118. poleAngle: number;
  114119. /**
  114120. * Gets or sets the mesh associated with the controller
  114121. */
  114122. mesh: AbstractMesh;
  114123. /**
  114124. * 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)
  114125. */
  114126. slerpAmount: number;
  114127. private _bone1Quat;
  114128. private _bone1Mat;
  114129. private _bone2Ang;
  114130. private _bone1;
  114131. private _bone2;
  114132. private _bone1Length;
  114133. private _bone2Length;
  114134. private _maxAngle;
  114135. private _maxReach;
  114136. private _rightHandedSystem;
  114137. private _bendAxis;
  114138. private _slerping;
  114139. private _adjustRoll;
  114140. /**
  114141. * Gets or sets maximum allowed angle
  114142. */
  114143. get maxAngle(): number;
  114144. set maxAngle(value: number);
  114145. /**
  114146. * Creates a new BoneIKController
  114147. * @param mesh defines the mesh to control
  114148. * @param bone defines the bone to control
  114149. * @param options defines options to set up the controller
  114150. */
  114151. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  114152. targetMesh?: AbstractMesh;
  114153. poleTargetMesh?: AbstractMesh;
  114154. poleTargetBone?: Bone;
  114155. poleTargetLocalOffset?: Vector3;
  114156. poleAngle?: number;
  114157. bendAxis?: Vector3;
  114158. maxAngle?: number;
  114159. slerpAmount?: number;
  114160. });
  114161. private _setMaxAngle;
  114162. /**
  114163. * Force the controller to update the bones
  114164. */
  114165. update(): void;
  114166. }
  114167. }
  114168. declare module BABYLON {
  114169. /**
  114170. * Class used to make a bone look toward a point in space
  114171. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  114172. */
  114173. export class BoneLookController {
  114174. private static _tmpVecs;
  114175. private static _tmpQuat;
  114176. private static _tmpMats;
  114177. /**
  114178. * The target Vector3 that the bone will look at
  114179. */
  114180. target: Vector3;
  114181. /**
  114182. * The mesh that the bone is attached to
  114183. */
  114184. mesh: AbstractMesh;
  114185. /**
  114186. * The bone that will be looking to the target
  114187. */
  114188. bone: Bone;
  114189. /**
  114190. * The up axis of the coordinate system that is used when the bone is rotated
  114191. */
  114192. upAxis: Vector3;
  114193. /**
  114194. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  114195. */
  114196. upAxisSpace: Space;
  114197. /**
  114198. * Used to make an adjustment to the yaw of the bone
  114199. */
  114200. adjustYaw: number;
  114201. /**
  114202. * Used to make an adjustment to the pitch of the bone
  114203. */
  114204. adjustPitch: number;
  114205. /**
  114206. * Used to make an adjustment to the roll of the bone
  114207. */
  114208. adjustRoll: number;
  114209. /**
  114210. * 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)
  114211. */
  114212. slerpAmount: number;
  114213. private _minYaw;
  114214. private _maxYaw;
  114215. private _minPitch;
  114216. private _maxPitch;
  114217. private _minYawSin;
  114218. private _minYawCos;
  114219. private _maxYawSin;
  114220. private _maxYawCos;
  114221. private _midYawConstraint;
  114222. private _minPitchTan;
  114223. private _maxPitchTan;
  114224. private _boneQuat;
  114225. private _slerping;
  114226. private _transformYawPitch;
  114227. private _transformYawPitchInv;
  114228. private _firstFrameSkipped;
  114229. private _yawRange;
  114230. private _fowardAxis;
  114231. /**
  114232. * Gets or sets the minimum yaw angle that the bone can look to
  114233. */
  114234. get minYaw(): number;
  114235. set minYaw(value: number);
  114236. /**
  114237. * Gets or sets the maximum yaw angle that the bone can look to
  114238. */
  114239. get maxYaw(): number;
  114240. set maxYaw(value: number);
  114241. /**
  114242. * Gets or sets the minimum pitch angle that the bone can look to
  114243. */
  114244. get minPitch(): number;
  114245. set minPitch(value: number);
  114246. /**
  114247. * Gets or sets the maximum pitch angle that the bone can look to
  114248. */
  114249. get maxPitch(): number;
  114250. set maxPitch(value: number);
  114251. /**
  114252. * Create a BoneLookController
  114253. * @param mesh the mesh that the bone belongs to
  114254. * @param bone the bone that will be looking to the target
  114255. * @param target the target Vector3 to look at
  114256. * @param options optional settings:
  114257. * * maxYaw: the maximum angle the bone will yaw to
  114258. * * minYaw: the minimum angle the bone will yaw to
  114259. * * maxPitch: the maximum angle the bone will pitch to
  114260. * * minPitch: the minimum angle the bone will yaw to
  114261. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  114262. * * upAxis: the up axis of the coordinate system
  114263. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  114264. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  114265. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  114266. * * adjustYaw: used to make an adjustment to the yaw of the bone
  114267. * * adjustPitch: used to make an adjustment to the pitch of the bone
  114268. * * adjustRoll: used to make an adjustment to the roll of the bone
  114269. **/
  114270. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  114271. maxYaw?: number;
  114272. minYaw?: number;
  114273. maxPitch?: number;
  114274. minPitch?: number;
  114275. slerpAmount?: number;
  114276. upAxis?: Vector3;
  114277. upAxisSpace?: Space;
  114278. yawAxis?: Vector3;
  114279. pitchAxis?: Vector3;
  114280. adjustYaw?: number;
  114281. adjustPitch?: number;
  114282. adjustRoll?: number;
  114283. });
  114284. /**
  114285. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  114286. */
  114287. update(): void;
  114288. private _getAngleDiff;
  114289. private _getAngleBetween;
  114290. private _isAngleBetween;
  114291. }
  114292. }
  114293. declare module BABYLON {
  114294. /**
  114295. * Manage the gamepad inputs to control an arc rotate camera.
  114296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114297. */
  114298. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  114299. /**
  114300. * Defines the camera the input is attached to.
  114301. */
  114302. camera: ArcRotateCamera;
  114303. /**
  114304. * Defines the gamepad the input is gathering event from.
  114305. */
  114306. gamepad: Nullable<Gamepad>;
  114307. /**
  114308. * Defines the gamepad rotation sensiblity.
  114309. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114310. */
  114311. gamepadRotationSensibility: number;
  114312. /**
  114313. * Defines the gamepad move sensiblity.
  114314. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114315. */
  114316. gamepadMoveSensibility: number;
  114317. private _yAxisScale;
  114318. /**
  114319. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114320. */
  114321. get invertYAxis(): boolean;
  114322. set invertYAxis(value: boolean);
  114323. private _onGamepadConnectedObserver;
  114324. private _onGamepadDisconnectedObserver;
  114325. /**
  114326. * Attach the input controls to a specific dom element to get the input from.
  114327. * @param element Defines the element the controls should be listened from
  114328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114329. */
  114330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114331. /**
  114332. * Detach the current controls from the specified dom element.
  114333. * @param element Defines the element to stop listening the inputs from
  114334. */
  114335. detachControl(element: Nullable<HTMLElement>): void;
  114336. /**
  114337. * Update the current camera state depending on the inputs that have been used this frame.
  114338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114339. */
  114340. checkInputs(): void;
  114341. /**
  114342. * Gets the class name of the current intput.
  114343. * @returns the class name
  114344. */
  114345. getClassName(): string;
  114346. /**
  114347. * Get the friendly name associated with the input class.
  114348. * @returns the input friendly name
  114349. */
  114350. getSimpleName(): string;
  114351. }
  114352. }
  114353. declare module BABYLON {
  114354. interface ArcRotateCameraInputsManager {
  114355. /**
  114356. * Add orientation input support to the input manager.
  114357. * @returns the current input manager
  114358. */
  114359. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  114360. }
  114361. /**
  114362. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  114363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114364. */
  114365. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  114366. /**
  114367. * Defines the camera the input is attached to.
  114368. */
  114369. camera: ArcRotateCamera;
  114370. /**
  114371. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  114372. */
  114373. alphaCorrection: number;
  114374. /**
  114375. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  114376. */
  114377. gammaCorrection: number;
  114378. private _alpha;
  114379. private _gamma;
  114380. private _dirty;
  114381. private _deviceOrientationHandler;
  114382. /**
  114383. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  114384. */
  114385. constructor();
  114386. /**
  114387. * Attach the input controls to a specific dom element to get the input from.
  114388. * @param element Defines the element the controls should be listened from
  114389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114390. */
  114391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114392. /** @hidden */
  114393. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  114394. /**
  114395. * Update the current camera state depending on the inputs that have been used this frame.
  114396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114397. */
  114398. checkInputs(): void;
  114399. /**
  114400. * Detach the current controls from the specified dom element.
  114401. * @param element Defines the element to stop listening the inputs from
  114402. */
  114403. detachControl(element: Nullable<HTMLElement>): void;
  114404. /**
  114405. * Gets the class name of the current intput.
  114406. * @returns the class name
  114407. */
  114408. getClassName(): string;
  114409. /**
  114410. * Get the friendly name associated with the input class.
  114411. * @returns the input friendly name
  114412. */
  114413. getSimpleName(): string;
  114414. }
  114415. }
  114416. declare module BABYLON {
  114417. /**
  114418. * Listen to mouse events to control the camera.
  114419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114420. */
  114421. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  114422. /**
  114423. * Defines the camera the input is attached to.
  114424. */
  114425. camera: FlyCamera;
  114426. /**
  114427. * Defines if touch is enabled. (Default is true.)
  114428. */
  114429. touchEnabled: boolean;
  114430. /**
  114431. * Defines the buttons associated with the input to handle camera rotation.
  114432. */
  114433. buttons: number[];
  114434. /**
  114435. * Assign buttons for Yaw control.
  114436. */
  114437. buttonsYaw: number[];
  114438. /**
  114439. * Assign buttons for Pitch control.
  114440. */
  114441. buttonsPitch: number[];
  114442. /**
  114443. * Assign buttons for Roll control.
  114444. */
  114445. buttonsRoll: number[];
  114446. /**
  114447. * Detect if any button is being pressed while mouse is moved.
  114448. * -1 = Mouse locked.
  114449. * 0 = Left button.
  114450. * 1 = Middle Button.
  114451. * 2 = Right Button.
  114452. */
  114453. activeButton: number;
  114454. /**
  114455. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  114456. * Higher values reduce its sensitivity.
  114457. */
  114458. angularSensibility: number;
  114459. private _mousemoveCallback;
  114460. private _observer;
  114461. private _rollObserver;
  114462. private previousPosition;
  114463. private noPreventDefault;
  114464. private element;
  114465. /**
  114466. * Listen to mouse events to control the camera.
  114467. * @param touchEnabled Define if touch is enabled. (Default is true.)
  114468. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114469. */
  114470. constructor(touchEnabled?: boolean);
  114471. /**
  114472. * Attach the mouse control to the HTML DOM element.
  114473. * @param element Defines the element that listens to the input events.
  114474. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  114475. */
  114476. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114477. /**
  114478. * Detach the current controls from the specified dom element.
  114479. * @param element Defines the element to stop listening the inputs from
  114480. */
  114481. detachControl(element: Nullable<HTMLElement>): void;
  114482. /**
  114483. * Gets the class name of the current input.
  114484. * @returns the class name.
  114485. */
  114486. getClassName(): string;
  114487. /**
  114488. * Get the friendly name associated with the input class.
  114489. * @returns the input's friendly name.
  114490. */
  114491. getSimpleName(): string;
  114492. private _pointerInput;
  114493. private _onMouseMove;
  114494. /**
  114495. * Rotate camera by mouse offset.
  114496. */
  114497. private rotateCamera;
  114498. }
  114499. }
  114500. declare module BABYLON {
  114501. /**
  114502. * Default Inputs manager for the FlyCamera.
  114503. * It groups all the default supported inputs for ease of use.
  114504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114505. */
  114506. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  114507. /**
  114508. * Instantiates a new FlyCameraInputsManager.
  114509. * @param camera Defines the camera the inputs belong to.
  114510. */
  114511. constructor(camera: FlyCamera);
  114512. /**
  114513. * Add keyboard input support to the input manager.
  114514. * @returns the new FlyCameraKeyboardMoveInput().
  114515. */
  114516. addKeyboard(): FlyCameraInputsManager;
  114517. /**
  114518. * Add mouse input support to the input manager.
  114519. * @param touchEnabled Enable touch screen support.
  114520. * @returns the new FlyCameraMouseInput().
  114521. */
  114522. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  114523. }
  114524. }
  114525. declare module BABYLON {
  114526. /**
  114527. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114528. * such as in a 3D Space Shooter or a Flight Simulator.
  114529. */
  114530. export class FlyCamera extends TargetCamera {
  114531. /**
  114532. * Define the collision ellipsoid of the camera.
  114533. * This is helpful for simulating a camera body, like a player's body.
  114534. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114535. */
  114536. ellipsoid: Vector3;
  114537. /**
  114538. * Define an offset for the position of the ellipsoid around the camera.
  114539. * This can be helpful if the camera is attached away from the player's body center,
  114540. * such as at its head.
  114541. */
  114542. ellipsoidOffset: Vector3;
  114543. /**
  114544. * Enable or disable collisions of the camera with the rest of the scene objects.
  114545. */
  114546. checkCollisions: boolean;
  114547. /**
  114548. * Enable or disable gravity on the camera.
  114549. */
  114550. applyGravity: boolean;
  114551. /**
  114552. * Define the current direction the camera is moving to.
  114553. */
  114554. cameraDirection: Vector3;
  114555. /**
  114556. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  114557. * This overrides and empties cameraRotation.
  114558. */
  114559. rotationQuaternion: Quaternion;
  114560. /**
  114561. * Track Roll to maintain the wanted Rolling when looking around.
  114562. */
  114563. _trackRoll: number;
  114564. /**
  114565. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  114566. */
  114567. rollCorrect: number;
  114568. /**
  114569. * Mimic a banked turn, Rolling the camera when Yawing.
  114570. * It's recommended to use rollCorrect = 10 for faster banking correction.
  114571. */
  114572. bankedTurn: boolean;
  114573. /**
  114574. * Limit in radians for how much Roll banking will add. (Default: 90°)
  114575. */
  114576. bankedTurnLimit: number;
  114577. /**
  114578. * Value of 0 disables the banked Roll.
  114579. * Value of 1 is equal to the Yaw angle in radians.
  114580. */
  114581. bankedTurnMultiplier: number;
  114582. /**
  114583. * The inputs manager loads all the input sources, such as keyboard and mouse.
  114584. */
  114585. inputs: FlyCameraInputsManager;
  114586. /**
  114587. * Gets the input sensibility for mouse input.
  114588. * Higher values reduce sensitivity.
  114589. */
  114590. get angularSensibility(): number;
  114591. /**
  114592. * Sets the input sensibility for a mouse input.
  114593. * Higher values reduce sensitivity.
  114594. */
  114595. set angularSensibility(value: number);
  114596. /**
  114597. * Get the keys for camera movement forward.
  114598. */
  114599. get keysForward(): number[];
  114600. /**
  114601. * Set the keys for camera movement forward.
  114602. */
  114603. set keysForward(value: number[]);
  114604. /**
  114605. * Get the keys for camera movement backward.
  114606. */
  114607. get keysBackward(): number[];
  114608. set keysBackward(value: number[]);
  114609. /**
  114610. * Get the keys for camera movement up.
  114611. */
  114612. get keysUp(): number[];
  114613. /**
  114614. * Set the keys for camera movement up.
  114615. */
  114616. set keysUp(value: number[]);
  114617. /**
  114618. * Get the keys for camera movement down.
  114619. */
  114620. get keysDown(): number[];
  114621. /**
  114622. * Set the keys for camera movement down.
  114623. */
  114624. set keysDown(value: number[]);
  114625. /**
  114626. * Get the keys for camera movement left.
  114627. */
  114628. get keysLeft(): number[];
  114629. /**
  114630. * Set the keys for camera movement left.
  114631. */
  114632. set keysLeft(value: number[]);
  114633. /**
  114634. * Set the keys for camera movement right.
  114635. */
  114636. get keysRight(): number[];
  114637. /**
  114638. * Set the keys for camera movement right.
  114639. */
  114640. set keysRight(value: number[]);
  114641. /**
  114642. * Event raised when the camera collides with a mesh in the scene.
  114643. */
  114644. onCollide: (collidedMesh: AbstractMesh) => void;
  114645. private _collider;
  114646. private _needMoveForGravity;
  114647. private _oldPosition;
  114648. private _diffPosition;
  114649. private _newPosition;
  114650. /** @hidden */
  114651. _localDirection: Vector3;
  114652. /** @hidden */
  114653. _transformedDirection: Vector3;
  114654. /**
  114655. * Instantiates a FlyCamera.
  114656. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114657. * such as in a 3D Space Shooter or a Flight Simulator.
  114658. * @param name Define the name of the camera in the scene.
  114659. * @param position Define the starting position of the camera in the scene.
  114660. * @param scene Define the scene the camera belongs to.
  114661. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  114662. */
  114663. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114664. /**
  114665. * Attach a control to the HTML DOM element.
  114666. * @param element Defines the element that listens to the input events.
  114667. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  114668. */
  114669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114670. /**
  114671. * Detach a control from the HTML DOM element.
  114672. * The camera will stop reacting to that input.
  114673. * @param element Defines the element that listens to the input events.
  114674. */
  114675. detachControl(element: HTMLElement): void;
  114676. private _collisionMask;
  114677. /**
  114678. * Get the mask that the camera ignores in collision events.
  114679. */
  114680. get collisionMask(): number;
  114681. /**
  114682. * Set the mask that the camera ignores in collision events.
  114683. */
  114684. set collisionMask(mask: number);
  114685. /** @hidden */
  114686. _collideWithWorld(displacement: Vector3): void;
  114687. /** @hidden */
  114688. private _onCollisionPositionChange;
  114689. /** @hidden */
  114690. _checkInputs(): void;
  114691. /** @hidden */
  114692. _decideIfNeedsToMove(): boolean;
  114693. /** @hidden */
  114694. _updatePosition(): void;
  114695. /**
  114696. * Restore the Roll to its target value at the rate specified.
  114697. * @param rate - Higher means slower restoring.
  114698. * @hidden
  114699. */
  114700. restoreRoll(rate: number): void;
  114701. /**
  114702. * Destroy the camera and release the current resources held by it.
  114703. */
  114704. dispose(): void;
  114705. /**
  114706. * Get the current object class name.
  114707. * @returns the class name.
  114708. */
  114709. getClassName(): string;
  114710. }
  114711. }
  114712. declare module BABYLON {
  114713. /**
  114714. * Listen to keyboard events to control the camera.
  114715. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114716. */
  114717. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  114718. /**
  114719. * Defines the camera the input is attached to.
  114720. */
  114721. camera: FlyCamera;
  114722. /**
  114723. * The list of keyboard keys used to control the forward move of the camera.
  114724. */
  114725. keysForward: number[];
  114726. /**
  114727. * The list of keyboard keys used to control the backward move of the camera.
  114728. */
  114729. keysBackward: number[];
  114730. /**
  114731. * The list of keyboard keys used to control the forward move of the camera.
  114732. */
  114733. keysUp: number[];
  114734. /**
  114735. * The list of keyboard keys used to control the backward move of the camera.
  114736. */
  114737. keysDown: number[];
  114738. /**
  114739. * The list of keyboard keys used to control the right strafe move of the camera.
  114740. */
  114741. keysRight: number[];
  114742. /**
  114743. * The list of keyboard keys used to control the left strafe move of the camera.
  114744. */
  114745. keysLeft: number[];
  114746. private _keys;
  114747. private _onCanvasBlurObserver;
  114748. private _onKeyboardObserver;
  114749. private _engine;
  114750. private _scene;
  114751. /**
  114752. * Attach the input controls to a specific dom element to get the input from.
  114753. * @param element Defines the element the controls should be listened from
  114754. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114755. */
  114756. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114757. /**
  114758. * Detach the current controls from the specified dom element.
  114759. * @param element Defines the element to stop listening the inputs from
  114760. */
  114761. detachControl(element: Nullable<HTMLElement>): void;
  114762. /**
  114763. * Gets the class name of the current intput.
  114764. * @returns the class name
  114765. */
  114766. getClassName(): string;
  114767. /** @hidden */
  114768. _onLostFocus(e: FocusEvent): void;
  114769. /**
  114770. * Get the friendly name associated with the input class.
  114771. * @returns the input friendly name
  114772. */
  114773. getSimpleName(): string;
  114774. /**
  114775. * Update the current camera state depending on the inputs that have been used this frame.
  114776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114777. */
  114778. checkInputs(): void;
  114779. }
  114780. }
  114781. declare module BABYLON {
  114782. /**
  114783. * Manage the mouse wheel inputs to control a follow camera.
  114784. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114785. */
  114786. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  114787. /**
  114788. * Defines the camera the input is attached to.
  114789. */
  114790. camera: FollowCamera;
  114791. /**
  114792. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  114793. */
  114794. axisControlRadius: boolean;
  114795. /**
  114796. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  114797. */
  114798. axisControlHeight: boolean;
  114799. /**
  114800. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  114801. */
  114802. axisControlRotation: boolean;
  114803. /**
  114804. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  114805. * relation to mouseWheel events.
  114806. */
  114807. wheelPrecision: number;
  114808. /**
  114809. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114810. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114811. */
  114812. wheelDeltaPercentage: number;
  114813. private _wheel;
  114814. private _observer;
  114815. /**
  114816. * Attach the input controls to a specific dom element to get the input from.
  114817. * @param element Defines the element the controls should be listened from
  114818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114819. */
  114820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114821. /**
  114822. * Detach the current controls from the specified dom element.
  114823. * @param element Defines the element to stop listening the inputs from
  114824. */
  114825. detachControl(element: Nullable<HTMLElement>): void;
  114826. /**
  114827. * Gets the class name of the current intput.
  114828. * @returns the class name
  114829. */
  114830. getClassName(): string;
  114831. /**
  114832. * Get the friendly name associated with the input class.
  114833. * @returns the input friendly name
  114834. */
  114835. getSimpleName(): string;
  114836. }
  114837. }
  114838. declare module BABYLON {
  114839. /**
  114840. * Manage the pointers inputs to control an follow camera.
  114841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114842. */
  114843. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  114844. /**
  114845. * Defines the camera the input is attached to.
  114846. */
  114847. camera: FollowCamera;
  114848. /**
  114849. * Gets the class name of the current input.
  114850. * @returns the class name
  114851. */
  114852. getClassName(): string;
  114853. /**
  114854. * Defines the pointer angular sensibility along the X axis or how fast is
  114855. * the camera rotating.
  114856. * A negative number will reverse the axis direction.
  114857. */
  114858. angularSensibilityX: number;
  114859. /**
  114860. * Defines the pointer angular sensibility along the Y axis or how fast is
  114861. * the camera rotating.
  114862. * A negative number will reverse the axis direction.
  114863. */
  114864. angularSensibilityY: number;
  114865. /**
  114866. * Defines the pointer pinch precision or how fast is the camera zooming.
  114867. * A negative number will reverse the axis direction.
  114868. */
  114869. pinchPrecision: number;
  114870. /**
  114871. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114872. * from 0.
  114873. * It defines the percentage of current camera.radius to use as delta when
  114874. * pinch zoom is used.
  114875. */
  114876. pinchDeltaPercentage: number;
  114877. /**
  114878. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  114879. */
  114880. axisXControlRadius: boolean;
  114881. /**
  114882. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  114883. */
  114884. axisXControlHeight: boolean;
  114885. /**
  114886. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  114887. */
  114888. axisXControlRotation: boolean;
  114889. /**
  114890. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  114891. */
  114892. axisYControlRadius: boolean;
  114893. /**
  114894. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  114895. */
  114896. axisYControlHeight: boolean;
  114897. /**
  114898. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  114899. */
  114900. axisYControlRotation: boolean;
  114901. /**
  114902. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  114903. */
  114904. axisPinchControlRadius: boolean;
  114905. /**
  114906. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  114907. */
  114908. axisPinchControlHeight: boolean;
  114909. /**
  114910. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  114911. */
  114912. axisPinchControlRotation: boolean;
  114913. /**
  114914. * Log error messages if basic misconfiguration has occurred.
  114915. */
  114916. warningEnable: boolean;
  114917. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114918. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114919. private _warningCounter;
  114920. private _warning;
  114921. }
  114922. }
  114923. declare module BABYLON {
  114924. /**
  114925. * Default Inputs manager for the FollowCamera.
  114926. * It groups all the default supported inputs for ease of use.
  114927. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114928. */
  114929. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114930. /**
  114931. * Instantiates a new FollowCameraInputsManager.
  114932. * @param camera Defines the camera the inputs belong to
  114933. */
  114934. constructor(camera: FollowCamera);
  114935. /**
  114936. * Add keyboard input support to the input manager.
  114937. * @returns the current input manager
  114938. */
  114939. addKeyboard(): FollowCameraInputsManager;
  114940. /**
  114941. * Add mouse wheel input support to the input manager.
  114942. * @returns the current input manager
  114943. */
  114944. addMouseWheel(): FollowCameraInputsManager;
  114945. /**
  114946. * Add pointers input support to the input manager.
  114947. * @returns the current input manager
  114948. */
  114949. addPointers(): FollowCameraInputsManager;
  114950. /**
  114951. * Add orientation input support to the input manager.
  114952. * @returns the current input manager
  114953. */
  114954. addVRDeviceOrientation(): FollowCameraInputsManager;
  114955. }
  114956. }
  114957. declare module BABYLON {
  114958. /**
  114959. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114960. * an arc rotate version arcFollowCamera are available.
  114961. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114962. */
  114963. export class FollowCamera extends TargetCamera {
  114964. /**
  114965. * Distance the follow camera should follow an object at
  114966. */
  114967. radius: number;
  114968. /**
  114969. * Minimum allowed distance of the camera to the axis of rotation
  114970. * (The camera can not get closer).
  114971. * This can help limiting how the Camera is able to move in the scene.
  114972. */
  114973. lowerRadiusLimit: Nullable<number>;
  114974. /**
  114975. * Maximum allowed distance of the camera to the axis of rotation
  114976. * (The camera can not get further).
  114977. * This can help limiting how the Camera is able to move in the scene.
  114978. */
  114979. upperRadiusLimit: Nullable<number>;
  114980. /**
  114981. * Define a rotation offset between the camera and the object it follows
  114982. */
  114983. rotationOffset: number;
  114984. /**
  114985. * Minimum allowed angle to camera position relative to target object.
  114986. * This can help limiting how the Camera is able to move in the scene.
  114987. */
  114988. lowerRotationOffsetLimit: Nullable<number>;
  114989. /**
  114990. * Maximum allowed angle to camera position relative to target object.
  114991. * This can help limiting how the Camera is able to move in the scene.
  114992. */
  114993. upperRotationOffsetLimit: Nullable<number>;
  114994. /**
  114995. * Define a height offset between the camera and the object it follows.
  114996. * It can help following an object from the top (like a car chaing a plane)
  114997. */
  114998. heightOffset: number;
  114999. /**
  115000. * Minimum allowed height of camera position relative to target object.
  115001. * This can help limiting how the Camera is able to move in the scene.
  115002. */
  115003. lowerHeightOffsetLimit: Nullable<number>;
  115004. /**
  115005. * Maximum allowed height of camera position relative to target object.
  115006. * This can help limiting how the Camera is able to move in the scene.
  115007. */
  115008. upperHeightOffsetLimit: Nullable<number>;
  115009. /**
  115010. * Define how fast the camera can accelerate to follow it s target.
  115011. */
  115012. cameraAcceleration: number;
  115013. /**
  115014. * Define the speed limit of the camera following an object.
  115015. */
  115016. maxCameraSpeed: number;
  115017. /**
  115018. * Define the target of the camera.
  115019. */
  115020. lockedTarget: Nullable<AbstractMesh>;
  115021. /**
  115022. * Defines the input associated with the camera.
  115023. */
  115024. inputs: FollowCameraInputsManager;
  115025. /**
  115026. * Instantiates the follow camera.
  115027. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115028. * @param name Define the name of the camera in the scene
  115029. * @param position Define the position of the camera
  115030. * @param scene Define the scene the camera belong to
  115031. * @param lockedTarget Define the target of the camera
  115032. */
  115033. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  115034. private _follow;
  115035. /**
  115036. * Attached controls to the current camera.
  115037. * @param element Defines the element the controls should be listened from
  115038. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115039. */
  115040. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115041. /**
  115042. * Detach the current controls from the camera.
  115043. * The camera will stop reacting to inputs.
  115044. * @param element Defines the element to stop listening the inputs from
  115045. */
  115046. detachControl(element: HTMLElement): void;
  115047. /** @hidden */
  115048. _checkInputs(): void;
  115049. private _checkLimits;
  115050. /**
  115051. * Gets the camera class name.
  115052. * @returns the class name
  115053. */
  115054. getClassName(): string;
  115055. }
  115056. /**
  115057. * Arc Rotate version of the follow camera.
  115058. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  115059. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115060. */
  115061. export class ArcFollowCamera extends TargetCamera {
  115062. /** The longitudinal angle of the camera */
  115063. alpha: number;
  115064. /** The latitudinal angle of the camera */
  115065. beta: number;
  115066. /** The radius of the camera from its target */
  115067. radius: number;
  115068. /** Define the camera target (the messh it should follow) */
  115069. target: Nullable<AbstractMesh>;
  115070. private _cartesianCoordinates;
  115071. /**
  115072. * Instantiates a new ArcFollowCamera
  115073. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115074. * @param name Define the name of the camera
  115075. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  115076. * @param beta Define the rotation angle of the camera around the elevation axis
  115077. * @param radius Define the radius of the camera from its target point
  115078. * @param target Define the target of the camera
  115079. * @param scene Define the scene the camera belongs to
  115080. */
  115081. constructor(name: string,
  115082. /** The longitudinal angle of the camera */
  115083. alpha: number,
  115084. /** The latitudinal angle of the camera */
  115085. beta: number,
  115086. /** The radius of the camera from its target */
  115087. radius: number,
  115088. /** Define the camera target (the messh it should follow) */
  115089. target: Nullable<AbstractMesh>, scene: Scene);
  115090. private _follow;
  115091. /** @hidden */
  115092. _checkInputs(): void;
  115093. /**
  115094. * Returns the class name of the object.
  115095. * It is mostly used internally for serialization purposes.
  115096. */
  115097. getClassName(): string;
  115098. }
  115099. }
  115100. declare module BABYLON {
  115101. /**
  115102. * Manage the keyboard inputs to control the movement of a follow camera.
  115103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115104. */
  115105. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  115106. /**
  115107. * Defines the camera the input is attached to.
  115108. */
  115109. camera: FollowCamera;
  115110. /**
  115111. * Defines the list of key codes associated with the up action (increase heightOffset)
  115112. */
  115113. keysHeightOffsetIncr: number[];
  115114. /**
  115115. * Defines the list of key codes associated with the down action (decrease heightOffset)
  115116. */
  115117. keysHeightOffsetDecr: number[];
  115118. /**
  115119. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  115120. */
  115121. keysHeightOffsetModifierAlt: boolean;
  115122. /**
  115123. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  115124. */
  115125. keysHeightOffsetModifierCtrl: boolean;
  115126. /**
  115127. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  115128. */
  115129. keysHeightOffsetModifierShift: boolean;
  115130. /**
  115131. * Defines the list of key codes associated with the left action (increase rotationOffset)
  115132. */
  115133. keysRotationOffsetIncr: number[];
  115134. /**
  115135. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  115136. */
  115137. keysRotationOffsetDecr: number[];
  115138. /**
  115139. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  115140. */
  115141. keysRotationOffsetModifierAlt: boolean;
  115142. /**
  115143. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  115144. */
  115145. keysRotationOffsetModifierCtrl: boolean;
  115146. /**
  115147. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  115148. */
  115149. keysRotationOffsetModifierShift: boolean;
  115150. /**
  115151. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  115152. */
  115153. keysRadiusIncr: number[];
  115154. /**
  115155. * Defines the list of key codes associated with the zoom-out action (increase radius)
  115156. */
  115157. keysRadiusDecr: number[];
  115158. /**
  115159. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  115160. */
  115161. keysRadiusModifierAlt: boolean;
  115162. /**
  115163. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  115164. */
  115165. keysRadiusModifierCtrl: boolean;
  115166. /**
  115167. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  115168. */
  115169. keysRadiusModifierShift: boolean;
  115170. /**
  115171. * Defines the rate of change of heightOffset.
  115172. */
  115173. heightSensibility: number;
  115174. /**
  115175. * Defines the rate of change of rotationOffset.
  115176. */
  115177. rotationSensibility: number;
  115178. /**
  115179. * Defines the rate of change of radius.
  115180. */
  115181. radiusSensibility: number;
  115182. private _keys;
  115183. private _ctrlPressed;
  115184. private _altPressed;
  115185. private _shiftPressed;
  115186. private _onCanvasBlurObserver;
  115187. private _onKeyboardObserver;
  115188. private _engine;
  115189. private _scene;
  115190. /**
  115191. * Attach the input controls to a specific dom element to get the input from.
  115192. * @param element Defines the element the controls should be listened from
  115193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115194. */
  115195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115196. /**
  115197. * Detach the current controls from the specified dom element.
  115198. * @param element Defines the element to stop listening the inputs from
  115199. */
  115200. detachControl(element: Nullable<HTMLElement>): void;
  115201. /**
  115202. * Update the current camera state depending on the inputs that have been used this frame.
  115203. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115204. */
  115205. checkInputs(): void;
  115206. /**
  115207. * Gets the class name of the current input.
  115208. * @returns the class name
  115209. */
  115210. getClassName(): string;
  115211. /**
  115212. * Get the friendly name associated with the input class.
  115213. * @returns the input friendly name
  115214. */
  115215. getSimpleName(): string;
  115216. /**
  115217. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115218. * allow modification of the heightOffset value.
  115219. */
  115220. private _modifierHeightOffset;
  115221. /**
  115222. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115223. * allow modification of the rotationOffset value.
  115224. */
  115225. private _modifierRotationOffset;
  115226. /**
  115227. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115228. * allow modification of the radius value.
  115229. */
  115230. private _modifierRadius;
  115231. }
  115232. }
  115233. declare module BABYLON {
  115234. interface FreeCameraInputsManager {
  115235. /**
  115236. * @hidden
  115237. */
  115238. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  115239. /**
  115240. * Add orientation input support to the input manager.
  115241. * @returns the current input manager
  115242. */
  115243. addDeviceOrientation(): FreeCameraInputsManager;
  115244. }
  115245. /**
  115246. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  115247. * Screen rotation is taken into account.
  115248. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115249. */
  115250. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  115251. private _camera;
  115252. private _screenOrientationAngle;
  115253. private _constantTranform;
  115254. private _screenQuaternion;
  115255. private _alpha;
  115256. private _beta;
  115257. private _gamma;
  115258. /**
  115259. * Can be used to detect if a device orientation sensor is available on a device
  115260. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  115261. * @returns a promise that will resolve on orientation change
  115262. */
  115263. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  115264. /**
  115265. * @hidden
  115266. */
  115267. _onDeviceOrientationChangedObservable: Observable<void>;
  115268. /**
  115269. * Instantiates a new input
  115270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115271. */
  115272. constructor();
  115273. /**
  115274. * Define the camera controlled by the input.
  115275. */
  115276. get camera(): FreeCamera;
  115277. set camera(camera: FreeCamera);
  115278. /**
  115279. * Attach the input controls to a specific dom element to get the input from.
  115280. * @param element Defines the element the controls should be listened from
  115281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115282. */
  115283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115284. private _orientationChanged;
  115285. private _deviceOrientation;
  115286. /**
  115287. * Detach the current controls from the specified dom element.
  115288. * @param element Defines the element to stop listening the inputs from
  115289. */
  115290. detachControl(element: Nullable<HTMLElement>): void;
  115291. /**
  115292. * Update the current camera state depending on the inputs that have been used this frame.
  115293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115294. */
  115295. checkInputs(): void;
  115296. /**
  115297. * Gets the class name of the current intput.
  115298. * @returns the class name
  115299. */
  115300. getClassName(): string;
  115301. /**
  115302. * Get the friendly name associated with the input class.
  115303. * @returns the input friendly name
  115304. */
  115305. getSimpleName(): string;
  115306. }
  115307. }
  115308. declare module BABYLON {
  115309. /**
  115310. * Manage the gamepad inputs to control a free camera.
  115311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115312. */
  115313. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  115314. /**
  115315. * Define the camera the input is attached to.
  115316. */
  115317. camera: FreeCamera;
  115318. /**
  115319. * Define the Gamepad controlling the input
  115320. */
  115321. gamepad: Nullable<Gamepad>;
  115322. /**
  115323. * Defines the gamepad rotation sensiblity.
  115324. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115325. */
  115326. gamepadAngularSensibility: number;
  115327. /**
  115328. * Defines the gamepad move sensiblity.
  115329. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115330. */
  115331. gamepadMoveSensibility: number;
  115332. private _yAxisScale;
  115333. /**
  115334. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115335. */
  115336. get invertYAxis(): boolean;
  115337. set invertYAxis(value: boolean);
  115338. private _onGamepadConnectedObserver;
  115339. private _onGamepadDisconnectedObserver;
  115340. private _cameraTransform;
  115341. private _deltaTransform;
  115342. private _vector3;
  115343. private _vector2;
  115344. /**
  115345. * Attach the input controls to a specific dom element to get the input from.
  115346. * @param element Defines the element the controls should be listened from
  115347. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115348. */
  115349. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115350. /**
  115351. * Detach the current controls from the specified dom element.
  115352. * @param element Defines the element to stop listening the inputs from
  115353. */
  115354. detachControl(element: Nullable<HTMLElement>): void;
  115355. /**
  115356. * Update the current camera state depending on the inputs that have been used this frame.
  115357. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115358. */
  115359. checkInputs(): void;
  115360. /**
  115361. * Gets the class name of the current intput.
  115362. * @returns the class name
  115363. */
  115364. getClassName(): string;
  115365. /**
  115366. * Get the friendly name associated with the input class.
  115367. * @returns the input friendly name
  115368. */
  115369. getSimpleName(): string;
  115370. }
  115371. }
  115372. declare module BABYLON {
  115373. /**
  115374. * Defines the potential axis of a Joystick
  115375. */
  115376. export enum JoystickAxis {
  115377. /** X axis */
  115378. X = 0,
  115379. /** Y axis */
  115380. Y = 1,
  115381. /** Z axis */
  115382. Z = 2
  115383. }
  115384. /**
  115385. * Class used to define virtual joystick (used in touch mode)
  115386. */
  115387. export class VirtualJoystick {
  115388. /**
  115389. * Gets or sets a boolean indicating that left and right values must be inverted
  115390. */
  115391. reverseLeftRight: boolean;
  115392. /**
  115393. * Gets or sets a boolean indicating that up and down values must be inverted
  115394. */
  115395. reverseUpDown: boolean;
  115396. /**
  115397. * Gets the offset value for the position (ie. the change of the position value)
  115398. */
  115399. deltaPosition: Vector3;
  115400. /**
  115401. * Gets a boolean indicating if the virtual joystick was pressed
  115402. */
  115403. pressed: boolean;
  115404. /**
  115405. * Canvas the virtual joystick will render onto, default z-index of this is 5
  115406. */
  115407. static Canvas: Nullable<HTMLCanvasElement>;
  115408. private static _globalJoystickIndex;
  115409. private static vjCanvasContext;
  115410. private static vjCanvasWidth;
  115411. private static vjCanvasHeight;
  115412. private static halfWidth;
  115413. private _action;
  115414. private _axisTargetedByLeftAndRight;
  115415. private _axisTargetedByUpAndDown;
  115416. private _joystickSensibility;
  115417. private _inversedSensibility;
  115418. private _joystickPointerID;
  115419. private _joystickColor;
  115420. private _joystickPointerPos;
  115421. private _joystickPreviousPointerPos;
  115422. private _joystickPointerStartPos;
  115423. private _deltaJoystickVector;
  115424. private _leftJoystick;
  115425. private _touches;
  115426. private _onPointerDownHandlerRef;
  115427. private _onPointerMoveHandlerRef;
  115428. private _onPointerUpHandlerRef;
  115429. private _onResize;
  115430. /**
  115431. * Creates a new virtual joystick
  115432. * @param leftJoystick defines that the joystick is for left hand (false by default)
  115433. */
  115434. constructor(leftJoystick?: boolean);
  115435. /**
  115436. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  115437. * @param newJoystickSensibility defines the new sensibility
  115438. */
  115439. setJoystickSensibility(newJoystickSensibility: number): void;
  115440. private _onPointerDown;
  115441. private _onPointerMove;
  115442. private _onPointerUp;
  115443. /**
  115444. * Change the color of the virtual joystick
  115445. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  115446. */
  115447. setJoystickColor(newColor: string): void;
  115448. /**
  115449. * Defines a callback to call when the joystick is touched
  115450. * @param action defines the callback
  115451. */
  115452. setActionOnTouch(action: () => any): void;
  115453. /**
  115454. * Defines which axis you'd like to control for left & right
  115455. * @param axis defines the axis to use
  115456. */
  115457. setAxisForLeftRight(axis: JoystickAxis): void;
  115458. /**
  115459. * Defines which axis you'd like to control for up & down
  115460. * @param axis defines the axis to use
  115461. */
  115462. setAxisForUpDown(axis: JoystickAxis): void;
  115463. private _drawVirtualJoystick;
  115464. /**
  115465. * Release internal HTML canvas
  115466. */
  115467. releaseCanvas(): void;
  115468. }
  115469. }
  115470. declare module BABYLON {
  115471. interface FreeCameraInputsManager {
  115472. /**
  115473. * Add virtual joystick input support to the input manager.
  115474. * @returns the current input manager
  115475. */
  115476. addVirtualJoystick(): FreeCameraInputsManager;
  115477. }
  115478. /**
  115479. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  115480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115481. */
  115482. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  115483. /**
  115484. * Defines the camera the input is attached to.
  115485. */
  115486. camera: FreeCamera;
  115487. private _leftjoystick;
  115488. private _rightjoystick;
  115489. /**
  115490. * Gets the left stick of the virtual joystick.
  115491. * @returns The virtual Joystick
  115492. */
  115493. getLeftJoystick(): VirtualJoystick;
  115494. /**
  115495. * Gets the right stick of the virtual joystick.
  115496. * @returns The virtual Joystick
  115497. */
  115498. getRightJoystick(): VirtualJoystick;
  115499. /**
  115500. * Update the current camera state depending on the inputs that have been used this frame.
  115501. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115502. */
  115503. checkInputs(): void;
  115504. /**
  115505. * Attach the input controls to a specific dom element to get the input from.
  115506. * @param element Defines the element the controls should be listened from
  115507. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115508. */
  115509. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115510. /**
  115511. * Detach the current controls from the specified dom element.
  115512. * @param element Defines the element to stop listening the inputs from
  115513. */
  115514. detachControl(element: Nullable<HTMLElement>): void;
  115515. /**
  115516. * Gets the class name of the current intput.
  115517. * @returns the class name
  115518. */
  115519. getClassName(): string;
  115520. /**
  115521. * Get the friendly name associated with the input class.
  115522. * @returns the input friendly name
  115523. */
  115524. getSimpleName(): string;
  115525. }
  115526. }
  115527. declare module BABYLON {
  115528. /**
  115529. * This represents a FPS type of camera controlled by touch.
  115530. * This is like a universal camera minus the Gamepad controls.
  115531. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115532. */
  115533. export class TouchCamera extends FreeCamera {
  115534. /**
  115535. * Defines the touch sensibility for rotation.
  115536. * The higher the faster.
  115537. */
  115538. get touchAngularSensibility(): number;
  115539. set touchAngularSensibility(value: number);
  115540. /**
  115541. * Defines the touch sensibility for move.
  115542. * The higher the faster.
  115543. */
  115544. get touchMoveSensibility(): number;
  115545. set touchMoveSensibility(value: number);
  115546. /**
  115547. * Instantiates a new touch camera.
  115548. * This represents a FPS type of camera controlled by touch.
  115549. * This is like a universal camera minus the Gamepad controls.
  115550. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115551. * @param name Define the name of the camera in the scene
  115552. * @param position Define the start position of the camera in the scene
  115553. * @param scene Define the scene the camera belongs to
  115554. */
  115555. constructor(name: string, position: Vector3, scene: Scene);
  115556. /**
  115557. * Gets the current object class name.
  115558. * @return the class name
  115559. */
  115560. getClassName(): string;
  115561. /** @hidden */
  115562. _setupInputs(): void;
  115563. }
  115564. }
  115565. declare module BABYLON {
  115566. /**
  115567. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  115568. * being tilted forward or back and left or right.
  115569. */
  115570. export class DeviceOrientationCamera extends FreeCamera {
  115571. private _initialQuaternion;
  115572. private _quaternionCache;
  115573. private _tmpDragQuaternion;
  115574. private _disablePointerInputWhenUsingDeviceOrientation;
  115575. /**
  115576. * Creates a new device orientation camera
  115577. * @param name The name of the camera
  115578. * @param position The start position camera
  115579. * @param scene The scene the camera belongs to
  115580. */
  115581. constructor(name: string, position: Vector3, scene: Scene);
  115582. /**
  115583. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  115584. */
  115585. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  115586. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  115587. private _dragFactor;
  115588. /**
  115589. * Enabled turning on the y axis when the orientation sensor is active
  115590. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  115591. */
  115592. enableHorizontalDragging(dragFactor?: number): void;
  115593. /**
  115594. * Gets the current instance class name ("DeviceOrientationCamera").
  115595. * This helps avoiding instanceof at run time.
  115596. * @returns the class name
  115597. */
  115598. getClassName(): string;
  115599. /**
  115600. * @hidden
  115601. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  115602. */
  115603. _checkInputs(): void;
  115604. /**
  115605. * Reset the camera to its default orientation on the specified axis only.
  115606. * @param axis The axis to reset
  115607. */
  115608. resetToCurrentRotation(axis?: Axis): void;
  115609. }
  115610. }
  115611. declare module BABYLON {
  115612. /**
  115613. * Defines supported buttons for XBox360 compatible gamepads
  115614. */
  115615. export enum Xbox360Button {
  115616. /** A */
  115617. A = 0,
  115618. /** B */
  115619. B = 1,
  115620. /** X */
  115621. X = 2,
  115622. /** Y */
  115623. Y = 3,
  115624. /** Left button */
  115625. LB = 4,
  115626. /** Right button */
  115627. RB = 5,
  115628. /** Back */
  115629. Back = 8,
  115630. /** Start */
  115631. Start = 9,
  115632. /** Left stick */
  115633. LeftStick = 10,
  115634. /** Right stick */
  115635. RightStick = 11
  115636. }
  115637. /** Defines values for XBox360 DPad */
  115638. export enum Xbox360Dpad {
  115639. /** Up */
  115640. Up = 12,
  115641. /** Down */
  115642. Down = 13,
  115643. /** Left */
  115644. Left = 14,
  115645. /** Right */
  115646. Right = 15
  115647. }
  115648. /**
  115649. * Defines a XBox360 gamepad
  115650. */
  115651. export class Xbox360Pad extends Gamepad {
  115652. private _leftTrigger;
  115653. private _rightTrigger;
  115654. private _onlefttriggerchanged;
  115655. private _onrighttriggerchanged;
  115656. private _onbuttondown;
  115657. private _onbuttonup;
  115658. private _ondpaddown;
  115659. private _ondpadup;
  115660. /** Observable raised when a button is pressed */
  115661. onButtonDownObservable: Observable<Xbox360Button>;
  115662. /** Observable raised when a button is released */
  115663. onButtonUpObservable: Observable<Xbox360Button>;
  115664. /** Observable raised when a pad is pressed */
  115665. onPadDownObservable: Observable<Xbox360Dpad>;
  115666. /** Observable raised when a pad is released */
  115667. onPadUpObservable: Observable<Xbox360Dpad>;
  115668. private _buttonA;
  115669. private _buttonB;
  115670. private _buttonX;
  115671. private _buttonY;
  115672. private _buttonBack;
  115673. private _buttonStart;
  115674. private _buttonLB;
  115675. private _buttonRB;
  115676. private _buttonLeftStick;
  115677. private _buttonRightStick;
  115678. private _dPadUp;
  115679. private _dPadDown;
  115680. private _dPadLeft;
  115681. private _dPadRight;
  115682. private _isXboxOnePad;
  115683. /**
  115684. * Creates a new XBox360 gamepad object
  115685. * @param id defines the id of this gamepad
  115686. * @param index defines its index
  115687. * @param gamepad defines the internal HTML gamepad object
  115688. * @param xboxOne defines if it is a XBox One gamepad
  115689. */
  115690. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  115691. /**
  115692. * Defines the callback to call when left trigger is pressed
  115693. * @param callback defines the callback to use
  115694. */
  115695. onlefttriggerchanged(callback: (value: number) => void): void;
  115696. /**
  115697. * Defines the callback to call when right trigger is pressed
  115698. * @param callback defines the callback to use
  115699. */
  115700. onrighttriggerchanged(callback: (value: number) => void): void;
  115701. /**
  115702. * Gets the left trigger value
  115703. */
  115704. get leftTrigger(): number;
  115705. /**
  115706. * Sets the left trigger value
  115707. */
  115708. set leftTrigger(newValue: number);
  115709. /**
  115710. * Gets the right trigger value
  115711. */
  115712. get rightTrigger(): number;
  115713. /**
  115714. * Sets the right trigger value
  115715. */
  115716. set rightTrigger(newValue: number);
  115717. /**
  115718. * Defines the callback to call when a button is pressed
  115719. * @param callback defines the callback to use
  115720. */
  115721. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  115722. /**
  115723. * Defines the callback to call when a button is released
  115724. * @param callback defines the callback to use
  115725. */
  115726. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  115727. /**
  115728. * Defines the callback to call when a pad is pressed
  115729. * @param callback defines the callback to use
  115730. */
  115731. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  115732. /**
  115733. * Defines the callback to call when a pad is released
  115734. * @param callback defines the callback to use
  115735. */
  115736. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  115737. private _setButtonValue;
  115738. private _setDPadValue;
  115739. /**
  115740. * Gets the value of the `A` button
  115741. */
  115742. get buttonA(): number;
  115743. /**
  115744. * Sets the value of the `A` button
  115745. */
  115746. set buttonA(value: number);
  115747. /**
  115748. * Gets the value of the `B` button
  115749. */
  115750. get buttonB(): number;
  115751. /**
  115752. * Sets the value of the `B` button
  115753. */
  115754. set buttonB(value: number);
  115755. /**
  115756. * Gets the value of the `X` button
  115757. */
  115758. get buttonX(): number;
  115759. /**
  115760. * Sets the value of the `X` button
  115761. */
  115762. set buttonX(value: number);
  115763. /**
  115764. * Gets the value of the `Y` button
  115765. */
  115766. get buttonY(): number;
  115767. /**
  115768. * Sets the value of the `Y` button
  115769. */
  115770. set buttonY(value: number);
  115771. /**
  115772. * Gets the value of the `Start` button
  115773. */
  115774. get buttonStart(): number;
  115775. /**
  115776. * Sets the value of the `Start` button
  115777. */
  115778. set buttonStart(value: number);
  115779. /**
  115780. * Gets the value of the `Back` button
  115781. */
  115782. get buttonBack(): number;
  115783. /**
  115784. * Sets the value of the `Back` button
  115785. */
  115786. set buttonBack(value: number);
  115787. /**
  115788. * Gets the value of the `Left` button
  115789. */
  115790. get buttonLB(): number;
  115791. /**
  115792. * Sets the value of the `Left` button
  115793. */
  115794. set buttonLB(value: number);
  115795. /**
  115796. * Gets the value of the `Right` button
  115797. */
  115798. get buttonRB(): number;
  115799. /**
  115800. * Sets the value of the `Right` button
  115801. */
  115802. set buttonRB(value: number);
  115803. /**
  115804. * Gets the value of the Left joystick
  115805. */
  115806. get buttonLeftStick(): number;
  115807. /**
  115808. * Sets the value of the Left joystick
  115809. */
  115810. set buttonLeftStick(value: number);
  115811. /**
  115812. * Gets the value of the Right joystick
  115813. */
  115814. get buttonRightStick(): number;
  115815. /**
  115816. * Sets the value of the Right joystick
  115817. */
  115818. set buttonRightStick(value: number);
  115819. /**
  115820. * Gets the value of D-pad up
  115821. */
  115822. get dPadUp(): number;
  115823. /**
  115824. * Sets the value of D-pad up
  115825. */
  115826. set dPadUp(value: number);
  115827. /**
  115828. * Gets the value of D-pad down
  115829. */
  115830. get dPadDown(): number;
  115831. /**
  115832. * Sets the value of D-pad down
  115833. */
  115834. set dPadDown(value: number);
  115835. /**
  115836. * Gets the value of D-pad left
  115837. */
  115838. get dPadLeft(): number;
  115839. /**
  115840. * Sets the value of D-pad left
  115841. */
  115842. set dPadLeft(value: number);
  115843. /**
  115844. * Gets the value of D-pad right
  115845. */
  115846. get dPadRight(): number;
  115847. /**
  115848. * Sets the value of D-pad right
  115849. */
  115850. set dPadRight(value: number);
  115851. /**
  115852. * Force the gamepad to synchronize with device values
  115853. */
  115854. update(): void;
  115855. /**
  115856. * Disposes the gamepad
  115857. */
  115858. dispose(): void;
  115859. }
  115860. }
  115861. declare module BABYLON {
  115862. /**
  115863. * Defines supported buttons for DualShock compatible gamepads
  115864. */
  115865. export enum DualShockButton {
  115866. /** Cross */
  115867. Cross = 0,
  115868. /** Circle */
  115869. Circle = 1,
  115870. /** Square */
  115871. Square = 2,
  115872. /** Triangle */
  115873. Triangle = 3,
  115874. /** L1 */
  115875. L1 = 4,
  115876. /** R1 */
  115877. R1 = 5,
  115878. /** Share */
  115879. Share = 8,
  115880. /** Options */
  115881. Options = 9,
  115882. /** Left stick */
  115883. LeftStick = 10,
  115884. /** Right stick */
  115885. RightStick = 11
  115886. }
  115887. /** Defines values for DualShock DPad */
  115888. export enum DualShockDpad {
  115889. /** Up */
  115890. Up = 12,
  115891. /** Down */
  115892. Down = 13,
  115893. /** Left */
  115894. Left = 14,
  115895. /** Right */
  115896. Right = 15
  115897. }
  115898. /**
  115899. * Defines a DualShock gamepad
  115900. */
  115901. export class DualShockPad extends Gamepad {
  115902. private _leftTrigger;
  115903. private _rightTrigger;
  115904. private _onlefttriggerchanged;
  115905. private _onrighttriggerchanged;
  115906. private _onbuttondown;
  115907. private _onbuttonup;
  115908. private _ondpaddown;
  115909. private _ondpadup;
  115910. /** Observable raised when a button is pressed */
  115911. onButtonDownObservable: Observable<DualShockButton>;
  115912. /** Observable raised when a button is released */
  115913. onButtonUpObservable: Observable<DualShockButton>;
  115914. /** Observable raised when a pad is pressed */
  115915. onPadDownObservable: Observable<DualShockDpad>;
  115916. /** Observable raised when a pad is released */
  115917. onPadUpObservable: Observable<DualShockDpad>;
  115918. private _buttonCross;
  115919. private _buttonCircle;
  115920. private _buttonSquare;
  115921. private _buttonTriangle;
  115922. private _buttonShare;
  115923. private _buttonOptions;
  115924. private _buttonL1;
  115925. private _buttonR1;
  115926. private _buttonLeftStick;
  115927. private _buttonRightStick;
  115928. private _dPadUp;
  115929. private _dPadDown;
  115930. private _dPadLeft;
  115931. private _dPadRight;
  115932. /**
  115933. * Creates a new DualShock gamepad object
  115934. * @param id defines the id of this gamepad
  115935. * @param index defines its index
  115936. * @param gamepad defines the internal HTML gamepad object
  115937. */
  115938. constructor(id: string, index: number, gamepad: any);
  115939. /**
  115940. * Defines the callback to call when left trigger is pressed
  115941. * @param callback defines the callback to use
  115942. */
  115943. onlefttriggerchanged(callback: (value: number) => void): void;
  115944. /**
  115945. * Defines the callback to call when right trigger is pressed
  115946. * @param callback defines the callback to use
  115947. */
  115948. onrighttriggerchanged(callback: (value: number) => void): void;
  115949. /**
  115950. * Gets the left trigger value
  115951. */
  115952. get leftTrigger(): number;
  115953. /**
  115954. * Sets the left trigger value
  115955. */
  115956. set leftTrigger(newValue: number);
  115957. /**
  115958. * Gets the right trigger value
  115959. */
  115960. get rightTrigger(): number;
  115961. /**
  115962. * Sets the right trigger value
  115963. */
  115964. set rightTrigger(newValue: number);
  115965. /**
  115966. * Defines the callback to call when a button is pressed
  115967. * @param callback defines the callback to use
  115968. */
  115969. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115970. /**
  115971. * Defines the callback to call when a button is released
  115972. * @param callback defines the callback to use
  115973. */
  115974. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115975. /**
  115976. * Defines the callback to call when a pad is pressed
  115977. * @param callback defines the callback to use
  115978. */
  115979. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115980. /**
  115981. * Defines the callback to call when a pad is released
  115982. * @param callback defines the callback to use
  115983. */
  115984. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  115985. private _setButtonValue;
  115986. private _setDPadValue;
  115987. /**
  115988. * Gets the value of the `Cross` button
  115989. */
  115990. get buttonCross(): number;
  115991. /**
  115992. * Sets the value of the `Cross` button
  115993. */
  115994. set buttonCross(value: number);
  115995. /**
  115996. * Gets the value of the `Circle` button
  115997. */
  115998. get buttonCircle(): number;
  115999. /**
  116000. * Sets the value of the `Circle` button
  116001. */
  116002. set buttonCircle(value: number);
  116003. /**
  116004. * Gets the value of the `Square` button
  116005. */
  116006. get buttonSquare(): number;
  116007. /**
  116008. * Sets the value of the `Square` button
  116009. */
  116010. set buttonSquare(value: number);
  116011. /**
  116012. * Gets the value of the `Triangle` button
  116013. */
  116014. get buttonTriangle(): number;
  116015. /**
  116016. * Sets the value of the `Triangle` button
  116017. */
  116018. set buttonTriangle(value: number);
  116019. /**
  116020. * Gets the value of the `Options` button
  116021. */
  116022. get buttonOptions(): number;
  116023. /**
  116024. * Sets the value of the `Options` button
  116025. */
  116026. set buttonOptions(value: number);
  116027. /**
  116028. * Gets the value of the `Share` button
  116029. */
  116030. get buttonShare(): number;
  116031. /**
  116032. * Sets the value of the `Share` button
  116033. */
  116034. set buttonShare(value: number);
  116035. /**
  116036. * Gets the value of the `L1` button
  116037. */
  116038. get buttonL1(): number;
  116039. /**
  116040. * Sets the value of the `L1` button
  116041. */
  116042. set buttonL1(value: number);
  116043. /**
  116044. * Gets the value of the `R1` button
  116045. */
  116046. get buttonR1(): number;
  116047. /**
  116048. * Sets the value of the `R1` button
  116049. */
  116050. set buttonR1(value: number);
  116051. /**
  116052. * Gets the value of the Left joystick
  116053. */
  116054. get buttonLeftStick(): number;
  116055. /**
  116056. * Sets the value of the Left joystick
  116057. */
  116058. set buttonLeftStick(value: number);
  116059. /**
  116060. * Gets the value of the Right joystick
  116061. */
  116062. get buttonRightStick(): number;
  116063. /**
  116064. * Sets the value of the Right joystick
  116065. */
  116066. set buttonRightStick(value: number);
  116067. /**
  116068. * Gets the value of D-pad up
  116069. */
  116070. get dPadUp(): number;
  116071. /**
  116072. * Sets the value of D-pad up
  116073. */
  116074. set dPadUp(value: number);
  116075. /**
  116076. * Gets the value of D-pad down
  116077. */
  116078. get dPadDown(): number;
  116079. /**
  116080. * Sets the value of D-pad down
  116081. */
  116082. set dPadDown(value: number);
  116083. /**
  116084. * Gets the value of D-pad left
  116085. */
  116086. get dPadLeft(): number;
  116087. /**
  116088. * Sets the value of D-pad left
  116089. */
  116090. set dPadLeft(value: number);
  116091. /**
  116092. * Gets the value of D-pad right
  116093. */
  116094. get dPadRight(): number;
  116095. /**
  116096. * Sets the value of D-pad right
  116097. */
  116098. set dPadRight(value: number);
  116099. /**
  116100. * Force the gamepad to synchronize with device values
  116101. */
  116102. update(): void;
  116103. /**
  116104. * Disposes the gamepad
  116105. */
  116106. dispose(): void;
  116107. }
  116108. }
  116109. declare module BABYLON {
  116110. /**
  116111. * Manager for handling gamepads
  116112. */
  116113. export class GamepadManager {
  116114. private _scene?;
  116115. private _babylonGamepads;
  116116. private _oneGamepadConnected;
  116117. /** @hidden */
  116118. _isMonitoring: boolean;
  116119. private _gamepadEventSupported;
  116120. private _gamepadSupport?;
  116121. /**
  116122. * observable to be triggered when the gamepad controller has been connected
  116123. */
  116124. onGamepadConnectedObservable: Observable<Gamepad>;
  116125. /**
  116126. * observable to be triggered when the gamepad controller has been disconnected
  116127. */
  116128. onGamepadDisconnectedObservable: Observable<Gamepad>;
  116129. private _onGamepadConnectedEvent;
  116130. private _onGamepadDisconnectedEvent;
  116131. /**
  116132. * Initializes the gamepad manager
  116133. * @param _scene BabylonJS scene
  116134. */
  116135. constructor(_scene?: Scene | undefined);
  116136. /**
  116137. * The gamepads in the game pad manager
  116138. */
  116139. get gamepads(): Gamepad[];
  116140. /**
  116141. * Get the gamepad controllers based on type
  116142. * @param type The type of gamepad controller
  116143. * @returns Nullable gamepad
  116144. */
  116145. getGamepadByType(type?: number): Nullable<Gamepad>;
  116146. /**
  116147. * Disposes the gamepad manager
  116148. */
  116149. dispose(): void;
  116150. private _addNewGamepad;
  116151. private _startMonitoringGamepads;
  116152. private _stopMonitoringGamepads;
  116153. /** @hidden */
  116154. _checkGamepadsStatus(): void;
  116155. private _updateGamepadObjects;
  116156. }
  116157. }
  116158. declare module BABYLON {
  116159. interface Scene {
  116160. /** @hidden */
  116161. _gamepadManager: Nullable<GamepadManager>;
  116162. /**
  116163. * Gets the gamepad manager associated with the scene
  116164. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  116165. */
  116166. gamepadManager: GamepadManager;
  116167. }
  116168. /**
  116169. * Interface representing a free camera inputs manager
  116170. */
  116171. interface FreeCameraInputsManager {
  116172. /**
  116173. * Adds gamepad input support to the FreeCameraInputsManager.
  116174. * @returns the FreeCameraInputsManager
  116175. */
  116176. addGamepad(): FreeCameraInputsManager;
  116177. }
  116178. /**
  116179. * Interface representing an arc rotate camera inputs manager
  116180. */
  116181. interface ArcRotateCameraInputsManager {
  116182. /**
  116183. * Adds gamepad input support to the ArcRotateCamera InputManager.
  116184. * @returns the camera inputs manager
  116185. */
  116186. addGamepad(): ArcRotateCameraInputsManager;
  116187. }
  116188. /**
  116189. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  116190. */
  116191. export class GamepadSystemSceneComponent implements ISceneComponent {
  116192. /**
  116193. * The component name helpfull to identify the component in the list of scene components.
  116194. */
  116195. readonly name: string;
  116196. /**
  116197. * The scene the component belongs to.
  116198. */
  116199. scene: Scene;
  116200. /**
  116201. * Creates a new instance of the component for the given scene
  116202. * @param scene Defines the scene to register the component in
  116203. */
  116204. constructor(scene: Scene);
  116205. /**
  116206. * Registers the component in a given scene
  116207. */
  116208. register(): void;
  116209. /**
  116210. * Rebuilds the elements related to this component in case of
  116211. * context lost for instance.
  116212. */
  116213. rebuild(): void;
  116214. /**
  116215. * Disposes the component and the associated ressources
  116216. */
  116217. dispose(): void;
  116218. private _beforeCameraUpdate;
  116219. }
  116220. }
  116221. declare module BABYLON {
  116222. /**
  116223. * 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,
  116224. * which still works and will still be found in many Playgrounds.
  116225. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116226. */
  116227. export class UniversalCamera extends TouchCamera {
  116228. /**
  116229. * Defines the gamepad rotation sensiblity.
  116230. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116231. */
  116232. get gamepadAngularSensibility(): number;
  116233. set gamepadAngularSensibility(value: number);
  116234. /**
  116235. * Defines the gamepad move sensiblity.
  116236. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116237. */
  116238. get gamepadMoveSensibility(): number;
  116239. set gamepadMoveSensibility(value: number);
  116240. /**
  116241. * 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,
  116242. * which still works and will still be found in many Playgrounds.
  116243. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116244. * @param name Define the name of the camera in the scene
  116245. * @param position Define the start position of the camera in the scene
  116246. * @param scene Define the scene the camera belongs to
  116247. */
  116248. constructor(name: string, position: Vector3, scene: Scene);
  116249. /**
  116250. * Gets the current object class name.
  116251. * @return the class name
  116252. */
  116253. getClassName(): string;
  116254. }
  116255. }
  116256. declare module BABYLON {
  116257. /**
  116258. * This represents a FPS type of camera. This is only here for back compat purpose.
  116259. * Please use the UniversalCamera instead as both are identical.
  116260. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116261. */
  116262. export class GamepadCamera extends UniversalCamera {
  116263. /**
  116264. * Instantiates a new Gamepad Camera
  116265. * This represents a FPS type of camera. This is only here for back compat purpose.
  116266. * Please use the UniversalCamera instead as both are identical.
  116267. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116268. * @param name Define the name of the camera in the scene
  116269. * @param position Define the start position of the camera in the scene
  116270. * @param scene Define the scene the camera belongs to
  116271. */
  116272. constructor(name: string, position: Vector3, scene: Scene);
  116273. /**
  116274. * Gets the current object class name.
  116275. * @return the class name
  116276. */
  116277. getClassName(): string;
  116278. }
  116279. }
  116280. declare module BABYLON {
  116281. /** @hidden */
  116282. export var passPixelShader: {
  116283. name: string;
  116284. shader: string;
  116285. };
  116286. }
  116287. declare module BABYLON {
  116288. /** @hidden */
  116289. export var passCubePixelShader: {
  116290. name: string;
  116291. shader: string;
  116292. };
  116293. }
  116294. declare module BABYLON {
  116295. /**
  116296. * PassPostProcess which produces an output the same as it's input
  116297. */
  116298. export class PassPostProcess extends PostProcess {
  116299. /**
  116300. * Creates the PassPostProcess
  116301. * @param name The name of the effect.
  116302. * @param options The required width/height ratio to downsize to before computing the render pass.
  116303. * @param camera The camera to apply the render pass to.
  116304. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116305. * @param engine The engine which the post process will be applied. (default: current engine)
  116306. * @param reusable If the post process can be reused on the same frame. (default: false)
  116307. * @param textureType The type of texture to be used when performing the post processing.
  116308. * @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)
  116309. */
  116310. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116311. }
  116312. /**
  116313. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116314. */
  116315. export class PassCubePostProcess extends PostProcess {
  116316. private _face;
  116317. /**
  116318. * Gets or sets the cube face to display.
  116319. * * 0 is +X
  116320. * * 1 is -X
  116321. * * 2 is +Y
  116322. * * 3 is -Y
  116323. * * 4 is +Z
  116324. * * 5 is -Z
  116325. */
  116326. get face(): number;
  116327. set face(value: number);
  116328. /**
  116329. * Creates the PassCubePostProcess
  116330. * @param name The name of the effect.
  116331. * @param options The required width/height ratio to downsize to before computing the render pass.
  116332. * @param camera The camera to apply the render pass to.
  116333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116334. * @param engine The engine which the post process will be applied. (default: current engine)
  116335. * @param reusable If the post process can be reused on the same frame. (default: false)
  116336. * @param textureType The type of texture to be used when performing the post processing.
  116337. * @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)
  116338. */
  116339. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116340. }
  116341. }
  116342. declare module BABYLON {
  116343. /** @hidden */
  116344. export var anaglyphPixelShader: {
  116345. name: string;
  116346. shader: string;
  116347. };
  116348. }
  116349. declare module BABYLON {
  116350. /**
  116351. * Postprocess used to generate anaglyphic rendering
  116352. */
  116353. export class AnaglyphPostProcess extends PostProcess {
  116354. private _passedProcess;
  116355. /**
  116356. * Creates a new AnaglyphPostProcess
  116357. * @param name defines postprocess name
  116358. * @param options defines creation options or target ratio scale
  116359. * @param rigCameras defines cameras using this postprocess
  116360. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116361. * @param engine defines hosting engine
  116362. * @param reusable defines if the postprocess will be reused multiple times per frame
  116363. */
  116364. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  116365. }
  116366. }
  116367. declare module BABYLON {
  116368. /**
  116369. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  116370. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116371. */
  116372. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  116373. /**
  116374. * Creates a new AnaglyphArcRotateCamera
  116375. * @param name defines camera name
  116376. * @param alpha defines alpha angle (in radians)
  116377. * @param beta defines beta angle (in radians)
  116378. * @param radius defines radius
  116379. * @param target defines camera target
  116380. * @param interaxialDistance defines distance between each color axis
  116381. * @param scene defines the hosting scene
  116382. */
  116383. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  116384. /**
  116385. * Gets camera class name
  116386. * @returns AnaglyphArcRotateCamera
  116387. */
  116388. getClassName(): string;
  116389. }
  116390. }
  116391. declare module BABYLON {
  116392. /**
  116393. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  116394. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116395. */
  116396. export class AnaglyphFreeCamera extends FreeCamera {
  116397. /**
  116398. * Creates a new AnaglyphFreeCamera
  116399. * @param name defines camera name
  116400. * @param position defines initial position
  116401. * @param interaxialDistance defines distance between each color axis
  116402. * @param scene defines the hosting scene
  116403. */
  116404. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116405. /**
  116406. * Gets camera class name
  116407. * @returns AnaglyphFreeCamera
  116408. */
  116409. getClassName(): string;
  116410. }
  116411. }
  116412. declare module BABYLON {
  116413. /**
  116414. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  116415. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116416. */
  116417. export class AnaglyphGamepadCamera extends GamepadCamera {
  116418. /**
  116419. * Creates a new AnaglyphGamepadCamera
  116420. * @param name defines camera name
  116421. * @param position defines initial position
  116422. * @param interaxialDistance defines distance between each color axis
  116423. * @param scene defines the hosting scene
  116424. */
  116425. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116426. /**
  116427. * Gets camera class name
  116428. * @returns AnaglyphGamepadCamera
  116429. */
  116430. getClassName(): string;
  116431. }
  116432. }
  116433. declare module BABYLON {
  116434. /**
  116435. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  116436. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116437. */
  116438. export class AnaglyphUniversalCamera extends UniversalCamera {
  116439. /**
  116440. * Creates a new AnaglyphUniversalCamera
  116441. * @param name defines camera name
  116442. * @param position defines initial position
  116443. * @param interaxialDistance defines distance between each color axis
  116444. * @param scene defines the hosting scene
  116445. */
  116446. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116447. /**
  116448. * Gets camera class name
  116449. * @returns AnaglyphUniversalCamera
  116450. */
  116451. getClassName(): string;
  116452. }
  116453. }
  116454. declare module BABYLON {
  116455. /** @hidden */
  116456. export var stereoscopicInterlacePixelShader: {
  116457. name: string;
  116458. shader: string;
  116459. };
  116460. }
  116461. declare module BABYLON {
  116462. /**
  116463. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  116464. */
  116465. export class StereoscopicInterlacePostProcessI extends PostProcess {
  116466. private _stepSize;
  116467. private _passedProcess;
  116468. /**
  116469. * Initializes a StereoscopicInterlacePostProcessI
  116470. * @param name The name of the effect.
  116471. * @param rigCameras The rig cameras to be appled to the post process
  116472. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  116473. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  116474. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116475. * @param engine The engine which the post process will be applied. (default: current engine)
  116476. * @param reusable If the post process can be reused on the same frame. (default: false)
  116477. */
  116478. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116479. }
  116480. /**
  116481. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  116482. */
  116483. export class StereoscopicInterlacePostProcess extends PostProcess {
  116484. private _stepSize;
  116485. private _passedProcess;
  116486. /**
  116487. * Initializes a StereoscopicInterlacePostProcess
  116488. * @param name The name of the effect.
  116489. * @param rigCameras The rig cameras to be appled to the post process
  116490. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  116491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116492. * @param engine The engine which the post process will be applied. (default: current engine)
  116493. * @param reusable If the post process can be reused on the same frame. (default: false)
  116494. */
  116495. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116496. }
  116497. }
  116498. declare module BABYLON {
  116499. /**
  116500. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  116501. * @see http://doc.babylonjs.com/features/cameras
  116502. */
  116503. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  116504. /**
  116505. * Creates a new StereoscopicArcRotateCamera
  116506. * @param name defines camera name
  116507. * @param alpha defines alpha angle (in radians)
  116508. * @param beta defines beta angle (in radians)
  116509. * @param radius defines radius
  116510. * @param target defines camera target
  116511. * @param interaxialDistance defines distance between each color axis
  116512. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116513. * @param scene defines the hosting scene
  116514. */
  116515. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116516. /**
  116517. * Gets camera class name
  116518. * @returns StereoscopicArcRotateCamera
  116519. */
  116520. getClassName(): string;
  116521. }
  116522. }
  116523. declare module BABYLON {
  116524. /**
  116525. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  116526. * @see http://doc.babylonjs.com/features/cameras
  116527. */
  116528. export class StereoscopicFreeCamera extends FreeCamera {
  116529. /**
  116530. * Creates a new StereoscopicFreeCamera
  116531. * @param name defines camera name
  116532. * @param position defines initial position
  116533. * @param interaxialDistance defines distance between each color axis
  116534. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116535. * @param scene defines the hosting scene
  116536. */
  116537. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116538. /**
  116539. * Gets camera class name
  116540. * @returns StereoscopicFreeCamera
  116541. */
  116542. getClassName(): string;
  116543. }
  116544. }
  116545. declare module BABYLON {
  116546. /**
  116547. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  116548. * @see http://doc.babylonjs.com/features/cameras
  116549. */
  116550. export class StereoscopicGamepadCamera extends GamepadCamera {
  116551. /**
  116552. * Creates a new StereoscopicGamepadCamera
  116553. * @param name defines camera name
  116554. * @param position defines initial position
  116555. * @param interaxialDistance defines distance between each color axis
  116556. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116557. * @param scene defines the hosting scene
  116558. */
  116559. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116560. /**
  116561. * Gets camera class name
  116562. * @returns StereoscopicGamepadCamera
  116563. */
  116564. getClassName(): string;
  116565. }
  116566. }
  116567. declare module BABYLON {
  116568. /**
  116569. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  116570. * @see http://doc.babylonjs.com/features/cameras
  116571. */
  116572. export class StereoscopicUniversalCamera extends UniversalCamera {
  116573. /**
  116574. * Creates a new StereoscopicUniversalCamera
  116575. * @param name defines camera name
  116576. * @param position defines initial position
  116577. * @param interaxialDistance defines distance between each color axis
  116578. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116579. * @param scene defines the hosting scene
  116580. */
  116581. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116582. /**
  116583. * Gets camera class name
  116584. * @returns StereoscopicUniversalCamera
  116585. */
  116586. getClassName(): string;
  116587. }
  116588. }
  116589. declare module BABYLON {
  116590. /**
  116591. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  116592. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116593. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116594. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116595. */
  116596. export class VirtualJoysticksCamera extends FreeCamera {
  116597. /**
  116598. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  116599. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116600. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116601. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116602. * @param name Define the name of the camera in the scene
  116603. * @param position Define the start position of the camera in the scene
  116604. * @param scene Define the scene the camera belongs to
  116605. */
  116606. constructor(name: string, position: Vector3, scene: Scene);
  116607. /**
  116608. * Gets the current object class name.
  116609. * @return the class name
  116610. */
  116611. getClassName(): string;
  116612. }
  116613. }
  116614. declare module BABYLON {
  116615. /**
  116616. * This represents all the required metrics to create a VR camera.
  116617. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  116618. */
  116619. export class VRCameraMetrics {
  116620. /**
  116621. * Define the horizontal resolution off the screen.
  116622. */
  116623. hResolution: number;
  116624. /**
  116625. * Define the vertical resolution off the screen.
  116626. */
  116627. vResolution: number;
  116628. /**
  116629. * Define the horizontal screen size.
  116630. */
  116631. hScreenSize: number;
  116632. /**
  116633. * Define the vertical screen size.
  116634. */
  116635. vScreenSize: number;
  116636. /**
  116637. * Define the vertical screen center position.
  116638. */
  116639. vScreenCenter: number;
  116640. /**
  116641. * Define the distance of the eyes to the screen.
  116642. */
  116643. eyeToScreenDistance: number;
  116644. /**
  116645. * Define the distance between both lenses
  116646. */
  116647. lensSeparationDistance: number;
  116648. /**
  116649. * Define the distance between both viewer's eyes.
  116650. */
  116651. interpupillaryDistance: number;
  116652. /**
  116653. * Define the distortion factor of the VR postprocess.
  116654. * Please, touch with care.
  116655. */
  116656. distortionK: number[];
  116657. /**
  116658. * Define the chromatic aberration correction factors for the VR post process.
  116659. */
  116660. chromaAbCorrection: number[];
  116661. /**
  116662. * Define the scale factor of the post process.
  116663. * The smaller the better but the slower.
  116664. */
  116665. postProcessScaleFactor: number;
  116666. /**
  116667. * Define an offset for the lens center.
  116668. */
  116669. lensCenterOffset: number;
  116670. /**
  116671. * Define if the current vr camera should compensate the distortion of the lense or not.
  116672. */
  116673. compensateDistortion: boolean;
  116674. /**
  116675. * Defines if multiview should be enabled when rendering (Default: false)
  116676. */
  116677. multiviewEnabled: boolean;
  116678. /**
  116679. * Gets the rendering aspect ratio based on the provided resolutions.
  116680. */
  116681. get aspectRatio(): number;
  116682. /**
  116683. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  116684. */
  116685. get aspectRatioFov(): number;
  116686. /**
  116687. * @hidden
  116688. */
  116689. get leftHMatrix(): Matrix;
  116690. /**
  116691. * @hidden
  116692. */
  116693. get rightHMatrix(): Matrix;
  116694. /**
  116695. * @hidden
  116696. */
  116697. get leftPreViewMatrix(): Matrix;
  116698. /**
  116699. * @hidden
  116700. */
  116701. get rightPreViewMatrix(): Matrix;
  116702. /**
  116703. * Get the default VRMetrics based on the most generic setup.
  116704. * @returns the default vr metrics
  116705. */
  116706. static GetDefault(): VRCameraMetrics;
  116707. }
  116708. }
  116709. declare module BABYLON {
  116710. /** @hidden */
  116711. export var vrDistortionCorrectionPixelShader: {
  116712. name: string;
  116713. shader: string;
  116714. };
  116715. }
  116716. declare module BABYLON {
  116717. /**
  116718. * VRDistortionCorrectionPostProcess used for mobile VR
  116719. */
  116720. export class VRDistortionCorrectionPostProcess extends PostProcess {
  116721. private _isRightEye;
  116722. private _distortionFactors;
  116723. private _postProcessScaleFactor;
  116724. private _lensCenterOffset;
  116725. private _scaleIn;
  116726. private _scaleFactor;
  116727. private _lensCenter;
  116728. /**
  116729. * Initializes the VRDistortionCorrectionPostProcess
  116730. * @param name The name of the effect.
  116731. * @param camera The camera to apply the render pass to.
  116732. * @param isRightEye If this is for the right eye distortion
  116733. * @param vrMetrics All the required metrics for the VR camera
  116734. */
  116735. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  116736. }
  116737. }
  116738. declare module BABYLON {
  116739. /**
  116740. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  116741. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116742. */
  116743. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  116744. /**
  116745. * Creates a new VRDeviceOrientationArcRotateCamera
  116746. * @param name defines camera name
  116747. * @param alpha defines the camera rotation along the logitudinal axis
  116748. * @param beta defines the camera rotation along the latitudinal axis
  116749. * @param radius defines the camera distance from its target
  116750. * @param target defines the camera target
  116751. * @param scene defines the scene the camera belongs to
  116752. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116753. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116754. */
  116755. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116756. /**
  116757. * Gets camera class name
  116758. * @returns VRDeviceOrientationArcRotateCamera
  116759. */
  116760. getClassName(): string;
  116761. }
  116762. }
  116763. declare module BABYLON {
  116764. /**
  116765. * Camera used to simulate VR rendering (based on FreeCamera)
  116766. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116767. */
  116768. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  116769. /**
  116770. * Creates a new VRDeviceOrientationFreeCamera
  116771. * @param name defines camera name
  116772. * @param position defines the start position of the camera
  116773. * @param scene defines the scene the camera belongs to
  116774. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116775. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116776. */
  116777. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116778. /**
  116779. * Gets camera class name
  116780. * @returns VRDeviceOrientationFreeCamera
  116781. */
  116782. getClassName(): string;
  116783. }
  116784. }
  116785. declare module BABYLON {
  116786. /**
  116787. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  116788. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116789. */
  116790. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  116791. /**
  116792. * Creates a new VRDeviceOrientationGamepadCamera
  116793. * @param name defines camera name
  116794. * @param position defines the start position of the camera
  116795. * @param scene defines the scene the camera belongs to
  116796. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116797. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116798. */
  116799. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116800. /**
  116801. * Gets camera class name
  116802. * @returns VRDeviceOrientationGamepadCamera
  116803. */
  116804. getClassName(): string;
  116805. }
  116806. }
  116807. declare module BABYLON {
  116808. /** @hidden */
  116809. export var imageProcessingPixelShader: {
  116810. name: string;
  116811. shader: string;
  116812. };
  116813. }
  116814. declare module BABYLON {
  116815. /**
  116816. * ImageProcessingPostProcess
  116817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116818. */
  116819. export class ImageProcessingPostProcess extends PostProcess {
  116820. /**
  116821. * Default configuration related to image processing available in the PBR Material.
  116822. */
  116823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116824. /**
  116825. * Gets the image processing configuration used either in this material.
  116826. */
  116827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116828. /**
  116829. * Sets the Default image processing configuration used either in the this material.
  116830. *
  116831. * If sets to null, the scene one is in use.
  116832. */
  116833. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  116834. /**
  116835. * Keep track of the image processing observer to allow dispose and replace.
  116836. */
  116837. private _imageProcessingObserver;
  116838. /**
  116839. * Attaches a new image processing configuration to the PBR Material.
  116840. * @param configuration
  116841. */
  116842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  116843. /**
  116844. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116845. */
  116846. get colorCurves(): Nullable<ColorCurves>;
  116847. /**
  116848. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116849. */
  116850. set colorCurves(value: Nullable<ColorCurves>);
  116851. /**
  116852. * Gets wether the color curves effect is enabled.
  116853. */
  116854. get colorCurvesEnabled(): boolean;
  116855. /**
  116856. * Sets wether the color curves effect is enabled.
  116857. */
  116858. set colorCurvesEnabled(value: boolean);
  116859. /**
  116860. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116861. */
  116862. get colorGradingTexture(): Nullable<BaseTexture>;
  116863. /**
  116864. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116865. */
  116866. set colorGradingTexture(value: Nullable<BaseTexture>);
  116867. /**
  116868. * Gets wether the color grading effect is enabled.
  116869. */
  116870. get colorGradingEnabled(): boolean;
  116871. /**
  116872. * Gets wether the color grading effect is enabled.
  116873. */
  116874. set colorGradingEnabled(value: boolean);
  116875. /**
  116876. * Gets exposure used in the effect.
  116877. */
  116878. get exposure(): number;
  116879. /**
  116880. * Sets exposure used in the effect.
  116881. */
  116882. set exposure(value: number);
  116883. /**
  116884. * Gets wether tonemapping is enabled or not.
  116885. */
  116886. get toneMappingEnabled(): boolean;
  116887. /**
  116888. * Sets wether tonemapping is enabled or not
  116889. */
  116890. set toneMappingEnabled(value: boolean);
  116891. /**
  116892. * Gets the type of tone mapping effect.
  116893. */
  116894. get toneMappingType(): number;
  116895. /**
  116896. * Sets the type of tone mapping effect.
  116897. */
  116898. set toneMappingType(value: number);
  116899. /**
  116900. * Gets contrast used in the effect.
  116901. */
  116902. get contrast(): number;
  116903. /**
  116904. * Sets contrast used in the effect.
  116905. */
  116906. set contrast(value: number);
  116907. /**
  116908. * Gets Vignette stretch size.
  116909. */
  116910. get vignetteStretch(): number;
  116911. /**
  116912. * Sets Vignette stretch size.
  116913. */
  116914. set vignetteStretch(value: number);
  116915. /**
  116916. * Gets Vignette centre X Offset.
  116917. */
  116918. get vignetteCentreX(): number;
  116919. /**
  116920. * Sets Vignette centre X Offset.
  116921. */
  116922. set vignetteCentreX(value: number);
  116923. /**
  116924. * Gets Vignette centre Y Offset.
  116925. */
  116926. get vignetteCentreY(): number;
  116927. /**
  116928. * Sets Vignette centre Y Offset.
  116929. */
  116930. set vignetteCentreY(value: number);
  116931. /**
  116932. * Gets Vignette weight or intensity of the vignette effect.
  116933. */
  116934. get vignetteWeight(): number;
  116935. /**
  116936. * Sets Vignette weight or intensity of the vignette effect.
  116937. */
  116938. set vignetteWeight(value: number);
  116939. /**
  116940. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116941. * if vignetteEnabled is set to true.
  116942. */
  116943. get vignetteColor(): Color4;
  116944. /**
  116945. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116946. * if vignetteEnabled is set to true.
  116947. */
  116948. set vignetteColor(value: Color4);
  116949. /**
  116950. * Gets Camera field of view used by the Vignette effect.
  116951. */
  116952. get vignetteCameraFov(): number;
  116953. /**
  116954. * Sets Camera field of view used by the Vignette effect.
  116955. */
  116956. set vignetteCameraFov(value: number);
  116957. /**
  116958. * Gets the vignette blend mode allowing different kind of effect.
  116959. */
  116960. get vignetteBlendMode(): number;
  116961. /**
  116962. * Sets the vignette blend mode allowing different kind of effect.
  116963. */
  116964. set vignetteBlendMode(value: number);
  116965. /**
  116966. * Gets wether the vignette effect is enabled.
  116967. */
  116968. get vignetteEnabled(): boolean;
  116969. /**
  116970. * Sets wether the vignette effect is enabled.
  116971. */
  116972. set vignetteEnabled(value: boolean);
  116973. private _fromLinearSpace;
  116974. /**
  116975. * Gets wether the input of the processing is in Gamma or Linear Space.
  116976. */
  116977. get fromLinearSpace(): boolean;
  116978. /**
  116979. * Sets wether the input of the processing is in Gamma or Linear Space.
  116980. */
  116981. set fromLinearSpace(value: boolean);
  116982. /**
  116983. * Defines cache preventing GC.
  116984. */
  116985. private _defines;
  116986. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  116987. /**
  116988. * "ImageProcessingPostProcess"
  116989. * @returns "ImageProcessingPostProcess"
  116990. */
  116991. getClassName(): string;
  116992. protected _updateParameters(): void;
  116993. dispose(camera?: Camera): void;
  116994. }
  116995. }
  116996. declare module BABYLON {
  116997. /**
  116998. * Class containing static functions to help procedurally build meshes
  116999. */
  117000. export class GroundBuilder {
  117001. /**
  117002. * Creates a ground mesh
  117003. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117004. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117006. * @param name defines the name of the mesh
  117007. * @param options defines the options used to create the mesh
  117008. * @param scene defines the hosting scene
  117009. * @returns the ground mesh
  117010. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117011. */
  117012. static CreateGround(name: string, options: {
  117013. width?: number;
  117014. height?: number;
  117015. subdivisions?: number;
  117016. subdivisionsX?: number;
  117017. subdivisionsY?: number;
  117018. updatable?: boolean;
  117019. }, scene: any): Mesh;
  117020. /**
  117021. * Creates a tiled ground mesh
  117022. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117023. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117024. * * 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
  117025. * * 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
  117026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117027. * @param name defines the name of the mesh
  117028. * @param options defines the options used to create the mesh
  117029. * @param scene defines the hosting scene
  117030. * @returns the tiled ground mesh
  117031. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117032. */
  117033. static CreateTiledGround(name: string, options: {
  117034. xmin: number;
  117035. zmin: number;
  117036. xmax: number;
  117037. zmax: number;
  117038. subdivisions?: {
  117039. w: number;
  117040. h: number;
  117041. };
  117042. precision?: {
  117043. w: number;
  117044. h: number;
  117045. };
  117046. updatable?: boolean;
  117047. }, scene?: Nullable<Scene>): Mesh;
  117048. /**
  117049. * Creates a ground mesh from a height map
  117050. * * The parameter `url` sets the URL of the height map image resource.
  117051. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117052. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117053. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117054. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117055. * * 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.
  117056. * * 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).
  117057. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117059. * @param name defines the name of the mesh
  117060. * @param url defines the url to the height map
  117061. * @param options defines the options used to create the mesh
  117062. * @param scene defines the hosting scene
  117063. * @returns the ground mesh
  117064. * @see https://doc.babylonjs.com/babylon101/height_map
  117065. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117066. */
  117067. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117068. width?: number;
  117069. height?: number;
  117070. subdivisions?: number;
  117071. minHeight?: number;
  117072. maxHeight?: number;
  117073. colorFilter?: Color3;
  117074. alphaFilter?: number;
  117075. updatable?: boolean;
  117076. onReady?: (mesh: GroundMesh) => void;
  117077. }, scene?: Nullable<Scene>): GroundMesh;
  117078. }
  117079. }
  117080. declare module BABYLON {
  117081. /**
  117082. * Class containing static functions to help procedurally build meshes
  117083. */
  117084. export class TorusBuilder {
  117085. /**
  117086. * Creates a torus mesh
  117087. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117088. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117089. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117090. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117091. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117093. * @param name defines the name of the mesh
  117094. * @param options defines the options used to create the mesh
  117095. * @param scene defines the hosting scene
  117096. * @returns the torus mesh
  117097. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117098. */
  117099. static CreateTorus(name: string, options: {
  117100. diameter?: number;
  117101. thickness?: number;
  117102. tessellation?: number;
  117103. updatable?: boolean;
  117104. sideOrientation?: number;
  117105. frontUVs?: Vector4;
  117106. backUVs?: Vector4;
  117107. }, scene: any): Mesh;
  117108. }
  117109. }
  117110. declare module BABYLON {
  117111. /**
  117112. * Class containing static functions to help procedurally build meshes
  117113. */
  117114. export class CylinderBuilder {
  117115. /**
  117116. * Creates a cylinder or a cone mesh
  117117. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117118. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117119. * * 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.
  117120. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117121. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117122. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117123. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117124. * * 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).
  117125. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117126. * * 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).
  117127. * * 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
  117128. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117129. * * 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
  117130. * * 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.
  117131. * * If `enclose` is false, a ring surface is one element.
  117132. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117133. * * 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
  117134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117137. * @param name defines the name of the mesh
  117138. * @param options defines the options used to create the mesh
  117139. * @param scene defines the hosting scene
  117140. * @returns the cylinder mesh
  117141. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117142. */
  117143. static CreateCylinder(name: string, options: {
  117144. height?: number;
  117145. diameterTop?: number;
  117146. diameterBottom?: number;
  117147. diameter?: number;
  117148. tessellation?: number;
  117149. subdivisions?: number;
  117150. arc?: number;
  117151. faceColors?: Color4[];
  117152. faceUV?: Vector4[];
  117153. updatable?: boolean;
  117154. hasRings?: boolean;
  117155. enclose?: boolean;
  117156. cap?: number;
  117157. sideOrientation?: number;
  117158. frontUVs?: Vector4;
  117159. backUVs?: Vector4;
  117160. }, scene: any): Mesh;
  117161. }
  117162. }
  117163. declare module BABYLON {
  117164. /**
  117165. * States of the webXR experience
  117166. */
  117167. export enum WebXRState {
  117168. /**
  117169. * Transitioning to being in XR mode
  117170. */
  117171. ENTERING_XR = 0,
  117172. /**
  117173. * Transitioning to non XR mode
  117174. */
  117175. EXITING_XR = 1,
  117176. /**
  117177. * In XR mode and presenting
  117178. */
  117179. IN_XR = 2,
  117180. /**
  117181. * Not entered XR mode
  117182. */
  117183. NOT_IN_XR = 3
  117184. }
  117185. /**
  117186. * Abstraction of the XR render target
  117187. */
  117188. export interface WebXRRenderTarget extends IDisposable {
  117189. /**
  117190. * xrpresent context of the canvas which can be used to display/mirror xr content
  117191. */
  117192. canvasContext: WebGLRenderingContext;
  117193. /**
  117194. * xr layer for the canvas
  117195. */
  117196. xrLayer: Nullable<XRWebGLLayer>;
  117197. /**
  117198. * Initializes the xr layer for the session
  117199. * @param xrSession xr session
  117200. * @returns a promise that will resolve once the XR Layer has been created
  117201. */
  117202. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117203. }
  117204. }
  117205. declare module BABYLON {
  117206. /**
  117207. * COnfiguration object for WebXR output canvas
  117208. */
  117209. export class WebXRManagedOutputCanvasOptions {
  117210. /**
  117211. * An optional canvas in case you wish to create it yourself and provide it here.
  117212. * If not provided, a new canvas will be created
  117213. */
  117214. canvasElement?: HTMLCanvasElement;
  117215. /**
  117216. * Options for this XR Layer output
  117217. */
  117218. canvasOptions?: XRWebGLLayerOptions;
  117219. /**
  117220. * CSS styling for a newly created canvas (if not provided)
  117221. */
  117222. newCanvasCssStyle?: string;
  117223. /**
  117224. * Get the default values of the configuration object
  117225. * @returns default values of this configuration object
  117226. */
  117227. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  117228. }
  117229. /**
  117230. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  117231. */
  117232. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  117233. private _options;
  117234. private _canvas;
  117235. private _engine;
  117236. /**
  117237. * Rendering context of the canvas which can be used to display/mirror xr content
  117238. */
  117239. canvasContext: WebGLRenderingContext;
  117240. /**
  117241. * xr layer for the canvas
  117242. */
  117243. xrLayer: Nullable<XRWebGLLayer>;
  117244. /**
  117245. * Initializes the canvas to be added/removed upon entering/exiting xr
  117246. * @param _xrSessionManager The XR Session manager
  117247. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  117248. */
  117249. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  117250. /**
  117251. * Disposes of the object
  117252. */
  117253. dispose(): void;
  117254. /**
  117255. * Initializes the xr layer for the session
  117256. * @param xrSession xr session
  117257. * @returns a promise that will resolve once the XR Layer has been created
  117258. */
  117259. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117260. private _addCanvas;
  117261. private _removeCanvas;
  117262. private _setManagedOutputCanvas;
  117263. }
  117264. }
  117265. declare module BABYLON {
  117266. /**
  117267. * Manages an XRSession to work with Babylon's engine
  117268. * @see https://doc.babylonjs.com/how_to/webxr
  117269. */
  117270. export class WebXRSessionManager implements IDisposable {
  117271. /** The scene which the session should be created for */
  117272. scene: Scene;
  117273. private _referenceSpace;
  117274. private _rttProvider;
  117275. private _sessionEnded;
  117276. private _xrNavigator;
  117277. private baseLayer;
  117278. /**
  117279. * The base reference space from which the session started. good if you want to reset your
  117280. * reference space
  117281. */
  117282. baseReferenceSpace: XRReferenceSpace;
  117283. /**
  117284. * Current XR frame
  117285. */
  117286. currentFrame: Nullable<XRFrame>;
  117287. /** WebXR timestamp updated every frame */
  117288. currentTimestamp: number;
  117289. /**
  117290. * Used just in case of a failure to initialize an immersive session.
  117291. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  117292. */
  117293. defaultHeightCompensation: number;
  117294. /**
  117295. * Fires every time a new xrFrame arrives which can be used to update the camera
  117296. */
  117297. onXRFrameObservable: Observable<XRFrame>;
  117298. /**
  117299. * Fires when the reference space changed
  117300. */
  117301. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  117302. /**
  117303. * Fires when the xr session is ended either by the device or manually done
  117304. */
  117305. onXRSessionEnded: Observable<any>;
  117306. /**
  117307. * Fires when the xr session is ended either by the device or manually done
  117308. */
  117309. onXRSessionInit: Observable<XRSession>;
  117310. /**
  117311. * Underlying xr session
  117312. */
  117313. session: XRSession;
  117314. /**
  117315. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  117316. * or get the offset the player is currently at.
  117317. */
  117318. viewerReferenceSpace: XRReferenceSpace;
  117319. /**
  117320. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  117321. * @param scene The scene which the session should be created for
  117322. */
  117323. constructor(
  117324. /** The scene which the session should be created for */
  117325. scene: Scene);
  117326. /**
  117327. * The current reference space used in this session. This reference space can constantly change!
  117328. * It is mainly used to offset the camera's position.
  117329. */
  117330. get referenceSpace(): XRReferenceSpace;
  117331. /**
  117332. * Set a new reference space and triggers the observable
  117333. */
  117334. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  117335. /**
  117336. * Disposes of the session manager
  117337. */
  117338. dispose(): void;
  117339. /**
  117340. * Stops the xrSession and restores the render loop
  117341. * @returns Promise which resolves after it exits XR
  117342. */
  117343. exitXRAsync(): Promise<void>;
  117344. /**
  117345. * Gets the correct render target texture to be rendered this frame for this eye
  117346. * @param eye the eye for which to get the render target
  117347. * @returns the render target for the specified eye
  117348. */
  117349. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  117350. /**
  117351. * Creates a WebXRRenderTarget object for the XR session
  117352. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  117353. * @param options optional options to provide when creating a new render target
  117354. * @returns a WebXR render target to which the session can render
  117355. */
  117356. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  117357. /**
  117358. * Initializes the manager
  117359. * After initialization enterXR can be called to start an XR session
  117360. * @returns Promise which resolves after it is initialized
  117361. */
  117362. initializeAsync(): Promise<void>;
  117363. /**
  117364. * Initializes an xr session
  117365. * @param xrSessionMode mode to initialize
  117366. * @param xrSessionInit defines optional and required values to pass to the session builder
  117367. * @returns a promise which will resolve once the session has been initialized
  117368. */
  117369. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  117370. /**
  117371. * Checks if a session would be supported for the creation options specified
  117372. * @param sessionMode session mode to check if supported eg. immersive-vr
  117373. * @returns A Promise that resolves to true if supported and false if not
  117374. */
  117375. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117376. /**
  117377. * Resets the reference space to the one started the session
  117378. */
  117379. resetReferenceSpace(): void;
  117380. /**
  117381. * Starts rendering to the xr layer
  117382. */
  117383. runXRRenderLoop(): void;
  117384. /**
  117385. * Sets the reference space on the xr session
  117386. * @param referenceSpaceType space to set
  117387. * @returns a promise that will resolve once the reference space has been set
  117388. */
  117389. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  117390. /**
  117391. * Updates the render state of the session
  117392. * @param state state to set
  117393. * @returns a promise that resolves once the render state has been updated
  117394. */
  117395. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  117396. /**
  117397. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  117398. * @param sessionMode defines the session to test
  117399. * @returns a promise with boolean as final value
  117400. */
  117401. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117402. private _createRenderTargetTexture;
  117403. }
  117404. }
  117405. declare module BABYLON {
  117406. /**
  117407. * WebXR Camera which holds the views for the xrSession
  117408. * @see https://doc.babylonjs.com/how_to/webxr_camera
  117409. */
  117410. export class WebXRCamera extends FreeCamera {
  117411. private _xrSessionManager;
  117412. private _firstFrame;
  117413. private _referenceQuaternion;
  117414. private _referencedPosition;
  117415. private _xrInvPositionCache;
  117416. private _xrInvQuaternionCache;
  117417. /**
  117418. * Should position compensation execute on first frame.
  117419. * This is used when copying the position from a native (non XR) camera
  117420. */
  117421. compensateOnFirstFrame: boolean;
  117422. /**
  117423. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  117424. * @param name the name of the camera
  117425. * @param scene the scene to add the camera to
  117426. * @param _xrSessionManager a constructed xr session manager
  117427. */
  117428. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  117429. /**
  117430. * Return the user's height, unrelated to the current ground.
  117431. * This will be the y position of this camera, when ground level is 0.
  117432. */
  117433. get realWorldHeight(): number;
  117434. /** @hidden */
  117435. _updateForDualEyeDebugging(): void;
  117436. /**
  117437. * Sets this camera's transformation based on a non-vr camera
  117438. * @param otherCamera the non-vr camera to copy the transformation from
  117439. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  117440. */
  117441. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  117442. /**
  117443. * Gets the current instance class name ("WebXRCamera").
  117444. * @returns the class name
  117445. */
  117446. getClassName(): string;
  117447. private _updateFromXRSession;
  117448. private _updateNumberOfRigCameras;
  117449. private _updateReferenceSpace;
  117450. private _updateReferenceSpaceOffset;
  117451. }
  117452. }
  117453. declare module BABYLON {
  117454. /**
  117455. * Defining the interface required for a (webxr) feature
  117456. */
  117457. export interface IWebXRFeature extends IDisposable {
  117458. /**
  117459. * Is this feature attached
  117460. */
  117461. attached: boolean;
  117462. /**
  117463. * Should auto-attach be disabled?
  117464. */
  117465. disableAutoAttach: boolean;
  117466. /**
  117467. * Attach the feature to the session
  117468. * Will usually be called by the features manager
  117469. *
  117470. * @param force should attachment be forced (even when already attached)
  117471. * @returns true if successful.
  117472. */
  117473. attach(force?: boolean): boolean;
  117474. /**
  117475. * Detach the feature from the session
  117476. * Will usually be called by the features manager
  117477. *
  117478. * @returns true if successful.
  117479. */
  117480. detach(): boolean;
  117481. }
  117482. /**
  117483. * A list of the currently available features without referencing them
  117484. */
  117485. export class WebXRFeatureName {
  117486. /**
  117487. * The name of the anchor system feature
  117488. */
  117489. static ANCHOR_SYSTEM: string;
  117490. /**
  117491. * The name of the background remover feature
  117492. */
  117493. static BACKGROUND_REMOVER: string;
  117494. /**
  117495. * The name of the hit test feature
  117496. */
  117497. static HIT_TEST: string;
  117498. /**
  117499. * physics impostors for xr controllers feature
  117500. */
  117501. static PHYSICS_CONTROLLERS: string;
  117502. /**
  117503. * The name of the plane detection feature
  117504. */
  117505. static PLANE_DETECTION: string;
  117506. /**
  117507. * The name of the pointer selection feature
  117508. */
  117509. static POINTER_SELECTION: string;
  117510. /**
  117511. * The name of the teleportation feature
  117512. */
  117513. static TELEPORTATION: string;
  117514. }
  117515. /**
  117516. * Defining the constructor of a feature. Used to register the modules.
  117517. */
  117518. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  117519. /**
  117520. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  117521. * It is mainly used in AR sessions.
  117522. *
  117523. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  117524. */
  117525. export class WebXRFeaturesManager implements IDisposable {
  117526. private _xrSessionManager;
  117527. private static readonly _AvailableFeatures;
  117528. private _features;
  117529. /**
  117530. * constructs a new features manages.
  117531. *
  117532. * @param _xrSessionManager an instance of WebXRSessionManager
  117533. */
  117534. constructor(_xrSessionManager: WebXRSessionManager);
  117535. /**
  117536. * Used to register a module. After calling this function a developer can use this feature in the scene.
  117537. * Mainly used internally.
  117538. *
  117539. * @param featureName the name of the feature to register
  117540. * @param constructorFunction the function used to construct the module
  117541. * @param version the (babylon) version of the module
  117542. * @param stable is that a stable version of this module
  117543. */
  117544. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  117545. /**
  117546. * Returns a constructor of a specific feature.
  117547. *
  117548. * @param featureName the name of the feature to construct
  117549. * @param version the version of the feature to load
  117550. * @param xrSessionManager the xrSessionManager. Used to construct the module
  117551. * @param options optional options provided to the module.
  117552. * @returns a function that, when called, will return a new instance of this feature
  117553. */
  117554. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  117555. /**
  117556. * Can be used to return the list of features currently registered
  117557. *
  117558. * @returns an Array of available features
  117559. */
  117560. static GetAvailableFeatures(): string[];
  117561. /**
  117562. * Gets the versions available for a specific feature
  117563. * @param featureName the name of the feature
  117564. * @returns an array with the available versions
  117565. */
  117566. static GetAvailableVersions(featureName: string): string[];
  117567. /**
  117568. * Return the latest unstable version of this feature
  117569. * @param featureName the name of the feature to search
  117570. * @returns the version number. if not found will return -1
  117571. */
  117572. static GetLatestVersionOfFeature(featureName: string): number;
  117573. /**
  117574. * Return the latest stable version of this feature
  117575. * @param featureName the name of the feature to search
  117576. * @returns the version number. if not found will return -1
  117577. */
  117578. static GetStableVersionOfFeature(featureName: string): number;
  117579. /**
  117580. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  117581. * Can be used during a session to start a feature
  117582. * @param featureName the name of feature to attach
  117583. */
  117584. attachFeature(featureName: string): void;
  117585. /**
  117586. * Can be used inside a session or when the session ends to detach a specific feature
  117587. * @param featureName the name of the feature to detach
  117588. */
  117589. detachFeature(featureName: string): void;
  117590. /**
  117591. * Used to disable an already-enabled feature
  117592. * The feature will be disposed and will be recreated once enabled.
  117593. * @param featureName the feature to disable
  117594. * @returns true if disable was successful
  117595. */
  117596. disableFeature(featureName: string | {
  117597. Name: string;
  117598. }): boolean;
  117599. /**
  117600. * dispose this features manager
  117601. */
  117602. dispose(): void;
  117603. /**
  117604. * 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.
  117605. * 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.
  117606. *
  117607. * @param featureName the name of the feature to load or the class of the feature
  117608. * @param version optional version to load. if not provided the latest version will be enabled
  117609. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  117610. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  117611. * @returns a new constructed feature or throws an error if feature not found.
  117612. */
  117613. enableFeature(featureName: string | {
  117614. Name: string;
  117615. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  117616. /**
  117617. * get the implementation of an enabled feature.
  117618. * @param featureName the name of the feature to load
  117619. * @returns the feature class, if found
  117620. */
  117621. getEnabledFeature(featureName: string): IWebXRFeature;
  117622. /**
  117623. * Get the list of enabled features
  117624. * @returns an array of enabled features
  117625. */
  117626. getEnabledFeatures(): string[];
  117627. }
  117628. }
  117629. declare module BABYLON {
  117630. /**
  117631. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  117632. * @see https://doc.babylonjs.com/how_to/webxr
  117633. */
  117634. export class WebXRExperienceHelper implements IDisposable {
  117635. private scene;
  117636. private _nonVRCamera;
  117637. private _originalSceneAutoClear;
  117638. private _supported;
  117639. /**
  117640. * Camera used to render xr content
  117641. */
  117642. camera: WebXRCamera;
  117643. /** A features manager for this xr session */
  117644. featuresManager: WebXRFeaturesManager;
  117645. /**
  117646. * Observers registered here will be triggered after the camera's initial transformation is set
  117647. * This can be used to set a different ground level or an extra rotation.
  117648. *
  117649. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  117650. * to the position set after this observable is done executing.
  117651. */
  117652. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  117653. /**
  117654. * Fires when the state of the experience helper has changed
  117655. */
  117656. onStateChangedObservable: Observable<WebXRState>;
  117657. /** Session manager used to keep track of xr session */
  117658. sessionManager: WebXRSessionManager;
  117659. /**
  117660. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  117661. */
  117662. state: WebXRState;
  117663. /**
  117664. * Creates a WebXRExperienceHelper
  117665. * @param scene The scene the helper should be created in
  117666. */
  117667. private constructor();
  117668. /**
  117669. * Creates the experience helper
  117670. * @param scene the scene to attach the experience helper to
  117671. * @returns a promise for the experience helper
  117672. */
  117673. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  117674. /**
  117675. * Disposes of the experience helper
  117676. */
  117677. dispose(): void;
  117678. /**
  117679. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  117680. * @param sessionMode options for the XR session
  117681. * @param referenceSpaceType frame of reference of the XR session
  117682. * @param renderTarget the output canvas that will be used to enter XR mode
  117683. * @returns promise that resolves after xr mode has entered
  117684. */
  117685. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  117686. /**
  117687. * Exits XR mode and returns the scene to its original state
  117688. * @returns promise that resolves after xr mode has exited
  117689. */
  117690. exitXRAsync(): Promise<void>;
  117691. private _nonXRToXRCamera;
  117692. private _setState;
  117693. }
  117694. }
  117695. declare module BABYLON {
  117696. /**
  117697. * X-Y values for axes in WebXR
  117698. */
  117699. export interface IWebXRMotionControllerAxesValue {
  117700. /**
  117701. * The value of the x axis
  117702. */
  117703. x: number;
  117704. /**
  117705. * The value of the y-axis
  117706. */
  117707. y: number;
  117708. }
  117709. /**
  117710. * changed / previous values for the values of this component
  117711. */
  117712. export interface IWebXRMotionControllerComponentChangesValues<T> {
  117713. /**
  117714. * current (this frame) value
  117715. */
  117716. current: T;
  117717. /**
  117718. * previous (last change) value
  117719. */
  117720. previous: T;
  117721. }
  117722. /**
  117723. * Represents changes in the component between current frame and last values recorded
  117724. */
  117725. export interface IWebXRMotionControllerComponentChanges {
  117726. /**
  117727. * will be populated with previous and current values if axes changed
  117728. */
  117729. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  117730. /**
  117731. * will be populated with previous and current values if pressed changed
  117732. */
  117733. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117734. /**
  117735. * will be populated with previous and current values if touched changed
  117736. */
  117737. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117738. /**
  117739. * will be populated with previous and current values if value changed
  117740. */
  117741. value?: IWebXRMotionControllerComponentChangesValues<number>;
  117742. }
  117743. /**
  117744. * This class represents a single component (for example button or thumbstick) of a motion controller
  117745. */
  117746. export class WebXRControllerComponent implements IDisposable {
  117747. /**
  117748. * the id of this component
  117749. */
  117750. id: string;
  117751. /**
  117752. * the type of the component
  117753. */
  117754. type: MotionControllerComponentType;
  117755. private _buttonIndex;
  117756. private _axesIndices;
  117757. private _axes;
  117758. private _changes;
  117759. private _currentValue;
  117760. private _hasChanges;
  117761. private _pressed;
  117762. private _touched;
  117763. /**
  117764. * button component type
  117765. */
  117766. static BUTTON_TYPE: MotionControllerComponentType;
  117767. /**
  117768. * squeeze component type
  117769. */
  117770. static SQUEEZE_TYPE: MotionControllerComponentType;
  117771. /**
  117772. * Thumbstick component type
  117773. */
  117774. static THUMBSTICK_TYPE: MotionControllerComponentType;
  117775. /**
  117776. * Touchpad component type
  117777. */
  117778. static TOUCHPAD_TYPE: MotionControllerComponentType;
  117779. /**
  117780. * trigger component type
  117781. */
  117782. static TRIGGER_TYPE: MotionControllerComponentType;
  117783. /**
  117784. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  117785. * the axes data changes
  117786. */
  117787. onAxisValueChangedObservable: Observable<{
  117788. x: number;
  117789. y: number;
  117790. }>;
  117791. /**
  117792. * Observers registered here will be triggered when the state of a button changes
  117793. * State change is either pressed / touched / value
  117794. */
  117795. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  117796. /**
  117797. * Creates a new component for a motion controller.
  117798. * It is created by the motion controller itself
  117799. *
  117800. * @param id the id of this component
  117801. * @param type the type of the component
  117802. * @param _buttonIndex index in the buttons array of the gamepad
  117803. * @param _axesIndices indices of the values in the axes array of the gamepad
  117804. */
  117805. constructor(
  117806. /**
  117807. * the id of this component
  117808. */
  117809. id: string,
  117810. /**
  117811. * the type of the component
  117812. */
  117813. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  117814. /**
  117815. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  117816. */
  117817. get axes(): IWebXRMotionControllerAxesValue;
  117818. /**
  117819. * Get the changes. Elements will be populated only if they changed with their previous and current value
  117820. */
  117821. get changes(): IWebXRMotionControllerComponentChanges;
  117822. /**
  117823. * Return whether or not the component changed the last frame
  117824. */
  117825. get hasChanges(): boolean;
  117826. /**
  117827. * is the button currently pressed
  117828. */
  117829. get pressed(): boolean;
  117830. /**
  117831. * is the button currently touched
  117832. */
  117833. get touched(): boolean;
  117834. /**
  117835. * Get the current value of this component
  117836. */
  117837. get value(): number;
  117838. /**
  117839. * Dispose this component
  117840. */
  117841. dispose(): void;
  117842. /**
  117843. * Are there axes correlating to this component
  117844. * @return true is axes data is available
  117845. */
  117846. isAxes(): boolean;
  117847. /**
  117848. * Is this component a button (hence - pressable)
  117849. * @returns true if can be pressed
  117850. */
  117851. isButton(): boolean;
  117852. /**
  117853. * update this component using the gamepad object it is in. Called on every frame
  117854. * @param nativeController the native gamepad controller object
  117855. */
  117856. update(nativeController: IMinimalMotionControllerObject): void;
  117857. }
  117858. }
  117859. declare module BABYLON {
  117860. /**
  117861. * Class used to represent data loading progression
  117862. */
  117863. export class SceneLoaderProgressEvent {
  117864. /** defines if data length to load can be evaluated */
  117865. readonly lengthComputable: boolean;
  117866. /** defines the loaded data length */
  117867. readonly loaded: number;
  117868. /** defines the data length to load */
  117869. readonly total: number;
  117870. /**
  117871. * Create a new progress event
  117872. * @param lengthComputable defines if data length to load can be evaluated
  117873. * @param loaded defines the loaded data length
  117874. * @param total defines the data length to load
  117875. */
  117876. constructor(
  117877. /** defines if data length to load can be evaluated */
  117878. lengthComputable: boolean,
  117879. /** defines the loaded data length */
  117880. loaded: number,
  117881. /** defines the data length to load */
  117882. total: number);
  117883. /**
  117884. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  117885. * @param event defines the source event
  117886. * @returns a new SceneLoaderProgressEvent
  117887. */
  117888. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  117889. }
  117890. /**
  117891. * Interface used by SceneLoader plugins to define supported file extensions
  117892. */
  117893. export interface ISceneLoaderPluginExtensions {
  117894. /**
  117895. * Defines the list of supported extensions
  117896. */
  117897. [extension: string]: {
  117898. isBinary: boolean;
  117899. };
  117900. }
  117901. /**
  117902. * Interface used by SceneLoader plugin factory
  117903. */
  117904. export interface ISceneLoaderPluginFactory {
  117905. /**
  117906. * Defines the name of the factory
  117907. */
  117908. name: string;
  117909. /**
  117910. * Function called to create a new plugin
  117911. * @return the new plugin
  117912. */
  117913. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  117914. /**
  117915. * The callback that returns true if the data can be directly loaded.
  117916. * @param data string containing the file data
  117917. * @returns if the data can be loaded directly
  117918. */
  117919. canDirectLoad?(data: string): boolean;
  117920. }
  117921. /**
  117922. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  117923. */
  117924. export interface ISceneLoaderPluginBase {
  117925. /**
  117926. * The friendly name of this plugin.
  117927. */
  117928. name: string;
  117929. /**
  117930. * The file extensions supported by this plugin.
  117931. */
  117932. extensions: string | ISceneLoaderPluginExtensions;
  117933. /**
  117934. * The callback called when loading from a url.
  117935. * @param scene scene loading this url
  117936. * @param url url to load
  117937. * @param onSuccess callback called when the file successfully loads
  117938. * @param onProgress callback called while file is loading (if the server supports this mode)
  117939. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117940. * @param onError callback called when the file fails to load
  117941. * @returns a file request object
  117942. */
  117943. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117944. /**
  117945. * The callback called when loading from a file object.
  117946. * @param scene scene loading this file
  117947. * @param file defines the file to load
  117948. * @param onSuccess defines the callback to call when data is loaded
  117949. * @param onProgress defines the callback to call during loading process
  117950. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117951. * @param onError defines the callback to call when an error occurs
  117952. * @returns a file request object
  117953. */
  117954. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117955. /**
  117956. * The callback that returns true if the data can be directly loaded.
  117957. * @param data string containing the file data
  117958. * @returns if the data can be loaded directly
  117959. */
  117960. canDirectLoad?(data: string): boolean;
  117961. /**
  117962. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117963. * @param scene scene loading this data
  117964. * @param data string containing the data
  117965. * @returns data to pass to the plugin
  117966. */
  117967. directLoad?(scene: Scene, data: string): any;
  117968. /**
  117969. * The callback that allows custom handling of the root url based on the response url.
  117970. * @param rootUrl the original root url
  117971. * @param responseURL the response url if available
  117972. * @returns the new root url
  117973. */
  117974. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117975. }
  117976. /**
  117977. * Interface used to define a SceneLoader plugin
  117978. */
  117979. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117980. /**
  117981. * Import meshes into a scene.
  117982. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  117983. * @param scene The scene to import into
  117984. * @param data The data to import
  117985. * @param rootUrl The root url for scene and resources
  117986. * @param meshes The meshes array to import into
  117987. * @param particleSystems The particle systems array to import into
  117988. * @param skeletons The skeletons array to import into
  117989. * @param onError The callback when import fails
  117990. * @returns True if successful or false otherwise
  117991. */
  117992. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  117993. /**
  117994. * Load into a scene.
  117995. * @param scene The scene to load into
  117996. * @param data The data to import
  117997. * @param rootUrl The root url for scene and resources
  117998. * @param onError The callback when import fails
  117999. * @returns True if successful or false otherwise
  118000. */
  118001. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  118002. /**
  118003. * Load into an asset container.
  118004. * @param scene The scene to load into
  118005. * @param data The data to import
  118006. * @param rootUrl The root url for scene and resources
  118007. * @param onError The callback when import fails
  118008. * @returns The loaded asset container
  118009. */
  118010. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  118011. }
  118012. /**
  118013. * Interface used to define an async SceneLoader plugin
  118014. */
  118015. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  118016. /**
  118017. * Import meshes into a scene.
  118018. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118019. * @param scene The scene to import into
  118020. * @param data The data to import
  118021. * @param rootUrl The root url for scene and resources
  118022. * @param onProgress The callback when the load progresses
  118023. * @param fileName Defines the name of the file to load
  118024. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  118025. */
  118026. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  118027. meshes: AbstractMesh[];
  118028. particleSystems: IParticleSystem[];
  118029. skeletons: Skeleton[];
  118030. animationGroups: AnimationGroup[];
  118031. }>;
  118032. /**
  118033. * Load into a scene.
  118034. * @param scene The scene to load into
  118035. * @param data The data to import
  118036. * @param rootUrl The root url for scene and resources
  118037. * @param onProgress The callback when the load progresses
  118038. * @param fileName Defines the name of the file to load
  118039. * @returns Nothing
  118040. */
  118041. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  118042. /**
  118043. * Load into an asset container.
  118044. * @param scene The scene to load into
  118045. * @param data The data to import
  118046. * @param rootUrl The root url for scene and resources
  118047. * @param onProgress The callback when the load progresses
  118048. * @param fileName Defines the name of the file to load
  118049. * @returns The loaded asset container
  118050. */
  118051. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  118052. }
  118053. /**
  118054. * Mode that determines how to handle old animation groups before loading new ones.
  118055. */
  118056. export enum SceneLoaderAnimationGroupLoadingMode {
  118057. /**
  118058. * Reset all old animations to initial state then dispose them.
  118059. */
  118060. Clean = 0,
  118061. /**
  118062. * Stop all old animations.
  118063. */
  118064. Stop = 1,
  118065. /**
  118066. * Restart old animations from first frame.
  118067. */
  118068. Sync = 2,
  118069. /**
  118070. * Old animations remains untouched.
  118071. */
  118072. NoSync = 3
  118073. }
  118074. /**
  118075. * Class used to load scene from various file formats using registered plugins
  118076. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  118077. */
  118078. export class SceneLoader {
  118079. /**
  118080. * No logging while loading
  118081. */
  118082. static readonly NO_LOGGING: number;
  118083. /**
  118084. * Minimal logging while loading
  118085. */
  118086. static readonly MINIMAL_LOGGING: number;
  118087. /**
  118088. * Summary logging while loading
  118089. */
  118090. static readonly SUMMARY_LOGGING: number;
  118091. /**
  118092. * Detailled logging while loading
  118093. */
  118094. static readonly DETAILED_LOGGING: number;
  118095. /**
  118096. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  118097. */
  118098. static get ForceFullSceneLoadingForIncremental(): boolean;
  118099. static set ForceFullSceneLoadingForIncremental(value: boolean);
  118100. /**
  118101. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  118102. */
  118103. static get ShowLoadingScreen(): boolean;
  118104. static set ShowLoadingScreen(value: boolean);
  118105. /**
  118106. * Defines the current logging level (while loading the scene)
  118107. * @ignorenaming
  118108. */
  118109. static get loggingLevel(): number;
  118110. static set loggingLevel(value: number);
  118111. /**
  118112. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  118113. */
  118114. static get CleanBoneMatrixWeights(): boolean;
  118115. static set CleanBoneMatrixWeights(value: boolean);
  118116. /**
  118117. * Event raised when a plugin is used to load a scene
  118118. */
  118119. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  118120. private static _registeredPlugins;
  118121. private static _getDefaultPlugin;
  118122. private static _getPluginForExtension;
  118123. private static _getPluginForDirectLoad;
  118124. private static _getPluginForFilename;
  118125. private static _getDirectLoad;
  118126. private static _loadData;
  118127. private static _getFileInfo;
  118128. /**
  118129. * Gets a plugin that can load the given extension
  118130. * @param extension defines the extension to load
  118131. * @returns a plugin or null if none works
  118132. */
  118133. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  118134. /**
  118135. * Gets a boolean indicating that the given extension can be loaded
  118136. * @param extension defines the extension to load
  118137. * @returns true if the extension is supported
  118138. */
  118139. static IsPluginForExtensionAvailable(extension: string): boolean;
  118140. /**
  118141. * Adds a new plugin to the list of registered plugins
  118142. * @param plugin defines the plugin to add
  118143. */
  118144. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  118145. /**
  118146. * Import meshes into a scene
  118147. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118148. * @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)
  118149. * @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)
  118150. * @param scene the instance of BABYLON.Scene to append to
  118151. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  118152. * @param onProgress a callback with a progress event for each file being loaded
  118153. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118154. * @param pluginExtension the extension used to determine the plugin
  118155. * @returns The loaded plugin
  118156. */
  118157. 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>;
  118158. /**
  118159. * Import meshes into a scene
  118160. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118161. * @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)
  118162. * @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)
  118163. * @param scene the instance of BABYLON.Scene to append to
  118164. * @param onProgress a callback with a progress event for each file being loaded
  118165. * @param pluginExtension the extension used to determine the plugin
  118166. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  118167. */
  118168. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  118169. meshes: AbstractMesh[];
  118170. particleSystems: IParticleSystem[];
  118171. skeletons: Skeleton[];
  118172. animationGroups: AnimationGroup[];
  118173. }>;
  118174. /**
  118175. * Load a scene
  118176. * @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)
  118177. * @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)
  118178. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118179. * @param onSuccess a callback with the scene when import succeeds
  118180. * @param onProgress a callback with a progress event for each file being loaded
  118181. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118182. * @param pluginExtension the extension used to determine the plugin
  118183. * @returns The loaded plugin
  118184. */
  118185. 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>;
  118186. /**
  118187. * Load a scene
  118188. * @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)
  118189. * @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)
  118190. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118191. * @param onProgress a callback with a progress event for each file being loaded
  118192. * @param pluginExtension the extension used to determine the plugin
  118193. * @returns The loaded scene
  118194. */
  118195. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118196. /**
  118197. * Append a scene
  118198. * @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)
  118199. * @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)
  118200. * @param scene is the instance of BABYLON.Scene to append to
  118201. * @param onSuccess a callback with the scene when import succeeds
  118202. * @param onProgress a callback with a progress event for each file being loaded
  118203. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118204. * @param pluginExtension the extension used to determine the plugin
  118205. * @returns The loaded plugin
  118206. */
  118207. 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>;
  118208. /**
  118209. * Append a scene
  118210. * @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)
  118211. * @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)
  118212. * @param scene is the instance of BABYLON.Scene to append to
  118213. * @param onProgress a callback with a progress event for each file being loaded
  118214. * @param pluginExtension the extension used to determine the plugin
  118215. * @returns The given scene
  118216. */
  118217. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118218. /**
  118219. * Load a scene into an asset container
  118220. * @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)
  118221. * @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)
  118222. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118223. * @param onSuccess a callback with the scene when import succeeds
  118224. * @param onProgress a callback with a progress event for each file being loaded
  118225. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118226. * @param pluginExtension the extension used to determine the plugin
  118227. * @returns The loaded plugin
  118228. */
  118229. 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>;
  118230. /**
  118231. * Load a scene into an asset container
  118232. * @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)
  118233. * @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)
  118234. * @param scene is the instance of Scene to append to
  118235. * @param onProgress a callback with a progress event for each file being loaded
  118236. * @param pluginExtension the extension used to determine the plugin
  118237. * @returns The loaded asset container
  118238. */
  118239. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  118240. /**
  118241. * Import animations from a file into a scene
  118242. * @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)
  118243. * @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)
  118244. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118245. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118246. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118247. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118248. * @param onSuccess a callback with the scene when import succeeds
  118249. * @param onProgress a callback with a progress event for each file being loaded
  118250. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118251. */
  118252. 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;
  118253. /**
  118254. * Import animations from a file into a scene
  118255. * @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)
  118256. * @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)
  118257. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118258. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118259. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118260. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118261. * @param onSuccess a callback with the scene when import succeeds
  118262. * @param onProgress a callback with a progress event for each file being loaded
  118263. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118264. * @returns the updated scene with imported animations
  118265. */
  118266. 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>;
  118267. }
  118268. }
  118269. declare module BABYLON {
  118270. /**
  118271. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  118272. */
  118273. export type MotionControllerHandness = "none" | "left" | "right";
  118274. /**
  118275. * The type of components available in motion controllers.
  118276. * This is not the name of the component.
  118277. */
  118278. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  118279. /**
  118280. * The state of a controller component
  118281. */
  118282. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  118283. /**
  118284. * The schema of motion controller layout.
  118285. * No object will be initialized using this interface
  118286. * This is used just to define the profile.
  118287. */
  118288. export interface IMotionControllerLayout {
  118289. /**
  118290. * Path to load the assets. Usually relative to the base path
  118291. */
  118292. assetPath: string;
  118293. /**
  118294. * Available components (unsorted)
  118295. */
  118296. components: {
  118297. /**
  118298. * A map of component Ids
  118299. */
  118300. [componentId: string]: {
  118301. /**
  118302. * The type of input the component outputs
  118303. */
  118304. type: MotionControllerComponentType;
  118305. /**
  118306. * The indices of this component in the gamepad object
  118307. */
  118308. gamepadIndices: {
  118309. /**
  118310. * Index of button
  118311. */
  118312. button?: number;
  118313. /**
  118314. * If available, index of x-axis
  118315. */
  118316. xAxis?: number;
  118317. /**
  118318. * If available, index of y-axis
  118319. */
  118320. yAxis?: number;
  118321. };
  118322. /**
  118323. * The mesh's root node name
  118324. */
  118325. rootNodeName: string;
  118326. /**
  118327. * Animation definitions for this model
  118328. */
  118329. visualResponses: {
  118330. [stateKey: string]: {
  118331. /**
  118332. * What property will be animated
  118333. */
  118334. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  118335. /**
  118336. * What states influence this visual response
  118337. */
  118338. states: MotionControllerComponentStateType[];
  118339. /**
  118340. * Type of animation - movement or visibility
  118341. */
  118342. valueNodeProperty: "transform" | "visibility";
  118343. /**
  118344. * Base node name to move. Its position will be calculated according to the min and max nodes
  118345. */
  118346. valueNodeName?: string;
  118347. /**
  118348. * Minimum movement node
  118349. */
  118350. minNodeName?: string;
  118351. /**
  118352. * Max movement node
  118353. */
  118354. maxNodeName?: string;
  118355. };
  118356. };
  118357. /**
  118358. * If touch enabled, what is the name of node to display user feedback
  118359. */
  118360. touchPointNodeName?: string;
  118361. };
  118362. };
  118363. /**
  118364. * Is it xr standard mapping or not
  118365. */
  118366. gamepadMapping: "" | "xr-standard";
  118367. /**
  118368. * Base root node of this entire model
  118369. */
  118370. rootNodeName: string;
  118371. /**
  118372. * Defines the main button component id
  118373. */
  118374. selectComponentId: string;
  118375. }
  118376. /**
  118377. * A definition for the layout map in the input profile
  118378. */
  118379. export interface IMotionControllerLayoutMap {
  118380. /**
  118381. * Layouts with handness type as a key
  118382. */
  118383. [handness: string]: IMotionControllerLayout;
  118384. }
  118385. /**
  118386. * The XR Input profile schema
  118387. * Profiles can be found here:
  118388. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  118389. */
  118390. export interface IMotionControllerProfile {
  118391. /**
  118392. * fallback profiles for this profileId
  118393. */
  118394. fallbackProfileIds: string[];
  118395. /**
  118396. * The layout map, with handness as key
  118397. */
  118398. layouts: IMotionControllerLayoutMap;
  118399. /**
  118400. * The id of this profile
  118401. * correlates to the profile(s) in the xrInput.profiles array
  118402. */
  118403. profileId: string;
  118404. }
  118405. /**
  118406. * A helper-interface for the 3 meshes needed for controller button animation
  118407. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  118408. */
  118409. export interface IMotionControllerButtonMeshMap {
  118410. /**
  118411. * the mesh that defines the pressed value mesh position.
  118412. * This is used to find the max-position of this button
  118413. */
  118414. pressedMesh: AbstractMesh;
  118415. /**
  118416. * the mesh that defines the unpressed value mesh position.
  118417. * This is used to find the min (or initial) position of this button
  118418. */
  118419. unpressedMesh: AbstractMesh;
  118420. /**
  118421. * The mesh that will be changed when value changes
  118422. */
  118423. valueMesh: AbstractMesh;
  118424. }
  118425. /**
  118426. * A helper-interface for the 3 meshes needed for controller axis animation.
  118427. * This will be expanded when touchpad animations are fully supported
  118428. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  118429. */
  118430. export interface IMotionControllerMeshMap {
  118431. /**
  118432. * the mesh that defines the maximum value mesh position.
  118433. */
  118434. maxMesh?: AbstractMesh;
  118435. /**
  118436. * the mesh that defines the minimum value mesh position.
  118437. */
  118438. minMesh?: AbstractMesh;
  118439. /**
  118440. * The mesh that will be changed when axis value changes
  118441. */
  118442. valueMesh: AbstractMesh;
  118443. }
  118444. /**
  118445. * The elements needed for change-detection of the gamepad objects in motion controllers
  118446. */
  118447. export interface IMinimalMotionControllerObject {
  118448. /**
  118449. * Available axes of this controller
  118450. */
  118451. axes: number[];
  118452. /**
  118453. * An array of available buttons
  118454. */
  118455. buttons: Array<{
  118456. /**
  118457. * Value of the button/trigger
  118458. */
  118459. value: number;
  118460. /**
  118461. * If the button/trigger is currently touched
  118462. */
  118463. touched: boolean;
  118464. /**
  118465. * If the button/trigger is currently pressed
  118466. */
  118467. pressed: boolean;
  118468. }>;
  118469. }
  118470. /**
  118471. * An Abstract Motion controller
  118472. * This class receives an xrInput and a profile layout and uses those to initialize the components
  118473. * Each component has an observable to check for changes in value and state
  118474. */
  118475. export abstract class WebXRAbstractMotionController implements IDisposable {
  118476. protected scene: Scene;
  118477. protected layout: IMotionControllerLayout;
  118478. /**
  118479. * The gamepad object correlating to this controller
  118480. */
  118481. gamepadObject: IMinimalMotionControllerObject;
  118482. /**
  118483. * handness (left/right/none) of this controller
  118484. */
  118485. handness: MotionControllerHandness;
  118486. private _initComponent;
  118487. private _modelReady;
  118488. /**
  118489. * A map of components (WebXRControllerComponent) in this motion controller
  118490. * Components have a ComponentType and can also have both button and axis definitions
  118491. */
  118492. readonly components: {
  118493. [id: string]: WebXRControllerComponent;
  118494. };
  118495. /**
  118496. * Disable the model's animation. Can be set at any time.
  118497. */
  118498. disableAnimation: boolean;
  118499. /**
  118500. * Observers registered here will be triggered when the model of this controller is done loading
  118501. */
  118502. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  118503. /**
  118504. * The profile id of this motion controller
  118505. */
  118506. abstract profileId: string;
  118507. /**
  118508. * The root mesh of the model. It is null if the model was not yet initialized
  118509. */
  118510. rootMesh: Nullable<AbstractMesh>;
  118511. /**
  118512. * constructs a new abstract motion controller
  118513. * @param scene the scene to which the model of the controller will be added
  118514. * @param layout The profile layout to load
  118515. * @param gamepadObject The gamepad object correlating to this controller
  118516. * @param handness handness (left/right/none) of this controller
  118517. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  118518. */
  118519. constructor(scene: Scene, layout: IMotionControllerLayout,
  118520. /**
  118521. * The gamepad object correlating to this controller
  118522. */
  118523. gamepadObject: IMinimalMotionControllerObject,
  118524. /**
  118525. * handness (left/right/none) of this controller
  118526. */
  118527. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  118528. /**
  118529. * Dispose this controller, the model mesh and all its components
  118530. */
  118531. dispose(): void;
  118532. /**
  118533. * Returns all components of specific type
  118534. * @param type the type to search for
  118535. * @return an array of components with this type
  118536. */
  118537. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  118538. /**
  118539. * get a component based an its component id as defined in layout.components
  118540. * @param id the id of the component
  118541. * @returns the component correlates to the id or undefined if not found
  118542. */
  118543. getComponent(id: string): WebXRControllerComponent;
  118544. /**
  118545. * Get the list of components available in this motion controller
  118546. * @returns an array of strings correlating to available components
  118547. */
  118548. getComponentIds(): string[];
  118549. /**
  118550. * Get the first component of specific type
  118551. * @param type type of component to find
  118552. * @return a controller component or null if not found
  118553. */
  118554. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  118555. /**
  118556. * Get the main (Select) component of this controller as defined in the layout
  118557. * @returns the main component of this controller
  118558. */
  118559. getMainComponent(): WebXRControllerComponent;
  118560. /**
  118561. * Loads the model correlating to this controller
  118562. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  118563. * @returns A promise fulfilled with the result of the model loading
  118564. */
  118565. loadModel(): Promise<boolean>;
  118566. /**
  118567. * Update this model using the current XRFrame
  118568. * @param xrFrame the current xr frame to use and update the model
  118569. */
  118570. updateFromXRFrame(xrFrame: XRFrame): void;
  118571. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118572. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118573. /**
  118574. * Moves the axis on the controller mesh based on its current state
  118575. * @param axis the index of the axis
  118576. * @param axisValue the value of the axis which determines the meshes new position
  118577. * @hidden
  118578. */
  118579. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  118580. /**
  118581. * Update the model itself with the current frame data
  118582. * @param xrFrame the frame to use for updating the model mesh
  118583. */
  118584. protected updateModel(xrFrame: XRFrame): void;
  118585. /**
  118586. * Get the filename and path for this controller's model
  118587. * @returns a map of filename and path
  118588. */
  118589. protected abstract _getFilenameAndPath(): {
  118590. filename: string;
  118591. path: string;
  118592. };
  118593. /**
  118594. * This function is called before the mesh is loaded. It checks for loading constraints.
  118595. * For example, this function can check if the GLB loader is available
  118596. * If this function returns false, the generic controller will be loaded instead
  118597. * @returns Is the client ready to load the mesh
  118598. */
  118599. protected abstract _getModelLoadingConstraints(): boolean;
  118600. /**
  118601. * This function will be called after the model was successfully loaded and can be used
  118602. * for mesh transformations before it is available for the user
  118603. * @param meshes the loaded meshes
  118604. */
  118605. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  118606. /**
  118607. * Set the root mesh for this controller. Important for the WebXR controller class
  118608. * @param meshes the loaded meshes
  118609. */
  118610. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  118611. /**
  118612. * A function executed each frame that updates the mesh (if needed)
  118613. * @param xrFrame the current xrFrame
  118614. */
  118615. protected abstract _updateModel(xrFrame: XRFrame): void;
  118616. private _getGenericFilenameAndPath;
  118617. private _getGenericParentMesh;
  118618. }
  118619. }
  118620. declare module BABYLON {
  118621. /**
  118622. * A generic trigger-only motion controller for WebXR
  118623. */
  118624. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  118625. /**
  118626. * Static version of the profile id of this controller
  118627. */
  118628. static ProfileId: string;
  118629. profileId: string;
  118630. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118631. protected _getFilenameAndPath(): {
  118632. filename: string;
  118633. path: string;
  118634. };
  118635. protected _getModelLoadingConstraints(): boolean;
  118636. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  118637. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118638. protected _updateModel(): void;
  118639. }
  118640. }
  118641. declare module BABYLON {
  118642. /**
  118643. * Class containing static functions to help procedurally build meshes
  118644. */
  118645. export class SphereBuilder {
  118646. /**
  118647. * Creates a sphere mesh
  118648. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118649. * * 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`)
  118650. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118651. * * 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
  118652. * * 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)
  118653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118654. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118656. * @param name defines the name of the mesh
  118657. * @param options defines the options used to create the mesh
  118658. * @param scene defines the hosting scene
  118659. * @returns the sphere mesh
  118660. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118661. */
  118662. static CreateSphere(name: string, options: {
  118663. segments?: number;
  118664. diameter?: number;
  118665. diameterX?: number;
  118666. diameterY?: number;
  118667. diameterZ?: number;
  118668. arc?: number;
  118669. slice?: number;
  118670. sideOrientation?: number;
  118671. frontUVs?: Vector4;
  118672. backUVs?: Vector4;
  118673. updatable?: boolean;
  118674. }, scene?: Nullable<Scene>): Mesh;
  118675. }
  118676. }
  118677. declare module BABYLON {
  118678. /**
  118679. * A profiled motion controller has its profile loaded from an online repository.
  118680. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  118681. */
  118682. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  118683. private _repositoryUrl;
  118684. private _buttonMeshMapping;
  118685. private _touchDots;
  118686. /**
  118687. * The profile ID of this controller. Will be populated when the controller initializes.
  118688. */
  118689. profileId: string;
  118690. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  118691. dispose(): void;
  118692. protected _getFilenameAndPath(): {
  118693. filename: string;
  118694. path: string;
  118695. };
  118696. protected _getModelLoadingConstraints(): boolean;
  118697. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118698. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118699. protected _updateModel(_xrFrame: XRFrame): void;
  118700. }
  118701. }
  118702. declare module BABYLON {
  118703. /**
  118704. * A construction function type to create a new controller based on an xrInput object
  118705. */
  118706. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  118707. /**
  118708. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  118709. *
  118710. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  118711. * it should be replaced with auto-loaded controllers.
  118712. *
  118713. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  118714. */
  118715. export class WebXRMotionControllerManager {
  118716. private static _AvailableControllers;
  118717. private static _Fallbacks;
  118718. private static _ProfileLoadingPromises;
  118719. private static _ProfilesList;
  118720. /**
  118721. * The base URL of the online controller repository. Can be changed at any time.
  118722. */
  118723. static BaseRepositoryUrl: string;
  118724. /**
  118725. * Which repository gets priority - local or online
  118726. */
  118727. static PrioritizeOnlineRepository: boolean;
  118728. /**
  118729. * Use the online repository, or use only locally-defined controllers
  118730. */
  118731. static UseOnlineRepository: boolean;
  118732. /**
  118733. * Clear the cache used for profile loading and reload when requested again
  118734. */
  118735. static ClearProfilesCache(): void;
  118736. /**
  118737. * Register the default fallbacks.
  118738. * This function is called automatically when this file is imported.
  118739. */
  118740. static DefaultFallbacks(): void;
  118741. /**
  118742. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  118743. * @param profileId the profile to which a fallback needs to be found
  118744. * @return an array with corresponding fallback profiles
  118745. */
  118746. static FindFallbackWithProfileId(profileId: string): string[];
  118747. /**
  118748. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  118749. * The order of search:
  118750. *
  118751. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  118752. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  118753. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  118754. * 4) return the generic trigger controller if none were found
  118755. *
  118756. * @param xrInput the xrInput to which a new controller is initialized
  118757. * @param scene the scene to which the model will be added
  118758. * @param forceProfile force a certain profile for this controller
  118759. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  118760. */
  118761. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  118762. /**
  118763. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  118764. *
  118765. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  118766. *
  118767. * @param type the profile type to register
  118768. * @param constructFunction the function to be called when loading this profile
  118769. */
  118770. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  118771. /**
  118772. * Register a fallback to a specific profile.
  118773. * @param profileId the profileId that will receive the fallbacks
  118774. * @param fallbacks A list of fallback profiles
  118775. */
  118776. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  118777. /**
  118778. * Will update the list of profiles available in the repository
  118779. * @return a promise that resolves to a map of profiles available online
  118780. */
  118781. static UpdateProfilesList(): Promise<{
  118782. [profile: string]: string;
  118783. }>;
  118784. private static _LoadProfileFromRepository;
  118785. private static _LoadProfilesFromAvailableControllers;
  118786. }
  118787. }
  118788. declare module BABYLON {
  118789. /**
  118790. * Configuration options for the WebXR controller creation
  118791. */
  118792. export interface IWebXRControllerOptions {
  118793. /**
  118794. * Should the controller mesh be animated when a user interacts with it
  118795. * The pressed buttons / thumbstick and touchpad animations will be disabled
  118796. */
  118797. disableMotionControllerAnimation?: boolean;
  118798. /**
  118799. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  118800. */
  118801. doNotLoadControllerMesh?: boolean;
  118802. /**
  118803. * Force a specific controller type for this controller.
  118804. * This can be used when creating your own profile or when testing different controllers
  118805. */
  118806. forceControllerProfile?: string;
  118807. }
  118808. /**
  118809. * Represents an XR controller
  118810. */
  118811. export class WebXRInputSource {
  118812. private _scene;
  118813. /** The underlying input source for the controller */
  118814. inputSource: XRInputSource;
  118815. private _options;
  118816. private _tmpQuaternion;
  118817. private _tmpVector;
  118818. private _uniqueId;
  118819. /**
  118820. * 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
  118821. */
  118822. grip?: AbstractMesh;
  118823. /**
  118824. * If available, this is the gamepad object related to this controller.
  118825. * Using this object it is possible to get click events and trackpad changes of the
  118826. * webxr controller that is currently being used.
  118827. */
  118828. motionController?: WebXRAbstractMotionController;
  118829. /**
  118830. * Event that fires when the controller is removed/disposed.
  118831. * The object provided as event data is this controller, after associated assets were disposed.
  118832. * uniqueId is still available.
  118833. */
  118834. onDisposeObservable: Observable<WebXRInputSource>;
  118835. /**
  118836. * Will be triggered when the mesh associated with the motion controller is done loading.
  118837. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  118838. * A shortened version of controller -> motion controller -> on mesh loaded.
  118839. */
  118840. onMeshLoadedObservable: Observable<AbstractMesh>;
  118841. /**
  118842. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  118843. */
  118844. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  118845. /**
  118846. * Pointer which can be used to select objects or attach a visible laser to
  118847. */
  118848. pointer: AbstractMesh;
  118849. /**
  118850. * Creates the controller
  118851. * @see https://doc.babylonjs.com/how_to/webxr
  118852. * @param _scene the scene which the controller should be associated to
  118853. * @param inputSource the underlying input source for the controller
  118854. * @param _options options for this controller creation
  118855. */
  118856. constructor(_scene: Scene,
  118857. /** The underlying input source for the controller */
  118858. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  118859. /**
  118860. * Get this controllers unique id
  118861. */
  118862. get uniqueId(): string;
  118863. /**
  118864. * Disposes of the object
  118865. */
  118866. dispose(): void;
  118867. /**
  118868. * Gets a world space ray coming from the pointer or grip
  118869. * @param result the resulting ray
  118870. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  118871. */
  118872. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  118873. /**
  118874. * Updates the controller pose based on the given XRFrame
  118875. * @param xrFrame xr frame to update the pose with
  118876. * @param referenceSpace reference space to use
  118877. */
  118878. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  118879. }
  118880. }
  118881. declare module BABYLON {
  118882. /**
  118883. * The schema for initialization options of the XR Input class
  118884. */
  118885. export interface IWebXRInputOptions {
  118886. /**
  118887. * If set to true no model will be automatically loaded
  118888. */
  118889. doNotLoadControllerMeshes?: boolean;
  118890. /**
  118891. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  118892. * If not found, the xr input profile data will be used.
  118893. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  118894. */
  118895. forceInputProfile?: string;
  118896. /**
  118897. * Do not send a request to the controller repository to load the profile.
  118898. *
  118899. * Instead, use the controllers available in babylon itself.
  118900. */
  118901. disableOnlineControllerRepository?: boolean;
  118902. /**
  118903. * A custom URL for the controllers repository
  118904. */
  118905. customControllersRepositoryURL?: string;
  118906. /**
  118907. * Should the controller model's components not move according to the user input
  118908. */
  118909. disableControllerAnimation?: boolean;
  118910. }
  118911. /**
  118912. * XR input used to track XR inputs such as controllers/rays
  118913. */
  118914. export class WebXRInput implements IDisposable {
  118915. /**
  118916. * the xr session manager for this session
  118917. */
  118918. xrSessionManager: WebXRSessionManager;
  118919. /**
  118920. * the WebXR camera for this session. Mainly used for teleportation
  118921. */
  118922. xrCamera: WebXRCamera;
  118923. private readonly options;
  118924. /**
  118925. * XR controllers being tracked
  118926. */
  118927. controllers: Array<WebXRInputSource>;
  118928. private _frameObserver;
  118929. private _sessionEndedObserver;
  118930. private _sessionInitObserver;
  118931. /**
  118932. * Event when a controller has been connected/added
  118933. */
  118934. onControllerAddedObservable: Observable<WebXRInputSource>;
  118935. /**
  118936. * Event when a controller has been removed/disconnected
  118937. */
  118938. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118939. /**
  118940. * Initializes the WebXRInput
  118941. * @param xrSessionManager the xr session manager for this session
  118942. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118943. * @param options = initialization options for this xr input
  118944. */
  118945. constructor(
  118946. /**
  118947. * the xr session manager for this session
  118948. */
  118949. xrSessionManager: WebXRSessionManager,
  118950. /**
  118951. * the WebXR camera for this session. Mainly used for teleportation
  118952. */
  118953. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118954. private _onInputSourcesChange;
  118955. private _addAndRemoveControllers;
  118956. /**
  118957. * Disposes of the object
  118958. */
  118959. dispose(): void;
  118960. }
  118961. }
  118962. declare module BABYLON {
  118963. /**
  118964. * This is the base class for all WebXR features.
  118965. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118966. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118967. */
  118968. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118969. protected _xrSessionManager: WebXRSessionManager;
  118970. private _attached;
  118971. private _removeOnDetach;
  118972. /**
  118973. * Should auto-attach be disabled?
  118974. */
  118975. disableAutoAttach: boolean;
  118976. /**
  118977. * Construct a new (abstract) WebXR feature
  118978. * @param _xrSessionManager the xr session manager for this feature
  118979. */
  118980. constructor(_xrSessionManager: WebXRSessionManager);
  118981. /**
  118982. * Is this feature attached
  118983. */
  118984. get attached(): boolean;
  118985. /**
  118986. * attach this feature
  118987. *
  118988. * @param force should attachment be forced (even when already attached)
  118989. * @returns true if successful, false is failed or already attached
  118990. */
  118991. attach(force?: boolean): boolean;
  118992. /**
  118993. * detach this feature.
  118994. *
  118995. * @returns true if successful, false if failed or already detached
  118996. */
  118997. detach(): boolean;
  118998. /**
  118999. * Dispose this feature and all of the resources attached
  119000. */
  119001. dispose(): void;
  119002. /**
  119003. * This is used to register callbacks that will automatically be removed when detach is called.
  119004. * @param observable the observable to which the observer will be attached
  119005. * @param callback the callback to register
  119006. */
  119007. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  119008. /**
  119009. * Code in this function will be executed on each xrFrame received from the browser.
  119010. * This function will not execute after the feature is detached.
  119011. * @param _xrFrame the current frame
  119012. */
  119013. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  119014. }
  119015. }
  119016. declare module BABYLON {
  119017. /**
  119018. * Renders a layer on top of an existing scene
  119019. */
  119020. export class UtilityLayerRenderer implements IDisposable {
  119021. /** the original scene that will be rendered on top of */
  119022. originalScene: Scene;
  119023. private _pointerCaptures;
  119024. private _lastPointerEvents;
  119025. private static _DefaultUtilityLayer;
  119026. private static _DefaultKeepDepthUtilityLayer;
  119027. private _sharedGizmoLight;
  119028. private _renderCamera;
  119029. /**
  119030. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  119031. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  119032. * @returns the camera that is used when rendering the utility layer
  119033. */
  119034. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  119035. /**
  119036. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  119037. * @param cam the camera that should be used when rendering the utility layer
  119038. */
  119039. setRenderCamera(cam: Nullable<Camera>): void;
  119040. /**
  119041. * @hidden
  119042. * Light which used by gizmos to get light shading
  119043. */
  119044. _getSharedGizmoLight(): HemisphericLight;
  119045. /**
  119046. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  119047. */
  119048. pickUtilitySceneFirst: boolean;
  119049. /**
  119050. * 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)
  119051. */
  119052. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  119053. /**
  119054. * 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)
  119055. */
  119056. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  119057. /**
  119058. * The scene that is rendered on top of the original scene
  119059. */
  119060. utilityLayerScene: Scene;
  119061. /**
  119062. * If the utility layer should automatically be rendered on top of existing scene
  119063. */
  119064. shouldRender: boolean;
  119065. /**
  119066. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  119067. */
  119068. onlyCheckPointerDownEvents: boolean;
  119069. /**
  119070. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  119071. */
  119072. processAllEvents: boolean;
  119073. /**
  119074. * Observable raised when the pointer move from the utility layer scene to the main scene
  119075. */
  119076. onPointerOutObservable: Observable<number>;
  119077. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  119078. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  119079. private _afterRenderObserver;
  119080. private _sceneDisposeObserver;
  119081. private _originalPointerObserver;
  119082. /**
  119083. * Instantiates a UtilityLayerRenderer
  119084. * @param originalScene the original scene that will be rendered on top of
  119085. * @param handleEvents boolean indicating if the utility layer should handle events
  119086. */
  119087. constructor(
  119088. /** the original scene that will be rendered on top of */
  119089. originalScene: Scene, handleEvents?: boolean);
  119090. private _notifyObservers;
  119091. /**
  119092. * Renders the utility layers scene on top of the original scene
  119093. */
  119094. render(): void;
  119095. /**
  119096. * Disposes of the renderer
  119097. */
  119098. dispose(): void;
  119099. private _updateCamera;
  119100. }
  119101. }
  119102. declare module BABYLON {
  119103. /**
  119104. * Options interface for the pointer selection module
  119105. */
  119106. export interface IWebXRControllerPointerSelectionOptions {
  119107. /**
  119108. * if provided, this scene will be used to render meshes.
  119109. */
  119110. customUtilityLayerScene?: Scene;
  119111. /**
  119112. * 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)
  119113. * If not disabled, the last picked point will be used to execute a pointer up event
  119114. * If disabled, pointer up event will be triggered right after the pointer down event.
  119115. * Used in screen and gaze target ray mode only
  119116. */
  119117. disablePointerUpOnTouchOut: boolean;
  119118. /**
  119119. * For gaze mode (time to select instead of press)
  119120. */
  119121. forceGazeMode: boolean;
  119122. /**
  119123. * 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
  119124. * to start a new countdown to the pointer down event.
  119125. * Defaults to 1.
  119126. */
  119127. gazeModePointerMovedFactor?: number;
  119128. /**
  119129. * Different button type to use instead of the main component
  119130. */
  119131. overrideButtonId?: string;
  119132. /**
  119133. * use this rendering group id for the meshes (optional)
  119134. */
  119135. renderingGroupId?: number;
  119136. /**
  119137. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  119138. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  119139. * 3000 means 3 seconds between pointing at something and selecting it
  119140. */
  119141. timeToSelect?: number;
  119142. /**
  119143. * Should meshes created here be added to a utility layer or the main scene
  119144. */
  119145. useUtilityLayer?: boolean;
  119146. /**
  119147. * the xr input to use with this pointer selection
  119148. */
  119149. xrInput: WebXRInput;
  119150. }
  119151. /**
  119152. * A module that will enable pointer selection for motion controllers of XR Input Sources
  119153. */
  119154. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  119155. private readonly _options;
  119156. private static _idCounter;
  119157. private _attachController;
  119158. private _controllers;
  119159. private _scene;
  119160. private _tmpVectorForPickCompare;
  119161. /**
  119162. * The module's name
  119163. */
  119164. static readonly Name: string;
  119165. /**
  119166. * The (Babylon) version of this module.
  119167. * This is an integer representing the implementation version.
  119168. * This number does not correspond to the WebXR specs version
  119169. */
  119170. static readonly Version: number;
  119171. /**
  119172. * Disable lighting on the laser pointer (so it will always be visible)
  119173. */
  119174. disablePointerLighting: boolean;
  119175. /**
  119176. * Disable lighting on the selection mesh (so it will always be visible)
  119177. */
  119178. disableSelectionMeshLighting: boolean;
  119179. /**
  119180. * Should the laser pointer be displayed
  119181. */
  119182. displayLaserPointer: boolean;
  119183. /**
  119184. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  119185. */
  119186. displaySelectionMesh: boolean;
  119187. /**
  119188. * This color will be set to the laser pointer when selection is triggered
  119189. */
  119190. laserPointerPickedColor: Color3;
  119191. /**
  119192. * Default color of the laser pointer
  119193. */
  119194. lasterPointerDefaultColor: Color3;
  119195. /**
  119196. * default color of the selection ring
  119197. */
  119198. selectionMeshDefaultColor: Color3;
  119199. /**
  119200. * This color will be applied to the selection ring when selection is triggered
  119201. */
  119202. selectionMeshPickedColor: Color3;
  119203. /**
  119204. * Optional filter to be used for ray selection. This predicate shares behavior with
  119205. * scene.pointerMovePredicate which takes priority if it is also assigned.
  119206. */
  119207. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119208. /**
  119209. * constructs a new background remover module
  119210. * @param _xrSessionManager the session manager for this module
  119211. * @param _options read-only options to be used in this module
  119212. */
  119213. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  119214. /**
  119215. * attach this feature
  119216. * Will usually be called by the features manager
  119217. *
  119218. * @returns true if successful.
  119219. */
  119220. attach(): boolean;
  119221. /**
  119222. * detach this feature.
  119223. * Will usually be called by the features manager
  119224. *
  119225. * @returns true if successful.
  119226. */
  119227. detach(): boolean;
  119228. /**
  119229. * Will get the mesh under a specific pointer.
  119230. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  119231. * @param controllerId the controllerId to check
  119232. * @returns The mesh under pointer or null if no mesh is under the pointer
  119233. */
  119234. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  119235. /**
  119236. * Get the xr controller that correlates to the pointer id in the pointer event
  119237. *
  119238. * @param id the pointer id to search for
  119239. * @returns the controller that correlates to this id or null if not found
  119240. */
  119241. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  119242. protected _onXRFrame(_xrFrame: XRFrame): void;
  119243. private _attachGazeMode;
  119244. private _attachScreenRayMode;
  119245. private _attachTrackedPointerRayMode;
  119246. private _convertNormalToDirectionOfRay;
  119247. private _detachController;
  119248. private _generateNewMeshPair;
  119249. private _pickingMoved;
  119250. private _updatePointerDistance;
  119251. }
  119252. }
  119253. declare module BABYLON {
  119254. /**
  119255. * Button which can be used to enter a different mode of XR
  119256. */
  119257. export class WebXREnterExitUIButton {
  119258. /** button element */
  119259. element: HTMLElement;
  119260. /** XR initialization options for the button */
  119261. sessionMode: XRSessionMode;
  119262. /** Reference space type */
  119263. referenceSpaceType: XRReferenceSpaceType;
  119264. /**
  119265. * Creates a WebXREnterExitUIButton
  119266. * @param element button element
  119267. * @param sessionMode XR initialization session mode
  119268. * @param referenceSpaceType the type of reference space to be used
  119269. */
  119270. constructor(
  119271. /** button element */
  119272. element: HTMLElement,
  119273. /** XR initialization options for the button */
  119274. sessionMode: XRSessionMode,
  119275. /** Reference space type */
  119276. referenceSpaceType: XRReferenceSpaceType);
  119277. /**
  119278. * Extendable function which can be used to update the button's visuals when the state changes
  119279. * @param activeButton the current active button in the UI
  119280. */
  119281. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  119282. }
  119283. /**
  119284. * Options to create the webXR UI
  119285. */
  119286. export class WebXREnterExitUIOptions {
  119287. /**
  119288. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  119289. */
  119290. customButtons?: Array<WebXREnterExitUIButton>;
  119291. /**
  119292. * A reference space type to use when creating the default button.
  119293. * Default is local-floor
  119294. */
  119295. referenceSpaceType?: XRReferenceSpaceType;
  119296. /**
  119297. * Context to enter xr with
  119298. */
  119299. renderTarget?: Nullable<WebXRRenderTarget>;
  119300. /**
  119301. * A session mode to use when creating the default button.
  119302. * Default is immersive-vr
  119303. */
  119304. sessionMode?: XRSessionMode;
  119305. }
  119306. /**
  119307. * UI to allow the user to enter/exit XR mode
  119308. */
  119309. export class WebXREnterExitUI implements IDisposable {
  119310. private scene;
  119311. /** version of the options passed to this UI */
  119312. options: WebXREnterExitUIOptions;
  119313. private _activeButton;
  119314. private _buttons;
  119315. private _overlay;
  119316. /**
  119317. * Fired every time the active button is changed.
  119318. *
  119319. * When xr is entered via a button that launches xr that button will be the callback parameter
  119320. *
  119321. * When exiting xr the callback parameter will be null)
  119322. */
  119323. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  119324. /**
  119325. *
  119326. * @param scene babylon scene object to use
  119327. * @param options (read-only) version of the options passed to this UI
  119328. */
  119329. private constructor();
  119330. /**
  119331. * Creates UI to allow the user to enter/exit XR mode
  119332. * @param scene the scene to add the ui to
  119333. * @param helper the xr experience helper to enter/exit xr with
  119334. * @param options options to configure the UI
  119335. * @returns the created ui
  119336. */
  119337. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  119338. /**
  119339. * Disposes of the XR UI component
  119340. */
  119341. dispose(): void;
  119342. private _updateButtons;
  119343. }
  119344. }
  119345. declare module BABYLON {
  119346. /**
  119347. * Class containing static functions to help procedurally build meshes
  119348. */
  119349. export class LinesBuilder {
  119350. /**
  119351. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119352. * * 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
  119353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119354. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119355. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119356. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119357. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119358. * * 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
  119359. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119361. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119362. * @param name defines the name of the new line system
  119363. * @param options defines the options used to create the line system
  119364. * @param scene defines the hosting scene
  119365. * @returns a new line system mesh
  119366. */
  119367. static CreateLineSystem(name: string, options: {
  119368. lines: Vector3[][];
  119369. updatable?: boolean;
  119370. instance?: Nullable<LinesMesh>;
  119371. colors?: Nullable<Color4[][]>;
  119372. useVertexAlpha?: boolean;
  119373. }, scene: Nullable<Scene>): LinesMesh;
  119374. /**
  119375. * Creates a line mesh
  119376. * 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
  119377. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119378. * * The parameter `points` is an array successive Vector3
  119379. * * 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
  119380. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119381. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119382. * * When updating an instance, remember that only point positions can change, not the number of points
  119383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119385. * @param name defines the name of the new line system
  119386. * @param options defines the options used to create the line system
  119387. * @param scene defines the hosting scene
  119388. * @returns a new line mesh
  119389. */
  119390. static CreateLines(name: string, options: {
  119391. points: Vector3[];
  119392. updatable?: boolean;
  119393. instance?: Nullable<LinesMesh>;
  119394. colors?: Color4[];
  119395. useVertexAlpha?: boolean;
  119396. }, scene?: Nullable<Scene>): LinesMesh;
  119397. /**
  119398. * Creates a dashed line mesh
  119399. * * 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
  119400. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119401. * * The parameter `points` is an array successive Vector3
  119402. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119403. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119404. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119405. * * 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
  119406. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119407. * * When updating an instance, remember that only point positions can change, not the number of points
  119408. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119409. * @param name defines the name of the mesh
  119410. * @param options defines the options used to create the mesh
  119411. * @param scene defines the hosting scene
  119412. * @returns the dashed line mesh
  119413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119414. */
  119415. static CreateDashedLines(name: string, options: {
  119416. points: Vector3[];
  119417. dashSize?: number;
  119418. gapSize?: number;
  119419. dashNb?: number;
  119420. updatable?: boolean;
  119421. instance?: LinesMesh;
  119422. useVertexAlpha?: boolean;
  119423. }, scene?: Nullable<Scene>): LinesMesh;
  119424. }
  119425. }
  119426. declare module BABYLON {
  119427. /**
  119428. * The options container for the teleportation module
  119429. */
  119430. export interface IWebXRTeleportationOptions {
  119431. /**
  119432. * if provided, this scene will be used to render meshes.
  119433. */
  119434. customUtilityLayerScene?: Scene;
  119435. /**
  119436. * Values to configure the default target mesh
  119437. */
  119438. defaultTargetMeshOptions?: {
  119439. /**
  119440. * Fill color of the teleportation area
  119441. */
  119442. teleportationFillColor?: string;
  119443. /**
  119444. * Border color for the teleportation area
  119445. */
  119446. teleportationBorderColor?: string;
  119447. /**
  119448. * Disable the mesh's animation sequence
  119449. */
  119450. disableAnimation?: boolean;
  119451. /**
  119452. * Disable lighting on the material or the ring and arrow
  119453. */
  119454. disableLighting?: boolean;
  119455. /**
  119456. * Override the default material of the torus and arrow
  119457. */
  119458. torusArrowMaterial?: Material;
  119459. };
  119460. /**
  119461. * A list of meshes to use as floor meshes.
  119462. * Meshes can be added and removed after initializing the feature using the
  119463. * addFloorMesh and removeFloorMesh functions
  119464. * If empty, rotation will still work
  119465. */
  119466. floorMeshes?: AbstractMesh[];
  119467. /**
  119468. * use this rendering group id for the meshes (optional)
  119469. */
  119470. renderingGroupId?: number;
  119471. /**
  119472. * Should teleportation move only to snap points
  119473. */
  119474. snapPointsOnly?: boolean;
  119475. /**
  119476. * An array of points to which the teleportation will snap to.
  119477. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  119478. */
  119479. snapPositions?: Vector3[];
  119480. /**
  119481. * How close should the teleportation ray be in order to snap to position.
  119482. * Default to 0.8 units (meters)
  119483. */
  119484. snapToPositionRadius?: number;
  119485. /**
  119486. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  119487. * If you want to support rotation, make sure your mesh has a direction indicator.
  119488. *
  119489. * When left untouched, the default mesh will be initialized.
  119490. */
  119491. teleportationTargetMesh?: AbstractMesh;
  119492. /**
  119493. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  119494. */
  119495. timeToTeleport?: number;
  119496. /**
  119497. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  119498. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  119499. */
  119500. useMainComponentOnly?: boolean;
  119501. /**
  119502. * Should meshes created here be added to a utility layer or the main scene
  119503. */
  119504. useUtilityLayer?: boolean;
  119505. /**
  119506. * Babylon XR Input class for controller
  119507. */
  119508. xrInput: WebXRInput;
  119509. }
  119510. /**
  119511. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  119512. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  119513. * the input of the attached controllers.
  119514. */
  119515. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  119516. private _options;
  119517. private _controllers;
  119518. private _currentTeleportationControllerId;
  119519. private _floorMeshes;
  119520. private _quadraticBezierCurve;
  119521. private _selectionFeature;
  119522. private _snapToPositions;
  119523. private _snappedToPoint;
  119524. private _teleportationRingMaterial?;
  119525. private _tmpRay;
  119526. private _tmpVector;
  119527. /**
  119528. * The module's name
  119529. */
  119530. static readonly Name: string;
  119531. /**
  119532. * The (Babylon) version of this module.
  119533. * This is an integer representing the implementation version.
  119534. * This number does not correspond to the webxr specs version
  119535. */
  119536. static readonly Version: number;
  119537. /**
  119538. * Is movement backwards enabled
  119539. */
  119540. backwardsMovementEnabled: boolean;
  119541. /**
  119542. * Distance to travel when moving backwards
  119543. */
  119544. backwardsTeleportationDistance: number;
  119545. /**
  119546. * The distance from the user to the inspection point in the direction of the controller
  119547. * A higher number will allow the user to move further
  119548. * defaults to 5 (meters, in xr units)
  119549. */
  119550. parabolicCheckRadius: number;
  119551. /**
  119552. * Should the module support parabolic ray on top of direct ray
  119553. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  119554. * Very helpful when moving between floors / different heights
  119555. */
  119556. parabolicRayEnabled: boolean;
  119557. /**
  119558. * How much rotation should be applied when rotating right and left
  119559. */
  119560. rotationAngle: number;
  119561. /**
  119562. * Is rotation enabled when moving forward?
  119563. * Disabling this feature will prevent the user from deciding the direction when teleporting
  119564. */
  119565. rotationEnabled: boolean;
  119566. /**
  119567. * constructs a new anchor system
  119568. * @param _xrSessionManager an instance of WebXRSessionManager
  119569. * @param _options configuration object for this feature
  119570. */
  119571. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  119572. /**
  119573. * Get the snapPointsOnly flag
  119574. */
  119575. get snapPointsOnly(): boolean;
  119576. /**
  119577. * Sets the snapPointsOnly flag
  119578. * @param snapToPoints should teleportation be exclusively to snap points
  119579. */
  119580. set snapPointsOnly(snapToPoints: boolean);
  119581. /**
  119582. * Add a new mesh to the floor meshes array
  119583. * @param mesh the mesh to use as floor mesh
  119584. */
  119585. addFloorMesh(mesh: AbstractMesh): void;
  119586. /**
  119587. * Add a new snap-to point to fix teleportation to this position
  119588. * @param newSnapPoint The new Snap-To point
  119589. */
  119590. addSnapPoint(newSnapPoint: Vector3): void;
  119591. attach(): boolean;
  119592. detach(): boolean;
  119593. dispose(): void;
  119594. /**
  119595. * Remove a mesh from the floor meshes array
  119596. * @param mesh the mesh to remove
  119597. */
  119598. removeFloorMesh(mesh: AbstractMesh): void;
  119599. /**
  119600. * Remove a mesh from the floor meshes array using its name
  119601. * @param name the mesh name to remove
  119602. */
  119603. removeFloorMeshByName(name: string): void;
  119604. /**
  119605. * 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
  119606. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  119607. * @returns was the point found and removed or not
  119608. */
  119609. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  119610. /**
  119611. * This function sets a selection feature that will be disabled when
  119612. * the forward ray is shown and will be reattached when hidden.
  119613. * This is used to remove the selection rays when moving.
  119614. * @param selectionFeature the feature to disable when forward movement is enabled
  119615. */
  119616. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  119617. protected _onXRFrame(_xrFrame: XRFrame): void;
  119618. private _attachController;
  119619. private _createDefaultTargetMesh;
  119620. private _detachController;
  119621. private _findClosestSnapPointWithRadius;
  119622. private _setTargetMeshPosition;
  119623. private _setTargetMeshVisibility;
  119624. private _showParabolicPath;
  119625. private _teleportForward;
  119626. }
  119627. }
  119628. declare module BABYLON {
  119629. /**
  119630. * Options for the default xr helper
  119631. */
  119632. export class WebXRDefaultExperienceOptions {
  119633. /**
  119634. * Enable or disable default UI to enter XR
  119635. */
  119636. disableDefaultUI?: boolean;
  119637. /**
  119638. * Should teleportation not initialize. defaults to false.
  119639. */
  119640. disableTeleportation?: boolean;
  119641. /**
  119642. * Floor meshes that will be used for teleport
  119643. */
  119644. floorMeshes?: Array<AbstractMesh>;
  119645. /**
  119646. * If set to true, the first frame will not be used to reset position
  119647. * The first frame is mainly used when copying transformation from the old camera
  119648. * Mainly used in AR
  119649. */
  119650. ignoreNativeCameraTransformation?: boolean;
  119651. /**
  119652. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  119653. */
  119654. inputOptions?: IWebXRInputOptions;
  119655. /**
  119656. * optional configuration for the output canvas
  119657. */
  119658. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  119659. /**
  119660. * optional UI options. This can be used among other to change session mode and reference space type
  119661. */
  119662. uiOptions?: WebXREnterExitUIOptions;
  119663. /**
  119664. * When loading teleportation and pointer select, use stable versions instead of latest.
  119665. */
  119666. useStablePlugins?: boolean;
  119667. }
  119668. /**
  119669. * Default experience which provides a similar setup to the previous webVRExperience
  119670. */
  119671. export class WebXRDefaultExperience {
  119672. /**
  119673. * Base experience
  119674. */
  119675. baseExperience: WebXRExperienceHelper;
  119676. /**
  119677. * Enables ui for entering/exiting xr
  119678. */
  119679. enterExitUI: WebXREnterExitUI;
  119680. /**
  119681. * Input experience extension
  119682. */
  119683. input: WebXRInput;
  119684. /**
  119685. * Enables laser pointer and selection
  119686. */
  119687. pointerSelection: WebXRControllerPointerSelection;
  119688. /**
  119689. * Default target xr should render to
  119690. */
  119691. renderTarget: WebXRRenderTarget;
  119692. /**
  119693. * Enables teleportation
  119694. */
  119695. teleportation: WebXRMotionControllerTeleportation;
  119696. private constructor();
  119697. /**
  119698. * Creates the default xr experience
  119699. * @param scene scene
  119700. * @param options options for basic configuration
  119701. * @returns resulting WebXRDefaultExperience
  119702. */
  119703. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119704. /**
  119705. * DIsposes of the experience helper
  119706. */
  119707. dispose(): void;
  119708. }
  119709. }
  119710. declare module BABYLON {
  119711. /**
  119712. * Options to modify the vr teleportation behavior.
  119713. */
  119714. export interface VRTeleportationOptions {
  119715. /**
  119716. * The name of the mesh which should be used as the teleportation floor. (default: null)
  119717. */
  119718. floorMeshName?: string;
  119719. /**
  119720. * A list of meshes to be used as the teleportation floor. (default: empty)
  119721. */
  119722. floorMeshes?: Mesh[];
  119723. /**
  119724. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  119725. */
  119726. teleportationMode?: number;
  119727. /**
  119728. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  119729. */
  119730. teleportationTime?: number;
  119731. /**
  119732. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  119733. */
  119734. teleportationSpeed?: number;
  119735. /**
  119736. * The easing function used in the animation or null for Linear. (default CircleEase)
  119737. */
  119738. easingFunction?: EasingFunction;
  119739. }
  119740. /**
  119741. * Options to modify the vr experience helper's behavior.
  119742. */
  119743. export interface VRExperienceHelperOptions extends WebVROptions {
  119744. /**
  119745. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  119746. */
  119747. createDeviceOrientationCamera?: boolean;
  119748. /**
  119749. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  119750. */
  119751. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  119752. /**
  119753. * Uses the main button on the controller to toggle the laser casted. (default: true)
  119754. */
  119755. laserToggle?: boolean;
  119756. /**
  119757. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  119758. */
  119759. floorMeshes?: Mesh[];
  119760. /**
  119761. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  119762. */
  119763. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  119764. /**
  119765. * Defines if WebXR should be used instead of WebVR (if available)
  119766. */
  119767. useXR?: boolean;
  119768. }
  119769. /**
  119770. * Event containing information after VR has been entered
  119771. */
  119772. export class OnAfterEnteringVRObservableEvent {
  119773. /**
  119774. * If entering vr was successful
  119775. */
  119776. success: boolean;
  119777. }
  119778. /**
  119779. * Helps to quickly add VR support to an existing scene.
  119780. * See http://doc.babylonjs.com/how_to/webvr_helper
  119781. */
  119782. export class VRExperienceHelper {
  119783. /** Options to modify the vr experience helper's behavior. */
  119784. webVROptions: VRExperienceHelperOptions;
  119785. private _scene;
  119786. private _position;
  119787. private _btnVR;
  119788. private _btnVRDisplayed;
  119789. private _webVRsupported;
  119790. private _webVRready;
  119791. private _webVRrequesting;
  119792. private _webVRpresenting;
  119793. private _hasEnteredVR;
  119794. private _fullscreenVRpresenting;
  119795. private _inputElement;
  119796. private _webVRCamera;
  119797. private _vrDeviceOrientationCamera;
  119798. private _deviceOrientationCamera;
  119799. private _existingCamera;
  119800. private _onKeyDown;
  119801. private _onVrDisplayPresentChange;
  119802. private _onVRDisplayChanged;
  119803. private _onVRRequestPresentStart;
  119804. private _onVRRequestPresentComplete;
  119805. /**
  119806. * 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)
  119807. */
  119808. enableGazeEvenWhenNoPointerLock: boolean;
  119809. /**
  119810. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  119811. */
  119812. exitVROnDoubleTap: boolean;
  119813. /**
  119814. * Observable raised right before entering VR.
  119815. */
  119816. onEnteringVRObservable: Observable<VRExperienceHelper>;
  119817. /**
  119818. * Observable raised when entering VR has completed.
  119819. */
  119820. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  119821. /**
  119822. * Observable raised when exiting VR.
  119823. */
  119824. onExitingVRObservable: Observable<VRExperienceHelper>;
  119825. /**
  119826. * Observable raised when controller mesh is loaded.
  119827. */
  119828. onControllerMeshLoadedObservable: Observable<WebVRController>;
  119829. /** Return this.onEnteringVRObservable
  119830. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  119831. */
  119832. get onEnteringVR(): Observable<VRExperienceHelper>;
  119833. /** Return this.onExitingVRObservable
  119834. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  119835. */
  119836. get onExitingVR(): Observable<VRExperienceHelper>;
  119837. /** Return this.onControllerMeshLoadedObservable
  119838. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  119839. */
  119840. get onControllerMeshLoaded(): Observable<WebVRController>;
  119841. private _rayLength;
  119842. private _useCustomVRButton;
  119843. private _teleportationRequested;
  119844. private _teleportActive;
  119845. private _floorMeshName;
  119846. private _floorMeshesCollection;
  119847. private _teleportationMode;
  119848. private _teleportationTime;
  119849. private _teleportationSpeed;
  119850. private _teleportationEasing;
  119851. private _rotationAllowed;
  119852. private _teleportBackwardsVector;
  119853. private _teleportationTarget;
  119854. private _isDefaultTeleportationTarget;
  119855. private _postProcessMove;
  119856. private _teleportationFillColor;
  119857. private _teleportationBorderColor;
  119858. private _rotationAngle;
  119859. private _haloCenter;
  119860. private _cameraGazer;
  119861. private _padSensibilityUp;
  119862. private _padSensibilityDown;
  119863. private _leftController;
  119864. private _rightController;
  119865. private _gazeColor;
  119866. private _laserColor;
  119867. private _pickedLaserColor;
  119868. private _pickedGazeColor;
  119869. /**
  119870. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  119871. */
  119872. onNewMeshSelected: Observable<AbstractMesh>;
  119873. /**
  119874. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  119875. * This observable will provide the mesh and the controller used to select the mesh
  119876. */
  119877. onMeshSelectedWithController: Observable<{
  119878. mesh: AbstractMesh;
  119879. controller: WebVRController;
  119880. }>;
  119881. /**
  119882. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  119883. */
  119884. onNewMeshPicked: Observable<PickingInfo>;
  119885. private _circleEase;
  119886. /**
  119887. * Observable raised before camera teleportation
  119888. */
  119889. onBeforeCameraTeleport: Observable<Vector3>;
  119890. /**
  119891. * Observable raised after camera teleportation
  119892. */
  119893. onAfterCameraTeleport: Observable<Vector3>;
  119894. /**
  119895. * Observable raised when current selected mesh gets unselected
  119896. */
  119897. onSelectedMeshUnselected: Observable<AbstractMesh>;
  119898. private _raySelectionPredicate;
  119899. /**
  119900. * To be optionaly changed by user to define custom ray selection
  119901. */
  119902. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119903. /**
  119904. * To be optionaly changed by user to define custom selection logic (after ray selection)
  119905. */
  119906. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119907. /**
  119908. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  119909. */
  119910. teleportationEnabled: boolean;
  119911. private _defaultHeight;
  119912. private _teleportationInitialized;
  119913. private _interactionsEnabled;
  119914. private _interactionsRequested;
  119915. private _displayGaze;
  119916. private _displayLaserPointer;
  119917. /**
  119918. * The mesh used to display where the user is going to teleport.
  119919. */
  119920. get teleportationTarget(): Mesh;
  119921. /**
  119922. * Sets the mesh to be used to display where the user is going to teleport.
  119923. */
  119924. set teleportationTarget(value: Mesh);
  119925. /**
  119926. * 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
  119927. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119928. * See http://doc.babylonjs.com/resources/baking_transformations
  119929. */
  119930. get gazeTrackerMesh(): Mesh;
  119931. set gazeTrackerMesh(value: Mesh);
  119932. /**
  119933. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119934. */
  119935. updateGazeTrackerScale: boolean;
  119936. /**
  119937. * If the gaze trackers color should be updated when selecting meshes
  119938. */
  119939. updateGazeTrackerColor: boolean;
  119940. /**
  119941. * If the controller laser color should be updated when selecting meshes
  119942. */
  119943. updateControllerLaserColor: boolean;
  119944. /**
  119945. * The gaze tracking mesh corresponding to the left controller
  119946. */
  119947. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119948. /**
  119949. * The gaze tracking mesh corresponding to the right controller
  119950. */
  119951. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119952. /**
  119953. * If the ray of the gaze should be displayed.
  119954. */
  119955. get displayGaze(): boolean;
  119956. /**
  119957. * Sets if the ray of the gaze should be displayed.
  119958. */
  119959. set displayGaze(value: boolean);
  119960. /**
  119961. * If the ray of the LaserPointer should be displayed.
  119962. */
  119963. get displayLaserPointer(): boolean;
  119964. /**
  119965. * Sets if the ray of the LaserPointer should be displayed.
  119966. */
  119967. set displayLaserPointer(value: boolean);
  119968. /**
  119969. * The deviceOrientationCamera used as the camera when not in VR.
  119970. */
  119971. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119972. /**
  119973. * Based on the current WebVR support, returns the current VR camera used.
  119974. */
  119975. get currentVRCamera(): Nullable<Camera>;
  119976. /**
  119977. * The webVRCamera which is used when in VR.
  119978. */
  119979. get webVRCamera(): WebVRFreeCamera;
  119980. /**
  119981. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119982. */
  119983. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  119984. /**
  119985. * The html button that is used to trigger entering into VR.
  119986. */
  119987. get vrButton(): Nullable<HTMLButtonElement>;
  119988. private get _teleportationRequestInitiated();
  119989. /**
  119990. * Defines whether or not Pointer lock should be requested when switching to
  119991. * full screen.
  119992. */
  119993. requestPointerLockOnFullScreen: boolean;
  119994. /**
  119995. * If asking to force XR, this will be populated with the default xr experience
  119996. */
  119997. xr: WebXRDefaultExperience;
  119998. /**
  119999. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  120000. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  120001. */
  120002. xrTestDone: boolean;
  120003. /**
  120004. * Instantiates a VRExperienceHelper.
  120005. * Helps to quickly add VR support to an existing scene.
  120006. * @param scene The scene the VRExperienceHelper belongs to.
  120007. * @param webVROptions Options to modify the vr experience helper's behavior.
  120008. */
  120009. constructor(scene: Scene,
  120010. /** Options to modify the vr experience helper's behavior. */
  120011. webVROptions?: VRExperienceHelperOptions);
  120012. private completeVRInit;
  120013. private _onDefaultMeshLoaded;
  120014. private _onResize;
  120015. private _onFullscreenChange;
  120016. /**
  120017. * Gets a value indicating if we are currently in VR mode.
  120018. */
  120019. get isInVRMode(): boolean;
  120020. private onVrDisplayPresentChange;
  120021. private onVRDisplayChanged;
  120022. private moveButtonToBottomRight;
  120023. private displayVRButton;
  120024. private updateButtonVisibility;
  120025. private _cachedAngularSensibility;
  120026. /**
  120027. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  120028. * Otherwise, will use the fullscreen API.
  120029. */
  120030. enterVR(): void;
  120031. /**
  120032. * Attempt to exit VR, or fullscreen.
  120033. */
  120034. exitVR(): void;
  120035. /**
  120036. * The position of the vr experience helper.
  120037. */
  120038. get position(): Vector3;
  120039. /**
  120040. * Sets the position of the vr experience helper.
  120041. */
  120042. set position(value: Vector3);
  120043. /**
  120044. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  120045. */
  120046. enableInteractions(): void;
  120047. private get _noControllerIsActive();
  120048. private beforeRender;
  120049. private _isTeleportationFloor;
  120050. /**
  120051. * Adds a floor mesh to be used for teleportation.
  120052. * @param floorMesh the mesh to be used for teleportation.
  120053. */
  120054. addFloorMesh(floorMesh: Mesh): void;
  120055. /**
  120056. * Removes a floor mesh from being used for teleportation.
  120057. * @param floorMesh the mesh to be removed.
  120058. */
  120059. removeFloorMesh(floorMesh: Mesh): void;
  120060. /**
  120061. * Enables interactions and teleportation using the VR controllers and gaze.
  120062. * @param vrTeleportationOptions options to modify teleportation behavior.
  120063. */
  120064. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  120065. private _onNewGamepadConnected;
  120066. private _tryEnableInteractionOnController;
  120067. private _onNewGamepadDisconnected;
  120068. private _enableInteractionOnController;
  120069. private _checkTeleportWithRay;
  120070. private _checkRotate;
  120071. private _checkTeleportBackwards;
  120072. private _enableTeleportationOnController;
  120073. private _createTeleportationCircles;
  120074. private _displayTeleportationTarget;
  120075. private _hideTeleportationTarget;
  120076. private _rotateCamera;
  120077. private _moveTeleportationSelectorTo;
  120078. private _workingVector;
  120079. private _workingQuaternion;
  120080. private _workingMatrix;
  120081. /**
  120082. * Time Constant Teleportation Mode
  120083. */
  120084. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  120085. /**
  120086. * Speed Constant Teleportation Mode
  120087. */
  120088. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  120089. /**
  120090. * Teleports the users feet to the desired location
  120091. * @param location The location where the user's feet should be placed
  120092. */
  120093. teleportCamera(location: Vector3): void;
  120094. private _convertNormalToDirectionOfRay;
  120095. private _castRayAndSelectObject;
  120096. private _notifySelectedMeshUnselected;
  120097. /**
  120098. * Permanently set new colors for the laser pointer
  120099. * @param color the new laser color
  120100. * @param pickedColor the new laser color when picked mesh detected
  120101. */
  120102. setLaserColor(color: Color3, pickedColor?: Color3): void;
  120103. /**
  120104. * Set lighting enabled / disabled on the laser pointer of both controllers
  120105. * @param enabled should the lighting be enabled on the laser pointer
  120106. */
  120107. setLaserLightingState(enabled?: boolean): void;
  120108. /**
  120109. * Permanently set new colors for the gaze pointer
  120110. * @param color the new gaze color
  120111. * @param pickedColor the new gaze color when picked mesh detected
  120112. */
  120113. setGazeColor(color: Color3, pickedColor?: Color3): void;
  120114. /**
  120115. * Sets the color of the laser ray from the vr controllers.
  120116. * @param color new color for the ray.
  120117. */
  120118. changeLaserColor(color: Color3): void;
  120119. /**
  120120. * Sets the color of the ray from the vr headsets gaze.
  120121. * @param color new color for the ray.
  120122. */
  120123. changeGazeColor(color: Color3): void;
  120124. /**
  120125. * Exits VR and disposes of the vr experience helper
  120126. */
  120127. dispose(): void;
  120128. /**
  120129. * Gets the name of the VRExperienceHelper class
  120130. * @returns "VRExperienceHelper"
  120131. */
  120132. getClassName(): string;
  120133. }
  120134. }
  120135. declare module BABYLON {
  120136. /**
  120137. * Contains an array of blocks representing the octree
  120138. */
  120139. export interface IOctreeContainer<T> {
  120140. /**
  120141. * Blocks within the octree
  120142. */
  120143. blocks: Array<OctreeBlock<T>>;
  120144. }
  120145. /**
  120146. * Class used to store a cell in an octree
  120147. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120148. */
  120149. export class OctreeBlock<T> {
  120150. /**
  120151. * Gets the content of the current block
  120152. */
  120153. entries: T[];
  120154. /**
  120155. * Gets the list of block children
  120156. */
  120157. blocks: Array<OctreeBlock<T>>;
  120158. private _depth;
  120159. private _maxDepth;
  120160. private _capacity;
  120161. private _minPoint;
  120162. private _maxPoint;
  120163. private _boundingVectors;
  120164. private _creationFunc;
  120165. /**
  120166. * Creates a new block
  120167. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  120168. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  120169. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120170. * @param depth defines the current depth of this block in the octree
  120171. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  120172. * @param creationFunc defines a callback to call when an element is added to the block
  120173. */
  120174. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  120175. /**
  120176. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120177. */
  120178. get capacity(): number;
  120179. /**
  120180. * Gets the minimum vector (in world space) of the block's bounding box
  120181. */
  120182. get minPoint(): Vector3;
  120183. /**
  120184. * Gets the maximum vector (in world space) of the block's bounding box
  120185. */
  120186. get maxPoint(): Vector3;
  120187. /**
  120188. * Add a new element to this block
  120189. * @param entry defines the element to add
  120190. */
  120191. addEntry(entry: T): void;
  120192. /**
  120193. * Remove an element from this block
  120194. * @param entry defines the element to remove
  120195. */
  120196. removeEntry(entry: T): void;
  120197. /**
  120198. * Add an array of elements to this block
  120199. * @param entries defines the array of elements to add
  120200. */
  120201. addEntries(entries: T[]): void;
  120202. /**
  120203. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  120204. * @param frustumPlanes defines the frustum planes to test
  120205. * @param selection defines the array to store current content if selection is positive
  120206. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120207. */
  120208. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120209. /**
  120210. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  120211. * @param sphereCenter defines the bounding sphere center
  120212. * @param sphereRadius defines the bounding sphere radius
  120213. * @param selection defines the array to store current content if selection is positive
  120214. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120215. */
  120216. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120217. /**
  120218. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  120219. * @param ray defines the ray to test with
  120220. * @param selection defines the array to store current content if selection is positive
  120221. */
  120222. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  120223. /**
  120224. * Subdivide the content into child blocks (this block will then be empty)
  120225. */
  120226. createInnerBlocks(): void;
  120227. /**
  120228. * @hidden
  120229. */
  120230. 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;
  120231. }
  120232. }
  120233. declare module BABYLON {
  120234. /**
  120235. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  120236. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120237. */
  120238. export class Octree<T> {
  120239. /** 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.) */
  120240. maxDepth: number;
  120241. /**
  120242. * Blocks within the octree containing objects
  120243. */
  120244. blocks: Array<OctreeBlock<T>>;
  120245. /**
  120246. * Content stored in the octree
  120247. */
  120248. dynamicContent: T[];
  120249. private _maxBlockCapacity;
  120250. private _selectionContent;
  120251. private _creationFunc;
  120252. /**
  120253. * Creates a octree
  120254. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120255. * @param creationFunc function to be used to instatiate the octree
  120256. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  120257. * @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.)
  120258. */
  120259. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  120260. /** 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.) */
  120261. maxDepth?: number);
  120262. /**
  120263. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  120264. * @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);
  120265. * @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);
  120266. * @param entries meshes to be added to the octree blocks
  120267. */
  120268. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  120269. /**
  120270. * Adds a mesh to the octree
  120271. * @param entry Mesh to add to the octree
  120272. */
  120273. addMesh(entry: T): void;
  120274. /**
  120275. * Remove an element from the octree
  120276. * @param entry defines the element to remove
  120277. */
  120278. removeMesh(entry: T): void;
  120279. /**
  120280. * Selects an array of meshes within the frustum
  120281. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  120282. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  120283. * @returns array of meshes within the frustum
  120284. */
  120285. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  120286. /**
  120287. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  120288. * @param sphereCenter defines the bounding sphere center
  120289. * @param sphereRadius defines the bounding sphere radius
  120290. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120291. * @returns an array of objects that intersect the sphere
  120292. */
  120293. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  120294. /**
  120295. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  120296. * @param ray defines the ray to test with
  120297. * @returns array of intersected objects
  120298. */
  120299. intersectsRay(ray: Ray): SmartArray<T>;
  120300. /**
  120301. * Adds a mesh into the octree block if it intersects the block
  120302. */
  120303. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  120304. /**
  120305. * Adds a submesh into the octree block if it intersects the block
  120306. */
  120307. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  120308. }
  120309. }
  120310. declare module BABYLON {
  120311. interface Scene {
  120312. /**
  120313. * @hidden
  120314. * Backing Filed
  120315. */
  120316. _selectionOctree: Octree<AbstractMesh>;
  120317. /**
  120318. * Gets the octree used to boost mesh selection (picking)
  120319. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120320. */
  120321. selectionOctree: Octree<AbstractMesh>;
  120322. /**
  120323. * Creates or updates the octree used to boost selection (picking)
  120324. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120325. * @param maxCapacity defines the maximum capacity per leaf
  120326. * @param maxDepth defines the maximum depth of the octree
  120327. * @returns an octree of AbstractMesh
  120328. */
  120329. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  120330. }
  120331. interface AbstractMesh {
  120332. /**
  120333. * @hidden
  120334. * Backing Field
  120335. */
  120336. _submeshesOctree: Octree<SubMesh>;
  120337. /**
  120338. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  120339. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  120340. * @param maxCapacity defines the maximum size of each block (64 by default)
  120341. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  120342. * @returns the new octree
  120343. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  120344. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120345. */
  120346. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  120347. }
  120348. /**
  120349. * Defines the octree scene component responsible to manage any octrees
  120350. * in a given scene.
  120351. */
  120352. export class OctreeSceneComponent {
  120353. /**
  120354. * The component name help to identify the component in the list of scene components.
  120355. */
  120356. readonly name: string;
  120357. /**
  120358. * The scene the component belongs to.
  120359. */
  120360. scene: Scene;
  120361. /**
  120362. * Indicates if the meshes have been checked to make sure they are isEnabled()
  120363. */
  120364. readonly checksIsEnabled: boolean;
  120365. /**
  120366. * Creates a new instance of the component for the given scene
  120367. * @param scene Defines the scene to register the component in
  120368. */
  120369. constructor(scene: Scene);
  120370. /**
  120371. * Registers the component in a given scene
  120372. */
  120373. register(): void;
  120374. /**
  120375. * Return the list of active meshes
  120376. * @returns the list of active meshes
  120377. */
  120378. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120379. /**
  120380. * Return the list of active sub meshes
  120381. * @param mesh The mesh to get the candidates sub meshes from
  120382. * @returns the list of active sub meshes
  120383. */
  120384. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120385. private _tempRay;
  120386. /**
  120387. * Return the list of sub meshes intersecting with a given local ray
  120388. * @param mesh defines the mesh to find the submesh for
  120389. * @param localRay defines the ray in local space
  120390. * @returns the list of intersecting sub meshes
  120391. */
  120392. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  120393. /**
  120394. * Return the list of sub meshes colliding with a collider
  120395. * @param mesh defines the mesh to find the submesh for
  120396. * @param collider defines the collider to evaluate the collision against
  120397. * @returns the list of colliding sub meshes
  120398. */
  120399. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  120400. /**
  120401. * Rebuilds the elements related to this component in case of
  120402. * context lost for instance.
  120403. */
  120404. rebuild(): void;
  120405. /**
  120406. * Disposes the component and the associated ressources.
  120407. */
  120408. dispose(): void;
  120409. }
  120410. }
  120411. declare module BABYLON {
  120412. /**
  120413. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  120414. */
  120415. export class Gizmo implements IDisposable {
  120416. /** The utility layer the gizmo will be added to */
  120417. gizmoLayer: UtilityLayerRenderer;
  120418. /**
  120419. * The root mesh of the gizmo
  120420. */
  120421. _rootMesh: Mesh;
  120422. private _attachedMesh;
  120423. /**
  120424. * Ratio for the scale of the gizmo (Default: 1)
  120425. */
  120426. scaleRatio: number;
  120427. /**
  120428. * If a custom mesh has been set (Default: false)
  120429. */
  120430. protected _customMeshSet: boolean;
  120431. /**
  120432. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  120433. * * When set, interactions will be enabled
  120434. */
  120435. get attachedMesh(): Nullable<AbstractMesh>;
  120436. set attachedMesh(value: Nullable<AbstractMesh>);
  120437. /**
  120438. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120439. * @param mesh The mesh to replace the default mesh of the gizmo
  120440. */
  120441. setCustomMesh(mesh: Mesh): void;
  120442. /**
  120443. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  120444. */
  120445. updateGizmoRotationToMatchAttachedMesh: boolean;
  120446. /**
  120447. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  120448. */
  120449. updateGizmoPositionToMatchAttachedMesh: boolean;
  120450. /**
  120451. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  120452. */
  120453. updateScale: boolean;
  120454. protected _interactionsEnabled: boolean;
  120455. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120456. private _beforeRenderObserver;
  120457. private _tempVector;
  120458. /**
  120459. * Creates a gizmo
  120460. * @param gizmoLayer The utility layer the gizmo will be added to
  120461. */
  120462. constructor(
  120463. /** The utility layer the gizmo will be added to */
  120464. gizmoLayer?: UtilityLayerRenderer);
  120465. /**
  120466. * Updates the gizmo to match the attached mesh's position/rotation
  120467. */
  120468. protected _update(): void;
  120469. /**
  120470. * Disposes of the gizmo
  120471. */
  120472. dispose(): void;
  120473. }
  120474. }
  120475. declare module BABYLON {
  120476. /**
  120477. * Single plane drag gizmo
  120478. */
  120479. export class PlaneDragGizmo extends Gizmo {
  120480. /**
  120481. * Drag behavior responsible for the gizmos dragging interactions
  120482. */
  120483. dragBehavior: PointerDragBehavior;
  120484. private _pointerObserver;
  120485. /**
  120486. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120487. */
  120488. snapDistance: number;
  120489. /**
  120490. * Event that fires each time the gizmo snaps to a new location.
  120491. * * snapDistance is the the change in distance
  120492. */
  120493. onSnapObservable: Observable<{
  120494. snapDistance: number;
  120495. }>;
  120496. private _plane;
  120497. private _coloredMaterial;
  120498. private _hoverMaterial;
  120499. private _isEnabled;
  120500. private _parent;
  120501. /** @hidden */
  120502. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  120503. /** @hidden */
  120504. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120505. /**
  120506. * Creates a PlaneDragGizmo
  120507. * @param gizmoLayer The utility layer the gizmo will be added to
  120508. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  120509. * @param color The color of the gizmo
  120510. */
  120511. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120512. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120513. /**
  120514. * If the gizmo is enabled
  120515. */
  120516. set isEnabled(value: boolean);
  120517. get isEnabled(): boolean;
  120518. /**
  120519. * Disposes of the gizmo
  120520. */
  120521. dispose(): void;
  120522. }
  120523. }
  120524. declare module BABYLON {
  120525. /**
  120526. * Gizmo that enables dragging a mesh along 3 axis
  120527. */
  120528. export class PositionGizmo extends Gizmo {
  120529. /**
  120530. * Internal gizmo used for interactions on the x axis
  120531. */
  120532. xGizmo: AxisDragGizmo;
  120533. /**
  120534. * Internal gizmo used for interactions on the y axis
  120535. */
  120536. yGizmo: AxisDragGizmo;
  120537. /**
  120538. * Internal gizmo used for interactions on the z axis
  120539. */
  120540. zGizmo: AxisDragGizmo;
  120541. /**
  120542. * Internal gizmo used for interactions on the yz plane
  120543. */
  120544. xPlaneGizmo: PlaneDragGizmo;
  120545. /**
  120546. * Internal gizmo used for interactions on the xz plane
  120547. */
  120548. yPlaneGizmo: PlaneDragGizmo;
  120549. /**
  120550. * Internal gizmo used for interactions on the xy plane
  120551. */
  120552. zPlaneGizmo: PlaneDragGizmo;
  120553. /**
  120554. * private variables
  120555. */
  120556. private _meshAttached;
  120557. private _updateGizmoRotationToMatchAttachedMesh;
  120558. private _snapDistance;
  120559. private _scaleRatio;
  120560. /** Fires an event when any of it's sub gizmos are dragged */
  120561. onDragStartObservable: Observable<unknown>;
  120562. /** Fires an event when any of it's sub gizmos are released from dragging */
  120563. onDragEndObservable: Observable<unknown>;
  120564. /**
  120565. * If set to true, planar drag is enabled
  120566. */
  120567. private _planarGizmoEnabled;
  120568. get attachedMesh(): Nullable<AbstractMesh>;
  120569. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120570. /**
  120571. * Creates a PositionGizmo
  120572. * @param gizmoLayer The utility layer the gizmo will be added to
  120573. */
  120574. constructor(gizmoLayer?: UtilityLayerRenderer);
  120575. /**
  120576. * If the planar drag gizmo is enabled
  120577. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  120578. */
  120579. set planarGizmoEnabled(value: boolean);
  120580. get planarGizmoEnabled(): boolean;
  120581. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120582. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120583. /**
  120584. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120585. */
  120586. set snapDistance(value: number);
  120587. get snapDistance(): number;
  120588. /**
  120589. * Ratio for the scale of the gizmo (Default: 1)
  120590. */
  120591. set scaleRatio(value: number);
  120592. get scaleRatio(): number;
  120593. /**
  120594. * Disposes of the gizmo
  120595. */
  120596. dispose(): void;
  120597. /**
  120598. * CustomMeshes are not supported by this gizmo
  120599. * @param mesh The mesh to replace the default mesh of the gizmo
  120600. */
  120601. setCustomMesh(mesh: Mesh): void;
  120602. }
  120603. }
  120604. declare module BABYLON {
  120605. /**
  120606. * Single axis drag gizmo
  120607. */
  120608. export class AxisDragGizmo extends Gizmo {
  120609. /**
  120610. * Drag behavior responsible for the gizmos dragging interactions
  120611. */
  120612. dragBehavior: PointerDragBehavior;
  120613. private _pointerObserver;
  120614. /**
  120615. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120616. */
  120617. snapDistance: number;
  120618. /**
  120619. * Event that fires each time the gizmo snaps to a new location.
  120620. * * snapDistance is the the change in distance
  120621. */
  120622. onSnapObservable: Observable<{
  120623. snapDistance: number;
  120624. }>;
  120625. private _isEnabled;
  120626. private _parent;
  120627. private _arrow;
  120628. private _coloredMaterial;
  120629. private _hoverMaterial;
  120630. /** @hidden */
  120631. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  120632. /** @hidden */
  120633. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120634. /**
  120635. * Creates an AxisDragGizmo
  120636. * @param gizmoLayer The utility layer the gizmo will be added to
  120637. * @param dragAxis The axis which the gizmo will be able to drag on
  120638. * @param color The color of the gizmo
  120639. */
  120640. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120641. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120642. /**
  120643. * If the gizmo is enabled
  120644. */
  120645. set isEnabled(value: boolean);
  120646. get isEnabled(): boolean;
  120647. /**
  120648. * Disposes of the gizmo
  120649. */
  120650. dispose(): void;
  120651. }
  120652. }
  120653. declare module BABYLON.Debug {
  120654. /**
  120655. * The Axes viewer will show 3 axes in a specific point in space
  120656. */
  120657. export class AxesViewer {
  120658. private _xAxis;
  120659. private _yAxis;
  120660. private _zAxis;
  120661. private _scaleLinesFactor;
  120662. private _instanced;
  120663. /**
  120664. * Gets the hosting scene
  120665. */
  120666. scene: Scene;
  120667. /**
  120668. * Gets or sets a number used to scale line length
  120669. */
  120670. scaleLines: number;
  120671. /** Gets the node hierarchy used to render x-axis */
  120672. get xAxis(): TransformNode;
  120673. /** Gets the node hierarchy used to render y-axis */
  120674. get yAxis(): TransformNode;
  120675. /** Gets the node hierarchy used to render z-axis */
  120676. get zAxis(): TransformNode;
  120677. /**
  120678. * Creates a new AxesViewer
  120679. * @param scene defines the hosting scene
  120680. * @param scaleLines defines a number used to scale line length (1 by default)
  120681. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  120682. * @param xAxis defines the node hierarchy used to render the x-axis
  120683. * @param yAxis defines the node hierarchy used to render the y-axis
  120684. * @param zAxis defines the node hierarchy used to render the z-axis
  120685. */
  120686. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  120687. /**
  120688. * Force the viewer to update
  120689. * @param position defines the position of the viewer
  120690. * @param xaxis defines the x axis of the viewer
  120691. * @param yaxis defines the y axis of the viewer
  120692. * @param zaxis defines the z axis of the viewer
  120693. */
  120694. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  120695. /**
  120696. * Creates an instance of this axes viewer.
  120697. * @returns a new axes viewer with instanced meshes
  120698. */
  120699. createInstance(): AxesViewer;
  120700. /** Releases resources */
  120701. dispose(): void;
  120702. private static _SetRenderingGroupId;
  120703. }
  120704. }
  120705. declare module BABYLON.Debug {
  120706. /**
  120707. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  120708. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  120709. */
  120710. export class BoneAxesViewer extends AxesViewer {
  120711. /**
  120712. * Gets or sets the target mesh where to display the axes viewer
  120713. */
  120714. mesh: Nullable<Mesh>;
  120715. /**
  120716. * Gets or sets the target bone where to display the axes viewer
  120717. */
  120718. bone: Nullable<Bone>;
  120719. /** Gets current position */
  120720. pos: Vector3;
  120721. /** Gets direction of X axis */
  120722. xaxis: Vector3;
  120723. /** Gets direction of Y axis */
  120724. yaxis: Vector3;
  120725. /** Gets direction of Z axis */
  120726. zaxis: Vector3;
  120727. /**
  120728. * Creates a new BoneAxesViewer
  120729. * @param scene defines the hosting scene
  120730. * @param bone defines the target bone
  120731. * @param mesh defines the target mesh
  120732. * @param scaleLines defines a scaling factor for line length (1 by default)
  120733. */
  120734. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  120735. /**
  120736. * Force the viewer to update
  120737. */
  120738. update(): void;
  120739. /** Releases resources */
  120740. dispose(): void;
  120741. }
  120742. }
  120743. declare module BABYLON {
  120744. /**
  120745. * Interface used to define scene explorer extensibility option
  120746. */
  120747. export interface IExplorerExtensibilityOption {
  120748. /**
  120749. * Define the option label
  120750. */
  120751. label: string;
  120752. /**
  120753. * Defines the action to execute on click
  120754. */
  120755. action: (entity: any) => void;
  120756. }
  120757. /**
  120758. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  120759. */
  120760. export interface IExplorerExtensibilityGroup {
  120761. /**
  120762. * Defines a predicate to test if a given type mut be extended
  120763. */
  120764. predicate: (entity: any) => boolean;
  120765. /**
  120766. * Gets the list of options added to a type
  120767. */
  120768. entries: IExplorerExtensibilityOption[];
  120769. }
  120770. /**
  120771. * Interface used to define the options to use to create the Inspector
  120772. */
  120773. export interface IInspectorOptions {
  120774. /**
  120775. * Display in overlay mode (default: false)
  120776. */
  120777. overlay?: boolean;
  120778. /**
  120779. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  120780. */
  120781. globalRoot?: HTMLElement;
  120782. /**
  120783. * Display the Scene explorer
  120784. */
  120785. showExplorer?: boolean;
  120786. /**
  120787. * Display the property inspector
  120788. */
  120789. showInspector?: boolean;
  120790. /**
  120791. * Display in embed mode (both panes on the right)
  120792. */
  120793. embedMode?: boolean;
  120794. /**
  120795. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  120796. */
  120797. handleResize?: boolean;
  120798. /**
  120799. * Allow the panes to popup (default: true)
  120800. */
  120801. enablePopup?: boolean;
  120802. /**
  120803. * Allow the panes to be closed by users (default: true)
  120804. */
  120805. enableClose?: boolean;
  120806. /**
  120807. * Optional list of extensibility entries
  120808. */
  120809. explorerExtensibility?: IExplorerExtensibilityGroup[];
  120810. /**
  120811. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  120812. */
  120813. inspectorURL?: string;
  120814. /**
  120815. * Optional initial tab (default to DebugLayerTab.Properties)
  120816. */
  120817. initialTab?: DebugLayerTab;
  120818. }
  120819. interface Scene {
  120820. /**
  120821. * @hidden
  120822. * Backing field
  120823. */
  120824. _debugLayer: DebugLayer;
  120825. /**
  120826. * Gets the debug layer (aka Inspector) associated with the scene
  120827. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120828. */
  120829. debugLayer: DebugLayer;
  120830. }
  120831. /**
  120832. * Enum of inspector action tab
  120833. */
  120834. export enum DebugLayerTab {
  120835. /**
  120836. * Properties tag (default)
  120837. */
  120838. Properties = 0,
  120839. /**
  120840. * Debug tab
  120841. */
  120842. Debug = 1,
  120843. /**
  120844. * Statistics tab
  120845. */
  120846. Statistics = 2,
  120847. /**
  120848. * Tools tab
  120849. */
  120850. Tools = 3,
  120851. /**
  120852. * Settings tab
  120853. */
  120854. Settings = 4
  120855. }
  120856. /**
  120857. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120858. * what is happening in your scene
  120859. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120860. */
  120861. export class DebugLayer {
  120862. /**
  120863. * Define the url to get the inspector script from.
  120864. * By default it uses the babylonjs CDN.
  120865. * @ignoreNaming
  120866. */
  120867. static InspectorURL: string;
  120868. private _scene;
  120869. private BJSINSPECTOR;
  120870. private _onPropertyChangedObservable?;
  120871. /**
  120872. * Observable triggered when a property is changed through the inspector.
  120873. */
  120874. get onPropertyChangedObservable(): any;
  120875. /**
  120876. * Instantiates a new debug layer.
  120877. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120878. * what is happening in your scene
  120879. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120880. * @param scene Defines the scene to inspect
  120881. */
  120882. constructor(scene: Scene);
  120883. /** Creates the inspector window. */
  120884. private _createInspector;
  120885. /**
  120886. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  120887. * @param entity defines the entity to select
  120888. * @param lineContainerTitle defines the specific block to highlight
  120889. */
  120890. select(entity: any, lineContainerTitle?: string): void;
  120891. /** Get the inspector from bundle or global */
  120892. private _getGlobalInspector;
  120893. /**
  120894. * Get if the inspector is visible or not.
  120895. * @returns true if visible otherwise, false
  120896. */
  120897. isVisible(): boolean;
  120898. /**
  120899. * Hide the inspector and close its window.
  120900. */
  120901. hide(): void;
  120902. /**
  120903. * Launch the debugLayer.
  120904. * @param config Define the configuration of the inspector
  120905. * @return a promise fulfilled when the debug layer is visible
  120906. */
  120907. show(config?: IInspectorOptions): Promise<DebugLayer>;
  120908. }
  120909. }
  120910. declare module BABYLON {
  120911. /**
  120912. * Class containing static functions to help procedurally build meshes
  120913. */
  120914. export class BoxBuilder {
  120915. /**
  120916. * Creates a box mesh
  120917. * * The parameter `size` sets the size (float) of each box side (default 1)
  120918. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120919. * * 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)
  120920. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120924. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120925. * @param name defines the name of the mesh
  120926. * @param options defines the options used to create the mesh
  120927. * @param scene defines the hosting scene
  120928. * @returns the box mesh
  120929. */
  120930. static CreateBox(name: string, options: {
  120931. size?: number;
  120932. width?: number;
  120933. height?: number;
  120934. depth?: number;
  120935. faceUV?: Vector4[];
  120936. faceColors?: Color4[];
  120937. sideOrientation?: number;
  120938. frontUVs?: Vector4;
  120939. backUVs?: Vector4;
  120940. wrap?: boolean;
  120941. topBaseAt?: number;
  120942. bottomBaseAt?: number;
  120943. updatable?: boolean;
  120944. }, scene?: Nullable<Scene>): Mesh;
  120945. }
  120946. }
  120947. declare module BABYLON.Debug {
  120948. /**
  120949. * Used to show the physics impostor around the specific mesh
  120950. */
  120951. export class PhysicsViewer {
  120952. /** @hidden */
  120953. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120954. /** @hidden */
  120955. protected _meshes: Array<Nullable<AbstractMesh>>;
  120956. /** @hidden */
  120957. protected _scene: Nullable<Scene>;
  120958. /** @hidden */
  120959. protected _numMeshes: number;
  120960. /** @hidden */
  120961. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120962. private _renderFunction;
  120963. private _utilityLayer;
  120964. private _debugBoxMesh;
  120965. private _debugSphereMesh;
  120966. private _debugCylinderMesh;
  120967. private _debugMaterial;
  120968. private _debugMeshMeshes;
  120969. /**
  120970. * Creates a new PhysicsViewer
  120971. * @param scene defines the hosting scene
  120972. */
  120973. constructor(scene: Scene);
  120974. /** @hidden */
  120975. protected _updateDebugMeshes(): void;
  120976. /**
  120977. * Renders a specified physic impostor
  120978. * @param impostor defines the impostor to render
  120979. * @param targetMesh defines the mesh represented by the impostor
  120980. * @returns the new debug mesh used to render the impostor
  120981. */
  120982. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  120983. /**
  120984. * Hides a specified physic impostor
  120985. * @param impostor defines the impostor to hide
  120986. */
  120987. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  120988. private _getDebugMaterial;
  120989. private _getDebugBoxMesh;
  120990. private _getDebugSphereMesh;
  120991. private _getDebugCylinderMesh;
  120992. private _getDebugMeshMesh;
  120993. private _getDebugMesh;
  120994. /** Releases all resources */
  120995. dispose(): void;
  120996. }
  120997. }
  120998. declare module BABYLON {
  120999. /**
  121000. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121001. * in order to better appreciate the issue one might have.
  121002. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121003. */
  121004. export class RayHelper {
  121005. /**
  121006. * Defines the ray we are currently tryin to visualize.
  121007. */
  121008. ray: Nullable<Ray>;
  121009. private _renderPoints;
  121010. private _renderLine;
  121011. private _renderFunction;
  121012. private _scene;
  121013. private _updateToMeshFunction;
  121014. private _attachedToMesh;
  121015. private _meshSpaceDirection;
  121016. private _meshSpaceOrigin;
  121017. /**
  121018. * Helper function to create a colored helper in a scene in one line.
  121019. * @param ray Defines the ray we are currently tryin to visualize
  121020. * @param scene Defines the scene the ray is used in
  121021. * @param color Defines the color we want to see the ray in
  121022. * @returns The newly created ray helper.
  121023. */
  121024. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  121025. /**
  121026. * Instantiate a new ray helper.
  121027. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121028. * in order to better appreciate the issue one might have.
  121029. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121030. * @param ray Defines the ray we are currently tryin to visualize
  121031. */
  121032. constructor(ray: Ray);
  121033. /**
  121034. * Shows the ray we are willing to debug.
  121035. * @param scene Defines the scene the ray needs to be rendered in
  121036. * @param color Defines the color the ray needs to be rendered in
  121037. */
  121038. show(scene: Scene, color?: Color3): void;
  121039. /**
  121040. * Hides the ray we are debugging.
  121041. */
  121042. hide(): void;
  121043. private _render;
  121044. /**
  121045. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  121046. * @param mesh Defines the mesh we want the helper attached to
  121047. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  121048. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  121049. * @param length Defines the length of the ray
  121050. */
  121051. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  121052. /**
  121053. * Detach the ray helper from the mesh it has previously been attached to.
  121054. */
  121055. detachFromMesh(): void;
  121056. private _updateToMesh;
  121057. /**
  121058. * Dispose the helper and release its associated resources.
  121059. */
  121060. dispose(): void;
  121061. }
  121062. }
  121063. declare module BABYLON.Debug {
  121064. /**
  121065. * Class used to render a debug view of a given skeleton
  121066. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  121067. */
  121068. export class SkeletonViewer {
  121069. /** defines the skeleton to render */
  121070. skeleton: Skeleton;
  121071. /** defines the mesh attached to the skeleton */
  121072. mesh: AbstractMesh;
  121073. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121074. autoUpdateBonesMatrices: boolean;
  121075. /** defines the rendering group id to use with the viewer */
  121076. renderingGroupId: number;
  121077. /** Gets or sets the color used to render the skeleton */
  121078. color: Color3;
  121079. private _scene;
  121080. private _debugLines;
  121081. private _debugMesh;
  121082. private _isEnabled;
  121083. private _renderFunction;
  121084. private _utilityLayer;
  121085. /**
  121086. * Returns the mesh used to render the bones
  121087. */
  121088. get debugMesh(): Nullable<LinesMesh>;
  121089. /**
  121090. * Creates a new SkeletonViewer
  121091. * @param skeleton defines the skeleton to render
  121092. * @param mesh defines the mesh attached to the skeleton
  121093. * @param scene defines the hosting scene
  121094. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  121095. * @param renderingGroupId defines the rendering group id to use with the viewer
  121096. */
  121097. constructor(
  121098. /** defines the skeleton to render */
  121099. skeleton: Skeleton,
  121100. /** defines the mesh attached to the skeleton */
  121101. mesh: AbstractMesh, scene: Scene,
  121102. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121103. autoUpdateBonesMatrices?: boolean,
  121104. /** defines the rendering group id to use with the viewer */
  121105. renderingGroupId?: number);
  121106. /** Gets or sets a boolean indicating if the viewer is enabled */
  121107. set isEnabled(value: boolean);
  121108. get isEnabled(): boolean;
  121109. private _getBonePosition;
  121110. private _getLinesForBonesWithLength;
  121111. private _getLinesForBonesNoLength;
  121112. /** Update the viewer to sync with current skeleton state */
  121113. update(): void;
  121114. /** Release associated resources */
  121115. dispose(): void;
  121116. }
  121117. }
  121118. declare module BABYLON {
  121119. /**
  121120. * Options to create the null engine
  121121. */
  121122. export class NullEngineOptions {
  121123. /**
  121124. * Render width (Default: 512)
  121125. */
  121126. renderWidth: number;
  121127. /**
  121128. * Render height (Default: 256)
  121129. */
  121130. renderHeight: number;
  121131. /**
  121132. * Texture size (Default: 512)
  121133. */
  121134. textureSize: number;
  121135. /**
  121136. * If delta time between frames should be constant
  121137. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121138. */
  121139. deterministicLockstep: boolean;
  121140. /**
  121141. * Maximum about of steps between frames (Default: 4)
  121142. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121143. */
  121144. lockstepMaxSteps: number;
  121145. }
  121146. /**
  121147. * The null engine class provides support for headless version of babylon.js.
  121148. * This can be used in server side scenario or for testing purposes
  121149. */
  121150. export class NullEngine extends Engine {
  121151. private _options;
  121152. /**
  121153. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121154. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121155. * @returns true if engine is in deterministic lock step mode
  121156. */
  121157. isDeterministicLockStep(): boolean;
  121158. /**
  121159. * Gets the max steps when engine is running in deterministic lock step
  121160. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121161. * @returns the max steps
  121162. */
  121163. getLockstepMaxSteps(): number;
  121164. /**
  121165. * Gets the current hardware scaling level.
  121166. * By default the hardware scaling level is computed from the window device ratio.
  121167. * 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.
  121168. * @returns a number indicating the current hardware scaling level
  121169. */
  121170. getHardwareScalingLevel(): number;
  121171. constructor(options?: NullEngineOptions);
  121172. /**
  121173. * Creates a vertex buffer
  121174. * @param vertices the data for the vertex buffer
  121175. * @returns the new WebGL static buffer
  121176. */
  121177. createVertexBuffer(vertices: FloatArray): DataBuffer;
  121178. /**
  121179. * Creates a new index buffer
  121180. * @param indices defines the content of the index buffer
  121181. * @param updatable defines if the index buffer must be updatable
  121182. * @returns a new webGL buffer
  121183. */
  121184. createIndexBuffer(indices: IndicesArray): DataBuffer;
  121185. /**
  121186. * Clear the current render buffer or the current render target (if any is set up)
  121187. * @param color defines the color to use
  121188. * @param backBuffer defines if the back buffer must be cleared
  121189. * @param depth defines if the depth buffer must be cleared
  121190. * @param stencil defines if the stencil buffer must be cleared
  121191. */
  121192. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121193. /**
  121194. * Gets the current render width
  121195. * @param useScreen defines if screen size must be used (or the current render target if any)
  121196. * @returns a number defining the current render width
  121197. */
  121198. getRenderWidth(useScreen?: boolean): number;
  121199. /**
  121200. * Gets the current render height
  121201. * @param useScreen defines if screen size must be used (or the current render target if any)
  121202. * @returns a number defining the current render height
  121203. */
  121204. getRenderHeight(useScreen?: boolean): number;
  121205. /**
  121206. * Set the WebGL's viewport
  121207. * @param viewport defines the viewport element to be used
  121208. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121209. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121210. */
  121211. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121212. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  121213. /**
  121214. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121215. * @param pipelineContext defines the pipeline context to use
  121216. * @param uniformsNames defines the list of uniform names
  121217. * @returns an array of webGL uniform locations
  121218. */
  121219. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121220. /**
  121221. * Gets the lsit of active attributes for a given webGL program
  121222. * @param pipelineContext defines the pipeline context to use
  121223. * @param attributesNames defines the list of attribute names to get
  121224. * @returns an array of indices indicating the offset of each attribute
  121225. */
  121226. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121227. /**
  121228. * Binds an effect to the webGL context
  121229. * @param effect defines the effect to bind
  121230. */
  121231. bindSamplers(effect: Effect): void;
  121232. /**
  121233. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121234. * @param effect defines the effect to activate
  121235. */
  121236. enableEffect(effect: Effect): void;
  121237. /**
  121238. * Set various states to the webGL context
  121239. * @param culling defines backface culling state
  121240. * @param zOffset defines the value to apply to zOffset (0 by default)
  121241. * @param force defines if states must be applied even if cache is up to date
  121242. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121243. */
  121244. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121245. /**
  121246. * Set the value of an uniform to an array of int32
  121247. * @param uniform defines the webGL uniform location where to store the value
  121248. * @param array defines the array of int32 to store
  121249. */
  121250. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121251. /**
  121252. * Set the value of an uniform to an array of int32 (stored as vec2)
  121253. * @param uniform defines the webGL uniform location where to store the value
  121254. * @param array defines the array of int32 to store
  121255. */
  121256. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121257. /**
  121258. * Set the value of an uniform to an array of int32 (stored as vec3)
  121259. * @param uniform defines the webGL uniform location where to store the value
  121260. * @param array defines the array of int32 to store
  121261. */
  121262. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121263. /**
  121264. * Set the value of an uniform to an array of int32 (stored as vec4)
  121265. * @param uniform defines the webGL uniform location where to store the value
  121266. * @param array defines the array of int32 to store
  121267. */
  121268. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121269. /**
  121270. * Set the value of an uniform to an array of float32
  121271. * @param uniform defines the webGL uniform location where to store the value
  121272. * @param array defines the array of float32 to store
  121273. */
  121274. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121275. /**
  121276. * Set the value of an uniform to an array of float32 (stored as vec2)
  121277. * @param uniform defines the webGL uniform location where to store the value
  121278. * @param array defines the array of float32 to store
  121279. */
  121280. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121281. /**
  121282. * Set the value of an uniform to an array of float32 (stored as vec3)
  121283. * @param uniform defines the webGL uniform location where to store the value
  121284. * @param array defines the array of float32 to store
  121285. */
  121286. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121287. /**
  121288. * Set the value of an uniform to an array of float32 (stored as vec4)
  121289. * @param uniform defines the webGL uniform location where to store the value
  121290. * @param array defines the array of float32 to store
  121291. */
  121292. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121293. /**
  121294. * Set the value of an uniform to an array of number
  121295. * @param uniform defines the webGL uniform location where to store the value
  121296. * @param array defines the array of number to store
  121297. */
  121298. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121299. /**
  121300. * Set the value of an uniform to an array of number (stored as vec2)
  121301. * @param uniform defines the webGL uniform location where to store the value
  121302. * @param array defines the array of number to store
  121303. */
  121304. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121305. /**
  121306. * Set the value of an uniform to an array of number (stored as vec3)
  121307. * @param uniform defines the webGL uniform location where to store the value
  121308. * @param array defines the array of number to store
  121309. */
  121310. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121311. /**
  121312. * Set the value of an uniform to an array of number (stored as vec4)
  121313. * @param uniform defines the webGL uniform location where to store the value
  121314. * @param array defines the array of number to store
  121315. */
  121316. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121317. /**
  121318. * Set the value of an uniform to an array of float32 (stored as matrices)
  121319. * @param uniform defines the webGL uniform location where to store the value
  121320. * @param matrices defines the array of float32 to store
  121321. */
  121322. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121323. /**
  121324. * Set the value of an uniform to a matrix (3x3)
  121325. * @param uniform defines the webGL uniform location where to store the value
  121326. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121327. */
  121328. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121329. /**
  121330. * Set the value of an uniform to a matrix (2x2)
  121331. * @param uniform defines the webGL uniform location where to store the value
  121332. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121333. */
  121334. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121335. /**
  121336. * Set the value of an uniform to a number (float)
  121337. * @param uniform defines the webGL uniform location where to store the value
  121338. * @param value defines the float number to store
  121339. */
  121340. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121341. /**
  121342. * Set the value of an uniform to a vec2
  121343. * @param uniform defines the webGL uniform location where to store the value
  121344. * @param x defines the 1st component of the value
  121345. * @param y defines the 2nd component of the value
  121346. */
  121347. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121348. /**
  121349. * Set the value of an uniform to a vec3
  121350. * @param uniform defines the webGL uniform location where to store the value
  121351. * @param x defines the 1st component of the value
  121352. * @param y defines the 2nd component of the value
  121353. * @param z defines the 3rd component of the value
  121354. */
  121355. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121356. /**
  121357. * Set the value of an uniform to a boolean
  121358. * @param uniform defines the webGL uniform location where to store the value
  121359. * @param bool defines the boolean to store
  121360. */
  121361. setBool(uniform: WebGLUniformLocation, bool: number): void;
  121362. /**
  121363. * Set the value of an uniform to a vec4
  121364. * @param uniform defines the webGL uniform location where to store the value
  121365. * @param x defines the 1st component of the value
  121366. * @param y defines the 2nd component of the value
  121367. * @param z defines the 3rd component of the value
  121368. * @param w defines the 4th component of the value
  121369. */
  121370. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121371. /**
  121372. * Sets the current alpha mode
  121373. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  121374. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121375. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121376. */
  121377. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121378. /**
  121379. * Bind webGl buffers directly to the webGL context
  121380. * @param vertexBuffers defines the vertex buffer to bind
  121381. * @param indexBuffer defines the index buffer to bind
  121382. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121383. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121384. * @param effect defines the effect associated with the vertex buffer
  121385. */
  121386. bindBuffers(vertexBuffers: {
  121387. [key: string]: VertexBuffer;
  121388. }, indexBuffer: DataBuffer, effect: Effect): void;
  121389. /**
  121390. * Force the entire cache to be cleared
  121391. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121392. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121393. */
  121394. wipeCaches(bruteForce?: boolean): void;
  121395. /**
  121396. * Send a draw order
  121397. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121398. * @param indexStart defines the starting index
  121399. * @param indexCount defines the number of index to draw
  121400. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121401. */
  121402. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121403. /**
  121404. * Draw a list of indexed primitives
  121405. * @param fillMode defines the primitive to use
  121406. * @param indexStart defines the starting index
  121407. * @param indexCount defines the number of index to draw
  121408. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121409. */
  121410. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121411. /**
  121412. * Draw a list of unindexed primitives
  121413. * @param fillMode defines the primitive to use
  121414. * @param verticesStart defines the index of first vertex to draw
  121415. * @param verticesCount defines the count of vertices to draw
  121416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121417. */
  121418. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121419. /** @hidden */
  121420. _createTexture(): WebGLTexture;
  121421. /** @hidden */
  121422. _releaseTexture(texture: InternalTexture): void;
  121423. /**
  121424. * Usually called from Texture.ts.
  121425. * Passed information to create a WebGLTexture
  121426. * @param urlArg defines a value which contains one of the following:
  121427. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121428. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121429. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121430. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121431. * @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)
  121432. * @param scene needed for loading to the correct scene
  121433. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121434. * @param onLoad optional callback to be called upon successful completion
  121435. * @param onError optional callback to be called upon failure
  121436. * @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
  121437. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121438. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121439. * @param forcedExtension defines the extension to use to pick the right loader
  121440. * @param mimeType defines an optional mime type
  121441. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121442. */
  121443. 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;
  121444. /**
  121445. * Creates a new render target texture
  121446. * @param size defines the size of the texture
  121447. * @param options defines the options used to create the texture
  121448. * @returns a new render target texture stored in an InternalTexture
  121449. */
  121450. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  121451. /**
  121452. * Update the sampling mode of a given texture
  121453. * @param samplingMode defines the required sampling mode
  121454. * @param texture defines the texture to update
  121455. */
  121456. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121457. /**
  121458. * Binds the frame buffer to the specified texture.
  121459. * @param texture The texture to render to or null for the default canvas
  121460. * @param faceIndex The face of the texture to render to in case of cube texture
  121461. * @param requiredWidth The width of the target to render to
  121462. * @param requiredHeight The height of the target to render to
  121463. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121464. * @param lodLevel defines le lod level to bind to the frame buffer
  121465. */
  121466. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121467. /**
  121468. * Unbind the current render target texture from the webGL context
  121469. * @param texture defines the render target texture to unbind
  121470. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121471. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121472. */
  121473. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121474. /**
  121475. * Creates a dynamic vertex buffer
  121476. * @param vertices the data for the dynamic vertex buffer
  121477. * @returns the new WebGL dynamic buffer
  121478. */
  121479. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  121480. /**
  121481. * Update the content of a dynamic texture
  121482. * @param texture defines the texture to update
  121483. * @param canvas defines the canvas containing the source
  121484. * @param invertY defines if data must be stored with Y axis inverted
  121485. * @param premulAlpha defines if alpha is stored as premultiplied
  121486. * @param format defines the format of the data
  121487. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  121488. */
  121489. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  121490. /**
  121491. * Gets a boolean indicating if all created effects are ready
  121492. * @returns true if all effects are ready
  121493. */
  121494. areAllEffectsReady(): boolean;
  121495. /**
  121496. * @hidden
  121497. * Get the current error code of the webGL context
  121498. * @returns the error code
  121499. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121500. */
  121501. getError(): number;
  121502. /** @hidden */
  121503. _getUnpackAlignement(): number;
  121504. /** @hidden */
  121505. _unpackFlipY(value: boolean): void;
  121506. /**
  121507. * Update a dynamic index buffer
  121508. * @param indexBuffer defines the target index buffer
  121509. * @param indices defines the data to update
  121510. * @param offset defines the offset in the target index buffer where update should start
  121511. */
  121512. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  121513. /**
  121514. * Updates a dynamic vertex buffer.
  121515. * @param vertexBuffer the vertex buffer to update
  121516. * @param vertices the data used to update the vertex buffer
  121517. * @param byteOffset the byte offset of the data (optional)
  121518. * @param byteLength the byte length of the data (optional)
  121519. */
  121520. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  121521. /** @hidden */
  121522. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  121523. /** @hidden */
  121524. _bindTexture(channel: number, texture: InternalTexture): void;
  121525. protected _deleteBuffer(buffer: WebGLBuffer): void;
  121526. /**
  121527. * 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
  121528. */
  121529. releaseEffects(): void;
  121530. displayLoadingUI(): void;
  121531. hideLoadingUI(): void;
  121532. /** @hidden */
  121533. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121534. /** @hidden */
  121535. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121536. /** @hidden */
  121537. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121538. /** @hidden */
  121539. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121540. }
  121541. }
  121542. declare module BABYLON {
  121543. /**
  121544. * @hidden
  121545. **/
  121546. export class _TimeToken {
  121547. _startTimeQuery: Nullable<WebGLQuery>;
  121548. _endTimeQuery: Nullable<WebGLQuery>;
  121549. _timeElapsedQuery: Nullable<WebGLQuery>;
  121550. _timeElapsedQueryEnded: boolean;
  121551. }
  121552. }
  121553. declare module BABYLON {
  121554. /** @hidden */
  121555. export class _OcclusionDataStorage {
  121556. /** @hidden */
  121557. occlusionInternalRetryCounter: number;
  121558. /** @hidden */
  121559. isOcclusionQueryInProgress: boolean;
  121560. /** @hidden */
  121561. isOccluded: boolean;
  121562. /** @hidden */
  121563. occlusionRetryCount: number;
  121564. /** @hidden */
  121565. occlusionType: number;
  121566. /** @hidden */
  121567. occlusionQueryAlgorithmType: number;
  121568. }
  121569. interface Engine {
  121570. /**
  121571. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  121572. * @return the new query
  121573. */
  121574. createQuery(): WebGLQuery;
  121575. /**
  121576. * Delete and release a webGL query
  121577. * @param query defines the query to delete
  121578. * @return the current engine
  121579. */
  121580. deleteQuery(query: WebGLQuery): Engine;
  121581. /**
  121582. * Check if a given query has resolved and got its value
  121583. * @param query defines the query to check
  121584. * @returns true if the query got its value
  121585. */
  121586. isQueryResultAvailable(query: WebGLQuery): boolean;
  121587. /**
  121588. * Gets the value of a given query
  121589. * @param query defines the query to check
  121590. * @returns the value of the query
  121591. */
  121592. getQueryResult(query: WebGLQuery): number;
  121593. /**
  121594. * Initiates an occlusion query
  121595. * @param algorithmType defines the algorithm to use
  121596. * @param query defines the query to use
  121597. * @returns the current engine
  121598. * @see http://doc.babylonjs.com/features/occlusionquery
  121599. */
  121600. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  121601. /**
  121602. * Ends an occlusion query
  121603. * @see http://doc.babylonjs.com/features/occlusionquery
  121604. * @param algorithmType defines the algorithm to use
  121605. * @returns the current engine
  121606. */
  121607. endOcclusionQuery(algorithmType: number): Engine;
  121608. /**
  121609. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  121610. * Please note that only one query can be issued at a time
  121611. * @returns a time token used to track the time span
  121612. */
  121613. startTimeQuery(): Nullable<_TimeToken>;
  121614. /**
  121615. * Ends a time query
  121616. * @param token defines the token used to measure the time span
  121617. * @returns the time spent (in ns)
  121618. */
  121619. endTimeQuery(token: _TimeToken): int;
  121620. /** @hidden */
  121621. _currentNonTimestampToken: Nullable<_TimeToken>;
  121622. /** @hidden */
  121623. _createTimeQuery(): WebGLQuery;
  121624. /** @hidden */
  121625. _deleteTimeQuery(query: WebGLQuery): void;
  121626. /** @hidden */
  121627. _getGlAlgorithmType(algorithmType: number): number;
  121628. /** @hidden */
  121629. _getTimeQueryResult(query: WebGLQuery): any;
  121630. /** @hidden */
  121631. _getTimeQueryAvailability(query: WebGLQuery): any;
  121632. }
  121633. interface AbstractMesh {
  121634. /**
  121635. * Backing filed
  121636. * @hidden
  121637. */
  121638. __occlusionDataStorage: _OcclusionDataStorage;
  121639. /**
  121640. * Access property
  121641. * @hidden
  121642. */
  121643. _occlusionDataStorage: _OcclusionDataStorage;
  121644. /**
  121645. * 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.
  121646. * The default value is -1 which means don't break the query and wait till the result
  121647. * @see http://doc.babylonjs.com/features/occlusionquery
  121648. */
  121649. occlusionRetryCount: number;
  121650. /**
  121651. * 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:
  121652. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  121653. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  121654. * * 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.
  121655. * @see http://doc.babylonjs.com/features/occlusionquery
  121656. */
  121657. occlusionType: number;
  121658. /**
  121659. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  121660. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  121661. * * 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.
  121662. * @see http://doc.babylonjs.com/features/occlusionquery
  121663. */
  121664. occlusionQueryAlgorithmType: number;
  121665. /**
  121666. * 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
  121667. * @see http://doc.babylonjs.com/features/occlusionquery
  121668. */
  121669. isOccluded: boolean;
  121670. /**
  121671. * Flag to check the progress status of the query
  121672. * @see http://doc.babylonjs.com/features/occlusionquery
  121673. */
  121674. isOcclusionQueryInProgress: boolean;
  121675. }
  121676. }
  121677. declare module BABYLON {
  121678. /** @hidden */
  121679. export var _forceTransformFeedbackToBundle: boolean;
  121680. interface Engine {
  121681. /**
  121682. * Creates a webGL transform feedback object
  121683. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  121684. * @returns the webGL transform feedback object
  121685. */
  121686. createTransformFeedback(): WebGLTransformFeedback;
  121687. /**
  121688. * Delete a webGL transform feedback object
  121689. * @param value defines the webGL transform feedback object to delete
  121690. */
  121691. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  121692. /**
  121693. * Bind a webGL transform feedback object to the webgl context
  121694. * @param value defines the webGL transform feedback object to bind
  121695. */
  121696. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  121697. /**
  121698. * Begins a transform feedback operation
  121699. * @param usePoints defines if points or triangles must be used
  121700. */
  121701. beginTransformFeedback(usePoints: boolean): void;
  121702. /**
  121703. * Ends a transform feedback operation
  121704. */
  121705. endTransformFeedback(): void;
  121706. /**
  121707. * Specify the varyings to use with transform feedback
  121708. * @param program defines the associated webGL program
  121709. * @param value defines the list of strings representing the varying names
  121710. */
  121711. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  121712. /**
  121713. * Bind a webGL buffer for a transform feedback operation
  121714. * @param value defines the webGL buffer to bind
  121715. */
  121716. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  121717. }
  121718. }
  121719. declare module BABYLON {
  121720. /**
  121721. * Creation options of the multi render target texture.
  121722. */
  121723. export interface IMultiRenderTargetOptions {
  121724. /**
  121725. * Define if the texture needs to create mip maps after render.
  121726. */
  121727. generateMipMaps?: boolean;
  121728. /**
  121729. * Define the types of all the draw buffers we want to create
  121730. */
  121731. types?: number[];
  121732. /**
  121733. * Define the sampling modes of all the draw buffers we want to create
  121734. */
  121735. samplingModes?: number[];
  121736. /**
  121737. * Define if a depth buffer is required
  121738. */
  121739. generateDepthBuffer?: boolean;
  121740. /**
  121741. * Define if a stencil buffer is required
  121742. */
  121743. generateStencilBuffer?: boolean;
  121744. /**
  121745. * Define if a depth texture is required instead of a depth buffer
  121746. */
  121747. generateDepthTexture?: boolean;
  121748. /**
  121749. * Define the number of desired draw buffers
  121750. */
  121751. textureCount?: number;
  121752. /**
  121753. * Define if aspect ratio should be adapted to the texture or stay the scene one
  121754. */
  121755. doNotChangeAspectRatio?: boolean;
  121756. /**
  121757. * Define the default type of the buffers we are creating
  121758. */
  121759. defaultType?: number;
  121760. }
  121761. /**
  121762. * A multi render target, like a render target provides the ability to render to a texture.
  121763. * Unlike the render target, it can render to several draw buffers in one draw.
  121764. * This is specially interesting in deferred rendering or for any effects requiring more than
  121765. * just one color from a single pass.
  121766. */
  121767. export class MultiRenderTarget extends RenderTargetTexture {
  121768. private _internalTextures;
  121769. private _textures;
  121770. private _multiRenderTargetOptions;
  121771. /**
  121772. * Get if draw buffers are currently supported by the used hardware and browser.
  121773. */
  121774. get isSupported(): boolean;
  121775. /**
  121776. * Get the list of textures generated by the multi render target.
  121777. */
  121778. get textures(): Texture[];
  121779. /**
  121780. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  121781. */
  121782. get depthTexture(): Texture;
  121783. /**
  121784. * Set the wrapping mode on U of all the textures we are rendering to.
  121785. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121786. */
  121787. set wrapU(wrap: number);
  121788. /**
  121789. * Set the wrapping mode on V of all the textures we are rendering to.
  121790. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121791. */
  121792. set wrapV(wrap: number);
  121793. /**
  121794. * Instantiate a new multi render target texture.
  121795. * A multi render target, like a render target provides the ability to render to a texture.
  121796. * Unlike the render target, it can render to several draw buffers in one draw.
  121797. * This is specially interesting in deferred rendering or for any effects requiring more than
  121798. * just one color from a single pass.
  121799. * @param name Define the name of the texture
  121800. * @param size Define the size of the buffers to render to
  121801. * @param count Define the number of target we are rendering into
  121802. * @param scene Define the scene the texture belongs to
  121803. * @param options Define the options used to create the multi render target
  121804. */
  121805. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  121806. /** @hidden */
  121807. _rebuild(): void;
  121808. private _createInternalTextures;
  121809. private _createTextures;
  121810. /**
  121811. * Define the number of samples used if MSAA is enabled.
  121812. */
  121813. get samples(): number;
  121814. set samples(value: number);
  121815. /**
  121816. * Resize all the textures in the multi render target.
  121817. * Be carrefull as it will recreate all the data in the new texture.
  121818. * @param size Define the new size
  121819. */
  121820. resize(size: any): void;
  121821. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  121822. /**
  121823. * Dispose the render targets and their associated resources
  121824. */
  121825. dispose(): void;
  121826. /**
  121827. * Release all the underlying texture used as draw buffers.
  121828. */
  121829. releaseInternalTextures(): void;
  121830. }
  121831. }
  121832. declare module BABYLON {
  121833. interface ThinEngine {
  121834. /**
  121835. * Unbind a list of render target textures from the webGL context
  121836. * This is used only when drawBuffer extension or webGL2 are active
  121837. * @param textures defines the render target textures to unbind
  121838. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121839. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121840. */
  121841. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  121842. /**
  121843. * Create a multi render target texture
  121844. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  121845. * @param size defines the size of the texture
  121846. * @param options defines the creation options
  121847. * @returns the cube texture as an InternalTexture
  121848. */
  121849. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  121850. /**
  121851. * Update the sample count for a given multiple render target texture
  121852. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121853. * @param textures defines the textures to update
  121854. * @param samples defines the sample count to set
  121855. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121856. */
  121857. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  121858. }
  121859. }
  121860. declare module BABYLON {
  121861. /**
  121862. * Class used to define an additional view for the engine
  121863. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121864. */
  121865. export class EngineView {
  121866. /** Defines the canvas where to render the view */
  121867. target: HTMLCanvasElement;
  121868. /** Defines an optional camera used to render the view (will use active camera else) */
  121869. camera?: Camera;
  121870. }
  121871. interface Engine {
  121872. /**
  121873. * Gets or sets the HTML element to use for attaching events
  121874. */
  121875. inputElement: Nullable<HTMLElement>;
  121876. /**
  121877. * Gets the current engine view
  121878. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121879. */
  121880. activeView: Nullable<EngineView>;
  121881. /** Gets or sets the list of views */
  121882. views: EngineView[];
  121883. /**
  121884. * Register a new child canvas
  121885. * @param canvas defines the canvas to register
  121886. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  121887. * @returns the associated view
  121888. */
  121889. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  121890. /**
  121891. * Remove a registered child canvas
  121892. * @param canvas defines the canvas to remove
  121893. * @returns the current engine
  121894. */
  121895. unRegisterView(canvas: HTMLCanvasElement): Engine;
  121896. }
  121897. }
  121898. declare module BABYLON {
  121899. interface Engine {
  121900. /** @hidden */
  121901. _excludedCompressedTextures: string[];
  121902. /** @hidden */
  121903. _textureFormatInUse: string;
  121904. /**
  121905. * Gets the list of texture formats supported
  121906. */
  121907. readonly texturesSupported: Array<string>;
  121908. /**
  121909. * Gets the texture format in use
  121910. */
  121911. readonly textureFormatInUse: Nullable<string>;
  121912. /**
  121913. * Set the compressed texture extensions or file names to skip.
  121914. *
  121915. * @param skippedFiles defines the list of those texture files you want to skip
  121916. * Example: [".dds", ".env", "myfile.png"]
  121917. */
  121918. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  121919. /**
  121920. * Set the compressed texture format to use, based on the formats you have, and the formats
  121921. * supported by the hardware / browser.
  121922. *
  121923. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  121924. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  121925. * to API arguments needed to compressed textures. This puts the burden on the container
  121926. * generator to house the arcane code for determining these for current & future formats.
  121927. *
  121928. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121929. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121930. *
  121931. * Note: The result of this call is not taken into account when a texture is base64.
  121932. *
  121933. * @param formatsAvailable defines the list of those format families you have created
  121934. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121935. *
  121936. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121937. * @returns The extension selected.
  121938. */
  121939. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121940. }
  121941. }
  121942. declare module BABYLON {
  121943. /**
  121944. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121945. */
  121946. export interface CubeMapInfo {
  121947. /**
  121948. * The pixel array for the front face.
  121949. * This is stored in format, left to right, up to down format.
  121950. */
  121951. front: Nullable<ArrayBufferView>;
  121952. /**
  121953. * The pixel array for the back face.
  121954. * This is stored in format, left to right, up to down format.
  121955. */
  121956. back: Nullable<ArrayBufferView>;
  121957. /**
  121958. * The pixel array for the left face.
  121959. * This is stored in format, left to right, up to down format.
  121960. */
  121961. left: Nullable<ArrayBufferView>;
  121962. /**
  121963. * The pixel array for the right face.
  121964. * This is stored in format, left to right, up to down format.
  121965. */
  121966. right: Nullable<ArrayBufferView>;
  121967. /**
  121968. * The pixel array for the up face.
  121969. * This is stored in format, left to right, up to down format.
  121970. */
  121971. up: Nullable<ArrayBufferView>;
  121972. /**
  121973. * The pixel array for the down face.
  121974. * This is stored in format, left to right, up to down format.
  121975. */
  121976. down: Nullable<ArrayBufferView>;
  121977. /**
  121978. * The size of the cubemap stored.
  121979. *
  121980. * Each faces will be size * size pixels.
  121981. */
  121982. size: number;
  121983. /**
  121984. * The format of the texture.
  121985. *
  121986. * RGBA, RGB.
  121987. */
  121988. format: number;
  121989. /**
  121990. * The type of the texture data.
  121991. *
  121992. * UNSIGNED_INT, FLOAT.
  121993. */
  121994. type: number;
  121995. /**
  121996. * Specifies whether the texture is in gamma space.
  121997. */
  121998. gammaSpace: boolean;
  121999. }
  122000. /**
  122001. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  122002. */
  122003. export class PanoramaToCubeMapTools {
  122004. private static FACE_FRONT;
  122005. private static FACE_BACK;
  122006. private static FACE_RIGHT;
  122007. private static FACE_LEFT;
  122008. private static FACE_DOWN;
  122009. private static FACE_UP;
  122010. /**
  122011. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  122012. *
  122013. * @param float32Array The source data.
  122014. * @param inputWidth The width of the input panorama.
  122015. * @param inputHeight The height of the input panorama.
  122016. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  122017. * @return The cubemap data
  122018. */
  122019. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  122020. private static CreateCubemapTexture;
  122021. private static CalcProjectionSpherical;
  122022. }
  122023. }
  122024. declare module BABYLON {
  122025. /**
  122026. * Helper class dealing with the extraction of spherical polynomial dataArray
  122027. * from a cube map.
  122028. */
  122029. export class CubeMapToSphericalPolynomialTools {
  122030. private static FileFaces;
  122031. /**
  122032. * Converts a texture to the according Spherical Polynomial data.
  122033. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122034. *
  122035. * @param texture The texture to extract the information from.
  122036. * @return The Spherical Polynomial data.
  122037. */
  122038. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  122039. /**
  122040. * Converts a cubemap to the according Spherical Polynomial data.
  122041. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122042. *
  122043. * @param cubeInfo The Cube map to extract the information from.
  122044. * @return The Spherical Polynomial data.
  122045. */
  122046. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  122047. }
  122048. }
  122049. declare module BABYLON {
  122050. interface BaseTexture {
  122051. /**
  122052. * Get the polynomial representation of the texture data.
  122053. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  122054. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  122055. */
  122056. sphericalPolynomial: Nullable<SphericalPolynomial>;
  122057. }
  122058. }
  122059. declare module BABYLON {
  122060. /** @hidden */
  122061. export var rgbdEncodePixelShader: {
  122062. name: string;
  122063. shader: string;
  122064. };
  122065. }
  122066. declare module BABYLON {
  122067. /** @hidden */
  122068. export var rgbdDecodePixelShader: {
  122069. name: string;
  122070. shader: string;
  122071. };
  122072. }
  122073. declare module BABYLON {
  122074. /**
  122075. * Raw texture data and descriptor sufficient for WebGL texture upload
  122076. */
  122077. export interface EnvironmentTextureInfo {
  122078. /**
  122079. * Version of the environment map
  122080. */
  122081. version: number;
  122082. /**
  122083. * Width of image
  122084. */
  122085. width: number;
  122086. /**
  122087. * Irradiance information stored in the file.
  122088. */
  122089. irradiance: any;
  122090. /**
  122091. * Specular information stored in the file.
  122092. */
  122093. specular: any;
  122094. }
  122095. /**
  122096. * Defines One Image in the file. It requires only the position in the file
  122097. * as well as the length.
  122098. */
  122099. interface BufferImageData {
  122100. /**
  122101. * Length of the image data.
  122102. */
  122103. length: number;
  122104. /**
  122105. * Position of the data from the null terminator delimiting the end of the JSON.
  122106. */
  122107. position: number;
  122108. }
  122109. /**
  122110. * Defines the specular data enclosed in the file.
  122111. * This corresponds to the version 1 of the data.
  122112. */
  122113. export interface EnvironmentTextureSpecularInfoV1 {
  122114. /**
  122115. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  122116. */
  122117. specularDataPosition?: number;
  122118. /**
  122119. * This contains all the images data needed to reconstruct the cubemap.
  122120. */
  122121. mipmaps: Array<BufferImageData>;
  122122. /**
  122123. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  122124. */
  122125. lodGenerationScale: number;
  122126. }
  122127. /**
  122128. * Sets of helpers addressing the serialization and deserialization of environment texture
  122129. * stored in a BabylonJS env file.
  122130. * Those files are usually stored as .env files.
  122131. */
  122132. export class EnvironmentTextureTools {
  122133. /**
  122134. * Magic number identifying the env file.
  122135. */
  122136. private static _MagicBytes;
  122137. /**
  122138. * Gets the environment info from an env file.
  122139. * @param data The array buffer containing the .env bytes.
  122140. * @returns the environment file info (the json header) if successfully parsed.
  122141. */
  122142. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  122143. /**
  122144. * Creates an environment texture from a loaded cube texture.
  122145. * @param texture defines the cube texture to convert in env file
  122146. * @return a promise containing the environment data if succesfull.
  122147. */
  122148. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  122149. /**
  122150. * Creates a JSON representation of the spherical data.
  122151. * @param texture defines the texture containing the polynomials
  122152. * @return the JSON representation of the spherical info
  122153. */
  122154. private static _CreateEnvTextureIrradiance;
  122155. /**
  122156. * Creates the ArrayBufferViews used for initializing environment texture image data.
  122157. * @param data the image data
  122158. * @param info parameters that determine what views will be created for accessing the underlying buffer
  122159. * @return the views described by info providing access to the underlying buffer
  122160. */
  122161. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  122162. /**
  122163. * Uploads the texture info contained in the env file to the GPU.
  122164. * @param texture defines the internal texture to upload to
  122165. * @param data defines the data to load
  122166. * @param info defines the texture info retrieved through the GetEnvInfo method
  122167. * @returns a promise
  122168. */
  122169. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  122170. private static _OnImageReadyAsync;
  122171. /**
  122172. * Uploads the levels of image data to the GPU.
  122173. * @param texture defines the internal texture to upload to
  122174. * @param imageData defines the array buffer views of image data [mipmap][face]
  122175. * @returns a promise
  122176. */
  122177. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  122178. /**
  122179. * Uploads spherical polynomials information to the texture.
  122180. * @param texture defines the texture we are trying to upload the information to
  122181. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  122182. */
  122183. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  122184. /** @hidden */
  122185. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122186. }
  122187. }
  122188. declare module BABYLON {
  122189. /**
  122190. * Contains position and normal vectors for a vertex
  122191. */
  122192. export class PositionNormalVertex {
  122193. /** the position of the vertex (defaut: 0,0,0) */
  122194. position: Vector3;
  122195. /** the normal of the vertex (defaut: 0,1,0) */
  122196. normal: Vector3;
  122197. /**
  122198. * Creates a PositionNormalVertex
  122199. * @param position the position of the vertex (defaut: 0,0,0)
  122200. * @param normal the normal of the vertex (defaut: 0,1,0)
  122201. */
  122202. constructor(
  122203. /** the position of the vertex (defaut: 0,0,0) */
  122204. position?: Vector3,
  122205. /** the normal of the vertex (defaut: 0,1,0) */
  122206. normal?: Vector3);
  122207. /**
  122208. * Clones the PositionNormalVertex
  122209. * @returns the cloned PositionNormalVertex
  122210. */
  122211. clone(): PositionNormalVertex;
  122212. }
  122213. /**
  122214. * Contains position, normal and uv vectors for a vertex
  122215. */
  122216. export class PositionNormalTextureVertex {
  122217. /** the position of the vertex (defaut: 0,0,0) */
  122218. position: Vector3;
  122219. /** the normal of the vertex (defaut: 0,1,0) */
  122220. normal: Vector3;
  122221. /** the uv of the vertex (default: 0,0) */
  122222. uv: Vector2;
  122223. /**
  122224. * Creates a PositionNormalTextureVertex
  122225. * @param position the position of the vertex (defaut: 0,0,0)
  122226. * @param normal the normal of the vertex (defaut: 0,1,0)
  122227. * @param uv the uv of the vertex (default: 0,0)
  122228. */
  122229. constructor(
  122230. /** the position of the vertex (defaut: 0,0,0) */
  122231. position?: Vector3,
  122232. /** the normal of the vertex (defaut: 0,1,0) */
  122233. normal?: Vector3,
  122234. /** the uv of the vertex (default: 0,0) */
  122235. uv?: Vector2);
  122236. /**
  122237. * Clones the PositionNormalTextureVertex
  122238. * @returns the cloned PositionNormalTextureVertex
  122239. */
  122240. clone(): PositionNormalTextureVertex;
  122241. }
  122242. }
  122243. declare module BABYLON {
  122244. /** @hidden */
  122245. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  122246. private _genericAttributeLocation;
  122247. private _varyingLocationCount;
  122248. private _varyingLocationMap;
  122249. private _replacements;
  122250. private _textureCount;
  122251. private _uniforms;
  122252. lineProcessor(line: string): string;
  122253. attributeProcessor(attribute: string): string;
  122254. varyingProcessor(varying: string, isFragment: boolean): string;
  122255. uniformProcessor(uniform: string): string;
  122256. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  122257. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  122258. }
  122259. }
  122260. declare module BABYLON {
  122261. /**
  122262. * Container for accessors for natively-stored mesh data buffers.
  122263. */
  122264. class NativeDataBuffer extends DataBuffer {
  122265. /**
  122266. * Accessor value used to identify/retrieve a natively-stored index buffer.
  122267. */
  122268. nativeIndexBuffer?: any;
  122269. /**
  122270. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  122271. */
  122272. nativeVertexBuffer?: any;
  122273. }
  122274. /** @hidden */
  122275. class NativeTexture extends InternalTexture {
  122276. getInternalTexture(): InternalTexture;
  122277. getViewCount(): number;
  122278. }
  122279. /** @hidden */
  122280. export class NativeEngine extends Engine {
  122281. private readonly _native;
  122282. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  122283. private readonly INVALID_HANDLE;
  122284. getHardwareScalingLevel(): number;
  122285. constructor();
  122286. /**
  122287. * Can be used to override the current requestAnimationFrame requester.
  122288. * @hidden
  122289. */
  122290. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  122291. /**
  122292. * Override default engine behavior.
  122293. * @param color
  122294. * @param backBuffer
  122295. * @param depth
  122296. * @param stencil
  122297. */
  122298. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  122299. /**
  122300. * Gets host document
  122301. * @returns the host document object
  122302. */
  122303. getHostDocument(): Nullable<Document>;
  122304. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122305. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  122306. createVertexBuffer(data: DataArray): NativeDataBuffer;
  122307. recordVertexArrayObject(vertexBuffers: {
  122308. [key: string]: VertexBuffer;
  122309. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  122310. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122311. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122312. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122313. /**
  122314. * Draw a list of indexed primitives
  122315. * @param fillMode defines the primitive to use
  122316. * @param indexStart defines the starting index
  122317. * @param indexCount defines the number of index to draw
  122318. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122319. */
  122320. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122321. /**
  122322. * Draw a list of unindexed primitives
  122323. * @param fillMode defines the primitive to use
  122324. * @param verticesStart defines the index of first vertex to draw
  122325. * @param verticesCount defines the count of vertices to draw
  122326. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122327. */
  122328. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122329. createPipelineContext(): IPipelineContext;
  122330. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  122331. /** @hidden */
  122332. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  122333. /** @hidden */
  122334. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  122335. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122336. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122337. protected _setProgram(program: WebGLProgram): void;
  122338. _releaseEffect(effect: Effect): void;
  122339. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122340. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  122341. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  122342. bindSamplers(effect: Effect): void;
  122343. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  122344. getRenderWidth(useScreen?: boolean): number;
  122345. getRenderHeight(useScreen?: boolean): number;
  122346. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  122347. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122348. /**
  122349. * Set the z offset to apply to current rendering
  122350. * @param value defines the offset to apply
  122351. */
  122352. setZOffset(value: number): void;
  122353. /**
  122354. * Gets the current value of the zOffset
  122355. * @returns the current zOffset state
  122356. */
  122357. getZOffset(): number;
  122358. /**
  122359. * Enable or disable depth buffering
  122360. * @param enable defines the state to set
  122361. */
  122362. setDepthBuffer(enable: boolean): void;
  122363. /**
  122364. * Gets a boolean indicating if depth writing is enabled
  122365. * @returns the current depth writing state
  122366. */
  122367. getDepthWrite(): boolean;
  122368. /**
  122369. * Enable or disable depth writing
  122370. * @param enable defines the state to set
  122371. */
  122372. setDepthWrite(enable: boolean): void;
  122373. /**
  122374. * Enable or disable color writing
  122375. * @param enable defines the state to set
  122376. */
  122377. setColorWrite(enable: boolean): void;
  122378. /**
  122379. * Gets a boolean indicating if color writing is enabled
  122380. * @returns the current color writing state
  122381. */
  122382. getColorWrite(): boolean;
  122383. /**
  122384. * Sets alpha constants used by some alpha blending modes
  122385. * @param r defines the red component
  122386. * @param g defines the green component
  122387. * @param b defines the blue component
  122388. * @param a defines the alpha component
  122389. */
  122390. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  122391. /**
  122392. * Sets the current alpha mode
  122393. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  122394. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122395. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122396. */
  122397. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122398. /**
  122399. * Gets the current alpha mode
  122400. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122401. * @returns the current alpha mode
  122402. */
  122403. getAlphaMode(): number;
  122404. setInt(uniform: WebGLUniformLocation, int: number): void;
  122405. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122406. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122407. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122408. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122409. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122410. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122411. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122412. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122413. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122414. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122415. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122416. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122417. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122418. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122419. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122420. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122421. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122422. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122423. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122424. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  122425. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  122426. wipeCaches(bruteForce?: boolean): void;
  122427. _createTexture(): WebGLTexture;
  122428. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  122429. /**
  122430. * Usually called from Texture.ts.
  122431. * Passed information to create a WebGLTexture
  122432. * @param urlArg defines a value which contains one of the following:
  122433. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122434. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122435. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122436. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122437. * @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)
  122438. * @param scene needed for loading to the correct scene
  122439. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122440. * @param onLoad optional callback to be called upon successful completion
  122441. * @param onError optional callback to be called upon failure
  122442. * @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
  122443. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122444. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122445. * @param forcedExtension defines the extension to use to pick the right loader
  122446. * @param mimeType defines an optional mime type
  122447. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122448. */
  122449. 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;
  122450. /**
  122451. * Creates a cube texture
  122452. * @param rootUrl defines the url where the files to load is located
  122453. * @param scene defines the current scene
  122454. * @param files defines the list of files to load (1 per face)
  122455. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  122456. * @param onLoad defines an optional callback raised when the texture is loaded
  122457. * @param onError defines an optional callback raised if there is an issue to load the texture
  122458. * @param format defines the format of the data
  122459. * @param forcedExtension defines the extension to use to pick the right loader
  122460. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  122461. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122462. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122463. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  122464. * @returns the cube texture as an InternalTexture
  122465. */
  122466. 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;
  122467. private _getSamplingFilter;
  122468. private static _GetNativeTextureFormat;
  122469. createRenderTargetTexture(size: number | {
  122470. width: number;
  122471. height: number;
  122472. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  122473. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122474. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122475. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122476. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  122477. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  122478. /**
  122479. * Updates a dynamic vertex buffer.
  122480. * @param vertexBuffer the vertex buffer to update
  122481. * @param data the data used to update the vertex buffer
  122482. * @param byteOffset the byte offset of the data (optional)
  122483. * @param byteLength the byte length of the data (optional)
  122484. */
  122485. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  122486. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  122487. private _updateAnisotropicLevel;
  122488. private _getAddressMode;
  122489. /** @hidden */
  122490. _bindTexture(channel: number, texture: InternalTexture): void;
  122491. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  122492. releaseEffects(): void;
  122493. /** @hidden */
  122494. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122495. /** @hidden */
  122496. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122497. /** @hidden */
  122498. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122499. /** @hidden */
  122500. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122501. }
  122502. }
  122503. declare module BABYLON {
  122504. /**
  122505. * Gather the list of clipboard event types as constants.
  122506. */
  122507. export class ClipboardEventTypes {
  122508. /**
  122509. * The clipboard event is fired when a copy command is active (pressed).
  122510. */
  122511. static readonly COPY: number;
  122512. /**
  122513. * The clipboard event is fired when a cut command is active (pressed).
  122514. */
  122515. static readonly CUT: number;
  122516. /**
  122517. * The clipboard event is fired when a paste command is active (pressed).
  122518. */
  122519. static readonly PASTE: number;
  122520. }
  122521. /**
  122522. * This class is used to store clipboard related info for the onClipboardObservable event.
  122523. */
  122524. export class ClipboardInfo {
  122525. /**
  122526. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122527. */
  122528. type: number;
  122529. /**
  122530. * Defines the related dom event
  122531. */
  122532. event: ClipboardEvent;
  122533. /**
  122534. *Creates an instance of ClipboardInfo.
  122535. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  122536. * @param event Defines the related dom event
  122537. */
  122538. constructor(
  122539. /**
  122540. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122541. */
  122542. type: number,
  122543. /**
  122544. * Defines the related dom event
  122545. */
  122546. event: ClipboardEvent);
  122547. /**
  122548. * Get the clipboard event's type from the keycode.
  122549. * @param keyCode Defines the keyCode for the current keyboard event.
  122550. * @return {number}
  122551. */
  122552. static GetTypeFromCharacter(keyCode: number): number;
  122553. }
  122554. }
  122555. declare module BABYLON {
  122556. /**
  122557. * Google Daydream controller
  122558. */
  122559. export class DaydreamController extends WebVRController {
  122560. /**
  122561. * Base Url for the controller model.
  122562. */
  122563. static MODEL_BASE_URL: string;
  122564. /**
  122565. * File name for the controller model.
  122566. */
  122567. static MODEL_FILENAME: string;
  122568. /**
  122569. * Gamepad Id prefix used to identify Daydream Controller.
  122570. */
  122571. static readonly GAMEPAD_ID_PREFIX: string;
  122572. /**
  122573. * Creates a new DaydreamController from a gamepad
  122574. * @param vrGamepad the gamepad that the controller should be created from
  122575. */
  122576. constructor(vrGamepad: any);
  122577. /**
  122578. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122579. * @param scene scene in which to add meshes
  122580. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122581. */
  122582. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122583. /**
  122584. * Called once for each button that changed state since the last frame
  122585. * @param buttonIdx Which button index changed
  122586. * @param state New state of the button
  122587. * @param changes Which properties on the state changed since last frame
  122588. */
  122589. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122590. }
  122591. }
  122592. declare module BABYLON {
  122593. /**
  122594. * Gear VR Controller
  122595. */
  122596. export class GearVRController extends WebVRController {
  122597. /**
  122598. * Base Url for the controller model.
  122599. */
  122600. static MODEL_BASE_URL: string;
  122601. /**
  122602. * File name for the controller model.
  122603. */
  122604. static MODEL_FILENAME: string;
  122605. /**
  122606. * Gamepad Id prefix used to identify this controller.
  122607. */
  122608. static readonly GAMEPAD_ID_PREFIX: string;
  122609. private readonly _buttonIndexToObservableNameMap;
  122610. /**
  122611. * Creates a new GearVRController from a gamepad
  122612. * @param vrGamepad the gamepad that the controller should be created from
  122613. */
  122614. constructor(vrGamepad: any);
  122615. /**
  122616. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122617. * @param scene scene in which to add meshes
  122618. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122619. */
  122620. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122621. /**
  122622. * Called once for each button that changed state since the last frame
  122623. * @param buttonIdx Which button index changed
  122624. * @param state New state of the button
  122625. * @param changes Which properties on the state changed since last frame
  122626. */
  122627. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122628. }
  122629. }
  122630. declare module BABYLON {
  122631. /**
  122632. * Generic Controller
  122633. */
  122634. export class GenericController extends WebVRController {
  122635. /**
  122636. * Base Url for the controller model.
  122637. */
  122638. static readonly MODEL_BASE_URL: string;
  122639. /**
  122640. * File name for the controller model.
  122641. */
  122642. static readonly MODEL_FILENAME: string;
  122643. /**
  122644. * Creates a new GenericController from a gamepad
  122645. * @param vrGamepad the gamepad that the controller should be created from
  122646. */
  122647. constructor(vrGamepad: any);
  122648. /**
  122649. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122650. * @param scene scene in which to add meshes
  122651. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122652. */
  122653. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122654. /**
  122655. * Called once for each button that changed state since the last frame
  122656. * @param buttonIdx Which button index changed
  122657. * @param state New state of the button
  122658. * @param changes Which properties on the state changed since last frame
  122659. */
  122660. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122661. }
  122662. }
  122663. declare module BABYLON {
  122664. /**
  122665. * Oculus Touch Controller
  122666. */
  122667. export class OculusTouchController extends WebVRController {
  122668. /**
  122669. * Base Url for the controller model.
  122670. */
  122671. static MODEL_BASE_URL: string;
  122672. /**
  122673. * File name for the left controller model.
  122674. */
  122675. static MODEL_LEFT_FILENAME: string;
  122676. /**
  122677. * File name for the right controller model.
  122678. */
  122679. static MODEL_RIGHT_FILENAME: string;
  122680. /**
  122681. * Base Url for the Quest controller model.
  122682. */
  122683. static QUEST_MODEL_BASE_URL: string;
  122684. /**
  122685. * @hidden
  122686. * If the controllers are running on a device that needs the updated Quest controller models
  122687. */
  122688. static _IsQuest: boolean;
  122689. /**
  122690. * Fired when the secondary trigger on this controller is modified
  122691. */
  122692. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  122693. /**
  122694. * Fired when the thumb rest on this controller is modified
  122695. */
  122696. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  122697. /**
  122698. * Creates a new OculusTouchController from a gamepad
  122699. * @param vrGamepad the gamepad that the controller should be created from
  122700. */
  122701. constructor(vrGamepad: any);
  122702. /**
  122703. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122704. * @param scene scene in which to add meshes
  122705. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122706. */
  122707. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122708. /**
  122709. * Fired when the A button on this controller is modified
  122710. */
  122711. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122712. /**
  122713. * Fired when the B button on this controller is modified
  122714. */
  122715. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122716. /**
  122717. * Fired when the X button on this controller is modified
  122718. */
  122719. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122720. /**
  122721. * Fired when the Y button on this controller is modified
  122722. */
  122723. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122724. /**
  122725. * Called once for each button that changed state since the last frame
  122726. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  122727. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  122728. * 2) secondary trigger (same)
  122729. * 3) A (right) X (left), touch, pressed = value
  122730. * 4) B / Y
  122731. * 5) thumb rest
  122732. * @param buttonIdx Which button index changed
  122733. * @param state New state of the button
  122734. * @param changes Which properties on the state changed since last frame
  122735. */
  122736. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122737. }
  122738. }
  122739. declare module BABYLON {
  122740. /**
  122741. * Vive Controller
  122742. */
  122743. export class ViveController extends WebVRController {
  122744. /**
  122745. * Base Url for the controller model.
  122746. */
  122747. static MODEL_BASE_URL: string;
  122748. /**
  122749. * File name for the controller model.
  122750. */
  122751. static MODEL_FILENAME: string;
  122752. /**
  122753. * Creates a new ViveController from a gamepad
  122754. * @param vrGamepad the gamepad that the controller should be created from
  122755. */
  122756. constructor(vrGamepad: any);
  122757. /**
  122758. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122759. * @param scene scene in which to add meshes
  122760. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122761. */
  122762. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122763. /**
  122764. * Fired when the left button on this controller is modified
  122765. */
  122766. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122767. /**
  122768. * Fired when the right button on this controller is modified
  122769. */
  122770. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122771. /**
  122772. * Fired when the menu button on this controller is modified
  122773. */
  122774. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122775. /**
  122776. * Called once for each button that changed state since the last frame
  122777. * Vive mapping:
  122778. * 0: touchpad
  122779. * 1: trigger
  122780. * 2: left AND right buttons
  122781. * 3: menu button
  122782. * @param buttonIdx Which button index changed
  122783. * @param state New state of the button
  122784. * @param changes Which properties on the state changed since last frame
  122785. */
  122786. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122787. }
  122788. }
  122789. declare module BABYLON {
  122790. /**
  122791. * Defines the WindowsMotionController object that the state of the windows motion controller
  122792. */
  122793. export class WindowsMotionController extends WebVRController {
  122794. /**
  122795. * The base url used to load the left and right controller models
  122796. */
  122797. static MODEL_BASE_URL: string;
  122798. /**
  122799. * The name of the left controller model file
  122800. */
  122801. static MODEL_LEFT_FILENAME: string;
  122802. /**
  122803. * The name of the right controller model file
  122804. */
  122805. static MODEL_RIGHT_FILENAME: string;
  122806. /**
  122807. * The controller name prefix for this controller type
  122808. */
  122809. static readonly GAMEPAD_ID_PREFIX: string;
  122810. /**
  122811. * The controller id pattern for this controller type
  122812. */
  122813. private static readonly GAMEPAD_ID_PATTERN;
  122814. private _loadedMeshInfo;
  122815. protected readonly _mapping: {
  122816. buttons: string[];
  122817. buttonMeshNames: {
  122818. trigger: string;
  122819. menu: string;
  122820. grip: string;
  122821. thumbstick: string;
  122822. trackpad: string;
  122823. };
  122824. buttonObservableNames: {
  122825. trigger: string;
  122826. menu: string;
  122827. grip: string;
  122828. thumbstick: string;
  122829. trackpad: string;
  122830. };
  122831. axisMeshNames: string[];
  122832. pointingPoseMeshName: string;
  122833. };
  122834. /**
  122835. * Fired when the trackpad on this controller is clicked
  122836. */
  122837. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122838. /**
  122839. * Fired when the trackpad on this controller is modified
  122840. */
  122841. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122842. /**
  122843. * The current x and y values of this controller's trackpad
  122844. */
  122845. trackpad: StickValues;
  122846. /**
  122847. * Creates a new WindowsMotionController from a gamepad
  122848. * @param vrGamepad the gamepad that the controller should be created from
  122849. */
  122850. constructor(vrGamepad: any);
  122851. /**
  122852. * Fired when the trigger on this controller is modified
  122853. */
  122854. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122855. /**
  122856. * Fired when the menu button on this controller is modified
  122857. */
  122858. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122859. /**
  122860. * Fired when the grip button on this controller is modified
  122861. */
  122862. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122863. /**
  122864. * Fired when the thumbstick button on this controller is modified
  122865. */
  122866. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122867. /**
  122868. * Fired when the touchpad button on this controller is modified
  122869. */
  122870. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122871. /**
  122872. * Fired when the touchpad values on this controller are modified
  122873. */
  122874. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  122875. protected _updateTrackpad(): void;
  122876. /**
  122877. * Called once per frame by the engine.
  122878. */
  122879. update(): void;
  122880. /**
  122881. * Called once for each button that changed state since the last frame
  122882. * @param buttonIdx Which button index changed
  122883. * @param state New state of the button
  122884. * @param changes Which properties on the state changed since last frame
  122885. */
  122886. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122887. /**
  122888. * Moves the buttons on the controller mesh based on their current state
  122889. * @param buttonName the name of the button to move
  122890. * @param buttonValue the value of the button which determines the buttons new position
  122891. */
  122892. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  122893. /**
  122894. * Moves the axis on the controller mesh based on its current state
  122895. * @param axis the index of the axis
  122896. * @param axisValue the value of the axis which determines the meshes new position
  122897. * @hidden
  122898. */
  122899. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  122900. /**
  122901. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122902. * @param scene scene in which to add meshes
  122903. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122904. */
  122905. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  122906. /**
  122907. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  122908. * can be transformed by button presses and axes values, based on this._mapping.
  122909. *
  122910. * @param scene scene in which the meshes exist
  122911. * @param meshes list of meshes that make up the controller model to process
  122912. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  122913. */
  122914. private processModel;
  122915. private createMeshInfo;
  122916. /**
  122917. * Gets the ray of the controller in the direction the controller is pointing
  122918. * @param length the length the resulting ray should be
  122919. * @returns a ray in the direction the controller is pointing
  122920. */
  122921. getForwardRay(length?: number): Ray;
  122922. /**
  122923. * Disposes of the controller
  122924. */
  122925. dispose(): void;
  122926. }
  122927. /**
  122928. * This class represents a new windows motion controller in XR.
  122929. */
  122930. export class XRWindowsMotionController extends WindowsMotionController {
  122931. /**
  122932. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122933. */
  122934. protected readonly _mapping: {
  122935. buttons: string[];
  122936. buttonMeshNames: {
  122937. trigger: string;
  122938. menu: string;
  122939. grip: string;
  122940. thumbstick: string;
  122941. trackpad: string;
  122942. };
  122943. buttonObservableNames: {
  122944. trigger: string;
  122945. menu: string;
  122946. grip: string;
  122947. thumbstick: string;
  122948. trackpad: string;
  122949. };
  122950. axisMeshNames: string[];
  122951. pointingPoseMeshName: string;
  122952. };
  122953. /**
  122954. * Construct a new XR-Based windows motion controller
  122955. *
  122956. * @param gamepadInfo the gamepad object from the browser
  122957. */
  122958. constructor(gamepadInfo: any);
  122959. /**
  122960. * holds the thumbstick values (X,Y)
  122961. */
  122962. thumbstickValues: StickValues;
  122963. /**
  122964. * Fired when the thumbstick on this controller is clicked
  122965. */
  122966. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122967. /**
  122968. * Fired when the thumbstick on this controller is modified
  122969. */
  122970. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122971. /**
  122972. * Fired when the touchpad button on this controller is modified
  122973. */
  122974. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122975. /**
  122976. * Fired when the touchpad values on this controller are modified
  122977. */
  122978. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122979. /**
  122980. * Fired when the thumbstick button on this controller is modified
  122981. * here to prevent breaking changes
  122982. */
  122983. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122984. /**
  122985. * updating the thumbstick(!) and not the trackpad.
  122986. * This is named this way due to the difference between WebVR and XR and to avoid
  122987. * changing the parent class.
  122988. */
  122989. protected _updateTrackpad(): void;
  122990. /**
  122991. * Disposes the class with joy
  122992. */
  122993. dispose(): void;
  122994. }
  122995. }
  122996. declare module BABYLON {
  122997. /**
  122998. * Class containing static functions to help procedurally build meshes
  122999. */
  123000. export class PolyhedronBuilder {
  123001. /**
  123002. * Creates a polyhedron mesh
  123003. * * 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
  123004. * * The parameter `size` (positive float, default 1) sets the polygon size
  123005. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123006. * * 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`
  123007. * * 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
  123008. * * 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)`)
  123009. * * 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
  123010. * * 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
  123011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123014. * @param name defines the name of the mesh
  123015. * @param options defines the options used to create the mesh
  123016. * @param scene defines the hosting scene
  123017. * @returns the polyhedron mesh
  123018. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123019. */
  123020. static CreatePolyhedron(name: string, options: {
  123021. type?: number;
  123022. size?: number;
  123023. sizeX?: number;
  123024. sizeY?: number;
  123025. sizeZ?: number;
  123026. custom?: any;
  123027. faceUV?: Vector4[];
  123028. faceColors?: Color4[];
  123029. flat?: boolean;
  123030. updatable?: boolean;
  123031. sideOrientation?: number;
  123032. frontUVs?: Vector4;
  123033. backUVs?: Vector4;
  123034. }, scene?: Nullable<Scene>): Mesh;
  123035. }
  123036. }
  123037. declare module BABYLON {
  123038. /**
  123039. * Gizmo that enables scaling a mesh along 3 axis
  123040. */
  123041. export class ScaleGizmo extends Gizmo {
  123042. /**
  123043. * Internal gizmo used for interactions on the x axis
  123044. */
  123045. xGizmo: AxisScaleGizmo;
  123046. /**
  123047. * Internal gizmo used for interactions on the y axis
  123048. */
  123049. yGizmo: AxisScaleGizmo;
  123050. /**
  123051. * Internal gizmo used for interactions on the z axis
  123052. */
  123053. zGizmo: AxisScaleGizmo;
  123054. /**
  123055. * Internal gizmo used to scale all axis equally
  123056. */
  123057. uniformScaleGizmo: AxisScaleGizmo;
  123058. private _meshAttached;
  123059. private _updateGizmoRotationToMatchAttachedMesh;
  123060. private _snapDistance;
  123061. private _scaleRatio;
  123062. private _uniformScalingMesh;
  123063. private _octahedron;
  123064. private _sensitivity;
  123065. /** Fires an event when any of it's sub gizmos are dragged */
  123066. onDragStartObservable: Observable<unknown>;
  123067. /** Fires an event when any of it's sub gizmos are released from dragging */
  123068. onDragEndObservable: Observable<unknown>;
  123069. get attachedMesh(): Nullable<AbstractMesh>;
  123070. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123071. /**
  123072. * Creates a ScaleGizmo
  123073. * @param gizmoLayer The utility layer the gizmo will be added to
  123074. */
  123075. constructor(gizmoLayer?: UtilityLayerRenderer);
  123076. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123077. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123078. /**
  123079. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123080. */
  123081. set snapDistance(value: number);
  123082. get snapDistance(): number;
  123083. /**
  123084. * Ratio for the scale of the gizmo (Default: 1)
  123085. */
  123086. set scaleRatio(value: number);
  123087. get scaleRatio(): number;
  123088. /**
  123089. * Sensitivity factor for dragging (Default: 1)
  123090. */
  123091. set sensitivity(value: number);
  123092. get sensitivity(): number;
  123093. /**
  123094. * Disposes of the gizmo
  123095. */
  123096. dispose(): void;
  123097. }
  123098. }
  123099. declare module BABYLON {
  123100. /**
  123101. * Single axis scale gizmo
  123102. */
  123103. export class AxisScaleGizmo extends Gizmo {
  123104. /**
  123105. * Drag behavior responsible for the gizmos dragging interactions
  123106. */
  123107. dragBehavior: PointerDragBehavior;
  123108. private _pointerObserver;
  123109. /**
  123110. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123111. */
  123112. snapDistance: number;
  123113. /**
  123114. * Event that fires each time the gizmo snaps to a new location.
  123115. * * snapDistance is the the change in distance
  123116. */
  123117. onSnapObservable: Observable<{
  123118. snapDistance: number;
  123119. }>;
  123120. /**
  123121. * If the scaling operation should be done on all axis (default: false)
  123122. */
  123123. uniformScaling: boolean;
  123124. /**
  123125. * Custom sensitivity value for the drag strength
  123126. */
  123127. sensitivity: number;
  123128. private _isEnabled;
  123129. private _parent;
  123130. private _arrow;
  123131. private _coloredMaterial;
  123132. private _hoverMaterial;
  123133. /**
  123134. * Creates an AxisScaleGizmo
  123135. * @param gizmoLayer The utility layer the gizmo will be added to
  123136. * @param dragAxis The axis which the gizmo will be able to scale on
  123137. * @param color The color of the gizmo
  123138. */
  123139. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  123140. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123141. /**
  123142. * If the gizmo is enabled
  123143. */
  123144. set isEnabled(value: boolean);
  123145. get isEnabled(): boolean;
  123146. /**
  123147. * Disposes of the gizmo
  123148. */
  123149. dispose(): void;
  123150. /**
  123151. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  123152. * @param mesh The mesh to replace the default mesh of the gizmo
  123153. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  123154. */
  123155. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  123156. }
  123157. }
  123158. declare module BABYLON {
  123159. /**
  123160. * Bounding box gizmo
  123161. */
  123162. export class BoundingBoxGizmo extends Gizmo {
  123163. private _lineBoundingBox;
  123164. private _rotateSpheresParent;
  123165. private _scaleBoxesParent;
  123166. private _boundingDimensions;
  123167. private _renderObserver;
  123168. private _pointerObserver;
  123169. private _scaleDragSpeed;
  123170. private _tmpQuaternion;
  123171. private _tmpVector;
  123172. private _tmpRotationMatrix;
  123173. /**
  123174. * 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)
  123175. */
  123176. ignoreChildren: boolean;
  123177. /**
  123178. * 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)
  123179. */
  123180. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  123181. /**
  123182. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  123183. */
  123184. rotationSphereSize: number;
  123185. /**
  123186. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  123187. */
  123188. scaleBoxSize: number;
  123189. /**
  123190. * 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)
  123191. */
  123192. fixedDragMeshScreenSize: boolean;
  123193. /**
  123194. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  123195. */
  123196. fixedDragMeshScreenSizeDistanceFactor: number;
  123197. /**
  123198. * Fired when a rotation sphere or scale box is dragged
  123199. */
  123200. onDragStartObservable: Observable<{}>;
  123201. /**
  123202. * Fired when a scale box is dragged
  123203. */
  123204. onScaleBoxDragObservable: Observable<{}>;
  123205. /**
  123206. * Fired when a scale box drag is ended
  123207. */
  123208. onScaleBoxDragEndObservable: Observable<{}>;
  123209. /**
  123210. * Fired when a rotation sphere is dragged
  123211. */
  123212. onRotationSphereDragObservable: Observable<{}>;
  123213. /**
  123214. * Fired when a rotation sphere drag is ended
  123215. */
  123216. onRotationSphereDragEndObservable: Observable<{}>;
  123217. /**
  123218. * 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)
  123219. */
  123220. scalePivot: Nullable<Vector3>;
  123221. /**
  123222. * Mesh used as a pivot to rotate the attached mesh
  123223. */
  123224. private _anchorMesh;
  123225. private _existingMeshScale;
  123226. private _dragMesh;
  123227. private pointerDragBehavior;
  123228. private coloredMaterial;
  123229. private hoverColoredMaterial;
  123230. /**
  123231. * Sets the color of the bounding box gizmo
  123232. * @param color the color to set
  123233. */
  123234. setColor(color: Color3): void;
  123235. /**
  123236. * Creates an BoundingBoxGizmo
  123237. * @param gizmoLayer The utility layer the gizmo will be added to
  123238. * @param color The color of the gizmo
  123239. */
  123240. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  123241. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123242. private _selectNode;
  123243. /**
  123244. * Updates the bounding box information for the Gizmo
  123245. */
  123246. updateBoundingBox(): void;
  123247. private _updateRotationSpheres;
  123248. private _updateScaleBoxes;
  123249. /**
  123250. * Enables rotation on the specified axis and disables rotation on the others
  123251. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  123252. */
  123253. setEnabledRotationAxis(axis: string): void;
  123254. /**
  123255. * Enables/disables scaling
  123256. * @param enable if scaling should be enabled
  123257. * @param homogeneousScaling defines if scaling should only be homogeneous
  123258. */
  123259. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  123260. private _updateDummy;
  123261. /**
  123262. * Enables a pointer drag behavior on the bounding box of the gizmo
  123263. */
  123264. enableDragBehavior(): void;
  123265. /**
  123266. * Disposes of the gizmo
  123267. */
  123268. dispose(): void;
  123269. /**
  123270. * 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)
  123271. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  123272. * @returns the bounding box mesh with the passed in mesh as a child
  123273. */
  123274. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  123275. /**
  123276. * CustomMeshes are not supported by this gizmo
  123277. * @param mesh The mesh to replace the default mesh of the gizmo
  123278. */
  123279. setCustomMesh(mesh: Mesh): void;
  123280. }
  123281. }
  123282. declare module BABYLON {
  123283. /**
  123284. * Single plane rotation gizmo
  123285. */
  123286. export class PlaneRotationGizmo extends Gizmo {
  123287. /**
  123288. * Drag behavior responsible for the gizmos dragging interactions
  123289. */
  123290. dragBehavior: PointerDragBehavior;
  123291. private _pointerObserver;
  123292. /**
  123293. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  123294. */
  123295. snapDistance: number;
  123296. /**
  123297. * Event that fires each time the gizmo snaps to a new location.
  123298. * * snapDistance is the the change in distance
  123299. */
  123300. onSnapObservable: Observable<{
  123301. snapDistance: number;
  123302. }>;
  123303. private _isEnabled;
  123304. private _parent;
  123305. /**
  123306. * Creates a PlaneRotationGizmo
  123307. * @param gizmoLayer The utility layer the gizmo will be added to
  123308. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  123309. * @param color The color of the gizmo
  123310. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123311. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123312. */
  123313. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  123314. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123315. /**
  123316. * If the gizmo is enabled
  123317. */
  123318. set isEnabled(value: boolean);
  123319. get isEnabled(): boolean;
  123320. /**
  123321. * Disposes of the gizmo
  123322. */
  123323. dispose(): void;
  123324. }
  123325. }
  123326. declare module BABYLON {
  123327. /**
  123328. * Gizmo that enables rotating a mesh along 3 axis
  123329. */
  123330. export class RotationGizmo extends Gizmo {
  123331. /**
  123332. * Internal gizmo used for interactions on the x axis
  123333. */
  123334. xGizmo: PlaneRotationGizmo;
  123335. /**
  123336. * Internal gizmo used for interactions on the y axis
  123337. */
  123338. yGizmo: PlaneRotationGizmo;
  123339. /**
  123340. * Internal gizmo used for interactions on the z axis
  123341. */
  123342. zGizmo: PlaneRotationGizmo;
  123343. /** Fires an event when any of it's sub gizmos are dragged */
  123344. onDragStartObservable: Observable<unknown>;
  123345. /** Fires an event when any of it's sub gizmos are released from dragging */
  123346. onDragEndObservable: Observable<unknown>;
  123347. private _meshAttached;
  123348. get attachedMesh(): Nullable<AbstractMesh>;
  123349. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123350. /**
  123351. * Creates a RotationGizmo
  123352. * @param gizmoLayer The utility layer the gizmo will be added to
  123353. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123354. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123355. */
  123356. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  123357. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123358. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123359. /**
  123360. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123361. */
  123362. set snapDistance(value: number);
  123363. get snapDistance(): number;
  123364. /**
  123365. * Ratio for the scale of the gizmo (Default: 1)
  123366. */
  123367. set scaleRatio(value: number);
  123368. get scaleRatio(): number;
  123369. /**
  123370. * Disposes of the gizmo
  123371. */
  123372. dispose(): void;
  123373. /**
  123374. * CustomMeshes are not supported by this gizmo
  123375. * @param mesh The mesh to replace the default mesh of the gizmo
  123376. */
  123377. setCustomMesh(mesh: Mesh): void;
  123378. }
  123379. }
  123380. declare module BABYLON {
  123381. /**
  123382. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  123383. */
  123384. export class GizmoManager implements IDisposable {
  123385. private scene;
  123386. /**
  123387. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  123388. */
  123389. gizmos: {
  123390. positionGizmo: Nullable<PositionGizmo>;
  123391. rotationGizmo: Nullable<RotationGizmo>;
  123392. scaleGizmo: Nullable<ScaleGizmo>;
  123393. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  123394. };
  123395. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  123396. clearGizmoOnEmptyPointerEvent: boolean;
  123397. /** Fires an event when the manager is attached to a mesh */
  123398. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  123399. private _gizmosEnabled;
  123400. private _pointerObserver;
  123401. private _attachedMesh;
  123402. private _boundingBoxColor;
  123403. private _defaultUtilityLayer;
  123404. private _defaultKeepDepthUtilityLayer;
  123405. /**
  123406. * When bounding box gizmo is enabled, this can be used to track drag/end events
  123407. */
  123408. boundingBoxDragBehavior: SixDofDragBehavior;
  123409. /**
  123410. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  123411. */
  123412. attachableMeshes: Nullable<Array<AbstractMesh>>;
  123413. /**
  123414. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  123415. */
  123416. usePointerToAttachGizmos: boolean;
  123417. /**
  123418. * Utility layer that the bounding box gizmo belongs to
  123419. */
  123420. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  123421. /**
  123422. * Utility layer that all gizmos besides bounding box belong to
  123423. */
  123424. get utilityLayer(): UtilityLayerRenderer;
  123425. /**
  123426. * Instatiates a gizmo manager
  123427. * @param scene the scene to overlay the gizmos on top of
  123428. */
  123429. constructor(scene: Scene);
  123430. /**
  123431. * Attaches a set of gizmos to the specified mesh
  123432. * @param mesh The mesh the gizmo's should be attached to
  123433. */
  123434. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123435. /**
  123436. * If the position gizmo is enabled
  123437. */
  123438. set positionGizmoEnabled(value: boolean);
  123439. get positionGizmoEnabled(): boolean;
  123440. /**
  123441. * If the rotation gizmo is enabled
  123442. */
  123443. set rotationGizmoEnabled(value: boolean);
  123444. get rotationGizmoEnabled(): boolean;
  123445. /**
  123446. * If the scale gizmo is enabled
  123447. */
  123448. set scaleGizmoEnabled(value: boolean);
  123449. get scaleGizmoEnabled(): boolean;
  123450. /**
  123451. * If the boundingBox gizmo is enabled
  123452. */
  123453. set boundingBoxGizmoEnabled(value: boolean);
  123454. get boundingBoxGizmoEnabled(): boolean;
  123455. /**
  123456. * Disposes of the gizmo manager
  123457. */
  123458. dispose(): void;
  123459. }
  123460. }
  123461. declare module BABYLON {
  123462. /**
  123463. * A directional light is defined by a direction (what a surprise!).
  123464. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  123465. * 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.
  123466. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123467. */
  123468. export class DirectionalLight extends ShadowLight {
  123469. private _shadowFrustumSize;
  123470. /**
  123471. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  123472. */
  123473. get shadowFrustumSize(): number;
  123474. /**
  123475. * Specifies a fix frustum size for the shadow generation.
  123476. */
  123477. set shadowFrustumSize(value: number);
  123478. private _shadowOrthoScale;
  123479. /**
  123480. * Gets the shadow projection scale against the optimal computed one.
  123481. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123482. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123483. */
  123484. get shadowOrthoScale(): number;
  123485. /**
  123486. * Sets the shadow projection scale against the optimal computed one.
  123487. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123488. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123489. */
  123490. set shadowOrthoScale(value: number);
  123491. /**
  123492. * Automatically compute the projection matrix to best fit (including all the casters)
  123493. * on each frame.
  123494. */
  123495. autoUpdateExtends: boolean;
  123496. /**
  123497. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  123498. * on each frame. autoUpdateExtends must be set to true for this to work
  123499. */
  123500. autoCalcShadowZBounds: boolean;
  123501. private _orthoLeft;
  123502. private _orthoRight;
  123503. private _orthoTop;
  123504. private _orthoBottom;
  123505. /**
  123506. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  123507. * The directional light is emitted from everywhere in the given direction.
  123508. * It can cast shadows.
  123509. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123510. * @param name The friendly name of the light
  123511. * @param direction The direction of the light
  123512. * @param scene The scene the light belongs to
  123513. */
  123514. constructor(name: string, direction: Vector3, scene: Scene);
  123515. /**
  123516. * Returns the string "DirectionalLight".
  123517. * @return The class name
  123518. */
  123519. getClassName(): string;
  123520. /**
  123521. * Returns the integer 1.
  123522. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123523. */
  123524. getTypeID(): number;
  123525. /**
  123526. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  123527. * Returns the DirectionalLight Shadow projection matrix.
  123528. */
  123529. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123530. /**
  123531. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  123532. * Returns the DirectionalLight Shadow projection matrix.
  123533. */
  123534. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  123535. /**
  123536. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  123537. * Returns the DirectionalLight Shadow projection matrix.
  123538. */
  123539. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123540. protected _buildUniformLayout(): void;
  123541. /**
  123542. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  123543. * @param effect The effect to update
  123544. * @param lightIndex The index of the light in the effect to update
  123545. * @returns The directional light
  123546. */
  123547. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  123548. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  123549. /**
  123550. * Gets the minZ used for shadow according to both the scene and the light.
  123551. *
  123552. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123553. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123554. * @param activeCamera The camera we are returning the min for
  123555. * @returns the depth min z
  123556. */
  123557. getDepthMinZ(activeCamera: Camera): number;
  123558. /**
  123559. * Gets the maxZ used for shadow according to both the scene and the light.
  123560. *
  123561. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123562. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123563. * @param activeCamera The camera we are returning the max for
  123564. * @returns the depth max z
  123565. */
  123566. getDepthMaxZ(activeCamera: Camera): number;
  123567. /**
  123568. * Prepares the list of defines specific to the light type.
  123569. * @param defines the list of defines
  123570. * @param lightIndex defines the index of the light for the effect
  123571. */
  123572. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123573. }
  123574. }
  123575. declare module BABYLON {
  123576. /**
  123577. * Class containing static functions to help procedurally build meshes
  123578. */
  123579. export class HemisphereBuilder {
  123580. /**
  123581. * Creates a hemisphere mesh
  123582. * @param name defines the name of the mesh
  123583. * @param options defines the options used to create the mesh
  123584. * @param scene defines the hosting scene
  123585. * @returns the hemisphere mesh
  123586. */
  123587. static CreateHemisphere(name: string, options: {
  123588. segments?: number;
  123589. diameter?: number;
  123590. sideOrientation?: number;
  123591. }, scene: any): Mesh;
  123592. }
  123593. }
  123594. declare module BABYLON {
  123595. /**
  123596. * A spot light is defined by a position, a direction, an angle, and an exponent.
  123597. * These values define a cone of light starting from the position, emitting toward the direction.
  123598. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  123599. * and the exponent defines the speed of the decay of the light with distance (reach).
  123600. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123601. */
  123602. export class SpotLight extends ShadowLight {
  123603. private _angle;
  123604. private _innerAngle;
  123605. private _cosHalfAngle;
  123606. private _lightAngleScale;
  123607. private _lightAngleOffset;
  123608. /**
  123609. * Gets the cone angle of the spot light in Radians.
  123610. */
  123611. get angle(): number;
  123612. /**
  123613. * Sets the cone angle of the spot light in Radians.
  123614. */
  123615. set angle(value: number);
  123616. /**
  123617. * Only used in gltf falloff mode, this defines the angle where
  123618. * the directional falloff will start before cutting at angle which could be seen
  123619. * as outer angle.
  123620. */
  123621. get innerAngle(): number;
  123622. /**
  123623. * Only used in gltf falloff mode, this defines the angle where
  123624. * the directional falloff will start before cutting at angle which could be seen
  123625. * as outer angle.
  123626. */
  123627. set innerAngle(value: number);
  123628. private _shadowAngleScale;
  123629. /**
  123630. * Allows scaling the angle of the light for shadow generation only.
  123631. */
  123632. get shadowAngleScale(): number;
  123633. /**
  123634. * Allows scaling the angle of the light for shadow generation only.
  123635. */
  123636. set shadowAngleScale(value: number);
  123637. /**
  123638. * The light decay speed with the distance from the emission spot.
  123639. */
  123640. exponent: number;
  123641. private _projectionTextureMatrix;
  123642. /**
  123643. * Allows reading the projecton texture
  123644. */
  123645. get projectionTextureMatrix(): Matrix;
  123646. protected _projectionTextureLightNear: number;
  123647. /**
  123648. * Gets the near clip of the Spotlight for texture projection.
  123649. */
  123650. get projectionTextureLightNear(): number;
  123651. /**
  123652. * Sets the near clip of the Spotlight for texture projection.
  123653. */
  123654. set projectionTextureLightNear(value: number);
  123655. protected _projectionTextureLightFar: number;
  123656. /**
  123657. * Gets the far clip of the Spotlight for texture projection.
  123658. */
  123659. get projectionTextureLightFar(): number;
  123660. /**
  123661. * Sets the far clip of the Spotlight for texture projection.
  123662. */
  123663. set projectionTextureLightFar(value: number);
  123664. protected _projectionTextureUpDirection: Vector3;
  123665. /**
  123666. * Gets the Up vector of the Spotlight for texture projection.
  123667. */
  123668. get projectionTextureUpDirection(): Vector3;
  123669. /**
  123670. * Sets the Up vector of the Spotlight for texture projection.
  123671. */
  123672. set projectionTextureUpDirection(value: Vector3);
  123673. private _projectionTexture;
  123674. /**
  123675. * Gets the projection texture of the light.
  123676. */
  123677. get projectionTexture(): Nullable<BaseTexture>;
  123678. /**
  123679. * Sets the projection texture of the light.
  123680. */
  123681. set projectionTexture(value: Nullable<BaseTexture>);
  123682. private _projectionTextureViewLightDirty;
  123683. private _projectionTextureProjectionLightDirty;
  123684. private _projectionTextureDirty;
  123685. private _projectionTextureViewTargetVector;
  123686. private _projectionTextureViewLightMatrix;
  123687. private _projectionTextureProjectionLightMatrix;
  123688. private _projectionTextureScalingMatrix;
  123689. /**
  123690. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  123691. * It can cast shadows.
  123692. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123693. * @param name The light friendly name
  123694. * @param position The position of the spot light in the scene
  123695. * @param direction The direction of the light in the scene
  123696. * @param angle The cone angle of the light in Radians
  123697. * @param exponent The light decay speed with the distance from the emission spot
  123698. * @param scene The scene the lights belongs to
  123699. */
  123700. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  123701. /**
  123702. * Returns the string "SpotLight".
  123703. * @returns the class name
  123704. */
  123705. getClassName(): string;
  123706. /**
  123707. * Returns the integer 2.
  123708. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123709. */
  123710. getTypeID(): number;
  123711. /**
  123712. * Overrides the direction setter to recompute the projection texture view light Matrix.
  123713. */
  123714. protected _setDirection(value: Vector3): void;
  123715. /**
  123716. * Overrides the position setter to recompute the projection texture view light Matrix.
  123717. */
  123718. protected _setPosition(value: Vector3): void;
  123719. /**
  123720. * 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.
  123721. * Returns the SpotLight.
  123722. */
  123723. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123724. protected _computeProjectionTextureViewLightMatrix(): void;
  123725. protected _computeProjectionTextureProjectionLightMatrix(): void;
  123726. /**
  123727. * Main function for light texture projection matrix computing.
  123728. */
  123729. protected _computeProjectionTextureMatrix(): void;
  123730. protected _buildUniformLayout(): void;
  123731. private _computeAngleValues;
  123732. /**
  123733. * Sets the passed Effect "effect" with the Light textures.
  123734. * @param effect The effect to update
  123735. * @param lightIndex The index of the light in the effect to update
  123736. * @returns The light
  123737. */
  123738. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  123739. /**
  123740. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  123741. * @param effect The effect to update
  123742. * @param lightIndex The index of the light in the effect to update
  123743. * @returns The spot light
  123744. */
  123745. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  123746. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123747. /**
  123748. * Disposes the light and the associated resources.
  123749. */
  123750. dispose(): void;
  123751. /**
  123752. * Prepares the list of defines specific to the light type.
  123753. * @param defines the list of defines
  123754. * @param lightIndex defines the index of the light for the effect
  123755. */
  123756. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123757. }
  123758. }
  123759. declare module BABYLON {
  123760. /**
  123761. * Gizmo that enables viewing a light
  123762. */
  123763. export class LightGizmo extends Gizmo {
  123764. private _lightMesh;
  123765. private _material;
  123766. private _cachedPosition;
  123767. private _cachedForward;
  123768. private _attachedMeshParent;
  123769. /**
  123770. * Creates a LightGizmo
  123771. * @param gizmoLayer The utility layer the gizmo will be added to
  123772. */
  123773. constructor(gizmoLayer?: UtilityLayerRenderer);
  123774. private _light;
  123775. /**
  123776. * The light that the gizmo is attached to
  123777. */
  123778. set light(light: Nullable<Light>);
  123779. get light(): Nullable<Light>;
  123780. /**
  123781. * Gets the material used to render the light gizmo
  123782. */
  123783. get material(): StandardMaterial;
  123784. /**
  123785. * @hidden
  123786. * Updates the gizmo to match the attached mesh's position/rotation
  123787. */
  123788. protected _update(): void;
  123789. private static _Scale;
  123790. /**
  123791. * Creates the lines for a light mesh
  123792. */
  123793. private static _CreateLightLines;
  123794. /**
  123795. * Disposes of the light gizmo
  123796. */
  123797. dispose(): void;
  123798. private static _CreateHemisphericLightMesh;
  123799. private static _CreatePointLightMesh;
  123800. private static _CreateSpotLightMesh;
  123801. private static _CreateDirectionalLightMesh;
  123802. }
  123803. }
  123804. declare module BABYLON {
  123805. /** @hidden */
  123806. export var backgroundFragmentDeclaration: {
  123807. name: string;
  123808. shader: string;
  123809. };
  123810. }
  123811. declare module BABYLON {
  123812. /** @hidden */
  123813. export var backgroundUboDeclaration: {
  123814. name: string;
  123815. shader: string;
  123816. };
  123817. }
  123818. declare module BABYLON {
  123819. /** @hidden */
  123820. export var backgroundPixelShader: {
  123821. name: string;
  123822. shader: string;
  123823. };
  123824. }
  123825. declare module BABYLON {
  123826. /** @hidden */
  123827. export var backgroundVertexDeclaration: {
  123828. name: string;
  123829. shader: string;
  123830. };
  123831. }
  123832. declare module BABYLON {
  123833. /** @hidden */
  123834. export var backgroundVertexShader: {
  123835. name: string;
  123836. shader: string;
  123837. };
  123838. }
  123839. declare module BABYLON {
  123840. /**
  123841. * Background material used to create an efficient environement around your scene.
  123842. */
  123843. export class BackgroundMaterial extends PushMaterial {
  123844. /**
  123845. * Standard reflectance value at parallel view angle.
  123846. */
  123847. static StandardReflectance0: number;
  123848. /**
  123849. * Standard reflectance value at grazing angle.
  123850. */
  123851. static StandardReflectance90: number;
  123852. protected _primaryColor: Color3;
  123853. /**
  123854. * Key light Color (multiply against the environement texture)
  123855. */
  123856. primaryColor: Color3;
  123857. protected __perceptualColor: Nullable<Color3>;
  123858. /**
  123859. * Experimental Internal Use Only.
  123860. *
  123861. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  123862. * This acts as a helper to set the primary color to a more "human friendly" value.
  123863. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  123864. * output color as close as possible from the chosen value.
  123865. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  123866. * part of lighting setup.)
  123867. */
  123868. get _perceptualColor(): Nullable<Color3>;
  123869. set _perceptualColor(value: Nullable<Color3>);
  123870. protected _primaryColorShadowLevel: float;
  123871. /**
  123872. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  123873. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  123874. */
  123875. get primaryColorShadowLevel(): float;
  123876. set primaryColorShadowLevel(value: float);
  123877. protected _primaryColorHighlightLevel: float;
  123878. /**
  123879. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  123880. * The primary color is used at the level chosen to define what the white area would look.
  123881. */
  123882. get primaryColorHighlightLevel(): float;
  123883. set primaryColorHighlightLevel(value: float);
  123884. protected _reflectionTexture: Nullable<BaseTexture>;
  123885. /**
  123886. * Reflection Texture used in the material.
  123887. * Should be author in a specific way for the best result (refer to the documentation).
  123888. */
  123889. reflectionTexture: Nullable<BaseTexture>;
  123890. protected _reflectionBlur: float;
  123891. /**
  123892. * Reflection Texture level of blur.
  123893. *
  123894. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  123895. * texture twice.
  123896. */
  123897. reflectionBlur: float;
  123898. protected _diffuseTexture: Nullable<BaseTexture>;
  123899. /**
  123900. * Diffuse Texture used in the material.
  123901. * Should be author in a specific way for the best result (refer to the documentation).
  123902. */
  123903. diffuseTexture: Nullable<BaseTexture>;
  123904. protected _shadowLights: Nullable<IShadowLight[]>;
  123905. /**
  123906. * Specify the list of lights casting shadow on the material.
  123907. * All scene shadow lights will be included if null.
  123908. */
  123909. shadowLights: Nullable<IShadowLight[]>;
  123910. protected _shadowLevel: float;
  123911. /**
  123912. * Helps adjusting the shadow to a softer level if required.
  123913. * 0 means black shadows and 1 means no shadows.
  123914. */
  123915. shadowLevel: float;
  123916. protected _sceneCenter: Vector3;
  123917. /**
  123918. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  123919. * It is usually zero but might be interesting to modify according to your setup.
  123920. */
  123921. sceneCenter: Vector3;
  123922. protected _opacityFresnel: boolean;
  123923. /**
  123924. * This helps specifying that the material is falling off to the sky box at grazing angle.
  123925. * This helps ensuring a nice transition when the camera goes under the ground.
  123926. */
  123927. opacityFresnel: boolean;
  123928. protected _reflectionFresnel: boolean;
  123929. /**
  123930. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123931. * This helps adding a mirror texture on the ground.
  123932. */
  123933. reflectionFresnel: boolean;
  123934. protected _reflectionFalloffDistance: number;
  123935. /**
  123936. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123937. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123938. */
  123939. reflectionFalloffDistance: number;
  123940. protected _reflectionAmount: number;
  123941. /**
  123942. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123943. */
  123944. reflectionAmount: number;
  123945. protected _reflectionReflectance0: number;
  123946. /**
  123947. * This specifies the weight of the reflection at grazing angle.
  123948. */
  123949. reflectionReflectance0: number;
  123950. protected _reflectionReflectance90: number;
  123951. /**
  123952. * This specifies the weight of the reflection at a perpendicular point of view.
  123953. */
  123954. reflectionReflectance90: number;
  123955. /**
  123956. * Sets the reflection reflectance fresnel values according to the default standard
  123957. * empirically know to work well :-)
  123958. */
  123959. set reflectionStandardFresnelWeight(value: number);
  123960. protected _useRGBColor: boolean;
  123961. /**
  123962. * Helps to directly use the maps channels instead of their level.
  123963. */
  123964. useRGBColor: boolean;
  123965. protected _enableNoise: boolean;
  123966. /**
  123967. * This helps reducing the banding effect that could occur on the background.
  123968. */
  123969. enableNoise: boolean;
  123970. /**
  123971. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123972. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123973. * Recommended to be keep at 1.0 except for special cases.
  123974. */
  123975. get fovMultiplier(): number;
  123976. set fovMultiplier(value: number);
  123977. private _fovMultiplier;
  123978. /**
  123979. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123980. */
  123981. useEquirectangularFOV: boolean;
  123982. private _maxSimultaneousLights;
  123983. /**
  123984. * Number of Simultaneous lights allowed on the material.
  123985. */
  123986. maxSimultaneousLights: int;
  123987. /**
  123988. * Default configuration related to image processing available in the Background Material.
  123989. */
  123990. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123991. /**
  123992. * Keep track of the image processing observer to allow dispose and replace.
  123993. */
  123994. private _imageProcessingObserver;
  123995. /**
  123996. * Attaches a new image processing configuration to the PBR Material.
  123997. * @param configuration (if null the scene configuration will be use)
  123998. */
  123999. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124000. /**
  124001. * Gets the image processing configuration used either in this material.
  124002. */
  124003. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  124004. /**
  124005. * Sets the Default image processing configuration used either in the this material.
  124006. *
  124007. * If sets to null, the scene one is in use.
  124008. */
  124009. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  124010. /**
  124011. * Gets wether the color curves effect is enabled.
  124012. */
  124013. get cameraColorCurvesEnabled(): boolean;
  124014. /**
  124015. * Sets wether the color curves effect is enabled.
  124016. */
  124017. set cameraColorCurvesEnabled(value: boolean);
  124018. /**
  124019. * Gets wether the color grading effect is enabled.
  124020. */
  124021. get cameraColorGradingEnabled(): boolean;
  124022. /**
  124023. * Gets wether the color grading effect is enabled.
  124024. */
  124025. set cameraColorGradingEnabled(value: boolean);
  124026. /**
  124027. * Gets wether tonemapping is enabled or not.
  124028. */
  124029. get cameraToneMappingEnabled(): boolean;
  124030. /**
  124031. * Sets wether tonemapping is enabled or not
  124032. */
  124033. set cameraToneMappingEnabled(value: boolean);
  124034. /**
  124035. * The camera exposure used on this material.
  124036. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124037. * This corresponds to a photographic exposure.
  124038. */
  124039. get cameraExposure(): float;
  124040. /**
  124041. * The camera exposure used on this material.
  124042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124043. * This corresponds to a photographic exposure.
  124044. */
  124045. set cameraExposure(value: float);
  124046. /**
  124047. * Gets The camera contrast used on this material.
  124048. */
  124049. get cameraContrast(): float;
  124050. /**
  124051. * Sets The camera contrast used on this material.
  124052. */
  124053. set cameraContrast(value: float);
  124054. /**
  124055. * Gets the Color Grading 2D Lookup Texture.
  124056. */
  124057. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124058. /**
  124059. * Sets the Color Grading 2D Lookup Texture.
  124060. */
  124061. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124062. /**
  124063. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124064. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124065. * 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;
  124066. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124067. */
  124068. get cameraColorCurves(): Nullable<ColorCurves>;
  124069. /**
  124070. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124071. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124072. * 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;
  124073. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124074. */
  124075. set cameraColorCurves(value: Nullable<ColorCurves>);
  124076. /**
  124077. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  124078. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  124079. */
  124080. switchToBGR: boolean;
  124081. private _renderTargets;
  124082. private _reflectionControls;
  124083. private _white;
  124084. private _primaryShadowColor;
  124085. private _primaryHighlightColor;
  124086. /**
  124087. * Instantiates a Background Material in the given scene
  124088. * @param name The friendly name of the material
  124089. * @param scene The scene to add the material to
  124090. */
  124091. constructor(name: string, scene: Scene);
  124092. /**
  124093. * Gets a boolean indicating that current material needs to register RTT
  124094. */
  124095. get hasRenderTargetTextures(): boolean;
  124096. /**
  124097. * The entire material has been created in order to prevent overdraw.
  124098. * @returns false
  124099. */
  124100. needAlphaTesting(): boolean;
  124101. /**
  124102. * The entire material has been created in order to prevent overdraw.
  124103. * @returns true if blending is enable
  124104. */
  124105. needAlphaBlending(): boolean;
  124106. /**
  124107. * Checks wether the material is ready to be rendered for a given mesh.
  124108. * @param mesh The mesh to render
  124109. * @param subMesh The submesh to check against
  124110. * @param useInstances Specify wether or not the material is used with instances
  124111. * @returns true if all the dependencies are ready (Textures, Effects...)
  124112. */
  124113. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124114. /**
  124115. * Compute the primary color according to the chosen perceptual color.
  124116. */
  124117. private _computePrimaryColorFromPerceptualColor;
  124118. /**
  124119. * Compute the highlights and shadow colors according to their chosen levels.
  124120. */
  124121. private _computePrimaryColors;
  124122. /**
  124123. * Build the uniform buffer used in the material.
  124124. */
  124125. buildUniformLayout(): void;
  124126. /**
  124127. * Unbind the material.
  124128. */
  124129. unbind(): void;
  124130. /**
  124131. * Bind only the world matrix to the material.
  124132. * @param world The world matrix to bind.
  124133. */
  124134. bindOnlyWorldMatrix(world: Matrix): void;
  124135. /**
  124136. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  124137. * @param world The world matrix to bind.
  124138. * @param subMesh The submesh to bind for.
  124139. */
  124140. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124141. /**
  124142. * Checks to see if a texture is used in the material.
  124143. * @param texture - Base texture to use.
  124144. * @returns - Boolean specifying if a texture is used in the material.
  124145. */
  124146. hasTexture(texture: BaseTexture): boolean;
  124147. /**
  124148. * Dispose the material.
  124149. * @param forceDisposeEffect Force disposal of the associated effect.
  124150. * @param forceDisposeTextures Force disposal of the associated textures.
  124151. */
  124152. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124153. /**
  124154. * Clones the material.
  124155. * @param name The cloned name.
  124156. * @returns The cloned material.
  124157. */
  124158. clone(name: string): BackgroundMaterial;
  124159. /**
  124160. * Serializes the current material to its JSON representation.
  124161. * @returns The JSON representation.
  124162. */
  124163. serialize(): any;
  124164. /**
  124165. * Gets the class name of the material
  124166. * @returns "BackgroundMaterial"
  124167. */
  124168. getClassName(): string;
  124169. /**
  124170. * Parse a JSON input to create back a background material.
  124171. * @param source The JSON data to parse
  124172. * @param scene The scene to create the parsed material in
  124173. * @param rootUrl The root url of the assets the material depends upon
  124174. * @returns the instantiated BackgroundMaterial.
  124175. */
  124176. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  124177. }
  124178. }
  124179. declare module BABYLON {
  124180. /**
  124181. * Represents the different options available during the creation of
  124182. * a Environment helper.
  124183. *
  124184. * This can control the default ground, skybox and image processing setup of your scene.
  124185. */
  124186. export interface IEnvironmentHelperOptions {
  124187. /**
  124188. * Specifies whether or not to create a ground.
  124189. * True by default.
  124190. */
  124191. createGround: boolean;
  124192. /**
  124193. * Specifies the ground size.
  124194. * 15 by default.
  124195. */
  124196. groundSize: number;
  124197. /**
  124198. * The texture used on the ground for the main color.
  124199. * Comes from the BabylonJS CDN by default.
  124200. *
  124201. * Remarks: Can be either a texture or a url.
  124202. */
  124203. groundTexture: string | BaseTexture;
  124204. /**
  124205. * The color mixed in the ground texture by default.
  124206. * BabylonJS clearColor by default.
  124207. */
  124208. groundColor: Color3;
  124209. /**
  124210. * Specifies the ground opacity.
  124211. * 1 by default.
  124212. */
  124213. groundOpacity: number;
  124214. /**
  124215. * Enables the ground to receive shadows.
  124216. * True by default.
  124217. */
  124218. enableGroundShadow: boolean;
  124219. /**
  124220. * Helps preventing the shadow to be fully black on the ground.
  124221. * 0.5 by default.
  124222. */
  124223. groundShadowLevel: number;
  124224. /**
  124225. * Creates a mirror texture attach to the ground.
  124226. * false by default.
  124227. */
  124228. enableGroundMirror: boolean;
  124229. /**
  124230. * Specifies the ground mirror size ratio.
  124231. * 0.3 by default as the default kernel is 64.
  124232. */
  124233. groundMirrorSizeRatio: number;
  124234. /**
  124235. * Specifies the ground mirror blur kernel size.
  124236. * 64 by default.
  124237. */
  124238. groundMirrorBlurKernel: number;
  124239. /**
  124240. * Specifies the ground mirror visibility amount.
  124241. * 1 by default
  124242. */
  124243. groundMirrorAmount: number;
  124244. /**
  124245. * Specifies the ground mirror reflectance weight.
  124246. * This uses the standard weight of the background material to setup the fresnel effect
  124247. * of the mirror.
  124248. * 1 by default.
  124249. */
  124250. groundMirrorFresnelWeight: number;
  124251. /**
  124252. * Specifies the ground mirror Falloff distance.
  124253. * This can helps reducing the size of the reflection.
  124254. * 0 by Default.
  124255. */
  124256. groundMirrorFallOffDistance: number;
  124257. /**
  124258. * Specifies the ground mirror texture type.
  124259. * Unsigned Int by Default.
  124260. */
  124261. groundMirrorTextureType: number;
  124262. /**
  124263. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  124264. * the shown objects.
  124265. */
  124266. groundYBias: number;
  124267. /**
  124268. * Specifies whether or not to create a skybox.
  124269. * True by default.
  124270. */
  124271. createSkybox: boolean;
  124272. /**
  124273. * Specifies the skybox size.
  124274. * 20 by default.
  124275. */
  124276. skyboxSize: number;
  124277. /**
  124278. * The texture used on the skybox for the main color.
  124279. * Comes from the BabylonJS CDN by default.
  124280. *
  124281. * Remarks: Can be either a texture or a url.
  124282. */
  124283. skyboxTexture: string | BaseTexture;
  124284. /**
  124285. * The color mixed in the skybox texture by default.
  124286. * BabylonJS clearColor by default.
  124287. */
  124288. skyboxColor: Color3;
  124289. /**
  124290. * The background rotation around the Y axis of the scene.
  124291. * This helps aligning the key lights of your scene with the background.
  124292. * 0 by default.
  124293. */
  124294. backgroundYRotation: number;
  124295. /**
  124296. * Compute automatically the size of the elements to best fit with the scene.
  124297. */
  124298. sizeAuto: boolean;
  124299. /**
  124300. * Default position of the rootMesh if autoSize is not true.
  124301. */
  124302. rootPosition: Vector3;
  124303. /**
  124304. * Sets up the image processing in the scene.
  124305. * true by default.
  124306. */
  124307. setupImageProcessing: boolean;
  124308. /**
  124309. * The texture used as your environment texture in the scene.
  124310. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  124311. *
  124312. * Remarks: Can be either a texture or a url.
  124313. */
  124314. environmentTexture: string | BaseTexture;
  124315. /**
  124316. * The value of the exposure to apply to the scene.
  124317. * 0.6 by default if setupImageProcessing is true.
  124318. */
  124319. cameraExposure: number;
  124320. /**
  124321. * The value of the contrast to apply to the scene.
  124322. * 1.6 by default if setupImageProcessing is true.
  124323. */
  124324. cameraContrast: number;
  124325. /**
  124326. * Specifies whether or not tonemapping should be enabled in the scene.
  124327. * true by default if setupImageProcessing is true.
  124328. */
  124329. toneMappingEnabled: boolean;
  124330. }
  124331. /**
  124332. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  124333. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  124334. * It also helps with the default setup of your imageProcessing configuration.
  124335. */
  124336. export class EnvironmentHelper {
  124337. /**
  124338. * Default ground texture URL.
  124339. */
  124340. private static _groundTextureCDNUrl;
  124341. /**
  124342. * Default skybox texture URL.
  124343. */
  124344. private static _skyboxTextureCDNUrl;
  124345. /**
  124346. * Default environment texture URL.
  124347. */
  124348. private static _environmentTextureCDNUrl;
  124349. /**
  124350. * Creates the default options for the helper.
  124351. */
  124352. private static _getDefaultOptions;
  124353. private _rootMesh;
  124354. /**
  124355. * Gets the root mesh created by the helper.
  124356. */
  124357. get rootMesh(): Mesh;
  124358. private _skybox;
  124359. /**
  124360. * Gets the skybox created by the helper.
  124361. */
  124362. get skybox(): Nullable<Mesh>;
  124363. private _skyboxTexture;
  124364. /**
  124365. * Gets the skybox texture created by the helper.
  124366. */
  124367. get skyboxTexture(): Nullable<BaseTexture>;
  124368. private _skyboxMaterial;
  124369. /**
  124370. * Gets the skybox material created by the helper.
  124371. */
  124372. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  124373. private _ground;
  124374. /**
  124375. * Gets the ground mesh created by the helper.
  124376. */
  124377. get ground(): Nullable<Mesh>;
  124378. private _groundTexture;
  124379. /**
  124380. * Gets the ground texture created by the helper.
  124381. */
  124382. get groundTexture(): Nullable<BaseTexture>;
  124383. private _groundMirror;
  124384. /**
  124385. * Gets the ground mirror created by the helper.
  124386. */
  124387. get groundMirror(): Nullable<MirrorTexture>;
  124388. /**
  124389. * Gets the ground mirror render list to helps pushing the meshes
  124390. * you wish in the ground reflection.
  124391. */
  124392. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  124393. private _groundMaterial;
  124394. /**
  124395. * Gets the ground material created by the helper.
  124396. */
  124397. get groundMaterial(): Nullable<BackgroundMaterial>;
  124398. /**
  124399. * Stores the creation options.
  124400. */
  124401. private readonly _scene;
  124402. private _options;
  124403. /**
  124404. * This observable will be notified with any error during the creation of the environment,
  124405. * mainly texture creation errors.
  124406. */
  124407. onErrorObservable: Observable<{
  124408. message?: string;
  124409. exception?: any;
  124410. }>;
  124411. /**
  124412. * constructor
  124413. * @param options Defines the options we want to customize the helper
  124414. * @param scene The scene to add the material to
  124415. */
  124416. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  124417. /**
  124418. * Updates the background according to the new options
  124419. * @param options
  124420. */
  124421. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  124422. /**
  124423. * Sets the primary color of all the available elements.
  124424. * @param color the main color to affect to the ground and the background
  124425. */
  124426. setMainColor(color: Color3): void;
  124427. /**
  124428. * Setup the image processing according to the specified options.
  124429. */
  124430. private _setupImageProcessing;
  124431. /**
  124432. * Setup the environment texture according to the specified options.
  124433. */
  124434. private _setupEnvironmentTexture;
  124435. /**
  124436. * Setup the background according to the specified options.
  124437. */
  124438. private _setupBackground;
  124439. /**
  124440. * Get the scene sizes according to the setup.
  124441. */
  124442. private _getSceneSize;
  124443. /**
  124444. * Setup the ground according to the specified options.
  124445. */
  124446. private _setupGround;
  124447. /**
  124448. * Setup the ground material according to the specified options.
  124449. */
  124450. private _setupGroundMaterial;
  124451. /**
  124452. * Setup the ground diffuse texture according to the specified options.
  124453. */
  124454. private _setupGroundDiffuseTexture;
  124455. /**
  124456. * Setup the ground mirror texture according to the specified options.
  124457. */
  124458. private _setupGroundMirrorTexture;
  124459. /**
  124460. * Setup the ground to receive the mirror texture.
  124461. */
  124462. private _setupMirrorInGroundMaterial;
  124463. /**
  124464. * Setup the skybox according to the specified options.
  124465. */
  124466. private _setupSkybox;
  124467. /**
  124468. * Setup the skybox material according to the specified options.
  124469. */
  124470. private _setupSkyboxMaterial;
  124471. /**
  124472. * Setup the skybox reflection texture according to the specified options.
  124473. */
  124474. private _setupSkyboxReflectionTexture;
  124475. private _errorHandler;
  124476. /**
  124477. * Dispose all the elements created by the Helper.
  124478. */
  124479. dispose(): void;
  124480. }
  124481. }
  124482. declare module BABYLON {
  124483. /**
  124484. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  124485. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  124486. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  124487. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124488. */
  124489. export class PhotoDome extends TransformNode {
  124490. /**
  124491. * Define the image as a Monoscopic panoramic 360 image.
  124492. */
  124493. static readonly MODE_MONOSCOPIC: number;
  124494. /**
  124495. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124496. */
  124497. static readonly MODE_TOPBOTTOM: number;
  124498. /**
  124499. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124500. */
  124501. static readonly MODE_SIDEBYSIDE: number;
  124502. private _useDirectMapping;
  124503. /**
  124504. * The texture being displayed on the sphere
  124505. */
  124506. protected _photoTexture: Texture;
  124507. /**
  124508. * Gets or sets the texture being displayed on the sphere
  124509. */
  124510. get photoTexture(): Texture;
  124511. set photoTexture(value: Texture);
  124512. /**
  124513. * Observable raised when an error occured while loading the 360 image
  124514. */
  124515. onLoadErrorObservable: Observable<string>;
  124516. /**
  124517. * The skybox material
  124518. */
  124519. protected _material: BackgroundMaterial;
  124520. /**
  124521. * The surface used for the skybox
  124522. */
  124523. protected _mesh: Mesh;
  124524. /**
  124525. * Gets the mesh used for the skybox.
  124526. */
  124527. get mesh(): Mesh;
  124528. /**
  124529. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124530. * Also see the options.resolution property.
  124531. */
  124532. get fovMultiplier(): number;
  124533. set fovMultiplier(value: number);
  124534. private _imageMode;
  124535. /**
  124536. * Gets or set the current video mode for the video. It can be:
  124537. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  124538. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124539. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124540. */
  124541. get imageMode(): number;
  124542. set imageMode(value: number);
  124543. /**
  124544. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  124545. * @param name Element's name, child elements will append suffixes for their own names.
  124546. * @param urlsOfPhoto defines the url of the photo to display
  124547. * @param options defines an object containing optional or exposed sub element properties
  124548. * @param onError defines a callback called when an error occured while loading the texture
  124549. */
  124550. constructor(name: string, urlOfPhoto: string, options: {
  124551. resolution?: number;
  124552. size?: number;
  124553. useDirectMapping?: boolean;
  124554. faceForward?: boolean;
  124555. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  124556. private _onBeforeCameraRenderObserver;
  124557. private _changeImageMode;
  124558. /**
  124559. * Releases resources associated with this node.
  124560. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124561. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124562. */
  124563. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124564. }
  124565. }
  124566. declare module BABYLON {
  124567. /**
  124568. * Class used to host RGBD texture specific utilities
  124569. */
  124570. export class RGBDTextureTools {
  124571. /**
  124572. * Expand the RGBD Texture from RGBD to Half Float if possible.
  124573. * @param texture the texture to expand.
  124574. */
  124575. static ExpandRGBDTexture(texture: Texture): void;
  124576. }
  124577. }
  124578. declare module BABYLON {
  124579. /**
  124580. * Class used to host texture specific utilities
  124581. */
  124582. export class BRDFTextureTools {
  124583. /**
  124584. * Prevents texture cache collision
  124585. */
  124586. private static _instanceNumber;
  124587. /**
  124588. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  124589. * @param scene defines the hosting scene
  124590. * @returns the environment BRDF texture
  124591. */
  124592. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  124593. private static _environmentBRDFBase64Texture;
  124594. }
  124595. }
  124596. declare module BABYLON {
  124597. /**
  124598. * @hidden
  124599. */
  124600. export interface IMaterialClearCoatDefines {
  124601. CLEARCOAT: boolean;
  124602. CLEARCOAT_DEFAULTIOR: boolean;
  124603. CLEARCOAT_TEXTURE: boolean;
  124604. CLEARCOAT_TEXTUREDIRECTUV: number;
  124605. CLEARCOAT_BUMP: boolean;
  124606. CLEARCOAT_BUMPDIRECTUV: number;
  124607. CLEARCOAT_TINT: boolean;
  124608. CLEARCOAT_TINT_TEXTURE: boolean;
  124609. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124610. /** @hidden */
  124611. _areTexturesDirty: boolean;
  124612. }
  124613. /**
  124614. * Define the code related to the clear coat parameters of the pbr material.
  124615. */
  124616. export class PBRClearCoatConfiguration {
  124617. /**
  124618. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124619. * The default fits with a polyurethane material.
  124620. */
  124621. private static readonly _DefaultIndexOfRefraction;
  124622. private _isEnabled;
  124623. /**
  124624. * Defines if the clear coat is enabled in the material.
  124625. */
  124626. isEnabled: boolean;
  124627. /**
  124628. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  124629. */
  124630. intensity: number;
  124631. /**
  124632. * Defines the clear coat layer roughness.
  124633. */
  124634. roughness: number;
  124635. private _indexOfRefraction;
  124636. /**
  124637. * Defines the index of refraction of the clear coat.
  124638. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124639. * The default fits with a polyurethane material.
  124640. * Changing the default value is more performance intensive.
  124641. */
  124642. indexOfRefraction: number;
  124643. private _texture;
  124644. /**
  124645. * Stores the clear coat values in a texture.
  124646. */
  124647. texture: Nullable<BaseTexture>;
  124648. private _bumpTexture;
  124649. /**
  124650. * Define the clear coat specific bump texture.
  124651. */
  124652. bumpTexture: Nullable<BaseTexture>;
  124653. private _isTintEnabled;
  124654. /**
  124655. * Defines if the clear coat tint is enabled in the material.
  124656. */
  124657. isTintEnabled: boolean;
  124658. /**
  124659. * Defines the clear coat tint of the material.
  124660. * This is only use if tint is enabled
  124661. */
  124662. tintColor: Color3;
  124663. /**
  124664. * Defines the distance at which the tint color should be found in the
  124665. * clear coat media.
  124666. * This is only use if tint is enabled
  124667. */
  124668. tintColorAtDistance: number;
  124669. /**
  124670. * Defines the clear coat layer thickness.
  124671. * This is only use if tint is enabled
  124672. */
  124673. tintThickness: number;
  124674. private _tintTexture;
  124675. /**
  124676. * Stores the clear tint values in a texture.
  124677. * rgb is tint
  124678. * a is a thickness factor
  124679. */
  124680. tintTexture: Nullable<BaseTexture>;
  124681. /** @hidden */
  124682. private _internalMarkAllSubMeshesAsTexturesDirty;
  124683. /** @hidden */
  124684. _markAllSubMeshesAsTexturesDirty(): void;
  124685. /**
  124686. * Instantiate a new istance of clear coat configuration.
  124687. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124688. */
  124689. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124690. /**
  124691. * Gets wehter the submesh is ready to be used or not.
  124692. * @param defines the list of "defines" to update.
  124693. * @param scene defines the scene the material belongs to.
  124694. * @param engine defines the engine the material belongs to.
  124695. * @param disableBumpMap defines wether the material disables bump or not.
  124696. * @returns - boolean indicating that the submesh is ready or not.
  124697. */
  124698. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  124699. /**
  124700. * Checks to see if a texture is used in the material.
  124701. * @param defines the list of "defines" to update.
  124702. * @param scene defines the scene to the material belongs to.
  124703. */
  124704. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  124705. /**
  124706. * Binds the material data.
  124707. * @param uniformBuffer defines the Uniform buffer to fill in.
  124708. * @param scene defines the scene the material belongs to.
  124709. * @param engine defines the engine the material belongs to.
  124710. * @param disableBumpMap defines wether the material disables bump or not.
  124711. * @param isFrozen defines wether the material is frozen or not.
  124712. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124713. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124714. */
  124715. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  124716. /**
  124717. * Checks to see if a texture is used in the material.
  124718. * @param texture - Base texture to use.
  124719. * @returns - Boolean specifying if a texture is used in the material.
  124720. */
  124721. hasTexture(texture: BaseTexture): boolean;
  124722. /**
  124723. * Returns an array of the actively used textures.
  124724. * @param activeTextures Array of BaseTextures
  124725. */
  124726. getActiveTextures(activeTextures: BaseTexture[]): void;
  124727. /**
  124728. * Returns the animatable textures.
  124729. * @param animatables Array of animatable textures.
  124730. */
  124731. getAnimatables(animatables: IAnimatable[]): void;
  124732. /**
  124733. * Disposes the resources of the material.
  124734. * @param forceDisposeTextures - Forces the disposal of all textures.
  124735. */
  124736. dispose(forceDisposeTextures?: boolean): void;
  124737. /**
  124738. * Get the current class name of the texture useful for serialization or dynamic coding.
  124739. * @returns "PBRClearCoatConfiguration"
  124740. */
  124741. getClassName(): string;
  124742. /**
  124743. * Add fallbacks to the effect fallbacks list.
  124744. * @param defines defines the Base texture to use.
  124745. * @param fallbacks defines the current fallback list.
  124746. * @param currentRank defines the current fallback rank.
  124747. * @returns the new fallback rank.
  124748. */
  124749. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124750. /**
  124751. * Add the required uniforms to the current list.
  124752. * @param uniforms defines the current uniform list.
  124753. */
  124754. static AddUniforms(uniforms: string[]): void;
  124755. /**
  124756. * Add the required samplers to the current list.
  124757. * @param samplers defines the current sampler list.
  124758. */
  124759. static AddSamplers(samplers: string[]): void;
  124760. /**
  124761. * Add the required uniforms to the current buffer.
  124762. * @param uniformBuffer defines the current uniform buffer.
  124763. */
  124764. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124765. /**
  124766. * Makes a duplicate of the current configuration into another one.
  124767. * @param clearCoatConfiguration define the config where to copy the info
  124768. */
  124769. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  124770. /**
  124771. * Serializes this clear coat configuration.
  124772. * @returns - An object with the serialized config.
  124773. */
  124774. serialize(): any;
  124775. /**
  124776. * Parses a anisotropy Configuration from a serialized object.
  124777. * @param source - Serialized object.
  124778. * @param scene Defines the scene we are parsing for
  124779. * @param rootUrl Defines the rootUrl to load from
  124780. */
  124781. parse(source: any, scene: Scene, rootUrl: string): void;
  124782. }
  124783. }
  124784. declare module BABYLON {
  124785. /**
  124786. * @hidden
  124787. */
  124788. export interface IMaterialAnisotropicDefines {
  124789. ANISOTROPIC: boolean;
  124790. ANISOTROPIC_TEXTURE: boolean;
  124791. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124792. MAINUV1: boolean;
  124793. _areTexturesDirty: boolean;
  124794. _needUVs: boolean;
  124795. }
  124796. /**
  124797. * Define the code related to the anisotropic parameters of the pbr material.
  124798. */
  124799. export class PBRAnisotropicConfiguration {
  124800. private _isEnabled;
  124801. /**
  124802. * Defines if the anisotropy is enabled in the material.
  124803. */
  124804. isEnabled: boolean;
  124805. /**
  124806. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  124807. */
  124808. intensity: number;
  124809. /**
  124810. * Defines if the effect is along the tangents, bitangents or in between.
  124811. * By default, the effect is "strectching" the highlights along the tangents.
  124812. */
  124813. direction: Vector2;
  124814. private _texture;
  124815. /**
  124816. * Stores the anisotropy values in a texture.
  124817. * rg is direction (like normal from -1 to 1)
  124818. * b is a intensity
  124819. */
  124820. texture: Nullable<BaseTexture>;
  124821. /** @hidden */
  124822. private _internalMarkAllSubMeshesAsTexturesDirty;
  124823. /** @hidden */
  124824. _markAllSubMeshesAsTexturesDirty(): void;
  124825. /**
  124826. * Instantiate a new istance of anisotropy configuration.
  124827. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124828. */
  124829. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124830. /**
  124831. * Specifies that the submesh is ready to be used.
  124832. * @param defines the list of "defines" to update.
  124833. * @param scene defines the scene the material belongs to.
  124834. * @returns - boolean indicating that the submesh is ready or not.
  124835. */
  124836. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  124837. /**
  124838. * Checks to see if a texture is used in the material.
  124839. * @param defines the list of "defines" to update.
  124840. * @param mesh the mesh we are preparing the defines for.
  124841. * @param scene defines the scene the material belongs to.
  124842. */
  124843. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  124844. /**
  124845. * Binds the material data.
  124846. * @param uniformBuffer defines the Uniform buffer to fill in.
  124847. * @param scene defines the scene the material belongs to.
  124848. * @param isFrozen defines wether the material is frozen or not.
  124849. */
  124850. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124851. /**
  124852. * Checks to see if a texture is used in the material.
  124853. * @param texture - Base texture to use.
  124854. * @returns - Boolean specifying if a texture is used in the material.
  124855. */
  124856. hasTexture(texture: BaseTexture): boolean;
  124857. /**
  124858. * Returns an array of the actively used textures.
  124859. * @param activeTextures Array of BaseTextures
  124860. */
  124861. getActiveTextures(activeTextures: BaseTexture[]): void;
  124862. /**
  124863. * Returns the animatable textures.
  124864. * @param animatables Array of animatable textures.
  124865. */
  124866. getAnimatables(animatables: IAnimatable[]): void;
  124867. /**
  124868. * Disposes the resources of the material.
  124869. * @param forceDisposeTextures - Forces the disposal of all textures.
  124870. */
  124871. dispose(forceDisposeTextures?: boolean): void;
  124872. /**
  124873. * Get the current class name of the texture useful for serialization or dynamic coding.
  124874. * @returns "PBRAnisotropicConfiguration"
  124875. */
  124876. getClassName(): string;
  124877. /**
  124878. * Add fallbacks to the effect fallbacks list.
  124879. * @param defines defines the Base texture to use.
  124880. * @param fallbacks defines the current fallback list.
  124881. * @param currentRank defines the current fallback rank.
  124882. * @returns the new fallback rank.
  124883. */
  124884. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124885. /**
  124886. * Add the required uniforms to the current list.
  124887. * @param uniforms defines the current uniform list.
  124888. */
  124889. static AddUniforms(uniforms: string[]): void;
  124890. /**
  124891. * Add the required uniforms to the current buffer.
  124892. * @param uniformBuffer defines the current uniform buffer.
  124893. */
  124894. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124895. /**
  124896. * Add the required samplers to the current list.
  124897. * @param samplers defines the current sampler list.
  124898. */
  124899. static AddSamplers(samplers: string[]): void;
  124900. /**
  124901. * Makes a duplicate of the current configuration into another one.
  124902. * @param anisotropicConfiguration define the config where to copy the info
  124903. */
  124904. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  124905. /**
  124906. * Serializes this anisotropy configuration.
  124907. * @returns - An object with the serialized config.
  124908. */
  124909. serialize(): any;
  124910. /**
  124911. * Parses a anisotropy Configuration from a serialized object.
  124912. * @param source - Serialized object.
  124913. * @param scene Defines the scene we are parsing for
  124914. * @param rootUrl Defines the rootUrl to load from
  124915. */
  124916. parse(source: any, scene: Scene, rootUrl: string): void;
  124917. }
  124918. }
  124919. declare module BABYLON {
  124920. /**
  124921. * @hidden
  124922. */
  124923. export interface IMaterialBRDFDefines {
  124924. BRDF_V_HEIGHT_CORRELATED: boolean;
  124925. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124926. SPHERICAL_HARMONICS: boolean;
  124927. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124928. /** @hidden */
  124929. _areMiscDirty: boolean;
  124930. }
  124931. /**
  124932. * Define the code related to the BRDF parameters of the pbr material.
  124933. */
  124934. export class PBRBRDFConfiguration {
  124935. /**
  124936. * Default value used for the energy conservation.
  124937. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124938. */
  124939. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124940. /**
  124941. * Default value used for the Smith Visibility Height Correlated mode.
  124942. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124943. */
  124944. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124945. /**
  124946. * Default value used for the IBL diffuse part.
  124947. * This can help switching back to the polynomials mode globally which is a tiny bit
  124948. * less GPU intensive at the drawback of a lower quality.
  124949. */
  124950. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124951. /**
  124952. * Default value used for activating energy conservation for the specular workflow.
  124953. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124954. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124955. */
  124956. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124957. private _useEnergyConservation;
  124958. /**
  124959. * Defines if the material uses energy conservation.
  124960. */
  124961. useEnergyConservation: boolean;
  124962. private _useSmithVisibilityHeightCorrelated;
  124963. /**
  124964. * LEGACY Mode set to false
  124965. * Defines if the material uses height smith correlated visibility term.
  124966. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124967. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124968. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124969. * Not relying on height correlated will also disable energy conservation.
  124970. */
  124971. useSmithVisibilityHeightCorrelated: boolean;
  124972. private _useSphericalHarmonics;
  124973. /**
  124974. * LEGACY Mode set to false
  124975. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124976. * diffuse part of the IBL.
  124977. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124978. * to the ground truth.
  124979. */
  124980. useSphericalHarmonics: boolean;
  124981. private _useSpecularGlossinessInputEnergyConservation;
  124982. /**
  124983. * Defines if the material uses energy conservation, when the specular workflow is active.
  124984. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124985. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124986. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  124987. */
  124988. useSpecularGlossinessInputEnergyConservation: boolean;
  124989. /** @hidden */
  124990. private _internalMarkAllSubMeshesAsMiscDirty;
  124991. /** @hidden */
  124992. _markAllSubMeshesAsMiscDirty(): void;
  124993. /**
  124994. * Instantiate a new istance of clear coat configuration.
  124995. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  124996. */
  124997. constructor(markAllSubMeshesAsMiscDirty: () => void);
  124998. /**
  124999. * Checks to see if a texture is used in the material.
  125000. * @param defines the list of "defines" to update.
  125001. */
  125002. prepareDefines(defines: IMaterialBRDFDefines): void;
  125003. /**
  125004. * Get the current class name of the texture useful for serialization or dynamic coding.
  125005. * @returns "PBRClearCoatConfiguration"
  125006. */
  125007. getClassName(): string;
  125008. /**
  125009. * Makes a duplicate of the current configuration into another one.
  125010. * @param brdfConfiguration define the config where to copy the info
  125011. */
  125012. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  125013. /**
  125014. * Serializes this BRDF configuration.
  125015. * @returns - An object with the serialized config.
  125016. */
  125017. serialize(): any;
  125018. /**
  125019. * Parses a anisotropy Configuration from a serialized object.
  125020. * @param source - Serialized object.
  125021. * @param scene Defines the scene we are parsing for
  125022. * @param rootUrl Defines the rootUrl to load from
  125023. */
  125024. parse(source: any, scene: Scene, rootUrl: string): void;
  125025. }
  125026. }
  125027. declare module BABYLON {
  125028. /**
  125029. * @hidden
  125030. */
  125031. export interface IMaterialSheenDefines {
  125032. SHEEN: boolean;
  125033. SHEEN_TEXTURE: boolean;
  125034. SHEEN_TEXTUREDIRECTUV: number;
  125035. SHEEN_LINKWITHALBEDO: boolean;
  125036. SHEEN_ROUGHNESS: boolean;
  125037. SHEEN_ALBEDOSCALING: boolean;
  125038. /** @hidden */
  125039. _areTexturesDirty: boolean;
  125040. }
  125041. /**
  125042. * Define the code related to the Sheen parameters of the pbr material.
  125043. */
  125044. export class PBRSheenConfiguration {
  125045. private _isEnabled;
  125046. /**
  125047. * Defines if the material uses sheen.
  125048. */
  125049. isEnabled: boolean;
  125050. private _linkSheenWithAlbedo;
  125051. /**
  125052. * Defines if the sheen is linked to the sheen color.
  125053. */
  125054. linkSheenWithAlbedo: boolean;
  125055. /**
  125056. * Defines the sheen intensity.
  125057. */
  125058. intensity: number;
  125059. /**
  125060. * Defines the sheen color.
  125061. */
  125062. color: Color3;
  125063. private _texture;
  125064. /**
  125065. * Stores the sheen tint values in a texture.
  125066. * rgb is tint
  125067. * a is a intensity
  125068. */
  125069. texture: Nullable<BaseTexture>;
  125070. private _roughness;
  125071. /**
  125072. * Defines the sheen roughness.
  125073. * It is not taken into account if linkSheenWithAlbedo is true.
  125074. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  125075. */
  125076. roughness: Nullable<number>;
  125077. private _albedoScaling;
  125078. /**
  125079. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  125080. * It allows the strength of the sheen effect to not depend on the base color of the material,
  125081. * making it easier to setup and tweak the effect
  125082. */
  125083. albedoScaling: boolean;
  125084. /** @hidden */
  125085. private _internalMarkAllSubMeshesAsTexturesDirty;
  125086. /** @hidden */
  125087. _markAllSubMeshesAsTexturesDirty(): void;
  125088. /**
  125089. * Instantiate a new istance of clear coat configuration.
  125090. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125091. */
  125092. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125093. /**
  125094. * Specifies that the submesh is ready to be used.
  125095. * @param defines the list of "defines" to update.
  125096. * @param scene defines the scene the material belongs to.
  125097. * @returns - boolean indicating that the submesh is ready or not.
  125098. */
  125099. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  125100. /**
  125101. * Checks to see if a texture is used in the material.
  125102. * @param defines the list of "defines" to update.
  125103. * @param scene defines the scene the material belongs to.
  125104. */
  125105. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  125106. /**
  125107. * Binds the material data.
  125108. * @param uniformBuffer defines the Uniform buffer to fill in.
  125109. * @param scene defines the scene the material belongs to.
  125110. * @param isFrozen defines wether the material is frozen or not.
  125111. */
  125112. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  125113. /**
  125114. * Checks to see if a texture is used in the material.
  125115. * @param texture - Base texture to use.
  125116. * @returns - Boolean specifying if a texture is used in the material.
  125117. */
  125118. hasTexture(texture: BaseTexture): boolean;
  125119. /**
  125120. * Returns an array of the actively used textures.
  125121. * @param activeTextures Array of BaseTextures
  125122. */
  125123. getActiveTextures(activeTextures: BaseTexture[]): void;
  125124. /**
  125125. * Returns the animatable textures.
  125126. * @param animatables Array of animatable textures.
  125127. */
  125128. getAnimatables(animatables: IAnimatable[]): void;
  125129. /**
  125130. * Disposes the resources of the material.
  125131. * @param forceDisposeTextures - Forces the disposal of all textures.
  125132. */
  125133. dispose(forceDisposeTextures?: boolean): void;
  125134. /**
  125135. * Get the current class name of the texture useful for serialization or dynamic coding.
  125136. * @returns "PBRSheenConfiguration"
  125137. */
  125138. getClassName(): string;
  125139. /**
  125140. * Add fallbacks to the effect fallbacks list.
  125141. * @param defines defines the Base texture to use.
  125142. * @param fallbacks defines the current fallback list.
  125143. * @param currentRank defines the current fallback rank.
  125144. * @returns the new fallback rank.
  125145. */
  125146. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125147. /**
  125148. * Add the required uniforms to the current list.
  125149. * @param uniforms defines the current uniform list.
  125150. */
  125151. static AddUniforms(uniforms: string[]): void;
  125152. /**
  125153. * Add the required uniforms to the current buffer.
  125154. * @param uniformBuffer defines the current uniform buffer.
  125155. */
  125156. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125157. /**
  125158. * Add the required samplers to the current list.
  125159. * @param samplers defines the current sampler list.
  125160. */
  125161. static AddSamplers(samplers: string[]): void;
  125162. /**
  125163. * Makes a duplicate of the current configuration into another one.
  125164. * @param sheenConfiguration define the config where to copy the info
  125165. */
  125166. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  125167. /**
  125168. * Serializes this BRDF configuration.
  125169. * @returns - An object with the serialized config.
  125170. */
  125171. serialize(): any;
  125172. /**
  125173. * Parses a anisotropy Configuration from a serialized object.
  125174. * @param source - Serialized object.
  125175. * @param scene Defines the scene we are parsing for
  125176. * @param rootUrl Defines the rootUrl to load from
  125177. */
  125178. parse(source: any, scene: Scene, rootUrl: string): void;
  125179. }
  125180. }
  125181. declare module BABYLON {
  125182. /**
  125183. * @hidden
  125184. */
  125185. export interface IMaterialSubSurfaceDefines {
  125186. SUBSURFACE: boolean;
  125187. SS_REFRACTION: boolean;
  125188. SS_TRANSLUCENCY: boolean;
  125189. SS_SCATERRING: boolean;
  125190. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125191. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125192. SS_REFRACTIONMAP_3D: boolean;
  125193. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125194. SS_LODINREFRACTIONALPHA: boolean;
  125195. SS_GAMMAREFRACTION: boolean;
  125196. SS_RGBDREFRACTION: boolean;
  125197. SS_LINEARSPECULARREFRACTION: boolean;
  125198. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125199. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125200. /** @hidden */
  125201. _areTexturesDirty: boolean;
  125202. }
  125203. /**
  125204. * Define the code related to the sub surface parameters of the pbr material.
  125205. */
  125206. export class PBRSubSurfaceConfiguration {
  125207. private _isRefractionEnabled;
  125208. /**
  125209. * Defines if the refraction is enabled in the material.
  125210. */
  125211. isRefractionEnabled: boolean;
  125212. private _isTranslucencyEnabled;
  125213. /**
  125214. * Defines if the translucency is enabled in the material.
  125215. */
  125216. isTranslucencyEnabled: boolean;
  125217. private _isScatteringEnabled;
  125218. /**
  125219. * Defines the refraction intensity of the material.
  125220. * The refraction when enabled replaces the Diffuse part of the material.
  125221. * The intensity helps transitionning between diffuse and refraction.
  125222. */
  125223. refractionIntensity: number;
  125224. /**
  125225. * Defines the translucency intensity of the material.
  125226. * When translucency has been enabled, this defines how much of the "translucency"
  125227. * is addded to the diffuse part of the material.
  125228. */
  125229. translucencyIntensity: number;
  125230. /**
  125231. * Defines the scattering intensity of the material.
  125232. * When scattering has been enabled, this defines how much of the "scattered light"
  125233. * is addded to the diffuse part of the material.
  125234. */
  125235. scatteringIntensity: number;
  125236. private _thicknessTexture;
  125237. /**
  125238. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  125239. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  125240. * 0 would mean minimumThickness
  125241. * 1 would mean maximumThickness
  125242. * The other channels might be use as a mask to vary the different effects intensity.
  125243. */
  125244. thicknessTexture: Nullable<BaseTexture>;
  125245. private _refractionTexture;
  125246. /**
  125247. * Defines the texture to use for refraction.
  125248. */
  125249. refractionTexture: Nullable<BaseTexture>;
  125250. private _indexOfRefraction;
  125251. /**
  125252. * Defines the index of refraction used in the material.
  125253. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  125254. */
  125255. indexOfRefraction: number;
  125256. private _invertRefractionY;
  125257. /**
  125258. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125259. */
  125260. invertRefractionY: boolean;
  125261. private _linkRefractionWithTransparency;
  125262. /**
  125263. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125264. * Materials half opaque for instance using refraction could benefit from this control.
  125265. */
  125266. linkRefractionWithTransparency: boolean;
  125267. /**
  125268. * Defines the minimum thickness stored in the thickness map.
  125269. * If no thickness map is defined, this value will be used to simulate thickness.
  125270. */
  125271. minimumThickness: number;
  125272. /**
  125273. * Defines the maximum thickness stored in the thickness map.
  125274. */
  125275. maximumThickness: number;
  125276. /**
  125277. * Defines the volume tint of the material.
  125278. * This is used for both translucency and scattering.
  125279. */
  125280. tintColor: Color3;
  125281. /**
  125282. * Defines the distance at which the tint color should be found in the media.
  125283. * This is used for refraction only.
  125284. */
  125285. tintColorAtDistance: number;
  125286. /**
  125287. * Defines how far each channel transmit through the media.
  125288. * It is defined as a color to simplify it selection.
  125289. */
  125290. diffusionDistance: Color3;
  125291. private _useMaskFromThicknessTexture;
  125292. /**
  125293. * Stores the intensity of the different subsurface effects in the thickness texture.
  125294. * * the green channel is the translucency intensity.
  125295. * * the blue channel is the scattering intensity.
  125296. * * the alpha channel is the refraction intensity.
  125297. */
  125298. useMaskFromThicknessTexture: boolean;
  125299. /** @hidden */
  125300. private _internalMarkAllSubMeshesAsTexturesDirty;
  125301. /** @hidden */
  125302. _markAllSubMeshesAsTexturesDirty(): void;
  125303. /**
  125304. * Instantiate a new istance of sub surface configuration.
  125305. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125306. */
  125307. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125308. /**
  125309. * Gets wehter the submesh is ready to be used or not.
  125310. * @param defines the list of "defines" to update.
  125311. * @param scene defines the scene the material belongs to.
  125312. * @returns - boolean indicating that the submesh is ready or not.
  125313. */
  125314. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  125315. /**
  125316. * Checks to see if a texture is used in the material.
  125317. * @param defines the list of "defines" to update.
  125318. * @param scene defines the scene to the material belongs to.
  125319. */
  125320. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  125321. /**
  125322. * Binds the material data.
  125323. * @param uniformBuffer defines the Uniform buffer to fill in.
  125324. * @param scene defines the scene the material belongs to.
  125325. * @param engine defines the engine the material belongs to.
  125326. * @param isFrozen defines wether the material is frozen or not.
  125327. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  125328. */
  125329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  125330. /**
  125331. * Unbinds the material from the mesh.
  125332. * @param activeEffect defines the effect that should be unbound from.
  125333. * @returns true if unbound, otherwise false
  125334. */
  125335. unbind(activeEffect: Effect): boolean;
  125336. /**
  125337. * Returns the texture used for refraction or null if none is used.
  125338. * @param scene defines the scene the material belongs to.
  125339. * @returns - Refraction texture if present. If no refraction texture and refraction
  125340. * is linked with transparency, returns environment texture. Otherwise, returns null.
  125341. */
  125342. private _getRefractionTexture;
  125343. /**
  125344. * Returns true if alpha blending should be disabled.
  125345. */
  125346. get disableAlphaBlending(): boolean;
  125347. /**
  125348. * Fills the list of render target textures.
  125349. * @param renderTargets the list of render targets to update
  125350. */
  125351. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  125352. /**
  125353. * Checks to see if a texture is used in the material.
  125354. * @param texture - Base texture to use.
  125355. * @returns - Boolean specifying if a texture is used in the material.
  125356. */
  125357. hasTexture(texture: BaseTexture): boolean;
  125358. /**
  125359. * Gets a boolean indicating that current material needs to register RTT
  125360. * @returns true if this uses a render target otherwise false.
  125361. */
  125362. hasRenderTargetTextures(): boolean;
  125363. /**
  125364. * Returns an array of the actively used textures.
  125365. * @param activeTextures Array of BaseTextures
  125366. */
  125367. getActiveTextures(activeTextures: BaseTexture[]): void;
  125368. /**
  125369. * Returns the animatable textures.
  125370. * @param animatables Array of animatable textures.
  125371. */
  125372. getAnimatables(animatables: IAnimatable[]): void;
  125373. /**
  125374. * Disposes the resources of the material.
  125375. * @param forceDisposeTextures - Forces the disposal of all textures.
  125376. */
  125377. dispose(forceDisposeTextures?: boolean): void;
  125378. /**
  125379. * Get the current class name of the texture useful for serialization or dynamic coding.
  125380. * @returns "PBRSubSurfaceConfiguration"
  125381. */
  125382. getClassName(): string;
  125383. /**
  125384. * Add fallbacks to the effect fallbacks list.
  125385. * @param defines defines the Base texture to use.
  125386. * @param fallbacks defines the current fallback list.
  125387. * @param currentRank defines the current fallback rank.
  125388. * @returns the new fallback rank.
  125389. */
  125390. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125391. /**
  125392. * Add the required uniforms to the current list.
  125393. * @param uniforms defines the current uniform list.
  125394. */
  125395. static AddUniforms(uniforms: string[]): void;
  125396. /**
  125397. * Add the required samplers to the current list.
  125398. * @param samplers defines the current sampler list.
  125399. */
  125400. static AddSamplers(samplers: string[]): void;
  125401. /**
  125402. * Add the required uniforms to the current buffer.
  125403. * @param uniformBuffer defines the current uniform buffer.
  125404. */
  125405. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125406. /**
  125407. * Makes a duplicate of the current configuration into another one.
  125408. * @param configuration define the config where to copy the info
  125409. */
  125410. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  125411. /**
  125412. * Serializes this Sub Surface configuration.
  125413. * @returns - An object with the serialized config.
  125414. */
  125415. serialize(): any;
  125416. /**
  125417. * Parses a anisotropy Configuration from a serialized object.
  125418. * @param source - Serialized object.
  125419. * @param scene Defines the scene we are parsing for
  125420. * @param rootUrl Defines the rootUrl to load from
  125421. */
  125422. parse(source: any, scene: Scene, rootUrl: string): void;
  125423. }
  125424. }
  125425. declare module BABYLON {
  125426. /** @hidden */
  125427. export var pbrFragmentDeclaration: {
  125428. name: string;
  125429. shader: string;
  125430. };
  125431. }
  125432. declare module BABYLON {
  125433. /** @hidden */
  125434. export var pbrUboDeclaration: {
  125435. name: string;
  125436. shader: string;
  125437. };
  125438. }
  125439. declare module BABYLON {
  125440. /** @hidden */
  125441. export var pbrFragmentExtraDeclaration: {
  125442. name: string;
  125443. shader: string;
  125444. };
  125445. }
  125446. declare module BABYLON {
  125447. /** @hidden */
  125448. export var pbrFragmentSamplersDeclaration: {
  125449. name: string;
  125450. shader: string;
  125451. };
  125452. }
  125453. declare module BABYLON {
  125454. /** @hidden */
  125455. export var pbrHelperFunctions: {
  125456. name: string;
  125457. shader: string;
  125458. };
  125459. }
  125460. declare module BABYLON {
  125461. /** @hidden */
  125462. export var harmonicsFunctions: {
  125463. name: string;
  125464. shader: string;
  125465. };
  125466. }
  125467. declare module BABYLON {
  125468. /** @hidden */
  125469. export var pbrDirectLightingSetupFunctions: {
  125470. name: string;
  125471. shader: string;
  125472. };
  125473. }
  125474. declare module BABYLON {
  125475. /** @hidden */
  125476. export var pbrDirectLightingFalloffFunctions: {
  125477. name: string;
  125478. shader: string;
  125479. };
  125480. }
  125481. declare module BABYLON {
  125482. /** @hidden */
  125483. export var pbrBRDFFunctions: {
  125484. name: string;
  125485. shader: string;
  125486. };
  125487. }
  125488. declare module BABYLON {
  125489. /** @hidden */
  125490. export var pbrDirectLightingFunctions: {
  125491. name: string;
  125492. shader: string;
  125493. };
  125494. }
  125495. declare module BABYLON {
  125496. /** @hidden */
  125497. export var pbrIBLFunctions: {
  125498. name: string;
  125499. shader: string;
  125500. };
  125501. }
  125502. declare module BABYLON {
  125503. /** @hidden */
  125504. export var pbrBlockAlbedoOpacity: {
  125505. name: string;
  125506. shader: string;
  125507. };
  125508. }
  125509. declare module BABYLON {
  125510. /** @hidden */
  125511. export var pbrBlockReflectivity: {
  125512. name: string;
  125513. shader: string;
  125514. };
  125515. }
  125516. declare module BABYLON {
  125517. /** @hidden */
  125518. export var pbrBlockAmbientOcclusion: {
  125519. name: string;
  125520. shader: string;
  125521. };
  125522. }
  125523. declare module BABYLON {
  125524. /** @hidden */
  125525. export var pbrBlockAlphaFresnel: {
  125526. name: string;
  125527. shader: string;
  125528. };
  125529. }
  125530. declare module BABYLON {
  125531. /** @hidden */
  125532. export var pbrBlockAnisotropic: {
  125533. name: string;
  125534. shader: string;
  125535. };
  125536. }
  125537. declare module BABYLON {
  125538. /** @hidden */
  125539. export var pbrBlockReflection: {
  125540. name: string;
  125541. shader: string;
  125542. };
  125543. }
  125544. declare module BABYLON {
  125545. /** @hidden */
  125546. export var pbrBlockSheen: {
  125547. name: string;
  125548. shader: string;
  125549. };
  125550. }
  125551. declare module BABYLON {
  125552. /** @hidden */
  125553. export var pbrBlockClearcoat: {
  125554. name: string;
  125555. shader: string;
  125556. };
  125557. }
  125558. declare module BABYLON {
  125559. /** @hidden */
  125560. export var pbrBlockSubSurface: {
  125561. name: string;
  125562. shader: string;
  125563. };
  125564. }
  125565. declare module BABYLON {
  125566. /** @hidden */
  125567. export var pbrBlockNormalGeometric: {
  125568. name: string;
  125569. shader: string;
  125570. };
  125571. }
  125572. declare module BABYLON {
  125573. /** @hidden */
  125574. export var pbrBlockNormalFinal: {
  125575. name: string;
  125576. shader: string;
  125577. };
  125578. }
  125579. declare module BABYLON {
  125580. /** @hidden */
  125581. export var pbrBlockGeometryInfo: {
  125582. name: string;
  125583. shader: string;
  125584. };
  125585. }
  125586. declare module BABYLON {
  125587. /** @hidden */
  125588. export var pbrBlockReflectance0: {
  125589. name: string;
  125590. shader: string;
  125591. };
  125592. }
  125593. declare module BABYLON {
  125594. /** @hidden */
  125595. export var pbrBlockReflectance: {
  125596. name: string;
  125597. shader: string;
  125598. };
  125599. }
  125600. declare module BABYLON {
  125601. /** @hidden */
  125602. export var pbrBlockDirectLighting: {
  125603. name: string;
  125604. shader: string;
  125605. };
  125606. }
  125607. declare module BABYLON {
  125608. /** @hidden */
  125609. export var pbrBlockFinalLitComponents: {
  125610. name: string;
  125611. shader: string;
  125612. };
  125613. }
  125614. declare module BABYLON {
  125615. /** @hidden */
  125616. export var pbrBlockFinalUnlitComponents: {
  125617. name: string;
  125618. shader: string;
  125619. };
  125620. }
  125621. declare module BABYLON {
  125622. /** @hidden */
  125623. export var pbrBlockFinalColorComposition: {
  125624. name: string;
  125625. shader: string;
  125626. };
  125627. }
  125628. declare module BABYLON {
  125629. /** @hidden */
  125630. export var pbrBlockImageProcessing: {
  125631. name: string;
  125632. shader: string;
  125633. };
  125634. }
  125635. declare module BABYLON {
  125636. /** @hidden */
  125637. export var pbrDebug: {
  125638. name: string;
  125639. shader: string;
  125640. };
  125641. }
  125642. declare module BABYLON {
  125643. /** @hidden */
  125644. export var pbrPixelShader: {
  125645. name: string;
  125646. shader: string;
  125647. };
  125648. }
  125649. declare module BABYLON {
  125650. /** @hidden */
  125651. export var pbrVertexDeclaration: {
  125652. name: string;
  125653. shader: string;
  125654. };
  125655. }
  125656. declare module BABYLON {
  125657. /** @hidden */
  125658. export var pbrVertexShader: {
  125659. name: string;
  125660. shader: string;
  125661. };
  125662. }
  125663. declare module BABYLON {
  125664. /**
  125665. * Manages the defines for the PBR Material.
  125666. * @hidden
  125667. */
  125668. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  125669. PBR: boolean;
  125670. MAINUV1: boolean;
  125671. MAINUV2: boolean;
  125672. UV1: boolean;
  125673. UV2: boolean;
  125674. ALBEDO: boolean;
  125675. GAMMAALBEDO: boolean;
  125676. ALBEDODIRECTUV: number;
  125677. VERTEXCOLOR: boolean;
  125678. AMBIENT: boolean;
  125679. AMBIENTDIRECTUV: number;
  125680. AMBIENTINGRAYSCALE: boolean;
  125681. OPACITY: boolean;
  125682. VERTEXALPHA: boolean;
  125683. OPACITYDIRECTUV: number;
  125684. OPACITYRGB: boolean;
  125685. ALPHATEST: boolean;
  125686. DEPTHPREPASS: boolean;
  125687. ALPHABLEND: boolean;
  125688. ALPHAFROMALBEDO: boolean;
  125689. ALPHATESTVALUE: string;
  125690. SPECULAROVERALPHA: boolean;
  125691. RADIANCEOVERALPHA: boolean;
  125692. ALPHAFRESNEL: boolean;
  125693. LINEARALPHAFRESNEL: boolean;
  125694. PREMULTIPLYALPHA: boolean;
  125695. EMISSIVE: boolean;
  125696. EMISSIVEDIRECTUV: number;
  125697. REFLECTIVITY: boolean;
  125698. REFLECTIVITYDIRECTUV: number;
  125699. SPECULARTERM: boolean;
  125700. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  125701. MICROSURFACEAUTOMATIC: boolean;
  125702. LODBASEDMICROSFURACE: boolean;
  125703. MICROSURFACEMAP: boolean;
  125704. MICROSURFACEMAPDIRECTUV: number;
  125705. METALLICWORKFLOW: boolean;
  125706. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  125707. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  125708. METALLNESSSTOREINMETALMAPBLUE: boolean;
  125709. AOSTOREINMETALMAPRED: boolean;
  125710. METALLICF0FACTORFROMMETALLICMAP: boolean;
  125711. ENVIRONMENTBRDF: boolean;
  125712. ENVIRONMENTBRDF_RGBD: boolean;
  125713. NORMAL: boolean;
  125714. TANGENT: boolean;
  125715. BUMP: boolean;
  125716. BUMPDIRECTUV: number;
  125717. OBJECTSPACE_NORMALMAP: boolean;
  125718. PARALLAX: boolean;
  125719. PARALLAXOCCLUSION: boolean;
  125720. NORMALXYSCALE: boolean;
  125721. LIGHTMAP: boolean;
  125722. LIGHTMAPDIRECTUV: number;
  125723. USELIGHTMAPASSHADOWMAP: boolean;
  125724. GAMMALIGHTMAP: boolean;
  125725. RGBDLIGHTMAP: boolean;
  125726. REFLECTION: boolean;
  125727. REFLECTIONMAP_3D: boolean;
  125728. REFLECTIONMAP_SPHERICAL: boolean;
  125729. REFLECTIONMAP_PLANAR: boolean;
  125730. REFLECTIONMAP_CUBIC: boolean;
  125731. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  125732. REFLECTIONMAP_PROJECTION: boolean;
  125733. REFLECTIONMAP_SKYBOX: boolean;
  125734. REFLECTIONMAP_EXPLICIT: boolean;
  125735. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  125736. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  125737. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  125738. INVERTCUBICMAP: boolean;
  125739. USESPHERICALFROMREFLECTIONMAP: boolean;
  125740. USEIRRADIANCEMAP: boolean;
  125741. SPHERICAL_HARMONICS: boolean;
  125742. USESPHERICALINVERTEX: boolean;
  125743. REFLECTIONMAP_OPPOSITEZ: boolean;
  125744. LODINREFLECTIONALPHA: boolean;
  125745. GAMMAREFLECTION: boolean;
  125746. RGBDREFLECTION: boolean;
  125747. LINEARSPECULARREFLECTION: boolean;
  125748. RADIANCEOCCLUSION: boolean;
  125749. HORIZONOCCLUSION: boolean;
  125750. INSTANCES: boolean;
  125751. NUM_BONE_INFLUENCERS: number;
  125752. BonesPerMesh: number;
  125753. BONETEXTURE: boolean;
  125754. NONUNIFORMSCALING: boolean;
  125755. MORPHTARGETS: boolean;
  125756. MORPHTARGETS_NORMAL: boolean;
  125757. MORPHTARGETS_TANGENT: boolean;
  125758. MORPHTARGETS_UV: boolean;
  125759. NUM_MORPH_INFLUENCERS: number;
  125760. IMAGEPROCESSING: boolean;
  125761. VIGNETTE: boolean;
  125762. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125763. VIGNETTEBLENDMODEOPAQUE: boolean;
  125764. TONEMAPPING: boolean;
  125765. TONEMAPPING_ACES: boolean;
  125766. CONTRAST: boolean;
  125767. COLORCURVES: boolean;
  125768. COLORGRADING: boolean;
  125769. COLORGRADING3D: boolean;
  125770. SAMPLER3DGREENDEPTH: boolean;
  125771. SAMPLER3DBGRMAP: boolean;
  125772. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125773. EXPOSURE: boolean;
  125774. MULTIVIEW: boolean;
  125775. USEPHYSICALLIGHTFALLOFF: boolean;
  125776. USEGLTFLIGHTFALLOFF: boolean;
  125777. TWOSIDEDLIGHTING: boolean;
  125778. SHADOWFLOAT: boolean;
  125779. CLIPPLANE: boolean;
  125780. CLIPPLANE2: boolean;
  125781. CLIPPLANE3: boolean;
  125782. CLIPPLANE4: boolean;
  125783. CLIPPLANE5: boolean;
  125784. CLIPPLANE6: boolean;
  125785. POINTSIZE: boolean;
  125786. FOG: boolean;
  125787. LOGARITHMICDEPTH: boolean;
  125788. FORCENORMALFORWARD: boolean;
  125789. SPECULARAA: boolean;
  125790. CLEARCOAT: boolean;
  125791. CLEARCOAT_DEFAULTIOR: boolean;
  125792. CLEARCOAT_TEXTURE: boolean;
  125793. CLEARCOAT_TEXTUREDIRECTUV: number;
  125794. CLEARCOAT_BUMP: boolean;
  125795. CLEARCOAT_BUMPDIRECTUV: number;
  125796. CLEARCOAT_TINT: boolean;
  125797. CLEARCOAT_TINT_TEXTURE: boolean;
  125798. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125799. ANISOTROPIC: boolean;
  125800. ANISOTROPIC_TEXTURE: boolean;
  125801. ANISOTROPIC_TEXTUREDIRECTUV: number;
  125802. BRDF_V_HEIGHT_CORRELATED: boolean;
  125803. MS_BRDF_ENERGY_CONSERVATION: boolean;
  125804. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  125805. SHEEN: boolean;
  125806. SHEEN_TEXTURE: boolean;
  125807. SHEEN_TEXTUREDIRECTUV: number;
  125808. SHEEN_LINKWITHALBEDO: boolean;
  125809. SHEEN_ROUGHNESS: boolean;
  125810. SHEEN_ALBEDOSCALING: boolean;
  125811. SUBSURFACE: boolean;
  125812. SS_REFRACTION: boolean;
  125813. SS_TRANSLUCENCY: boolean;
  125814. SS_SCATERRING: boolean;
  125815. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125816. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125817. SS_REFRACTIONMAP_3D: boolean;
  125818. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125819. SS_LODINREFRACTIONALPHA: boolean;
  125820. SS_GAMMAREFRACTION: boolean;
  125821. SS_RGBDREFRACTION: boolean;
  125822. SS_LINEARSPECULARREFRACTION: boolean;
  125823. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125824. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125825. UNLIT: boolean;
  125826. DEBUGMODE: number;
  125827. /**
  125828. * Initializes the PBR Material defines.
  125829. */
  125830. constructor();
  125831. /**
  125832. * Resets the PBR Material defines.
  125833. */
  125834. reset(): void;
  125835. }
  125836. /**
  125837. * The Physically based material base class of BJS.
  125838. *
  125839. * This offers the main features of a standard PBR material.
  125840. * For more information, please refer to the documentation :
  125841. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125842. */
  125843. export abstract class PBRBaseMaterial extends PushMaterial {
  125844. /**
  125845. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125846. */
  125847. static readonly PBRMATERIAL_OPAQUE: number;
  125848. /**
  125849. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125850. */
  125851. static readonly PBRMATERIAL_ALPHATEST: number;
  125852. /**
  125853. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125854. */
  125855. static readonly PBRMATERIAL_ALPHABLEND: number;
  125856. /**
  125857. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125858. * They are also discarded below the alpha cutoff threshold to improve performances.
  125859. */
  125860. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125861. /**
  125862. * Defines the default value of how much AO map is occluding the analytical lights
  125863. * (point spot...).
  125864. */
  125865. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125866. /**
  125867. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  125868. */
  125869. static readonly LIGHTFALLOFF_PHYSICAL: number;
  125870. /**
  125871. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  125872. * to enhance interoperability with other engines.
  125873. */
  125874. static readonly LIGHTFALLOFF_GLTF: number;
  125875. /**
  125876. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  125877. * to enhance interoperability with other materials.
  125878. */
  125879. static readonly LIGHTFALLOFF_STANDARD: number;
  125880. /**
  125881. * Intensity of the direct lights e.g. the four lights available in your scene.
  125882. * This impacts both the direct diffuse and specular highlights.
  125883. */
  125884. protected _directIntensity: number;
  125885. /**
  125886. * Intensity of the emissive part of the material.
  125887. * This helps controlling the emissive effect without modifying the emissive color.
  125888. */
  125889. protected _emissiveIntensity: number;
  125890. /**
  125891. * Intensity of the environment e.g. how much the environment will light the object
  125892. * either through harmonics for rough material or through the refelction for shiny ones.
  125893. */
  125894. protected _environmentIntensity: number;
  125895. /**
  125896. * This is a special control allowing the reduction of the specular highlights coming from the
  125897. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125898. */
  125899. protected _specularIntensity: number;
  125900. /**
  125901. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  125902. */
  125903. private _lightingInfos;
  125904. /**
  125905. * Debug Control allowing disabling the bump map on this material.
  125906. */
  125907. protected _disableBumpMap: boolean;
  125908. /**
  125909. * AKA Diffuse Texture in standard nomenclature.
  125910. */
  125911. protected _albedoTexture: Nullable<BaseTexture>;
  125912. /**
  125913. * AKA Occlusion Texture in other nomenclature.
  125914. */
  125915. protected _ambientTexture: Nullable<BaseTexture>;
  125916. /**
  125917. * AKA Occlusion Texture Intensity in other nomenclature.
  125918. */
  125919. protected _ambientTextureStrength: number;
  125920. /**
  125921. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125922. * 1 means it completely occludes it
  125923. * 0 mean it has no impact
  125924. */
  125925. protected _ambientTextureImpactOnAnalyticalLights: number;
  125926. /**
  125927. * Stores the alpha values in a texture.
  125928. */
  125929. protected _opacityTexture: Nullable<BaseTexture>;
  125930. /**
  125931. * Stores the reflection values in a texture.
  125932. */
  125933. protected _reflectionTexture: Nullable<BaseTexture>;
  125934. /**
  125935. * Stores the emissive values in a texture.
  125936. */
  125937. protected _emissiveTexture: Nullable<BaseTexture>;
  125938. /**
  125939. * AKA Specular texture in other nomenclature.
  125940. */
  125941. protected _reflectivityTexture: Nullable<BaseTexture>;
  125942. /**
  125943. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125944. */
  125945. protected _metallicTexture: Nullable<BaseTexture>;
  125946. /**
  125947. * Specifies the metallic scalar of the metallic/roughness workflow.
  125948. * Can also be used to scale the metalness values of the metallic texture.
  125949. */
  125950. protected _metallic: Nullable<number>;
  125951. /**
  125952. * Specifies the roughness scalar of the metallic/roughness workflow.
  125953. * Can also be used to scale the roughness values of the metallic texture.
  125954. */
  125955. protected _roughness: Nullable<number>;
  125956. /**
  125957. * Specifies the an F0 factor to help configuring the material F0.
  125958. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125959. * to 0.5 the previously hard coded value stays the same.
  125960. * Can also be used to scale the F0 values of the metallic texture.
  125961. */
  125962. protected _metallicF0Factor: number;
  125963. /**
  125964. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125965. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125966. * your expectation as it multiplies with the texture data.
  125967. */
  125968. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  125969. /**
  125970. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125971. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125972. */
  125973. protected _microSurfaceTexture: Nullable<BaseTexture>;
  125974. /**
  125975. * Stores surface normal data used to displace a mesh in a texture.
  125976. */
  125977. protected _bumpTexture: Nullable<BaseTexture>;
  125978. /**
  125979. * Stores the pre-calculated light information of a mesh in a texture.
  125980. */
  125981. protected _lightmapTexture: Nullable<BaseTexture>;
  125982. /**
  125983. * The color of a material in ambient lighting.
  125984. */
  125985. protected _ambientColor: Color3;
  125986. /**
  125987. * AKA Diffuse Color in other nomenclature.
  125988. */
  125989. protected _albedoColor: Color3;
  125990. /**
  125991. * AKA Specular Color in other nomenclature.
  125992. */
  125993. protected _reflectivityColor: Color3;
  125994. /**
  125995. * The color applied when light is reflected from a material.
  125996. */
  125997. protected _reflectionColor: Color3;
  125998. /**
  125999. * The color applied when light is emitted from a material.
  126000. */
  126001. protected _emissiveColor: Color3;
  126002. /**
  126003. * AKA Glossiness in other nomenclature.
  126004. */
  126005. protected _microSurface: number;
  126006. /**
  126007. * Specifies that the material will use the light map as a show map.
  126008. */
  126009. protected _useLightmapAsShadowmap: boolean;
  126010. /**
  126011. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126012. * makes the reflect vector face the model (under horizon).
  126013. */
  126014. protected _useHorizonOcclusion: boolean;
  126015. /**
  126016. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126017. * too much the area relying on ambient texture to define their ambient occlusion.
  126018. */
  126019. protected _useRadianceOcclusion: boolean;
  126020. /**
  126021. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126022. */
  126023. protected _useAlphaFromAlbedoTexture: boolean;
  126024. /**
  126025. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  126026. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126027. */
  126028. protected _useSpecularOverAlpha: boolean;
  126029. /**
  126030. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126031. */
  126032. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126033. /**
  126034. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126035. */
  126036. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  126037. /**
  126038. * Specifies if the metallic texture contains the roughness information in its green channel.
  126039. */
  126040. protected _useRoughnessFromMetallicTextureGreen: boolean;
  126041. /**
  126042. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126043. */
  126044. protected _useMetallnessFromMetallicTextureBlue: boolean;
  126045. /**
  126046. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126047. */
  126048. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  126049. /**
  126050. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126051. */
  126052. protected _useAmbientInGrayScale: boolean;
  126053. /**
  126054. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126055. * The material will try to infer what glossiness each pixel should be.
  126056. */
  126057. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  126058. /**
  126059. * Defines the falloff type used in this material.
  126060. * It by default is Physical.
  126061. */
  126062. protected _lightFalloff: number;
  126063. /**
  126064. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126065. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126066. */
  126067. protected _useRadianceOverAlpha: boolean;
  126068. /**
  126069. * Allows using an object space normal map (instead of tangent space).
  126070. */
  126071. protected _useObjectSpaceNormalMap: boolean;
  126072. /**
  126073. * Allows using the bump map in parallax mode.
  126074. */
  126075. protected _useParallax: boolean;
  126076. /**
  126077. * Allows using the bump map in parallax occlusion mode.
  126078. */
  126079. protected _useParallaxOcclusion: boolean;
  126080. /**
  126081. * Controls the scale bias of the parallax mode.
  126082. */
  126083. protected _parallaxScaleBias: number;
  126084. /**
  126085. * If sets to true, disables all the lights affecting the material.
  126086. */
  126087. protected _disableLighting: boolean;
  126088. /**
  126089. * Number of Simultaneous lights allowed on the material.
  126090. */
  126091. protected _maxSimultaneousLights: number;
  126092. /**
  126093. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126094. */
  126095. protected _invertNormalMapX: boolean;
  126096. /**
  126097. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126098. */
  126099. protected _invertNormalMapY: boolean;
  126100. /**
  126101. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126102. */
  126103. protected _twoSidedLighting: boolean;
  126104. /**
  126105. * Defines the alpha limits in alpha test mode.
  126106. */
  126107. protected _alphaCutOff: number;
  126108. /**
  126109. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126110. */
  126111. protected _forceAlphaTest: boolean;
  126112. /**
  126113. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126114. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126115. */
  126116. protected _useAlphaFresnel: boolean;
  126117. /**
  126118. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126119. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126120. */
  126121. protected _useLinearAlphaFresnel: boolean;
  126122. /**
  126123. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  126124. * from cos thetav and roughness:
  126125. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  126126. */
  126127. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  126128. /**
  126129. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126130. */
  126131. protected _forceIrradianceInFragment: boolean;
  126132. /**
  126133. * Force normal to face away from face.
  126134. */
  126135. protected _forceNormalForward: boolean;
  126136. /**
  126137. * Enables specular anti aliasing in the PBR shader.
  126138. * It will both interacts on the Geometry for analytical and IBL lighting.
  126139. * It also prefilter the roughness map based on the bump values.
  126140. */
  126141. protected _enableSpecularAntiAliasing: boolean;
  126142. /**
  126143. * Default configuration related to image processing available in the PBR Material.
  126144. */
  126145. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126146. /**
  126147. * Keep track of the image processing observer to allow dispose and replace.
  126148. */
  126149. private _imageProcessingObserver;
  126150. /**
  126151. * Attaches a new image processing configuration to the PBR Material.
  126152. * @param configuration
  126153. */
  126154. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126155. /**
  126156. * Stores the available render targets.
  126157. */
  126158. private _renderTargets;
  126159. /**
  126160. * Sets the global ambient color for the material used in lighting calculations.
  126161. */
  126162. private _globalAmbientColor;
  126163. /**
  126164. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  126165. */
  126166. private _useLogarithmicDepth;
  126167. /**
  126168. * If set to true, no lighting calculations will be applied.
  126169. */
  126170. private _unlit;
  126171. private _debugMode;
  126172. /**
  126173. * @hidden
  126174. * This is reserved for the inspector.
  126175. * Defines the material debug mode.
  126176. * It helps seeing only some components of the material while troubleshooting.
  126177. */
  126178. debugMode: number;
  126179. /**
  126180. * @hidden
  126181. * This is reserved for the inspector.
  126182. * Specify from where on screen the debug mode should start.
  126183. * The value goes from -1 (full screen) to 1 (not visible)
  126184. * It helps with side by side comparison against the final render
  126185. * This defaults to -1
  126186. */
  126187. private debugLimit;
  126188. /**
  126189. * @hidden
  126190. * This is reserved for the inspector.
  126191. * As the default viewing range might not be enough (if the ambient is really small for instance)
  126192. * You can use the factor to better multiply the final value.
  126193. */
  126194. private debugFactor;
  126195. /**
  126196. * Defines the clear coat layer parameters for the material.
  126197. */
  126198. readonly clearCoat: PBRClearCoatConfiguration;
  126199. /**
  126200. * Defines the anisotropic parameters for the material.
  126201. */
  126202. readonly anisotropy: PBRAnisotropicConfiguration;
  126203. /**
  126204. * Defines the BRDF parameters for the material.
  126205. */
  126206. readonly brdf: PBRBRDFConfiguration;
  126207. /**
  126208. * Defines the Sheen parameters for the material.
  126209. */
  126210. readonly sheen: PBRSheenConfiguration;
  126211. /**
  126212. * Defines the SubSurface parameters for the material.
  126213. */
  126214. readonly subSurface: PBRSubSurfaceConfiguration;
  126215. /**
  126216. * Custom callback helping to override the default shader used in the material.
  126217. */
  126218. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  126219. protected _rebuildInParallel: boolean;
  126220. /**
  126221. * Instantiates a new PBRMaterial instance.
  126222. *
  126223. * @param name The material name
  126224. * @param scene The scene the material will be use in.
  126225. */
  126226. constructor(name: string, scene: Scene);
  126227. /**
  126228. * Gets a boolean indicating that current material needs to register RTT
  126229. */
  126230. get hasRenderTargetTextures(): boolean;
  126231. /**
  126232. * Gets the name of the material class.
  126233. */
  126234. getClassName(): string;
  126235. /**
  126236. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126237. */
  126238. get useLogarithmicDepth(): boolean;
  126239. /**
  126240. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126241. */
  126242. set useLogarithmicDepth(value: boolean);
  126243. /**
  126244. * Returns true if alpha blending should be disabled.
  126245. */
  126246. protected get _disableAlphaBlending(): boolean;
  126247. /**
  126248. * Specifies whether or not this material should be rendered in alpha blend mode.
  126249. */
  126250. needAlphaBlending(): boolean;
  126251. /**
  126252. * Specifies whether or not this material should be rendered in alpha test mode.
  126253. */
  126254. needAlphaTesting(): boolean;
  126255. /**
  126256. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  126257. */
  126258. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  126259. /**
  126260. * Gets the texture used for the alpha test.
  126261. */
  126262. getAlphaTestTexture(): Nullable<BaseTexture>;
  126263. /**
  126264. * Specifies that the submesh is ready to be used.
  126265. * @param mesh - BJS mesh.
  126266. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  126267. * @param useInstances - Specifies that instances should be used.
  126268. * @returns - boolean indicating that the submesh is ready or not.
  126269. */
  126270. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126271. /**
  126272. * Specifies if the material uses metallic roughness workflow.
  126273. * @returns boolean specifiying if the material uses metallic roughness workflow.
  126274. */
  126275. isMetallicWorkflow(): boolean;
  126276. private _prepareEffect;
  126277. private _prepareDefines;
  126278. /**
  126279. * Force shader compilation
  126280. */
  126281. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  126282. /**
  126283. * Initializes the uniform buffer layout for the shader.
  126284. */
  126285. buildUniformLayout(): void;
  126286. /**
  126287. * Unbinds the material from the mesh
  126288. */
  126289. unbind(): void;
  126290. /**
  126291. * Binds the submesh data.
  126292. * @param world - The world matrix.
  126293. * @param mesh - The BJS mesh.
  126294. * @param subMesh - A submesh of the BJS mesh.
  126295. */
  126296. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126297. /**
  126298. * Returns the animatable textures.
  126299. * @returns - Array of animatable textures.
  126300. */
  126301. getAnimatables(): IAnimatable[];
  126302. /**
  126303. * Returns the texture used for reflections.
  126304. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  126305. */
  126306. private _getReflectionTexture;
  126307. /**
  126308. * Returns an array of the actively used textures.
  126309. * @returns - Array of BaseTextures
  126310. */
  126311. getActiveTextures(): BaseTexture[];
  126312. /**
  126313. * Checks to see if a texture is used in the material.
  126314. * @param texture - Base texture to use.
  126315. * @returns - Boolean specifying if a texture is used in the material.
  126316. */
  126317. hasTexture(texture: BaseTexture): boolean;
  126318. /**
  126319. * Disposes the resources of the material.
  126320. * @param forceDisposeEffect - Forces the disposal of effects.
  126321. * @param forceDisposeTextures - Forces the disposal of all textures.
  126322. */
  126323. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126324. }
  126325. }
  126326. declare module BABYLON {
  126327. /**
  126328. * The Physically based material of BJS.
  126329. *
  126330. * This offers the main features of a standard PBR material.
  126331. * For more information, please refer to the documentation :
  126332. * https://doc.babylonjs.com/how_to/physically_based_rendering
  126333. */
  126334. export class PBRMaterial extends PBRBaseMaterial {
  126335. /**
  126336. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  126337. */
  126338. static readonly PBRMATERIAL_OPAQUE: number;
  126339. /**
  126340. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  126341. */
  126342. static readonly PBRMATERIAL_ALPHATEST: number;
  126343. /**
  126344. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126345. */
  126346. static readonly PBRMATERIAL_ALPHABLEND: number;
  126347. /**
  126348. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126349. * They are also discarded below the alpha cutoff threshold to improve performances.
  126350. */
  126351. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  126352. /**
  126353. * Defines the default value of how much AO map is occluding the analytical lights
  126354. * (point spot...).
  126355. */
  126356. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  126357. /**
  126358. * Intensity of the direct lights e.g. the four lights available in your scene.
  126359. * This impacts both the direct diffuse and specular highlights.
  126360. */
  126361. directIntensity: number;
  126362. /**
  126363. * Intensity of the emissive part of the material.
  126364. * This helps controlling the emissive effect without modifying the emissive color.
  126365. */
  126366. emissiveIntensity: number;
  126367. /**
  126368. * Intensity of the environment e.g. how much the environment will light the object
  126369. * either through harmonics for rough material or through the refelction for shiny ones.
  126370. */
  126371. environmentIntensity: number;
  126372. /**
  126373. * This is a special control allowing the reduction of the specular highlights coming from the
  126374. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126375. */
  126376. specularIntensity: number;
  126377. /**
  126378. * Debug Control allowing disabling the bump map on this material.
  126379. */
  126380. disableBumpMap: boolean;
  126381. /**
  126382. * AKA Diffuse Texture in standard nomenclature.
  126383. */
  126384. albedoTexture: BaseTexture;
  126385. /**
  126386. * AKA Occlusion Texture in other nomenclature.
  126387. */
  126388. ambientTexture: BaseTexture;
  126389. /**
  126390. * AKA Occlusion Texture Intensity in other nomenclature.
  126391. */
  126392. ambientTextureStrength: number;
  126393. /**
  126394. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126395. * 1 means it completely occludes it
  126396. * 0 mean it has no impact
  126397. */
  126398. ambientTextureImpactOnAnalyticalLights: number;
  126399. /**
  126400. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  126401. */
  126402. opacityTexture: BaseTexture;
  126403. /**
  126404. * Stores the reflection values in a texture.
  126405. */
  126406. reflectionTexture: Nullable<BaseTexture>;
  126407. /**
  126408. * Stores the emissive values in a texture.
  126409. */
  126410. emissiveTexture: BaseTexture;
  126411. /**
  126412. * AKA Specular texture in other nomenclature.
  126413. */
  126414. reflectivityTexture: BaseTexture;
  126415. /**
  126416. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126417. */
  126418. metallicTexture: BaseTexture;
  126419. /**
  126420. * Specifies the metallic scalar of the metallic/roughness workflow.
  126421. * Can also be used to scale the metalness values of the metallic texture.
  126422. */
  126423. metallic: Nullable<number>;
  126424. /**
  126425. * Specifies the roughness scalar of the metallic/roughness workflow.
  126426. * Can also be used to scale the roughness values of the metallic texture.
  126427. */
  126428. roughness: Nullable<number>;
  126429. /**
  126430. * Specifies the an F0 factor to help configuring the material F0.
  126431. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126432. * to 0.5 the previously hard coded value stays the same.
  126433. * Can also be used to scale the F0 values of the metallic texture.
  126434. */
  126435. metallicF0Factor: number;
  126436. /**
  126437. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126438. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126439. * your expectation as it multiplies with the texture data.
  126440. */
  126441. useMetallicF0FactorFromMetallicTexture: boolean;
  126442. /**
  126443. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126444. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126445. */
  126446. microSurfaceTexture: BaseTexture;
  126447. /**
  126448. * Stores surface normal data used to displace a mesh in a texture.
  126449. */
  126450. bumpTexture: BaseTexture;
  126451. /**
  126452. * Stores the pre-calculated light information of a mesh in a texture.
  126453. */
  126454. lightmapTexture: BaseTexture;
  126455. /**
  126456. * Stores the refracted light information in a texture.
  126457. */
  126458. get refractionTexture(): Nullable<BaseTexture>;
  126459. set refractionTexture(value: Nullable<BaseTexture>);
  126460. /**
  126461. * The color of a material in ambient lighting.
  126462. */
  126463. ambientColor: Color3;
  126464. /**
  126465. * AKA Diffuse Color in other nomenclature.
  126466. */
  126467. albedoColor: Color3;
  126468. /**
  126469. * AKA Specular Color in other nomenclature.
  126470. */
  126471. reflectivityColor: Color3;
  126472. /**
  126473. * The color reflected from the material.
  126474. */
  126475. reflectionColor: Color3;
  126476. /**
  126477. * The color emitted from the material.
  126478. */
  126479. emissiveColor: Color3;
  126480. /**
  126481. * AKA Glossiness in other nomenclature.
  126482. */
  126483. microSurface: number;
  126484. /**
  126485. * source material index of refraction (IOR)' / 'destination material IOR.
  126486. */
  126487. get indexOfRefraction(): number;
  126488. set indexOfRefraction(value: number);
  126489. /**
  126490. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126491. */
  126492. get invertRefractionY(): boolean;
  126493. set invertRefractionY(value: boolean);
  126494. /**
  126495. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126496. * Materials half opaque for instance using refraction could benefit from this control.
  126497. */
  126498. get linkRefractionWithTransparency(): boolean;
  126499. set linkRefractionWithTransparency(value: boolean);
  126500. /**
  126501. * If true, the light map contains occlusion information instead of lighting info.
  126502. */
  126503. useLightmapAsShadowmap: boolean;
  126504. /**
  126505. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126506. */
  126507. useAlphaFromAlbedoTexture: boolean;
  126508. /**
  126509. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126510. */
  126511. forceAlphaTest: boolean;
  126512. /**
  126513. * Defines the alpha limits in alpha test mode.
  126514. */
  126515. alphaCutOff: number;
  126516. /**
  126517. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  126518. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126519. */
  126520. useSpecularOverAlpha: boolean;
  126521. /**
  126522. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126523. */
  126524. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126525. /**
  126526. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126527. */
  126528. useRoughnessFromMetallicTextureAlpha: boolean;
  126529. /**
  126530. * Specifies if the metallic texture contains the roughness information in its green channel.
  126531. */
  126532. useRoughnessFromMetallicTextureGreen: boolean;
  126533. /**
  126534. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126535. */
  126536. useMetallnessFromMetallicTextureBlue: boolean;
  126537. /**
  126538. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126539. */
  126540. useAmbientOcclusionFromMetallicTextureRed: boolean;
  126541. /**
  126542. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126543. */
  126544. useAmbientInGrayScale: boolean;
  126545. /**
  126546. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126547. * The material will try to infer what glossiness each pixel should be.
  126548. */
  126549. useAutoMicroSurfaceFromReflectivityMap: boolean;
  126550. /**
  126551. * BJS is using an harcoded light falloff based on a manually sets up range.
  126552. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126553. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126554. */
  126555. get usePhysicalLightFalloff(): boolean;
  126556. /**
  126557. * BJS is using an harcoded light falloff based on a manually sets up range.
  126558. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126559. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126560. */
  126561. set usePhysicalLightFalloff(value: boolean);
  126562. /**
  126563. * In order to support the falloff compatibility with gltf, a special mode has been added
  126564. * to reproduce the gltf light falloff.
  126565. */
  126566. get useGLTFLightFalloff(): boolean;
  126567. /**
  126568. * In order to support the falloff compatibility with gltf, a special mode has been added
  126569. * to reproduce the gltf light falloff.
  126570. */
  126571. set useGLTFLightFalloff(value: boolean);
  126572. /**
  126573. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126574. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126575. */
  126576. useRadianceOverAlpha: boolean;
  126577. /**
  126578. * Allows using an object space normal map (instead of tangent space).
  126579. */
  126580. useObjectSpaceNormalMap: boolean;
  126581. /**
  126582. * Allows using the bump map in parallax mode.
  126583. */
  126584. useParallax: boolean;
  126585. /**
  126586. * Allows using the bump map in parallax occlusion mode.
  126587. */
  126588. useParallaxOcclusion: boolean;
  126589. /**
  126590. * Controls the scale bias of the parallax mode.
  126591. */
  126592. parallaxScaleBias: number;
  126593. /**
  126594. * If sets to true, disables all the lights affecting the material.
  126595. */
  126596. disableLighting: boolean;
  126597. /**
  126598. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126599. */
  126600. forceIrradianceInFragment: boolean;
  126601. /**
  126602. * Number of Simultaneous lights allowed on the material.
  126603. */
  126604. maxSimultaneousLights: number;
  126605. /**
  126606. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126607. */
  126608. invertNormalMapX: boolean;
  126609. /**
  126610. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126611. */
  126612. invertNormalMapY: boolean;
  126613. /**
  126614. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126615. */
  126616. twoSidedLighting: boolean;
  126617. /**
  126618. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126619. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126620. */
  126621. useAlphaFresnel: boolean;
  126622. /**
  126623. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126624. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126625. */
  126626. useLinearAlphaFresnel: boolean;
  126627. /**
  126628. * Let user defines the brdf lookup texture used for IBL.
  126629. * A default 8bit version is embedded but you could point at :
  126630. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  126631. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  126632. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  126633. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  126634. */
  126635. environmentBRDFTexture: Nullable<BaseTexture>;
  126636. /**
  126637. * Force normal to face away from face.
  126638. */
  126639. forceNormalForward: boolean;
  126640. /**
  126641. * Enables specular anti aliasing in the PBR shader.
  126642. * It will both interacts on the Geometry for analytical and IBL lighting.
  126643. * It also prefilter the roughness map based on the bump values.
  126644. */
  126645. enableSpecularAntiAliasing: boolean;
  126646. /**
  126647. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126648. * makes the reflect vector face the model (under horizon).
  126649. */
  126650. useHorizonOcclusion: boolean;
  126651. /**
  126652. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126653. * too much the area relying on ambient texture to define their ambient occlusion.
  126654. */
  126655. useRadianceOcclusion: boolean;
  126656. /**
  126657. * If set to true, no lighting calculations will be applied.
  126658. */
  126659. unlit: boolean;
  126660. /**
  126661. * Gets the image processing configuration used either in this material.
  126662. */
  126663. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126664. /**
  126665. * Sets the Default image processing configuration used either in the this material.
  126666. *
  126667. * If sets to null, the scene one is in use.
  126668. */
  126669. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126670. /**
  126671. * Gets wether the color curves effect is enabled.
  126672. */
  126673. get cameraColorCurvesEnabled(): boolean;
  126674. /**
  126675. * Sets wether the color curves effect is enabled.
  126676. */
  126677. set cameraColorCurvesEnabled(value: boolean);
  126678. /**
  126679. * Gets wether the color grading effect is enabled.
  126680. */
  126681. get cameraColorGradingEnabled(): boolean;
  126682. /**
  126683. * Gets wether the color grading effect is enabled.
  126684. */
  126685. set cameraColorGradingEnabled(value: boolean);
  126686. /**
  126687. * Gets wether tonemapping is enabled or not.
  126688. */
  126689. get cameraToneMappingEnabled(): boolean;
  126690. /**
  126691. * Sets wether tonemapping is enabled or not
  126692. */
  126693. set cameraToneMappingEnabled(value: boolean);
  126694. /**
  126695. * The camera exposure used on this material.
  126696. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126697. * This corresponds to a photographic exposure.
  126698. */
  126699. get cameraExposure(): number;
  126700. /**
  126701. * The camera exposure used on this material.
  126702. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126703. * This corresponds to a photographic exposure.
  126704. */
  126705. set cameraExposure(value: number);
  126706. /**
  126707. * Gets The camera contrast used on this material.
  126708. */
  126709. get cameraContrast(): number;
  126710. /**
  126711. * Sets The camera contrast used on this material.
  126712. */
  126713. set cameraContrast(value: number);
  126714. /**
  126715. * Gets the Color Grading 2D Lookup Texture.
  126716. */
  126717. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126718. /**
  126719. * Sets the Color Grading 2D Lookup Texture.
  126720. */
  126721. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126722. /**
  126723. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126724. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126725. * 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;
  126726. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126727. */
  126728. get cameraColorCurves(): Nullable<ColorCurves>;
  126729. /**
  126730. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126731. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126732. * 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;
  126733. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126734. */
  126735. set cameraColorCurves(value: Nullable<ColorCurves>);
  126736. /**
  126737. * Instantiates a new PBRMaterial instance.
  126738. *
  126739. * @param name The material name
  126740. * @param scene The scene the material will be use in.
  126741. */
  126742. constructor(name: string, scene: Scene);
  126743. /**
  126744. * Returns the name of this material class.
  126745. */
  126746. getClassName(): string;
  126747. /**
  126748. * Makes a duplicate of the current material.
  126749. * @param name - name to use for the new material.
  126750. */
  126751. clone(name: string): PBRMaterial;
  126752. /**
  126753. * Serializes this PBR Material.
  126754. * @returns - An object with the serialized material.
  126755. */
  126756. serialize(): any;
  126757. /**
  126758. * Parses a PBR Material from a serialized object.
  126759. * @param source - Serialized object.
  126760. * @param scene - BJS scene instance.
  126761. * @param rootUrl - url for the scene object
  126762. * @returns - PBRMaterial
  126763. */
  126764. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  126765. }
  126766. }
  126767. declare module BABYLON {
  126768. /**
  126769. * Direct draw surface info
  126770. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  126771. */
  126772. export interface DDSInfo {
  126773. /**
  126774. * Width of the texture
  126775. */
  126776. width: number;
  126777. /**
  126778. * Width of the texture
  126779. */
  126780. height: number;
  126781. /**
  126782. * Number of Mipmaps for the texture
  126783. * @see https://en.wikipedia.org/wiki/Mipmap
  126784. */
  126785. mipmapCount: number;
  126786. /**
  126787. * If the textures format is a known fourCC format
  126788. * @see https://www.fourcc.org/
  126789. */
  126790. isFourCC: boolean;
  126791. /**
  126792. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  126793. */
  126794. isRGB: boolean;
  126795. /**
  126796. * If the texture is a lumincance format
  126797. */
  126798. isLuminance: boolean;
  126799. /**
  126800. * If this is a cube texture
  126801. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  126802. */
  126803. isCube: boolean;
  126804. /**
  126805. * If the texture is a compressed format eg. FOURCC_DXT1
  126806. */
  126807. isCompressed: boolean;
  126808. /**
  126809. * The dxgiFormat of the texture
  126810. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  126811. */
  126812. dxgiFormat: number;
  126813. /**
  126814. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  126815. */
  126816. textureType: number;
  126817. /**
  126818. * Sphericle polynomial created for the dds texture
  126819. */
  126820. sphericalPolynomial?: SphericalPolynomial;
  126821. }
  126822. /**
  126823. * Class used to provide DDS decompression tools
  126824. */
  126825. export class DDSTools {
  126826. /**
  126827. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  126828. */
  126829. static StoreLODInAlphaChannel: boolean;
  126830. /**
  126831. * Gets DDS information from an array buffer
  126832. * @param data defines the array buffer view to read data from
  126833. * @returns the DDS information
  126834. */
  126835. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  126836. private static _FloatView;
  126837. private static _Int32View;
  126838. private static _ToHalfFloat;
  126839. private static _FromHalfFloat;
  126840. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  126841. private static _GetHalfFloatRGBAArrayBuffer;
  126842. private static _GetFloatRGBAArrayBuffer;
  126843. private static _GetFloatAsUIntRGBAArrayBuffer;
  126844. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  126845. private static _GetRGBAArrayBuffer;
  126846. private static _ExtractLongWordOrder;
  126847. private static _GetRGBArrayBuffer;
  126848. private static _GetLuminanceArrayBuffer;
  126849. /**
  126850. * Uploads DDS Levels to a Babylon Texture
  126851. * @hidden
  126852. */
  126853. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  126854. }
  126855. interface ThinEngine {
  126856. /**
  126857. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  126858. * @param rootUrl defines the url where the file to load is located
  126859. * @param scene defines the current scene
  126860. * @param lodScale defines scale to apply to the mip map selection
  126861. * @param lodOffset defines offset to apply to the mip map selection
  126862. * @param onLoad defines an optional callback raised when the texture is loaded
  126863. * @param onError defines an optional callback raised if there is an issue to load the texture
  126864. * @param format defines the format of the data
  126865. * @param forcedExtension defines the extension to use to pick the right loader
  126866. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  126867. * @returns the cube texture as an InternalTexture
  126868. */
  126869. 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;
  126870. }
  126871. }
  126872. declare module BABYLON {
  126873. /**
  126874. * Implementation of the DDS Texture Loader.
  126875. * @hidden
  126876. */
  126877. export class _DDSTextureLoader implements IInternalTextureLoader {
  126878. /**
  126879. * Defines wether the loader supports cascade loading the different faces.
  126880. */
  126881. readonly supportCascades: boolean;
  126882. /**
  126883. * This returns if the loader support the current file information.
  126884. * @param extension defines the file extension of the file being loaded
  126885. * @returns true if the loader can load the specified file
  126886. */
  126887. canLoad(extension: string): boolean;
  126888. /**
  126889. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126890. * @param data contains the texture data
  126891. * @param texture defines the BabylonJS internal texture
  126892. * @param createPolynomials will be true if polynomials have been requested
  126893. * @param onLoad defines the callback to trigger once the texture is ready
  126894. * @param onError defines the callback to trigger in case of error
  126895. */
  126896. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126897. /**
  126898. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126899. * @param data contains the texture data
  126900. * @param texture defines the BabylonJS internal texture
  126901. * @param callback defines the method to call once ready to upload
  126902. */
  126903. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126904. }
  126905. }
  126906. declare module BABYLON {
  126907. /**
  126908. * Implementation of the ENV Texture Loader.
  126909. * @hidden
  126910. */
  126911. export class _ENVTextureLoader implements IInternalTextureLoader {
  126912. /**
  126913. * Defines wether the loader supports cascade loading the different faces.
  126914. */
  126915. readonly supportCascades: boolean;
  126916. /**
  126917. * This returns if the loader support the current file information.
  126918. * @param extension defines the file extension of the file being loaded
  126919. * @returns true if the loader can load the specified file
  126920. */
  126921. canLoad(extension: string): boolean;
  126922. /**
  126923. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126924. * @param data contains the texture data
  126925. * @param texture defines the BabylonJS internal texture
  126926. * @param createPolynomials will be true if polynomials have been requested
  126927. * @param onLoad defines the callback to trigger once the texture is ready
  126928. * @param onError defines the callback to trigger in case of error
  126929. */
  126930. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126931. /**
  126932. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126933. * @param data contains the texture data
  126934. * @param texture defines the BabylonJS internal texture
  126935. * @param callback defines the method to call once ready to upload
  126936. */
  126937. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126938. }
  126939. }
  126940. declare module BABYLON {
  126941. /**
  126942. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  126943. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  126944. */
  126945. export class KhronosTextureContainer {
  126946. /** contents of the KTX container file */
  126947. data: ArrayBufferView;
  126948. private static HEADER_LEN;
  126949. private static COMPRESSED_2D;
  126950. private static COMPRESSED_3D;
  126951. private static TEX_2D;
  126952. private static TEX_3D;
  126953. /**
  126954. * Gets the openGL type
  126955. */
  126956. glType: number;
  126957. /**
  126958. * Gets the openGL type size
  126959. */
  126960. glTypeSize: number;
  126961. /**
  126962. * Gets the openGL format
  126963. */
  126964. glFormat: number;
  126965. /**
  126966. * Gets the openGL internal format
  126967. */
  126968. glInternalFormat: number;
  126969. /**
  126970. * Gets the base internal format
  126971. */
  126972. glBaseInternalFormat: number;
  126973. /**
  126974. * Gets image width in pixel
  126975. */
  126976. pixelWidth: number;
  126977. /**
  126978. * Gets image height in pixel
  126979. */
  126980. pixelHeight: number;
  126981. /**
  126982. * Gets image depth in pixels
  126983. */
  126984. pixelDepth: number;
  126985. /**
  126986. * Gets the number of array elements
  126987. */
  126988. numberOfArrayElements: number;
  126989. /**
  126990. * Gets the number of faces
  126991. */
  126992. numberOfFaces: number;
  126993. /**
  126994. * Gets the number of mipmap levels
  126995. */
  126996. numberOfMipmapLevels: number;
  126997. /**
  126998. * Gets the bytes of key value data
  126999. */
  127000. bytesOfKeyValueData: number;
  127001. /**
  127002. * Gets the load type
  127003. */
  127004. loadType: number;
  127005. /**
  127006. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  127007. */
  127008. isInvalid: boolean;
  127009. /**
  127010. * Creates a new KhronosTextureContainer
  127011. * @param data contents of the KTX container file
  127012. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  127013. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  127014. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  127015. */
  127016. constructor(
  127017. /** contents of the KTX container file */
  127018. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  127019. /**
  127020. * Uploads KTX content to a Babylon Texture.
  127021. * It is assumed that the texture has already been created & is currently bound
  127022. * @hidden
  127023. */
  127024. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  127025. private _upload2DCompressedLevels;
  127026. /**
  127027. * Checks if the given data starts with a KTX file identifier.
  127028. * @param data the data to check
  127029. * @returns true if the data is a KTX file or false otherwise
  127030. */
  127031. static IsValid(data: ArrayBufferView): boolean;
  127032. }
  127033. }
  127034. declare module BABYLON {
  127035. /**
  127036. * Class for loading KTX2 files
  127037. * !!! Experimental Extension Subject to Changes !!!
  127038. * @hidden
  127039. */
  127040. export class KhronosTextureContainer2 {
  127041. private static _ModulePromise;
  127042. private static _TranscodeFormat;
  127043. constructor(engine: ThinEngine);
  127044. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  127045. private _determineTranscodeFormat;
  127046. /**
  127047. * Checks if the given data starts with a KTX2 file identifier.
  127048. * @param data the data to check
  127049. * @returns true if the data is a KTX2 file or false otherwise
  127050. */
  127051. static IsValid(data: ArrayBufferView): boolean;
  127052. }
  127053. }
  127054. declare module BABYLON {
  127055. /**
  127056. * Implementation of the KTX Texture Loader.
  127057. * @hidden
  127058. */
  127059. export class _KTXTextureLoader implements IInternalTextureLoader {
  127060. /**
  127061. * Defines wether the loader supports cascade loading the different faces.
  127062. */
  127063. readonly supportCascades: boolean;
  127064. /**
  127065. * This returns if the loader support the current file information.
  127066. * @param extension defines the file extension of the file being loaded
  127067. * @returns true if the loader can load the specified file
  127068. */
  127069. canLoad(extension: string): boolean;
  127070. /**
  127071. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127072. * @param data contains the texture data
  127073. * @param texture defines the BabylonJS internal texture
  127074. * @param createPolynomials will be true if polynomials have been requested
  127075. * @param onLoad defines the callback to trigger once the texture is ready
  127076. * @param onError defines the callback to trigger in case of error
  127077. */
  127078. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127079. /**
  127080. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127081. * @param data contains the texture data
  127082. * @param texture defines the BabylonJS internal texture
  127083. * @param callback defines the method to call once ready to upload
  127084. */
  127085. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  127086. }
  127087. }
  127088. declare module BABYLON {
  127089. /** @hidden */
  127090. export var _forceSceneHelpersToBundle: boolean;
  127091. interface Scene {
  127092. /**
  127093. * Creates a default light for the scene.
  127094. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  127095. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  127096. */
  127097. createDefaultLight(replace?: boolean): void;
  127098. /**
  127099. * Creates a default camera for the scene.
  127100. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  127101. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127102. * @param replace has default false, when true replaces the active camera in the scene
  127103. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  127104. */
  127105. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127106. /**
  127107. * Creates a default camera and a default light.
  127108. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  127109. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127110. * @param replace has the default false, when true replaces the active camera/light in the scene
  127111. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  127112. */
  127113. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127114. /**
  127115. * Creates a new sky box
  127116. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  127117. * @param environmentTexture defines the texture to use as environment texture
  127118. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  127119. * @param scale defines the overall scale of the skybox
  127120. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  127121. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  127122. * @returns a new mesh holding the sky box
  127123. */
  127124. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  127125. /**
  127126. * Creates a new environment
  127127. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  127128. * @param options defines the options you can use to configure the environment
  127129. * @returns the new EnvironmentHelper
  127130. */
  127131. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  127132. /**
  127133. * Creates a new VREXperienceHelper
  127134. * @see http://doc.babylonjs.com/how_to/webvr_helper
  127135. * @param webVROptions defines the options used to create the new VREXperienceHelper
  127136. * @returns a new VREXperienceHelper
  127137. */
  127138. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  127139. /**
  127140. * Creates a new WebXRDefaultExperience
  127141. * @see http://doc.babylonjs.com/how_to/webxr
  127142. * @param options experience options
  127143. * @returns a promise for a new WebXRDefaultExperience
  127144. */
  127145. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127146. }
  127147. }
  127148. declare module BABYLON {
  127149. /**
  127150. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  127151. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  127152. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  127153. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  127154. */
  127155. export class VideoDome extends TransformNode {
  127156. /**
  127157. * Define the video source as a Monoscopic panoramic 360 video.
  127158. */
  127159. static readonly MODE_MONOSCOPIC: number;
  127160. /**
  127161. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127162. */
  127163. static readonly MODE_TOPBOTTOM: number;
  127164. /**
  127165. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127166. */
  127167. static readonly MODE_SIDEBYSIDE: number;
  127168. private _halfDome;
  127169. private _useDirectMapping;
  127170. /**
  127171. * The video texture being displayed on the sphere
  127172. */
  127173. protected _videoTexture: VideoTexture;
  127174. /**
  127175. * Gets the video texture being displayed on the sphere
  127176. */
  127177. get videoTexture(): VideoTexture;
  127178. /**
  127179. * The skybox material
  127180. */
  127181. protected _material: BackgroundMaterial;
  127182. /**
  127183. * The surface used for the skybox
  127184. */
  127185. protected _mesh: Mesh;
  127186. /**
  127187. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  127188. */
  127189. private _halfDomeMask;
  127190. /**
  127191. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  127192. * Also see the options.resolution property.
  127193. */
  127194. get fovMultiplier(): number;
  127195. set fovMultiplier(value: number);
  127196. private _videoMode;
  127197. /**
  127198. * Gets or set the current video mode for the video. It can be:
  127199. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  127200. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127201. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127202. */
  127203. get videoMode(): number;
  127204. set videoMode(value: number);
  127205. /**
  127206. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  127207. *
  127208. */
  127209. get halfDome(): boolean;
  127210. /**
  127211. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  127212. */
  127213. set halfDome(enabled: boolean);
  127214. /**
  127215. * Oberserver used in Stereoscopic VR Mode.
  127216. */
  127217. private _onBeforeCameraRenderObserver;
  127218. /**
  127219. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  127220. * @param name Element's name, child elements will append suffixes for their own names.
  127221. * @param urlsOrVideo defines the url(s) or the video element to use
  127222. * @param options An object containing optional or exposed sub element properties
  127223. */
  127224. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  127225. resolution?: number;
  127226. clickToPlay?: boolean;
  127227. autoPlay?: boolean;
  127228. loop?: boolean;
  127229. size?: number;
  127230. poster?: string;
  127231. faceForward?: boolean;
  127232. useDirectMapping?: boolean;
  127233. halfDomeMode?: boolean;
  127234. }, scene: Scene);
  127235. private _changeVideoMode;
  127236. /**
  127237. * Releases resources associated with this node.
  127238. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127239. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127240. */
  127241. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  127242. }
  127243. }
  127244. declare module BABYLON {
  127245. /**
  127246. * This class can be used to get instrumentation data from a Babylon engine
  127247. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127248. */
  127249. export class EngineInstrumentation implements IDisposable {
  127250. /**
  127251. * Define the instrumented engine.
  127252. */
  127253. engine: Engine;
  127254. private _captureGPUFrameTime;
  127255. private _gpuFrameTimeToken;
  127256. private _gpuFrameTime;
  127257. private _captureShaderCompilationTime;
  127258. private _shaderCompilationTime;
  127259. private _onBeginFrameObserver;
  127260. private _onEndFrameObserver;
  127261. private _onBeforeShaderCompilationObserver;
  127262. private _onAfterShaderCompilationObserver;
  127263. /**
  127264. * Gets the perf counter used for GPU frame time
  127265. */
  127266. get gpuFrameTimeCounter(): PerfCounter;
  127267. /**
  127268. * Gets the GPU frame time capture status
  127269. */
  127270. get captureGPUFrameTime(): boolean;
  127271. /**
  127272. * Enable or disable the GPU frame time capture
  127273. */
  127274. set captureGPUFrameTime(value: boolean);
  127275. /**
  127276. * Gets the perf counter used for shader compilation time
  127277. */
  127278. get shaderCompilationTimeCounter(): PerfCounter;
  127279. /**
  127280. * Gets the shader compilation time capture status
  127281. */
  127282. get captureShaderCompilationTime(): boolean;
  127283. /**
  127284. * Enable or disable the shader compilation time capture
  127285. */
  127286. set captureShaderCompilationTime(value: boolean);
  127287. /**
  127288. * Instantiates a new engine instrumentation.
  127289. * This class can be used to get instrumentation data from a Babylon engine
  127290. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127291. * @param engine Defines the engine to instrument
  127292. */
  127293. constructor(
  127294. /**
  127295. * Define the instrumented engine.
  127296. */
  127297. engine: Engine);
  127298. /**
  127299. * Dispose and release associated resources.
  127300. */
  127301. dispose(): void;
  127302. }
  127303. }
  127304. declare module BABYLON {
  127305. /**
  127306. * This class can be used to get instrumentation data from a Babylon engine
  127307. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127308. */
  127309. export class SceneInstrumentation implements IDisposable {
  127310. /**
  127311. * Defines the scene to instrument
  127312. */
  127313. scene: Scene;
  127314. private _captureActiveMeshesEvaluationTime;
  127315. private _activeMeshesEvaluationTime;
  127316. private _captureRenderTargetsRenderTime;
  127317. private _renderTargetsRenderTime;
  127318. private _captureFrameTime;
  127319. private _frameTime;
  127320. private _captureRenderTime;
  127321. private _renderTime;
  127322. private _captureInterFrameTime;
  127323. private _interFrameTime;
  127324. private _captureParticlesRenderTime;
  127325. private _particlesRenderTime;
  127326. private _captureSpritesRenderTime;
  127327. private _spritesRenderTime;
  127328. private _capturePhysicsTime;
  127329. private _physicsTime;
  127330. private _captureAnimationsTime;
  127331. private _animationsTime;
  127332. private _captureCameraRenderTime;
  127333. private _cameraRenderTime;
  127334. private _onBeforeActiveMeshesEvaluationObserver;
  127335. private _onAfterActiveMeshesEvaluationObserver;
  127336. private _onBeforeRenderTargetsRenderObserver;
  127337. private _onAfterRenderTargetsRenderObserver;
  127338. private _onAfterRenderObserver;
  127339. private _onBeforeDrawPhaseObserver;
  127340. private _onAfterDrawPhaseObserver;
  127341. private _onBeforeAnimationsObserver;
  127342. private _onBeforeParticlesRenderingObserver;
  127343. private _onAfterParticlesRenderingObserver;
  127344. private _onBeforeSpritesRenderingObserver;
  127345. private _onAfterSpritesRenderingObserver;
  127346. private _onBeforePhysicsObserver;
  127347. private _onAfterPhysicsObserver;
  127348. private _onAfterAnimationsObserver;
  127349. private _onBeforeCameraRenderObserver;
  127350. private _onAfterCameraRenderObserver;
  127351. /**
  127352. * Gets the perf counter used for active meshes evaluation time
  127353. */
  127354. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  127355. /**
  127356. * Gets the active meshes evaluation time capture status
  127357. */
  127358. get captureActiveMeshesEvaluationTime(): boolean;
  127359. /**
  127360. * Enable or disable the active meshes evaluation time capture
  127361. */
  127362. set captureActiveMeshesEvaluationTime(value: boolean);
  127363. /**
  127364. * Gets the perf counter used for render targets render time
  127365. */
  127366. get renderTargetsRenderTimeCounter(): PerfCounter;
  127367. /**
  127368. * Gets the render targets render time capture status
  127369. */
  127370. get captureRenderTargetsRenderTime(): boolean;
  127371. /**
  127372. * Enable or disable the render targets render time capture
  127373. */
  127374. set captureRenderTargetsRenderTime(value: boolean);
  127375. /**
  127376. * Gets the perf counter used for particles render time
  127377. */
  127378. get particlesRenderTimeCounter(): PerfCounter;
  127379. /**
  127380. * Gets the particles render time capture status
  127381. */
  127382. get captureParticlesRenderTime(): boolean;
  127383. /**
  127384. * Enable or disable the particles render time capture
  127385. */
  127386. set captureParticlesRenderTime(value: boolean);
  127387. /**
  127388. * Gets the perf counter used for sprites render time
  127389. */
  127390. get spritesRenderTimeCounter(): PerfCounter;
  127391. /**
  127392. * Gets the sprites render time capture status
  127393. */
  127394. get captureSpritesRenderTime(): boolean;
  127395. /**
  127396. * Enable or disable the sprites render time capture
  127397. */
  127398. set captureSpritesRenderTime(value: boolean);
  127399. /**
  127400. * Gets the perf counter used for physics time
  127401. */
  127402. get physicsTimeCounter(): PerfCounter;
  127403. /**
  127404. * Gets the physics time capture status
  127405. */
  127406. get capturePhysicsTime(): boolean;
  127407. /**
  127408. * Enable or disable the physics time capture
  127409. */
  127410. set capturePhysicsTime(value: boolean);
  127411. /**
  127412. * Gets the perf counter used for animations time
  127413. */
  127414. get animationsTimeCounter(): PerfCounter;
  127415. /**
  127416. * Gets the animations time capture status
  127417. */
  127418. get captureAnimationsTime(): boolean;
  127419. /**
  127420. * Enable or disable the animations time capture
  127421. */
  127422. set captureAnimationsTime(value: boolean);
  127423. /**
  127424. * Gets the perf counter used for frame time capture
  127425. */
  127426. get frameTimeCounter(): PerfCounter;
  127427. /**
  127428. * Gets the frame time capture status
  127429. */
  127430. get captureFrameTime(): boolean;
  127431. /**
  127432. * Enable or disable the frame time capture
  127433. */
  127434. set captureFrameTime(value: boolean);
  127435. /**
  127436. * Gets the perf counter used for inter-frames time capture
  127437. */
  127438. get interFrameTimeCounter(): PerfCounter;
  127439. /**
  127440. * Gets the inter-frames time capture status
  127441. */
  127442. get captureInterFrameTime(): boolean;
  127443. /**
  127444. * Enable or disable the inter-frames time capture
  127445. */
  127446. set captureInterFrameTime(value: boolean);
  127447. /**
  127448. * Gets the perf counter used for render time capture
  127449. */
  127450. get renderTimeCounter(): PerfCounter;
  127451. /**
  127452. * Gets the render time capture status
  127453. */
  127454. get captureRenderTime(): boolean;
  127455. /**
  127456. * Enable or disable the render time capture
  127457. */
  127458. set captureRenderTime(value: boolean);
  127459. /**
  127460. * Gets the perf counter used for camera render time capture
  127461. */
  127462. get cameraRenderTimeCounter(): PerfCounter;
  127463. /**
  127464. * Gets the camera render time capture status
  127465. */
  127466. get captureCameraRenderTime(): boolean;
  127467. /**
  127468. * Enable or disable the camera render time capture
  127469. */
  127470. set captureCameraRenderTime(value: boolean);
  127471. /**
  127472. * Gets the perf counter used for draw calls
  127473. */
  127474. get drawCallsCounter(): PerfCounter;
  127475. /**
  127476. * Instantiates a new scene instrumentation.
  127477. * This class can be used to get instrumentation data from a Babylon engine
  127478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127479. * @param scene Defines the scene to instrument
  127480. */
  127481. constructor(
  127482. /**
  127483. * Defines the scene to instrument
  127484. */
  127485. scene: Scene);
  127486. /**
  127487. * Dispose and release associated resources.
  127488. */
  127489. dispose(): void;
  127490. }
  127491. }
  127492. declare module BABYLON {
  127493. /** @hidden */
  127494. export var glowMapGenerationPixelShader: {
  127495. name: string;
  127496. shader: string;
  127497. };
  127498. }
  127499. declare module BABYLON {
  127500. /** @hidden */
  127501. export var glowMapGenerationVertexShader: {
  127502. name: string;
  127503. shader: string;
  127504. };
  127505. }
  127506. declare module BABYLON {
  127507. /**
  127508. * Effect layer options. This helps customizing the behaviour
  127509. * of the effect layer.
  127510. */
  127511. export interface IEffectLayerOptions {
  127512. /**
  127513. * Multiplication factor apply to the canvas size to compute the render target size
  127514. * used to generated the objects (the smaller the faster).
  127515. */
  127516. mainTextureRatio: number;
  127517. /**
  127518. * Enforces a fixed size texture to ensure effect stability across devices.
  127519. */
  127520. mainTextureFixedSize?: number;
  127521. /**
  127522. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  127523. */
  127524. alphaBlendingMode: number;
  127525. /**
  127526. * The camera attached to the layer.
  127527. */
  127528. camera: Nullable<Camera>;
  127529. /**
  127530. * The rendering group to draw the layer in.
  127531. */
  127532. renderingGroupId: number;
  127533. }
  127534. /**
  127535. * The effect layer Helps adding post process effect blended with the main pass.
  127536. *
  127537. * This can be for instance use to generate glow or higlight effects on the scene.
  127538. *
  127539. * The effect layer class can not be used directly and is intented to inherited from to be
  127540. * customized per effects.
  127541. */
  127542. export abstract class EffectLayer {
  127543. private _vertexBuffers;
  127544. private _indexBuffer;
  127545. private _cachedDefines;
  127546. private _effectLayerMapGenerationEffect;
  127547. private _effectLayerOptions;
  127548. private _mergeEffect;
  127549. protected _scene: Scene;
  127550. protected _engine: Engine;
  127551. protected _maxSize: number;
  127552. protected _mainTextureDesiredSize: ISize;
  127553. protected _mainTexture: RenderTargetTexture;
  127554. protected _shouldRender: boolean;
  127555. protected _postProcesses: PostProcess[];
  127556. protected _textures: BaseTexture[];
  127557. protected _emissiveTextureAndColor: {
  127558. texture: Nullable<BaseTexture>;
  127559. color: Color4;
  127560. };
  127561. /**
  127562. * The name of the layer
  127563. */
  127564. name: string;
  127565. /**
  127566. * The clear color of the texture used to generate the glow map.
  127567. */
  127568. neutralColor: Color4;
  127569. /**
  127570. * Specifies whether the highlight layer is enabled or not.
  127571. */
  127572. isEnabled: boolean;
  127573. /**
  127574. * Gets the camera attached to the layer.
  127575. */
  127576. get camera(): Nullable<Camera>;
  127577. /**
  127578. * Gets the rendering group id the layer should render in.
  127579. */
  127580. get renderingGroupId(): number;
  127581. set renderingGroupId(renderingGroupId: number);
  127582. /**
  127583. * An event triggered when the effect layer has been disposed.
  127584. */
  127585. onDisposeObservable: Observable<EffectLayer>;
  127586. /**
  127587. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  127588. */
  127589. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  127590. /**
  127591. * An event triggered when the generated texture is being merged in the scene.
  127592. */
  127593. onBeforeComposeObservable: Observable<EffectLayer>;
  127594. /**
  127595. * An event triggered when the mesh is rendered into the effect render target.
  127596. */
  127597. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  127598. /**
  127599. * An event triggered after the mesh has been rendered into the effect render target.
  127600. */
  127601. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  127602. /**
  127603. * An event triggered when the generated texture has been merged in the scene.
  127604. */
  127605. onAfterComposeObservable: Observable<EffectLayer>;
  127606. /**
  127607. * An event triggered when the efffect layer changes its size.
  127608. */
  127609. onSizeChangedObservable: Observable<EffectLayer>;
  127610. /** @hidden */
  127611. static _SceneComponentInitialization: (scene: Scene) => void;
  127612. /**
  127613. * Instantiates a new effect Layer and references it in the scene.
  127614. * @param name The name of the layer
  127615. * @param scene The scene to use the layer in
  127616. */
  127617. constructor(
  127618. /** The Friendly of the effect in the scene */
  127619. name: string, scene: Scene);
  127620. /**
  127621. * Get the effect name of the layer.
  127622. * @return The effect name
  127623. */
  127624. abstract getEffectName(): string;
  127625. /**
  127626. * Checks for the readiness of the element composing the layer.
  127627. * @param subMesh the mesh to check for
  127628. * @param useInstances specify whether or not to use instances to render the mesh
  127629. * @return true if ready otherwise, false
  127630. */
  127631. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127632. /**
  127633. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127634. * @returns true if the effect requires stencil during the main canvas render pass.
  127635. */
  127636. abstract needStencil(): boolean;
  127637. /**
  127638. * Create the merge effect. This is the shader use to blit the information back
  127639. * to the main canvas at the end of the scene rendering.
  127640. * @returns The effect containing the shader used to merge the effect on the main canvas
  127641. */
  127642. protected abstract _createMergeEffect(): Effect;
  127643. /**
  127644. * Creates the render target textures and post processes used in the effect layer.
  127645. */
  127646. protected abstract _createTextureAndPostProcesses(): void;
  127647. /**
  127648. * Implementation specific of rendering the generating effect on the main canvas.
  127649. * @param effect The effect used to render through
  127650. */
  127651. protected abstract _internalRender(effect: Effect): void;
  127652. /**
  127653. * Sets the required values for both the emissive texture and and the main color.
  127654. */
  127655. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127656. /**
  127657. * Free any resources and references associated to a mesh.
  127658. * Internal use
  127659. * @param mesh The mesh to free.
  127660. */
  127661. abstract _disposeMesh(mesh: Mesh): void;
  127662. /**
  127663. * Serializes this layer (Glow or Highlight for example)
  127664. * @returns a serialized layer object
  127665. */
  127666. abstract serialize?(): any;
  127667. /**
  127668. * Initializes the effect layer with the required options.
  127669. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  127670. */
  127671. protected _init(options: Partial<IEffectLayerOptions>): void;
  127672. /**
  127673. * Generates the index buffer of the full screen quad blending to the main canvas.
  127674. */
  127675. private _generateIndexBuffer;
  127676. /**
  127677. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  127678. */
  127679. private _generateVertexBuffer;
  127680. /**
  127681. * Sets the main texture desired size which is the closest power of two
  127682. * of the engine canvas size.
  127683. */
  127684. private _setMainTextureSize;
  127685. /**
  127686. * Creates the main texture for the effect layer.
  127687. */
  127688. protected _createMainTexture(): void;
  127689. /**
  127690. * Adds specific effects defines.
  127691. * @param defines The defines to add specifics to.
  127692. */
  127693. protected _addCustomEffectDefines(defines: string[]): void;
  127694. /**
  127695. * Checks for the readiness of the element composing the layer.
  127696. * @param subMesh the mesh to check for
  127697. * @param useInstances specify whether or not to use instances to render the mesh
  127698. * @param emissiveTexture the associated emissive texture used to generate the glow
  127699. * @return true if ready otherwise, false
  127700. */
  127701. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  127702. /**
  127703. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  127704. */
  127705. render(): void;
  127706. /**
  127707. * Determine if a given mesh will be used in the current effect.
  127708. * @param mesh mesh to test
  127709. * @returns true if the mesh will be used
  127710. */
  127711. hasMesh(mesh: AbstractMesh): boolean;
  127712. /**
  127713. * Returns true if the layer contains information to display, otherwise false.
  127714. * @returns true if the glow layer should be rendered
  127715. */
  127716. shouldRender(): boolean;
  127717. /**
  127718. * Returns true if the mesh should render, otherwise false.
  127719. * @param mesh The mesh to render
  127720. * @returns true if it should render otherwise false
  127721. */
  127722. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  127723. /**
  127724. * Returns true if the mesh can be rendered, otherwise false.
  127725. * @param mesh The mesh to render
  127726. * @param material The material used on the mesh
  127727. * @returns true if it can be rendered otherwise false
  127728. */
  127729. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127730. /**
  127731. * Returns true if the mesh should render, otherwise false.
  127732. * @param mesh The mesh to render
  127733. * @returns true if it should render otherwise false
  127734. */
  127735. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  127736. /**
  127737. * Renders the submesh passed in parameter to the generation map.
  127738. */
  127739. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  127740. /**
  127741. * Defines whether the current material of the mesh should be use to render the effect.
  127742. * @param mesh defines the current mesh to render
  127743. */
  127744. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127745. /**
  127746. * Rebuild the required buffers.
  127747. * @hidden Internal use only.
  127748. */
  127749. _rebuild(): void;
  127750. /**
  127751. * Dispose only the render target textures and post process.
  127752. */
  127753. private _disposeTextureAndPostProcesses;
  127754. /**
  127755. * Dispose the highlight layer and free resources.
  127756. */
  127757. dispose(): void;
  127758. /**
  127759. * Gets the class name of the effect layer
  127760. * @returns the string with the class name of the effect layer
  127761. */
  127762. getClassName(): string;
  127763. /**
  127764. * Creates an effect layer from parsed effect layer data
  127765. * @param parsedEffectLayer defines effect layer data
  127766. * @param scene defines the current scene
  127767. * @param rootUrl defines the root URL containing the effect layer information
  127768. * @returns a parsed effect Layer
  127769. */
  127770. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  127771. }
  127772. }
  127773. declare module BABYLON {
  127774. interface AbstractScene {
  127775. /**
  127776. * The list of effect layers (highlights/glow) added to the scene
  127777. * @see http://doc.babylonjs.com/how_to/highlight_layer
  127778. * @see http://doc.babylonjs.com/how_to/glow_layer
  127779. */
  127780. effectLayers: Array<EffectLayer>;
  127781. /**
  127782. * Removes the given effect layer from this scene.
  127783. * @param toRemove defines the effect layer to remove
  127784. * @returns the index of the removed effect layer
  127785. */
  127786. removeEffectLayer(toRemove: EffectLayer): number;
  127787. /**
  127788. * Adds the given effect layer to this scene
  127789. * @param newEffectLayer defines the effect layer to add
  127790. */
  127791. addEffectLayer(newEffectLayer: EffectLayer): void;
  127792. }
  127793. /**
  127794. * Defines the layer scene component responsible to manage any effect layers
  127795. * in a given scene.
  127796. */
  127797. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  127798. /**
  127799. * The component name helpfull to identify the component in the list of scene components.
  127800. */
  127801. readonly name: string;
  127802. /**
  127803. * The scene the component belongs to.
  127804. */
  127805. scene: Scene;
  127806. private _engine;
  127807. private _renderEffects;
  127808. private _needStencil;
  127809. private _previousStencilState;
  127810. /**
  127811. * Creates a new instance of the component for the given scene
  127812. * @param scene Defines the scene to register the component in
  127813. */
  127814. constructor(scene: Scene);
  127815. /**
  127816. * Registers the component in a given scene
  127817. */
  127818. register(): void;
  127819. /**
  127820. * Rebuilds the elements related to this component in case of
  127821. * context lost for instance.
  127822. */
  127823. rebuild(): void;
  127824. /**
  127825. * Serializes the component data to the specified json object
  127826. * @param serializationObject The object to serialize to
  127827. */
  127828. serialize(serializationObject: any): void;
  127829. /**
  127830. * Adds all the elements from the container to the scene
  127831. * @param container the container holding the elements
  127832. */
  127833. addFromContainer(container: AbstractScene): void;
  127834. /**
  127835. * Removes all the elements in the container from the scene
  127836. * @param container contains the elements to remove
  127837. * @param dispose if the removed element should be disposed (default: false)
  127838. */
  127839. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127840. /**
  127841. * Disposes the component and the associated ressources.
  127842. */
  127843. dispose(): void;
  127844. private _isReadyForMesh;
  127845. private _renderMainTexture;
  127846. private _setStencil;
  127847. private _setStencilBack;
  127848. private _draw;
  127849. private _drawCamera;
  127850. private _drawRenderingGroup;
  127851. }
  127852. }
  127853. declare module BABYLON {
  127854. /** @hidden */
  127855. export var glowMapMergePixelShader: {
  127856. name: string;
  127857. shader: string;
  127858. };
  127859. }
  127860. declare module BABYLON {
  127861. /** @hidden */
  127862. export var glowMapMergeVertexShader: {
  127863. name: string;
  127864. shader: string;
  127865. };
  127866. }
  127867. declare module BABYLON {
  127868. interface AbstractScene {
  127869. /**
  127870. * Return a the first highlight layer of the scene with a given name.
  127871. * @param name The name of the highlight layer to look for.
  127872. * @return The highlight layer if found otherwise null.
  127873. */
  127874. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  127875. }
  127876. /**
  127877. * Glow layer options. This helps customizing the behaviour
  127878. * of the glow layer.
  127879. */
  127880. export interface IGlowLayerOptions {
  127881. /**
  127882. * Multiplication factor apply to the canvas size to compute the render target size
  127883. * used to generated the glowing objects (the smaller the faster).
  127884. */
  127885. mainTextureRatio: number;
  127886. /**
  127887. * Enforces a fixed size texture to ensure resize independant blur.
  127888. */
  127889. mainTextureFixedSize?: number;
  127890. /**
  127891. * How big is the kernel of the blur texture.
  127892. */
  127893. blurKernelSize: number;
  127894. /**
  127895. * The camera attached to the layer.
  127896. */
  127897. camera: Nullable<Camera>;
  127898. /**
  127899. * Enable MSAA by chosing the number of samples.
  127900. */
  127901. mainTextureSamples?: number;
  127902. /**
  127903. * The rendering group to draw the layer in.
  127904. */
  127905. renderingGroupId: number;
  127906. }
  127907. /**
  127908. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  127909. *
  127910. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  127911. *
  127912. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  127913. */
  127914. export class GlowLayer extends EffectLayer {
  127915. /**
  127916. * Effect Name of the layer.
  127917. */
  127918. static readonly EffectName: string;
  127919. /**
  127920. * The default blur kernel size used for the glow.
  127921. */
  127922. static DefaultBlurKernelSize: number;
  127923. /**
  127924. * The default texture size ratio used for the glow.
  127925. */
  127926. static DefaultTextureRatio: number;
  127927. /**
  127928. * Sets the kernel size of the blur.
  127929. */
  127930. set blurKernelSize(value: number);
  127931. /**
  127932. * Gets the kernel size of the blur.
  127933. */
  127934. get blurKernelSize(): number;
  127935. /**
  127936. * Sets the glow intensity.
  127937. */
  127938. set intensity(value: number);
  127939. /**
  127940. * Gets the glow intensity.
  127941. */
  127942. get intensity(): number;
  127943. private _options;
  127944. private _intensity;
  127945. private _horizontalBlurPostprocess1;
  127946. private _verticalBlurPostprocess1;
  127947. private _horizontalBlurPostprocess2;
  127948. private _verticalBlurPostprocess2;
  127949. private _blurTexture1;
  127950. private _blurTexture2;
  127951. private _postProcesses1;
  127952. private _postProcesses2;
  127953. private _includedOnlyMeshes;
  127954. private _excludedMeshes;
  127955. private _meshesUsingTheirOwnMaterials;
  127956. /**
  127957. * Callback used to let the user override the color selection on a per mesh basis
  127958. */
  127959. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  127960. /**
  127961. * Callback used to let the user override the texture selection on a per mesh basis
  127962. */
  127963. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  127964. /**
  127965. * Instantiates a new glow Layer and references it to the scene.
  127966. * @param name The name of the layer
  127967. * @param scene The scene to use the layer in
  127968. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  127969. */
  127970. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  127971. /**
  127972. * Get the effect name of the layer.
  127973. * @return The effect name
  127974. */
  127975. getEffectName(): string;
  127976. /**
  127977. * Create the merge effect. This is the shader use to blit the information back
  127978. * to the main canvas at the end of the scene rendering.
  127979. */
  127980. protected _createMergeEffect(): Effect;
  127981. /**
  127982. * Creates the render target textures and post processes used in the glow layer.
  127983. */
  127984. protected _createTextureAndPostProcesses(): void;
  127985. /**
  127986. * Checks for the readiness of the element composing the layer.
  127987. * @param subMesh the mesh to check for
  127988. * @param useInstances specify wether or not to use instances to render the mesh
  127989. * @param emissiveTexture the associated emissive texture used to generate the glow
  127990. * @return true if ready otherwise, false
  127991. */
  127992. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127993. /**
  127994. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127995. */
  127996. needStencil(): boolean;
  127997. /**
  127998. * Returns true if the mesh can be rendered, otherwise false.
  127999. * @param mesh The mesh to render
  128000. * @param material The material used on the mesh
  128001. * @returns true if it can be rendered otherwise false
  128002. */
  128003. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  128004. /**
  128005. * Implementation specific of rendering the generating effect on the main canvas.
  128006. * @param effect The effect used to render through
  128007. */
  128008. protected _internalRender(effect: Effect): void;
  128009. /**
  128010. * Sets the required values for both the emissive texture and and the main color.
  128011. */
  128012. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128013. /**
  128014. * Returns true if the mesh should render, otherwise false.
  128015. * @param mesh The mesh to render
  128016. * @returns true if it should render otherwise false
  128017. */
  128018. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128019. /**
  128020. * Adds specific effects defines.
  128021. * @param defines The defines to add specifics to.
  128022. */
  128023. protected _addCustomEffectDefines(defines: string[]): void;
  128024. /**
  128025. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  128026. * @param mesh The mesh to exclude from the glow layer
  128027. */
  128028. addExcludedMesh(mesh: Mesh): void;
  128029. /**
  128030. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  128031. * @param mesh The mesh to remove
  128032. */
  128033. removeExcludedMesh(mesh: Mesh): void;
  128034. /**
  128035. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  128036. * @param mesh The mesh to include in the glow layer
  128037. */
  128038. addIncludedOnlyMesh(mesh: Mesh): void;
  128039. /**
  128040. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  128041. * @param mesh The mesh to remove
  128042. */
  128043. removeIncludedOnlyMesh(mesh: Mesh): void;
  128044. /**
  128045. * Determine if a given mesh will be used in the glow layer
  128046. * @param mesh The mesh to test
  128047. * @returns true if the mesh will be highlighted by the current glow layer
  128048. */
  128049. hasMesh(mesh: AbstractMesh): boolean;
  128050. /**
  128051. * Defines whether the current material of the mesh should be use to render the effect.
  128052. * @param mesh defines the current mesh to render
  128053. */
  128054. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  128055. /**
  128056. * Add a mesh to be rendered through its own material and not with emissive only.
  128057. * @param mesh The mesh for which we need to use its material
  128058. */
  128059. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  128060. /**
  128061. * Remove a mesh from being rendered through its own material and not with emissive only.
  128062. * @param mesh The mesh for which we need to not use its material
  128063. */
  128064. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  128065. /**
  128066. * Free any resources and references associated to a mesh.
  128067. * Internal use
  128068. * @param mesh The mesh to free.
  128069. * @hidden
  128070. */
  128071. _disposeMesh(mesh: Mesh): void;
  128072. /**
  128073. * Gets the class name of the effect layer
  128074. * @returns the string with the class name of the effect layer
  128075. */
  128076. getClassName(): string;
  128077. /**
  128078. * Serializes this glow layer
  128079. * @returns a serialized glow layer object
  128080. */
  128081. serialize(): any;
  128082. /**
  128083. * Creates a Glow Layer from parsed glow layer data
  128084. * @param parsedGlowLayer defines glow layer data
  128085. * @param scene defines the current scene
  128086. * @param rootUrl defines the root URL containing the glow layer information
  128087. * @returns a parsed Glow Layer
  128088. */
  128089. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  128090. }
  128091. }
  128092. declare module BABYLON {
  128093. /** @hidden */
  128094. export var glowBlurPostProcessPixelShader: {
  128095. name: string;
  128096. shader: string;
  128097. };
  128098. }
  128099. declare module BABYLON {
  128100. interface AbstractScene {
  128101. /**
  128102. * Return a the first highlight layer of the scene with a given name.
  128103. * @param name The name of the highlight layer to look for.
  128104. * @return The highlight layer if found otherwise null.
  128105. */
  128106. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  128107. }
  128108. /**
  128109. * Highlight layer options. This helps customizing the behaviour
  128110. * of the highlight layer.
  128111. */
  128112. export interface IHighlightLayerOptions {
  128113. /**
  128114. * Multiplication factor apply to the canvas size to compute the render target size
  128115. * used to generated the glowing objects (the smaller the faster).
  128116. */
  128117. mainTextureRatio: number;
  128118. /**
  128119. * Enforces a fixed size texture to ensure resize independant blur.
  128120. */
  128121. mainTextureFixedSize?: number;
  128122. /**
  128123. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  128124. * of the picture to blur (the smaller the faster).
  128125. */
  128126. blurTextureSizeRatio: number;
  128127. /**
  128128. * How big in texel of the blur texture is the vertical blur.
  128129. */
  128130. blurVerticalSize: number;
  128131. /**
  128132. * How big in texel of the blur texture is the horizontal blur.
  128133. */
  128134. blurHorizontalSize: number;
  128135. /**
  128136. * Alpha blending mode used to apply the blur. Default is combine.
  128137. */
  128138. alphaBlendingMode: number;
  128139. /**
  128140. * The camera attached to the layer.
  128141. */
  128142. camera: Nullable<Camera>;
  128143. /**
  128144. * Should we display highlight as a solid stroke?
  128145. */
  128146. isStroke?: boolean;
  128147. /**
  128148. * The rendering group to draw the layer in.
  128149. */
  128150. renderingGroupId: number;
  128151. }
  128152. /**
  128153. * The highlight layer Helps adding a glow effect around a mesh.
  128154. *
  128155. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  128156. * glowy meshes to your scene.
  128157. *
  128158. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  128159. */
  128160. export class HighlightLayer extends EffectLayer {
  128161. name: string;
  128162. /**
  128163. * Effect Name of the highlight layer.
  128164. */
  128165. static readonly EffectName: string;
  128166. /**
  128167. * The neutral color used during the preparation of the glow effect.
  128168. * This is black by default as the blend operation is a blend operation.
  128169. */
  128170. static NeutralColor: Color4;
  128171. /**
  128172. * Stencil value used for glowing meshes.
  128173. */
  128174. static GlowingMeshStencilReference: number;
  128175. /**
  128176. * Stencil value used for the other meshes in the scene.
  128177. */
  128178. static NormalMeshStencilReference: number;
  128179. /**
  128180. * Specifies whether or not the inner glow is ACTIVE in the layer.
  128181. */
  128182. innerGlow: boolean;
  128183. /**
  128184. * Specifies whether or not the outer glow is ACTIVE in the layer.
  128185. */
  128186. outerGlow: boolean;
  128187. /**
  128188. * Specifies the horizontal size of the blur.
  128189. */
  128190. set blurHorizontalSize(value: number);
  128191. /**
  128192. * Specifies the vertical size of the blur.
  128193. */
  128194. set blurVerticalSize(value: number);
  128195. /**
  128196. * Gets the horizontal size of the blur.
  128197. */
  128198. get blurHorizontalSize(): number;
  128199. /**
  128200. * Gets the vertical size of the blur.
  128201. */
  128202. get blurVerticalSize(): number;
  128203. /**
  128204. * An event triggered when the highlight layer is being blurred.
  128205. */
  128206. onBeforeBlurObservable: Observable<HighlightLayer>;
  128207. /**
  128208. * An event triggered when the highlight layer has been blurred.
  128209. */
  128210. onAfterBlurObservable: Observable<HighlightLayer>;
  128211. private _instanceGlowingMeshStencilReference;
  128212. private _options;
  128213. private _downSamplePostprocess;
  128214. private _horizontalBlurPostprocess;
  128215. private _verticalBlurPostprocess;
  128216. private _blurTexture;
  128217. private _meshes;
  128218. private _excludedMeshes;
  128219. /**
  128220. * Instantiates a new highlight Layer and references it to the scene..
  128221. * @param name The name of the layer
  128222. * @param scene The scene to use the layer in
  128223. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  128224. */
  128225. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  128226. /**
  128227. * Get the effect name of the layer.
  128228. * @return The effect name
  128229. */
  128230. getEffectName(): string;
  128231. /**
  128232. * Create the merge effect. This is the shader use to blit the information back
  128233. * to the main canvas at the end of the scene rendering.
  128234. */
  128235. protected _createMergeEffect(): Effect;
  128236. /**
  128237. * Creates the render target textures and post processes used in the highlight layer.
  128238. */
  128239. protected _createTextureAndPostProcesses(): void;
  128240. /**
  128241. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  128242. */
  128243. needStencil(): boolean;
  128244. /**
  128245. * Checks for the readiness of the element composing the layer.
  128246. * @param subMesh the mesh to check for
  128247. * @param useInstances specify wether or not to use instances to render the mesh
  128248. * @param emissiveTexture the associated emissive texture used to generate the glow
  128249. * @return true if ready otherwise, false
  128250. */
  128251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128252. /**
  128253. * Implementation specific of rendering the generating effect on the main canvas.
  128254. * @param effect The effect used to render through
  128255. */
  128256. protected _internalRender(effect: Effect): void;
  128257. /**
  128258. * Returns true if the layer contains information to display, otherwise false.
  128259. */
  128260. shouldRender(): boolean;
  128261. /**
  128262. * Returns true if the mesh should render, otherwise false.
  128263. * @param mesh The mesh to render
  128264. * @returns true if it should render otherwise false
  128265. */
  128266. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128267. /**
  128268. * Adds specific effects defines.
  128269. * @param defines The defines to add specifics to.
  128270. */
  128271. protected _addCustomEffectDefines(defines: string[]): void;
  128272. /**
  128273. * Sets the required values for both the emissive texture and and the main color.
  128274. */
  128275. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128276. /**
  128277. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  128278. * @param mesh The mesh to exclude from the highlight layer
  128279. */
  128280. addExcludedMesh(mesh: Mesh): void;
  128281. /**
  128282. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  128283. * @param mesh The mesh to highlight
  128284. */
  128285. removeExcludedMesh(mesh: Mesh): void;
  128286. /**
  128287. * Determine if a given mesh will be highlighted by the current HighlightLayer
  128288. * @param mesh mesh to test
  128289. * @returns true if the mesh will be highlighted by the current HighlightLayer
  128290. */
  128291. hasMesh(mesh: AbstractMesh): boolean;
  128292. /**
  128293. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  128294. * @param mesh The mesh to highlight
  128295. * @param color The color of the highlight
  128296. * @param glowEmissiveOnly Extract the glow from the emissive texture
  128297. */
  128298. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  128299. /**
  128300. * Remove a mesh from the highlight layer in order to make it stop glowing.
  128301. * @param mesh The mesh to highlight
  128302. */
  128303. removeMesh(mesh: Mesh): void;
  128304. /**
  128305. * Remove all the meshes currently referenced in the highlight layer
  128306. */
  128307. removeAllMeshes(): void;
  128308. /**
  128309. * Force the stencil to the normal expected value for none glowing parts
  128310. */
  128311. private _defaultStencilReference;
  128312. /**
  128313. * Free any resources and references associated to a mesh.
  128314. * Internal use
  128315. * @param mesh The mesh to free.
  128316. * @hidden
  128317. */
  128318. _disposeMesh(mesh: Mesh): void;
  128319. /**
  128320. * Dispose the highlight layer and free resources.
  128321. */
  128322. dispose(): void;
  128323. /**
  128324. * Gets the class name of the effect layer
  128325. * @returns the string with the class name of the effect layer
  128326. */
  128327. getClassName(): string;
  128328. /**
  128329. * Serializes this Highlight layer
  128330. * @returns a serialized Highlight layer object
  128331. */
  128332. serialize(): any;
  128333. /**
  128334. * Creates a Highlight layer from parsed Highlight layer data
  128335. * @param parsedHightlightLayer defines the Highlight layer data
  128336. * @param scene defines the current scene
  128337. * @param rootUrl defines the root URL containing the Highlight layer information
  128338. * @returns a parsed Highlight layer
  128339. */
  128340. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  128341. }
  128342. }
  128343. declare module BABYLON {
  128344. interface AbstractScene {
  128345. /**
  128346. * The list of layers (background and foreground) of the scene
  128347. */
  128348. layers: Array<Layer>;
  128349. }
  128350. /**
  128351. * Defines the layer scene component responsible to manage any layers
  128352. * in a given scene.
  128353. */
  128354. export class LayerSceneComponent implements ISceneComponent {
  128355. /**
  128356. * The component name helpfull to identify the component in the list of scene components.
  128357. */
  128358. readonly name: string;
  128359. /**
  128360. * The scene the component belongs to.
  128361. */
  128362. scene: Scene;
  128363. private _engine;
  128364. /**
  128365. * Creates a new instance of the component for the given scene
  128366. * @param scene Defines the scene to register the component in
  128367. */
  128368. constructor(scene: Scene);
  128369. /**
  128370. * Registers the component in a given scene
  128371. */
  128372. register(): void;
  128373. /**
  128374. * Rebuilds the elements related to this component in case of
  128375. * context lost for instance.
  128376. */
  128377. rebuild(): void;
  128378. /**
  128379. * Disposes the component and the associated ressources.
  128380. */
  128381. dispose(): void;
  128382. private _draw;
  128383. private _drawCameraPredicate;
  128384. private _drawCameraBackground;
  128385. private _drawCameraForeground;
  128386. private _drawRenderTargetPredicate;
  128387. private _drawRenderTargetBackground;
  128388. private _drawRenderTargetForeground;
  128389. /**
  128390. * Adds all the elements from the container to the scene
  128391. * @param container the container holding the elements
  128392. */
  128393. addFromContainer(container: AbstractScene): void;
  128394. /**
  128395. * Removes all the elements in the container from the scene
  128396. * @param container contains the elements to remove
  128397. * @param dispose if the removed element should be disposed (default: false)
  128398. */
  128399. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128400. }
  128401. }
  128402. declare module BABYLON {
  128403. /** @hidden */
  128404. export var layerPixelShader: {
  128405. name: string;
  128406. shader: string;
  128407. };
  128408. }
  128409. declare module BABYLON {
  128410. /** @hidden */
  128411. export var layerVertexShader: {
  128412. name: string;
  128413. shader: string;
  128414. };
  128415. }
  128416. declare module BABYLON {
  128417. /**
  128418. * This represents a full screen 2d layer.
  128419. * This can be useful to display a picture in the background of your scene for instance.
  128420. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128421. */
  128422. export class Layer {
  128423. /**
  128424. * Define the name of the layer.
  128425. */
  128426. name: string;
  128427. /**
  128428. * Define the texture the layer should display.
  128429. */
  128430. texture: Nullable<Texture>;
  128431. /**
  128432. * Is the layer in background or foreground.
  128433. */
  128434. isBackground: boolean;
  128435. /**
  128436. * Define the color of the layer (instead of texture).
  128437. */
  128438. color: Color4;
  128439. /**
  128440. * Define the scale of the layer in order to zoom in out of the texture.
  128441. */
  128442. scale: Vector2;
  128443. /**
  128444. * Define an offset for the layer in order to shift the texture.
  128445. */
  128446. offset: Vector2;
  128447. /**
  128448. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  128449. */
  128450. alphaBlendingMode: number;
  128451. /**
  128452. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  128453. * Alpha test will not mix with the background color in case of transparency.
  128454. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  128455. */
  128456. alphaTest: boolean;
  128457. /**
  128458. * Define a mask to restrict the layer to only some of the scene cameras.
  128459. */
  128460. layerMask: number;
  128461. /**
  128462. * Define the list of render target the layer is visible into.
  128463. */
  128464. renderTargetTextures: RenderTargetTexture[];
  128465. /**
  128466. * Define if the layer is only used in renderTarget or if it also
  128467. * renders in the main frame buffer of the canvas.
  128468. */
  128469. renderOnlyInRenderTargetTextures: boolean;
  128470. private _scene;
  128471. private _vertexBuffers;
  128472. private _indexBuffer;
  128473. private _effect;
  128474. private _previousDefines;
  128475. /**
  128476. * An event triggered when the layer is disposed.
  128477. */
  128478. onDisposeObservable: Observable<Layer>;
  128479. private _onDisposeObserver;
  128480. /**
  128481. * Back compatibility with callback before the onDisposeObservable existed.
  128482. * The set callback will be triggered when the layer has been disposed.
  128483. */
  128484. set onDispose(callback: () => void);
  128485. /**
  128486. * An event triggered before rendering the scene
  128487. */
  128488. onBeforeRenderObservable: Observable<Layer>;
  128489. private _onBeforeRenderObserver;
  128490. /**
  128491. * Back compatibility with callback before the onBeforeRenderObservable existed.
  128492. * The set callback will be triggered just before rendering the layer.
  128493. */
  128494. set onBeforeRender(callback: () => void);
  128495. /**
  128496. * An event triggered after rendering the scene
  128497. */
  128498. onAfterRenderObservable: Observable<Layer>;
  128499. private _onAfterRenderObserver;
  128500. /**
  128501. * Back compatibility with callback before the onAfterRenderObservable existed.
  128502. * The set callback will be triggered just after rendering the layer.
  128503. */
  128504. set onAfterRender(callback: () => void);
  128505. /**
  128506. * Instantiates a new layer.
  128507. * This represents a full screen 2d layer.
  128508. * This can be useful to display a picture in the background of your scene for instance.
  128509. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128510. * @param name Define the name of the layer in the scene
  128511. * @param imgUrl Define the url of the texture to display in the layer
  128512. * @param scene Define the scene the layer belongs to
  128513. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  128514. * @param color Defines a color for the layer
  128515. */
  128516. constructor(
  128517. /**
  128518. * Define the name of the layer.
  128519. */
  128520. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  128521. private _createIndexBuffer;
  128522. /** @hidden */
  128523. _rebuild(): void;
  128524. /**
  128525. * Renders the layer in the scene.
  128526. */
  128527. render(): void;
  128528. /**
  128529. * Disposes and releases the associated ressources.
  128530. */
  128531. dispose(): void;
  128532. }
  128533. }
  128534. declare module BABYLON {
  128535. /** @hidden */
  128536. export var lensFlarePixelShader: {
  128537. name: string;
  128538. shader: string;
  128539. };
  128540. }
  128541. declare module BABYLON {
  128542. /** @hidden */
  128543. export var lensFlareVertexShader: {
  128544. name: string;
  128545. shader: string;
  128546. };
  128547. }
  128548. declare module BABYLON {
  128549. /**
  128550. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128551. * It is usually composed of several `lensFlare`.
  128552. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128553. */
  128554. export class LensFlareSystem {
  128555. /**
  128556. * Define the name of the lens flare system
  128557. */
  128558. name: string;
  128559. /**
  128560. * List of lens flares used in this system.
  128561. */
  128562. lensFlares: LensFlare[];
  128563. /**
  128564. * Define a limit from the border the lens flare can be visible.
  128565. */
  128566. borderLimit: number;
  128567. /**
  128568. * Define a viewport border we do not want to see the lens flare in.
  128569. */
  128570. viewportBorder: number;
  128571. /**
  128572. * Define a predicate which could limit the list of meshes able to occlude the effect.
  128573. */
  128574. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128575. /**
  128576. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  128577. */
  128578. layerMask: number;
  128579. /**
  128580. * Define the id of the lens flare system in the scene.
  128581. * (equal to name by default)
  128582. */
  128583. id: string;
  128584. private _scene;
  128585. private _emitter;
  128586. private _vertexBuffers;
  128587. private _indexBuffer;
  128588. private _effect;
  128589. private _positionX;
  128590. private _positionY;
  128591. private _isEnabled;
  128592. /** @hidden */
  128593. static _SceneComponentInitialization: (scene: Scene) => void;
  128594. /**
  128595. * Instantiates a lens flare system.
  128596. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128597. * It is usually composed of several `lensFlare`.
  128598. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128599. * @param name Define the name of the lens flare system in the scene
  128600. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  128601. * @param scene Define the scene the lens flare system belongs to
  128602. */
  128603. constructor(
  128604. /**
  128605. * Define the name of the lens flare system
  128606. */
  128607. name: string, emitter: any, scene: Scene);
  128608. /**
  128609. * Define if the lens flare system is enabled.
  128610. */
  128611. get isEnabled(): boolean;
  128612. set isEnabled(value: boolean);
  128613. /**
  128614. * Get the scene the effects belongs to.
  128615. * @returns the scene holding the lens flare system
  128616. */
  128617. getScene(): Scene;
  128618. /**
  128619. * Get the emitter of the lens flare system.
  128620. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128621. * @returns the emitter of the lens flare system
  128622. */
  128623. getEmitter(): any;
  128624. /**
  128625. * Set the emitter of the lens flare system.
  128626. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128627. * @param newEmitter Define the new emitter of the system
  128628. */
  128629. setEmitter(newEmitter: any): void;
  128630. /**
  128631. * Get the lens flare system emitter position.
  128632. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  128633. * @returns the position
  128634. */
  128635. getEmitterPosition(): Vector3;
  128636. /**
  128637. * @hidden
  128638. */
  128639. computeEffectivePosition(globalViewport: Viewport): boolean;
  128640. /** @hidden */
  128641. _isVisible(): boolean;
  128642. /**
  128643. * @hidden
  128644. */
  128645. render(): boolean;
  128646. /**
  128647. * Dispose and release the lens flare with its associated resources.
  128648. */
  128649. dispose(): void;
  128650. /**
  128651. * Parse a lens flare system from a JSON repressentation
  128652. * @param parsedLensFlareSystem Define the JSON to parse
  128653. * @param scene Define the scene the parsed system should be instantiated in
  128654. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  128655. * @returns the parsed system
  128656. */
  128657. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  128658. /**
  128659. * Serialize the current Lens Flare System into a JSON representation.
  128660. * @returns the serialized JSON
  128661. */
  128662. serialize(): any;
  128663. }
  128664. }
  128665. declare module BABYLON {
  128666. /**
  128667. * This represents one of the lens effect in a `lensFlareSystem`.
  128668. * It controls one of the indiviual texture used in the effect.
  128669. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128670. */
  128671. export class LensFlare {
  128672. /**
  128673. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128674. */
  128675. size: number;
  128676. /**
  128677. * 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.
  128678. */
  128679. position: number;
  128680. /**
  128681. * Define the lens color.
  128682. */
  128683. color: Color3;
  128684. /**
  128685. * Define the lens texture.
  128686. */
  128687. texture: Nullable<Texture>;
  128688. /**
  128689. * Define the alpha mode to render this particular lens.
  128690. */
  128691. alphaMode: number;
  128692. private _system;
  128693. /**
  128694. * Creates a new Lens Flare.
  128695. * This represents one of the lens effect in a `lensFlareSystem`.
  128696. * It controls one of the indiviual texture used in the effect.
  128697. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128698. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  128699. * @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.
  128700. * @param color Define the lens color
  128701. * @param imgUrl Define the lens texture url
  128702. * @param system Define the `lensFlareSystem` this flare is part of
  128703. * @returns The newly created Lens Flare
  128704. */
  128705. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  128706. /**
  128707. * Instantiates a new Lens Flare.
  128708. * This represents one of the lens effect in a `lensFlareSystem`.
  128709. * It controls one of the indiviual texture used in the effect.
  128710. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128711. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  128712. * @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.
  128713. * @param color Define the lens color
  128714. * @param imgUrl Define the lens texture url
  128715. * @param system Define the `lensFlareSystem` this flare is part of
  128716. */
  128717. constructor(
  128718. /**
  128719. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128720. */
  128721. size: number,
  128722. /**
  128723. * 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.
  128724. */
  128725. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  128726. /**
  128727. * Dispose and release the lens flare with its associated resources.
  128728. */
  128729. dispose(): void;
  128730. }
  128731. }
  128732. declare module BABYLON {
  128733. interface AbstractScene {
  128734. /**
  128735. * The list of lens flare system added to the scene
  128736. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128737. */
  128738. lensFlareSystems: Array<LensFlareSystem>;
  128739. /**
  128740. * Removes the given lens flare system from this scene.
  128741. * @param toRemove The lens flare system to remove
  128742. * @returns The index of the removed lens flare system
  128743. */
  128744. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  128745. /**
  128746. * Adds the given lens flare system to this scene
  128747. * @param newLensFlareSystem The lens flare system to add
  128748. */
  128749. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  128750. /**
  128751. * Gets a lens flare system using its name
  128752. * @param name defines the name to look for
  128753. * @returns the lens flare system or null if not found
  128754. */
  128755. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  128756. /**
  128757. * Gets a lens flare system using its id
  128758. * @param id defines the id to look for
  128759. * @returns the lens flare system or null if not found
  128760. */
  128761. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  128762. }
  128763. /**
  128764. * Defines the lens flare scene component responsible to manage any lens flares
  128765. * in a given scene.
  128766. */
  128767. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  128768. /**
  128769. * The component name helpfull to identify the component in the list of scene components.
  128770. */
  128771. readonly name: string;
  128772. /**
  128773. * The scene the component belongs to.
  128774. */
  128775. scene: Scene;
  128776. /**
  128777. * Creates a new instance of the component for the given scene
  128778. * @param scene Defines the scene to register the component in
  128779. */
  128780. constructor(scene: Scene);
  128781. /**
  128782. * Registers the component in a given scene
  128783. */
  128784. register(): void;
  128785. /**
  128786. * Rebuilds the elements related to this component in case of
  128787. * context lost for instance.
  128788. */
  128789. rebuild(): void;
  128790. /**
  128791. * Adds all the elements from the container to the scene
  128792. * @param container the container holding the elements
  128793. */
  128794. addFromContainer(container: AbstractScene): void;
  128795. /**
  128796. * Removes all the elements in the container from the scene
  128797. * @param container contains the elements to remove
  128798. * @param dispose if the removed element should be disposed (default: false)
  128799. */
  128800. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128801. /**
  128802. * Serializes the component data to the specified json object
  128803. * @param serializationObject The object to serialize to
  128804. */
  128805. serialize(serializationObject: any): void;
  128806. /**
  128807. * Disposes the component and the associated ressources.
  128808. */
  128809. dispose(): void;
  128810. private _draw;
  128811. }
  128812. }
  128813. declare module BABYLON {
  128814. /** @hidden */
  128815. export var depthPixelShader: {
  128816. name: string;
  128817. shader: string;
  128818. };
  128819. }
  128820. declare module BABYLON {
  128821. /** @hidden */
  128822. export var depthVertexShader: {
  128823. name: string;
  128824. shader: string;
  128825. };
  128826. }
  128827. declare module BABYLON {
  128828. /**
  128829. * This represents a depth renderer in Babylon.
  128830. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128831. */
  128832. export class DepthRenderer {
  128833. private _scene;
  128834. private _depthMap;
  128835. private _effect;
  128836. private readonly _storeNonLinearDepth;
  128837. private readonly _clearColor;
  128838. /** Get if the depth renderer is using packed depth or not */
  128839. readonly isPacked: boolean;
  128840. private _cachedDefines;
  128841. private _camera;
  128842. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  128843. enabled: boolean;
  128844. /**
  128845. * Specifiess that the depth renderer will only be used within
  128846. * the camera it is created for.
  128847. * This can help forcing its rendering during the camera processing.
  128848. */
  128849. useOnlyInActiveCamera: boolean;
  128850. /** @hidden */
  128851. static _SceneComponentInitialization: (scene: Scene) => void;
  128852. /**
  128853. * Instantiates a depth renderer
  128854. * @param scene The scene the renderer belongs to
  128855. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128856. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128857. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128858. */
  128859. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128860. /**
  128861. * Creates the depth rendering effect and checks if the effect is ready.
  128862. * @param subMesh The submesh to be used to render the depth map of
  128863. * @param useInstances If multiple world instances should be used
  128864. * @returns if the depth renderer is ready to render the depth map
  128865. */
  128866. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128867. /**
  128868. * Gets the texture which the depth map will be written to.
  128869. * @returns The depth map texture
  128870. */
  128871. getDepthMap(): RenderTargetTexture;
  128872. /**
  128873. * Disposes of the depth renderer.
  128874. */
  128875. dispose(): void;
  128876. }
  128877. }
  128878. declare module BABYLON {
  128879. /** @hidden */
  128880. export var minmaxReduxPixelShader: {
  128881. name: string;
  128882. shader: string;
  128883. };
  128884. }
  128885. declare module BABYLON {
  128886. /**
  128887. * This class computes a min/max reduction from a texture: it means it computes the minimum
  128888. * and maximum values from all values of the texture.
  128889. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  128890. * The source values are read from the red channel of the texture.
  128891. */
  128892. export class MinMaxReducer {
  128893. /**
  128894. * Observable triggered when the computation has been performed
  128895. */
  128896. onAfterReductionPerformed: Observable<{
  128897. min: number;
  128898. max: number;
  128899. }>;
  128900. protected _camera: Camera;
  128901. protected _sourceTexture: Nullable<RenderTargetTexture>;
  128902. protected _reductionSteps: Nullable<Array<PostProcess>>;
  128903. protected _postProcessManager: PostProcessManager;
  128904. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  128905. protected _forceFullscreenViewport: boolean;
  128906. /**
  128907. * Creates a min/max reducer
  128908. * @param camera The camera to use for the post processes
  128909. */
  128910. constructor(camera: Camera);
  128911. /**
  128912. * Gets the texture used to read the values from.
  128913. */
  128914. get sourceTexture(): Nullable<RenderTargetTexture>;
  128915. /**
  128916. * Sets the source texture to read the values from.
  128917. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  128918. * because in such textures '1' value must not be taken into account to compute the maximum
  128919. * as this value is used to clear the texture.
  128920. * Note that the computation is not activated by calling this function, you must call activate() for that!
  128921. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  128922. * @param depthRedux Indicates if the texture is a depth texture or not
  128923. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  128924. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128925. */
  128926. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128927. /**
  128928. * Defines the refresh rate of the computation.
  128929. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128930. */
  128931. get refreshRate(): number;
  128932. set refreshRate(value: number);
  128933. protected _activated: boolean;
  128934. /**
  128935. * Gets the activation status of the reducer
  128936. */
  128937. get activated(): boolean;
  128938. /**
  128939. * Activates the reduction computation.
  128940. * When activated, the observers registered in onAfterReductionPerformed are
  128941. * called after the compuation is performed
  128942. */
  128943. activate(): void;
  128944. /**
  128945. * Deactivates the reduction computation.
  128946. */
  128947. deactivate(): void;
  128948. /**
  128949. * Disposes the min/max reducer
  128950. * @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.
  128951. */
  128952. dispose(disposeAll?: boolean): void;
  128953. }
  128954. }
  128955. declare module BABYLON {
  128956. /**
  128957. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  128958. */
  128959. export class DepthReducer extends MinMaxReducer {
  128960. private _depthRenderer;
  128961. private _depthRendererId;
  128962. /**
  128963. * Gets the depth renderer used for the computation.
  128964. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  128965. */
  128966. get depthRenderer(): Nullable<DepthRenderer>;
  128967. /**
  128968. * Creates a depth reducer
  128969. * @param camera The camera used to render the depth texture
  128970. */
  128971. constructor(camera: Camera);
  128972. /**
  128973. * Sets the depth renderer to use to generate the depth map
  128974. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  128975. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  128976. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128977. */
  128978. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  128979. /** @hidden */
  128980. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128981. /**
  128982. * Activates the reduction computation.
  128983. * When activated, the observers registered in onAfterReductionPerformed are
  128984. * called after the compuation is performed
  128985. */
  128986. activate(): void;
  128987. /**
  128988. * Deactivates the reduction computation.
  128989. */
  128990. deactivate(): void;
  128991. /**
  128992. * Disposes the depth reducer
  128993. * @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.
  128994. */
  128995. dispose(disposeAll?: boolean): void;
  128996. }
  128997. }
  128998. declare module BABYLON {
  128999. /**
  129000. * A CSM implementation allowing casting shadows on large scenes.
  129001. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129002. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  129003. */
  129004. export class CascadedShadowGenerator extends ShadowGenerator {
  129005. private static readonly frustumCornersNDCSpace;
  129006. /**
  129007. * Name of the CSM class
  129008. */
  129009. static CLASSNAME: string;
  129010. /**
  129011. * Defines the default number of cascades used by the CSM.
  129012. */
  129013. static readonly DEFAULT_CASCADES_COUNT: number;
  129014. /**
  129015. * Defines the minimum number of cascades used by the CSM.
  129016. */
  129017. static readonly MIN_CASCADES_COUNT: number;
  129018. /**
  129019. * Defines the maximum number of cascades used by the CSM.
  129020. */
  129021. static readonly MAX_CASCADES_COUNT: number;
  129022. protected _validateFilter(filter: number): number;
  129023. /**
  129024. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  129025. */
  129026. penumbraDarkness: number;
  129027. private _numCascades;
  129028. /**
  129029. * Gets or set the number of cascades used by the CSM.
  129030. */
  129031. get numCascades(): number;
  129032. set numCascades(value: number);
  129033. /**
  129034. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  129035. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  129036. */
  129037. stabilizeCascades: boolean;
  129038. private _freezeShadowCastersBoundingInfo;
  129039. private _freezeShadowCastersBoundingInfoObservable;
  129040. /**
  129041. * Enables or disables the shadow casters bounding info computation.
  129042. * If your shadow casters don't move, you can disable this feature.
  129043. * If it is enabled, the bounding box computation is done every frame.
  129044. */
  129045. get freezeShadowCastersBoundingInfo(): boolean;
  129046. set freezeShadowCastersBoundingInfo(freeze: boolean);
  129047. private _scbiMin;
  129048. private _scbiMax;
  129049. protected _computeShadowCastersBoundingInfo(): void;
  129050. protected _shadowCastersBoundingInfo: BoundingInfo;
  129051. /**
  129052. * Gets or sets the shadow casters bounding info.
  129053. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  129054. * so that the system won't overwrite the bounds you provide
  129055. */
  129056. get shadowCastersBoundingInfo(): BoundingInfo;
  129057. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  129058. protected _breaksAreDirty: boolean;
  129059. protected _minDistance: number;
  129060. protected _maxDistance: number;
  129061. /**
  129062. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  129063. *
  129064. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  129065. * If you don't know these values, simply leave them to their defaults and don't call this function.
  129066. * @param min minimal distance for the breaks (default to 0.)
  129067. * @param max maximal distance for the breaks (default to 1.)
  129068. */
  129069. setMinMaxDistance(min: number, max: number): void;
  129070. /** Gets the minimal distance used in the cascade break computation */
  129071. get minDistance(): number;
  129072. /** Gets the maximal distance used in the cascade break computation */
  129073. get maxDistance(): number;
  129074. /**
  129075. * Gets the class name of that object
  129076. * @returns "CascadedShadowGenerator"
  129077. */
  129078. getClassName(): string;
  129079. private _cascadeMinExtents;
  129080. private _cascadeMaxExtents;
  129081. /**
  129082. * Gets a cascade minimum extents
  129083. * @param cascadeIndex index of the cascade
  129084. * @returns the minimum cascade extents
  129085. */
  129086. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  129087. /**
  129088. * Gets a cascade maximum extents
  129089. * @param cascadeIndex index of the cascade
  129090. * @returns the maximum cascade extents
  129091. */
  129092. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  129093. private _cascades;
  129094. private _currentLayer;
  129095. private _viewSpaceFrustumsZ;
  129096. private _viewMatrices;
  129097. private _projectionMatrices;
  129098. private _transformMatrices;
  129099. private _transformMatricesAsArray;
  129100. private _frustumLengths;
  129101. private _lightSizeUVCorrection;
  129102. private _depthCorrection;
  129103. private _frustumCornersWorldSpace;
  129104. private _frustumCenter;
  129105. private _shadowCameraPos;
  129106. private _shadowMaxZ;
  129107. /**
  129108. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  129109. * It defaults to camera.maxZ
  129110. */
  129111. get shadowMaxZ(): number;
  129112. /**
  129113. * Sets the shadow max z distance.
  129114. */
  129115. set shadowMaxZ(value: number);
  129116. protected _debug: boolean;
  129117. /**
  129118. * Gets or sets the debug flag.
  129119. * When enabled, the cascades are materialized by different colors on the screen.
  129120. */
  129121. get debug(): boolean;
  129122. set debug(dbg: boolean);
  129123. private _depthClamp;
  129124. /**
  129125. * Gets or sets the depth clamping value.
  129126. *
  129127. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  129128. * to account for the shadow casters far away.
  129129. *
  129130. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  129131. */
  129132. get depthClamp(): boolean;
  129133. set depthClamp(value: boolean);
  129134. private _cascadeBlendPercentage;
  129135. /**
  129136. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  129137. * It defaults to 0.1 (10% blending).
  129138. */
  129139. get cascadeBlendPercentage(): number;
  129140. set cascadeBlendPercentage(value: number);
  129141. private _lambda;
  129142. /**
  129143. * Gets or set the lambda parameter.
  129144. * This parameter is used to split the camera frustum and create the cascades.
  129145. * 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.
  129146. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  129147. */
  129148. get lambda(): number;
  129149. set lambda(value: number);
  129150. /**
  129151. * Gets the view matrix corresponding to a given cascade
  129152. * @param cascadeNum cascade to retrieve the view matrix from
  129153. * @returns the cascade view matrix
  129154. */
  129155. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  129156. /**
  129157. * Gets the projection matrix corresponding to a given cascade
  129158. * @param cascadeNum cascade to retrieve the projection matrix from
  129159. * @returns the cascade projection matrix
  129160. */
  129161. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  129162. /**
  129163. * Gets the transformation matrix corresponding to a given cascade
  129164. * @param cascadeNum cascade to retrieve the transformation matrix from
  129165. * @returns the cascade transformation matrix
  129166. */
  129167. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  129168. private _depthRenderer;
  129169. /**
  129170. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  129171. *
  129172. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  129173. *
  129174. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  129175. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  129176. * @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
  129177. */
  129178. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  129179. private _depthReducer;
  129180. private _autoCalcDepthBounds;
  129181. /**
  129182. * Gets or sets the autoCalcDepthBounds property.
  129183. *
  129184. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  129185. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  129186. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  129187. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  129188. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  129189. */
  129190. get autoCalcDepthBounds(): boolean;
  129191. set autoCalcDepthBounds(value: boolean);
  129192. /**
  129193. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  129194. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  129195. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  129196. * for setting the refresh rate on the renderer yourself!
  129197. */
  129198. get autoCalcDepthBoundsRefreshRate(): number;
  129199. set autoCalcDepthBoundsRefreshRate(value: number);
  129200. /**
  129201. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  129202. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  129203. * you change the camera near/far planes!
  129204. */
  129205. splitFrustum(): void;
  129206. private _splitFrustum;
  129207. private _computeMatrices;
  129208. private _computeFrustumInWorldSpace;
  129209. private _computeCascadeFrustum;
  129210. /**
  129211. * Support test.
  129212. */
  129213. static get IsSupported(): boolean;
  129214. /** @hidden */
  129215. static _SceneComponentInitialization: (scene: Scene) => void;
  129216. /**
  129217. * Creates a Cascaded Shadow Generator object.
  129218. * A ShadowGenerator is the required tool to use the shadows.
  129219. * Each directional light casting shadows needs to use its own ShadowGenerator.
  129220. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129221. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  129222. * @param light The directional light object generating the shadows.
  129223. * @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.
  129224. */
  129225. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  129226. protected _initializeGenerator(): void;
  129227. protected _createTargetRenderTexture(): void;
  129228. protected _initializeShadowMap(): void;
  129229. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  129230. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  129231. /**
  129232. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  129233. * @param defines Defines of the material we want to update
  129234. * @param lightIndex Index of the light in the enabled light list of the material
  129235. */
  129236. prepareDefines(defines: any, lightIndex: number): void;
  129237. /**
  129238. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  129239. * defined in the generator but impacting the effect).
  129240. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  129241. * @param effect The effect we are binfing the information for
  129242. */
  129243. bindShadowLight(lightIndex: string, effect: Effect): void;
  129244. /**
  129245. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  129246. * (eq to view projection * shadow projection matrices)
  129247. * @returns The transform matrix used to create the shadow map
  129248. */
  129249. getTransformMatrix(): Matrix;
  129250. /**
  129251. * Disposes the ShadowGenerator.
  129252. * Returns nothing.
  129253. */
  129254. dispose(): void;
  129255. /**
  129256. * Serializes the shadow generator setup to a json object.
  129257. * @returns The serialized JSON object
  129258. */
  129259. serialize(): any;
  129260. /**
  129261. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  129262. * @param parsedShadowGenerator The JSON object to parse
  129263. * @param scene The scene to create the shadow map for
  129264. * @returns The parsed shadow generator
  129265. */
  129266. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  129267. }
  129268. }
  129269. declare module BABYLON {
  129270. /**
  129271. * Defines the shadow generator component responsible to manage any shadow generators
  129272. * in a given scene.
  129273. */
  129274. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  129275. /**
  129276. * The component name helpfull to identify the component in the list of scene components.
  129277. */
  129278. readonly name: string;
  129279. /**
  129280. * The scene the component belongs to.
  129281. */
  129282. scene: Scene;
  129283. /**
  129284. * Creates a new instance of the component for the given scene
  129285. * @param scene Defines the scene to register the component in
  129286. */
  129287. constructor(scene: Scene);
  129288. /**
  129289. * Registers the component in a given scene
  129290. */
  129291. register(): void;
  129292. /**
  129293. * Rebuilds the elements related to this component in case of
  129294. * context lost for instance.
  129295. */
  129296. rebuild(): void;
  129297. /**
  129298. * Serializes the component data to the specified json object
  129299. * @param serializationObject The object to serialize to
  129300. */
  129301. serialize(serializationObject: any): void;
  129302. /**
  129303. * Adds all the elements from the container to the scene
  129304. * @param container the container holding the elements
  129305. */
  129306. addFromContainer(container: AbstractScene): void;
  129307. /**
  129308. * Removes all the elements in the container from the scene
  129309. * @param container contains the elements to remove
  129310. * @param dispose if the removed element should be disposed (default: false)
  129311. */
  129312. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129313. /**
  129314. * Rebuilds the elements related to this component in case of
  129315. * context lost for instance.
  129316. */
  129317. dispose(): void;
  129318. private _gatherRenderTargets;
  129319. }
  129320. }
  129321. declare module BABYLON {
  129322. /**
  129323. * A point light is a light defined by an unique point in world space.
  129324. * The light is emitted in every direction from this point.
  129325. * A good example of a point light is a standard light bulb.
  129326. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129327. */
  129328. export class PointLight extends ShadowLight {
  129329. private _shadowAngle;
  129330. /**
  129331. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129332. * This specifies what angle the shadow will use to be created.
  129333. *
  129334. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129335. */
  129336. get shadowAngle(): number;
  129337. /**
  129338. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129339. * This specifies what angle the shadow will use to be created.
  129340. *
  129341. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129342. */
  129343. set shadowAngle(value: number);
  129344. /**
  129345. * Gets the direction if it has been set.
  129346. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129347. */
  129348. get direction(): Vector3;
  129349. /**
  129350. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129351. */
  129352. set direction(value: Vector3);
  129353. /**
  129354. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  129355. * A PointLight emits the light in every direction.
  129356. * It can cast shadows.
  129357. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  129358. * ```javascript
  129359. * var pointLight = new PointLight("pl", camera.position, scene);
  129360. * ```
  129361. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129362. * @param name The light friendly name
  129363. * @param position The position of the point light in the scene
  129364. * @param scene The scene the lights belongs to
  129365. */
  129366. constructor(name: string, position: Vector3, scene: Scene);
  129367. /**
  129368. * Returns the string "PointLight"
  129369. * @returns the class name
  129370. */
  129371. getClassName(): string;
  129372. /**
  129373. * Returns the integer 0.
  129374. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129375. */
  129376. getTypeID(): number;
  129377. /**
  129378. * Specifies wether or not the shadowmap should be a cube texture.
  129379. * @returns true if the shadowmap needs to be a cube texture.
  129380. */
  129381. needCube(): boolean;
  129382. /**
  129383. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  129384. * @param faceIndex The index of the face we are computed the direction to generate shadow
  129385. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  129386. */
  129387. getShadowDirection(faceIndex?: number): Vector3;
  129388. /**
  129389. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  129390. * - fov = PI / 2
  129391. * - aspect ratio : 1.0
  129392. * - z-near and far equal to the active camera minZ and maxZ.
  129393. * Returns the PointLight.
  129394. */
  129395. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129396. protected _buildUniformLayout(): void;
  129397. /**
  129398. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  129399. * @param effect The effect to update
  129400. * @param lightIndex The index of the light in the effect to update
  129401. * @returns The point light
  129402. */
  129403. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  129404. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129405. /**
  129406. * Prepares the list of defines specific to the light type.
  129407. * @param defines the list of defines
  129408. * @param lightIndex defines the index of the light for the effect
  129409. */
  129410. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129411. }
  129412. }
  129413. declare module BABYLON {
  129414. /**
  129415. * Header information of HDR texture files.
  129416. */
  129417. export interface HDRInfo {
  129418. /**
  129419. * The height of the texture in pixels.
  129420. */
  129421. height: number;
  129422. /**
  129423. * The width of the texture in pixels.
  129424. */
  129425. width: number;
  129426. /**
  129427. * The index of the beginning of the data in the binary file.
  129428. */
  129429. dataPosition: number;
  129430. }
  129431. /**
  129432. * This groups tools to convert HDR texture to native colors array.
  129433. */
  129434. export class HDRTools {
  129435. private static Ldexp;
  129436. private static Rgbe2float;
  129437. private static readStringLine;
  129438. /**
  129439. * Reads header information from an RGBE texture stored in a native array.
  129440. * More information on this format are available here:
  129441. * https://en.wikipedia.org/wiki/RGBE_image_format
  129442. *
  129443. * @param uint8array The binary file stored in native array.
  129444. * @return The header information.
  129445. */
  129446. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  129447. /**
  129448. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  129449. * This RGBE texture needs to store the information as a panorama.
  129450. *
  129451. * More information on this format are available here:
  129452. * https://en.wikipedia.org/wiki/RGBE_image_format
  129453. *
  129454. * @param buffer The binary file stored in an array buffer.
  129455. * @param size The expected size of the extracted cubemap.
  129456. * @return The Cube Map information.
  129457. */
  129458. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  129459. /**
  129460. * Returns the pixels data extracted from an RGBE texture.
  129461. * This pixels will be stored left to right up to down in the R G B order in one array.
  129462. *
  129463. * More information on this format are available here:
  129464. * https://en.wikipedia.org/wiki/RGBE_image_format
  129465. *
  129466. * @param uint8array The binary file stored in an array buffer.
  129467. * @param hdrInfo The header information of the file.
  129468. * @return The pixels data in RGB right to left up to down order.
  129469. */
  129470. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  129471. private static RGBE_ReadPixels_RLE;
  129472. }
  129473. }
  129474. declare module BABYLON {
  129475. /**
  129476. * This represents a texture coming from an HDR input.
  129477. *
  129478. * The only supported format is currently panorama picture stored in RGBE format.
  129479. * Example of such files can be found on HDRLib: http://hdrlib.com/
  129480. */
  129481. export class HDRCubeTexture extends BaseTexture {
  129482. private static _facesMapping;
  129483. private _generateHarmonics;
  129484. private _noMipmap;
  129485. private _textureMatrix;
  129486. private _size;
  129487. private _onLoad;
  129488. private _onError;
  129489. /**
  129490. * The texture URL.
  129491. */
  129492. url: string;
  129493. /**
  129494. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  129495. */
  129496. coordinatesMode: number;
  129497. protected _isBlocking: boolean;
  129498. /**
  129499. * Sets wether or not the texture is blocking during loading.
  129500. */
  129501. set isBlocking(value: boolean);
  129502. /**
  129503. * Gets wether or not the texture is blocking during loading.
  129504. */
  129505. get isBlocking(): boolean;
  129506. protected _rotationY: number;
  129507. /**
  129508. * Sets texture matrix rotation angle around Y axis in radians.
  129509. */
  129510. set rotationY(value: number);
  129511. /**
  129512. * Gets texture matrix rotation angle around Y axis radians.
  129513. */
  129514. get rotationY(): number;
  129515. /**
  129516. * Gets or sets the center of the bounding box associated with the cube texture
  129517. * It must define where the camera used to render the texture was set
  129518. */
  129519. boundingBoxPosition: Vector3;
  129520. private _boundingBoxSize;
  129521. /**
  129522. * Gets or sets the size of the bounding box associated with the cube texture
  129523. * When defined, the cubemap will switch to local mode
  129524. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  129525. * @example https://www.babylonjs-playground.com/#RNASML
  129526. */
  129527. set boundingBoxSize(value: Vector3);
  129528. get boundingBoxSize(): Vector3;
  129529. /**
  129530. * Instantiates an HDRTexture from the following parameters.
  129531. *
  129532. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  129533. * @param scene The scene the texture will be used in
  129534. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129535. * @param noMipmap Forces to not generate the mipmap if true
  129536. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  129537. * @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)
  129538. * @param reserved Reserved flag for internal use.
  129539. */
  129540. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129541. /**
  129542. * Get the current class name of the texture useful for serialization or dynamic coding.
  129543. * @returns "HDRCubeTexture"
  129544. */
  129545. getClassName(): string;
  129546. /**
  129547. * Occurs when the file is raw .hdr file.
  129548. */
  129549. private loadTexture;
  129550. clone(): HDRCubeTexture;
  129551. delayLoad(): void;
  129552. /**
  129553. * Get the texture reflection matrix used to rotate/transform the reflection.
  129554. * @returns the reflection matrix
  129555. */
  129556. getReflectionTextureMatrix(): Matrix;
  129557. /**
  129558. * Set the texture reflection matrix used to rotate/transform the reflection.
  129559. * @param value Define the reflection matrix to set
  129560. */
  129561. setReflectionTextureMatrix(value: Matrix): void;
  129562. /**
  129563. * Parses a JSON representation of an HDR Texture in order to create the texture
  129564. * @param parsedTexture Define the JSON representation
  129565. * @param scene Define the scene the texture should be created in
  129566. * @param rootUrl Define the root url in case we need to load relative dependencies
  129567. * @returns the newly created texture after parsing
  129568. */
  129569. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  129570. serialize(): any;
  129571. }
  129572. }
  129573. declare module BABYLON {
  129574. /**
  129575. * Class used to control physics engine
  129576. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129577. */
  129578. export class PhysicsEngine implements IPhysicsEngine {
  129579. private _physicsPlugin;
  129580. /**
  129581. * Global value used to control the smallest number supported by the simulation
  129582. */
  129583. static Epsilon: number;
  129584. private _impostors;
  129585. private _joints;
  129586. private _subTimeStep;
  129587. /**
  129588. * Gets the gravity vector used by the simulation
  129589. */
  129590. gravity: Vector3;
  129591. /**
  129592. * Factory used to create the default physics plugin.
  129593. * @returns The default physics plugin
  129594. */
  129595. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  129596. /**
  129597. * Creates a new Physics Engine
  129598. * @param gravity defines the gravity vector used by the simulation
  129599. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  129600. */
  129601. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  129602. /**
  129603. * Sets the gravity vector used by the simulation
  129604. * @param gravity defines the gravity vector to use
  129605. */
  129606. setGravity(gravity: Vector3): void;
  129607. /**
  129608. * Set the time step of the physics engine.
  129609. * Default is 1/60.
  129610. * To slow it down, enter 1/600 for example.
  129611. * To speed it up, 1/30
  129612. * @param newTimeStep defines the new timestep to apply to this world.
  129613. */
  129614. setTimeStep(newTimeStep?: number): void;
  129615. /**
  129616. * Get the time step of the physics engine.
  129617. * @returns the current time step
  129618. */
  129619. getTimeStep(): number;
  129620. /**
  129621. * Set the sub time step of the physics engine.
  129622. * Default is 0 meaning there is no sub steps
  129623. * To increase physics resolution precision, set a small value (like 1 ms)
  129624. * @param subTimeStep defines the new sub timestep used for physics resolution.
  129625. */
  129626. setSubTimeStep(subTimeStep?: number): void;
  129627. /**
  129628. * Get the sub time step of the physics engine.
  129629. * @returns the current sub time step
  129630. */
  129631. getSubTimeStep(): number;
  129632. /**
  129633. * Release all resources
  129634. */
  129635. dispose(): void;
  129636. /**
  129637. * Gets the name of the current physics plugin
  129638. * @returns the name of the plugin
  129639. */
  129640. getPhysicsPluginName(): string;
  129641. /**
  129642. * Adding a new impostor for the impostor tracking.
  129643. * This will be done by the impostor itself.
  129644. * @param impostor the impostor to add
  129645. */
  129646. addImpostor(impostor: PhysicsImpostor): void;
  129647. /**
  129648. * Remove an impostor from the engine.
  129649. * This impostor and its mesh will not longer be updated by the physics engine.
  129650. * @param impostor the impostor to remove
  129651. */
  129652. removeImpostor(impostor: PhysicsImpostor): void;
  129653. /**
  129654. * Add a joint to the physics engine
  129655. * @param mainImpostor defines the main impostor to which the joint is added.
  129656. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  129657. * @param joint defines the joint that will connect both impostors.
  129658. */
  129659. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129660. /**
  129661. * Removes a joint from the simulation
  129662. * @param mainImpostor defines the impostor used with the joint
  129663. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  129664. * @param joint defines the joint to remove
  129665. */
  129666. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129667. /**
  129668. * Called by the scene. No need to call it.
  129669. * @param delta defines the timespam between frames
  129670. */
  129671. _step(delta: number): void;
  129672. /**
  129673. * Gets the current plugin used to run the simulation
  129674. * @returns current plugin
  129675. */
  129676. getPhysicsPlugin(): IPhysicsEnginePlugin;
  129677. /**
  129678. * Gets the list of physic impostors
  129679. * @returns an array of PhysicsImpostor
  129680. */
  129681. getImpostors(): Array<PhysicsImpostor>;
  129682. /**
  129683. * Gets the impostor for a physics enabled object
  129684. * @param object defines the object impersonated by the impostor
  129685. * @returns the PhysicsImpostor or null if not found
  129686. */
  129687. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  129688. /**
  129689. * Gets the impostor for a physics body object
  129690. * @param body defines physics body used by the impostor
  129691. * @returns the PhysicsImpostor or null if not found
  129692. */
  129693. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  129694. /**
  129695. * Does a raycast in the physics world
  129696. * @param from when should the ray start?
  129697. * @param to when should the ray end?
  129698. * @returns PhysicsRaycastResult
  129699. */
  129700. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129701. }
  129702. }
  129703. declare module BABYLON {
  129704. /** @hidden */
  129705. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  129706. private _useDeltaForWorldStep;
  129707. world: any;
  129708. name: string;
  129709. private _physicsMaterials;
  129710. private _fixedTimeStep;
  129711. private _cannonRaycastResult;
  129712. private _raycastResult;
  129713. private _physicsBodysToRemoveAfterStep;
  129714. BJSCANNON: any;
  129715. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  129716. setGravity(gravity: Vector3): void;
  129717. setTimeStep(timeStep: number): void;
  129718. getTimeStep(): number;
  129719. executeStep(delta: number): void;
  129720. private _removeMarkedPhysicsBodiesFromWorld;
  129721. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129722. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129723. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129724. private _processChildMeshes;
  129725. removePhysicsBody(impostor: PhysicsImpostor): void;
  129726. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129727. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129728. private _addMaterial;
  129729. private _checkWithEpsilon;
  129730. private _createShape;
  129731. private _createHeightmap;
  129732. private _minus90X;
  129733. private _plus90X;
  129734. private _tmpPosition;
  129735. private _tmpDeltaPosition;
  129736. private _tmpUnityRotation;
  129737. private _updatePhysicsBodyTransformation;
  129738. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129739. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129740. isSupported(): boolean;
  129741. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129742. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129743. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129744. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129745. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129746. getBodyMass(impostor: PhysicsImpostor): number;
  129747. getBodyFriction(impostor: PhysicsImpostor): number;
  129748. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129749. getBodyRestitution(impostor: PhysicsImpostor): number;
  129750. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129751. sleepBody(impostor: PhysicsImpostor): void;
  129752. wakeUpBody(impostor: PhysicsImpostor): void;
  129753. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  129754. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129755. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129756. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129757. getRadius(impostor: PhysicsImpostor): number;
  129758. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129759. dispose(): void;
  129760. private _extendNamespace;
  129761. /**
  129762. * Does a raycast in the physics world
  129763. * @param from when should the ray start?
  129764. * @param to when should the ray end?
  129765. * @returns PhysicsRaycastResult
  129766. */
  129767. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129768. }
  129769. }
  129770. declare module BABYLON {
  129771. /** @hidden */
  129772. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  129773. world: any;
  129774. name: string;
  129775. BJSOIMO: any;
  129776. private _raycastResult;
  129777. constructor(iterations?: number, oimoInjection?: any);
  129778. setGravity(gravity: Vector3): void;
  129779. setTimeStep(timeStep: number): void;
  129780. getTimeStep(): number;
  129781. private _tmpImpostorsArray;
  129782. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129783. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129784. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129785. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129786. private _tmpPositionVector;
  129787. removePhysicsBody(impostor: PhysicsImpostor): void;
  129788. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129789. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129790. isSupported(): boolean;
  129791. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129792. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129793. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129794. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129795. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129796. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129797. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129798. getBodyMass(impostor: PhysicsImpostor): number;
  129799. getBodyFriction(impostor: PhysicsImpostor): number;
  129800. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129801. getBodyRestitution(impostor: PhysicsImpostor): number;
  129802. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129803. sleepBody(impostor: PhysicsImpostor): void;
  129804. wakeUpBody(impostor: PhysicsImpostor): void;
  129805. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129806. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  129807. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  129808. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129809. getRadius(impostor: PhysicsImpostor): number;
  129810. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129811. dispose(): void;
  129812. /**
  129813. * Does a raycast in the physics world
  129814. * @param from when should the ray start?
  129815. * @param to when should the ray end?
  129816. * @returns PhysicsRaycastResult
  129817. */
  129818. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129819. }
  129820. }
  129821. declare module BABYLON {
  129822. /**
  129823. * Class containing static functions to help procedurally build meshes
  129824. */
  129825. export class RibbonBuilder {
  129826. /**
  129827. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129828. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129829. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129830. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129831. * * 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
  129832. * * 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
  129833. * * 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
  129834. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129835. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129836. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129837. * * 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
  129838. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129839. * * 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
  129840. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129842. * @param name defines the name of the mesh
  129843. * @param options defines the options used to create the mesh
  129844. * @param scene defines the hosting scene
  129845. * @returns the ribbon mesh
  129846. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129847. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129848. */
  129849. static CreateRibbon(name: string, options: {
  129850. pathArray: Vector3[][];
  129851. closeArray?: boolean;
  129852. closePath?: boolean;
  129853. offset?: number;
  129854. updatable?: boolean;
  129855. sideOrientation?: number;
  129856. frontUVs?: Vector4;
  129857. backUVs?: Vector4;
  129858. instance?: Mesh;
  129859. invertUV?: boolean;
  129860. uvs?: Vector2[];
  129861. colors?: Color4[];
  129862. }, scene?: Nullable<Scene>): Mesh;
  129863. }
  129864. }
  129865. declare module BABYLON {
  129866. /**
  129867. * Class containing static functions to help procedurally build meshes
  129868. */
  129869. export class ShapeBuilder {
  129870. /**
  129871. * 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.
  129872. * * 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.
  129873. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129874. * * 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.
  129875. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129876. * * 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
  129877. * * 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
  129878. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129879. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129880. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129881. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129883. * @param name defines the name of the mesh
  129884. * @param options defines the options used to create the mesh
  129885. * @param scene defines the hosting scene
  129886. * @returns the extruded shape mesh
  129887. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129889. */
  129890. static ExtrudeShape(name: string, options: {
  129891. shape: Vector3[];
  129892. path: Vector3[];
  129893. scale?: number;
  129894. rotation?: number;
  129895. cap?: number;
  129896. updatable?: boolean;
  129897. sideOrientation?: number;
  129898. frontUVs?: Vector4;
  129899. backUVs?: Vector4;
  129900. instance?: Mesh;
  129901. invertUV?: boolean;
  129902. }, scene?: Nullable<Scene>): Mesh;
  129903. /**
  129904. * Creates an custom extruded shape mesh.
  129905. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129906. * * 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.
  129907. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129908. * * 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
  129909. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129910. * * 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
  129911. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129912. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129913. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129914. * * 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
  129915. * * 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
  129916. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129918. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129919. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129921. * @param name defines the name of the mesh
  129922. * @param options defines the options used to create the mesh
  129923. * @param scene defines the hosting scene
  129924. * @returns the custom extruded shape mesh
  129925. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129926. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129927. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129928. */
  129929. static ExtrudeShapeCustom(name: string, options: {
  129930. shape: Vector3[];
  129931. path: Vector3[];
  129932. scaleFunction?: any;
  129933. rotationFunction?: any;
  129934. ribbonCloseArray?: boolean;
  129935. ribbonClosePath?: boolean;
  129936. cap?: number;
  129937. updatable?: boolean;
  129938. sideOrientation?: number;
  129939. frontUVs?: Vector4;
  129940. backUVs?: Vector4;
  129941. instance?: Mesh;
  129942. invertUV?: boolean;
  129943. }, scene?: Nullable<Scene>): Mesh;
  129944. private static _ExtrudeShapeGeneric;
  129945. }
  129946. }
  129947. declare module BABYLON {
  129948. /**
  129949. * AmmoJS Physics plugin
  129950. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  129951. * @see https://github.com/kripken/ammo.js/
  129952. */
  129953. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  129954. private _useDeltaForWorldStep;
  129955. /**
  129956. * Reference to the Ammo library
  129957. */
  129958. bjsAMMO: any;
  129959. /**
  129960. * Created ammoJS world which physics bodies are added to
  129961. */
  129962. world: any;
  129963. /**
  129964. * Name of the plugin
  129965. */
  129966. name: string;
  129967. private _timeStep;
  129968. private _fixedTimeStep;
  129969. private _maxSteps;
  129970. private _tmpQuaternion;
  129971. private _tmpAmmoTransform;
  129972. private _tmpAmmoQuaternion;
  129973. private _tmpAmmoConcreteContactResultCallback;
  129974. private _collisionConfiguration;
  129975. private _dispatcher;
  129976. private _overlappingPairCache;
  129977. private _solver;
  129978. private _softBodySolver;
  129979. private _tmpAmmoVectorA;
  129980. private _tmpAmmoVectorB;
  129981. private _tmpAmmoVectorC;
  129982. private _tmpAmmoVectorD;
  129983. private _tmpContactCallbackResult;
  129984. private _tmpAmmoVectorRCA;
  129985. private _tmpAmmoVectorRCB;
  129986. private _raycastResult;
  129987. private static readonly DISABLE_COLLISION_FLAG;
  129988. private static readonly KINEMATIC_FLAG;
  129989. private static readonly DISABLE_DEACTIVATION_FLAG;
  129990. /**
  129991. * Initializes the ammoJS plugin
  129992. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  129993. * @param ammoInjection can be used to inject your own ammo reference
  129994. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  129995. */
  129996. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  129997. /**
  129998. * Sets the gravity of the physics world (m/(s^2))
  129999. * @param gravity Gravity to set
  130000. */
  130001. setGravity(gravity: Vector3): void;
  130002. /**
  130003. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  130004. * @param timeStep timestep to use in seconds
  130005. */
  130006. setTimeStep(timeStep: number): void;
  130007. /**
  130008. * 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)
  130009. * @param fixedTimeStep fixedTimeStep to use in seconds
  130010. */
  130011. setFixedTimeStep(fixedTimeStep: number): void;
  130012. /**
  130013. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  130014. * @param maxSteps the maximum number of steps by the physics engine per frame
  130015. */
  130016. setMaxSteps(maxSteps: number): void;
  130017. /**
  130018. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  130019. * @returns the current timestep in seconds
  130020. */
  130021. getTimeStep(): number;
  130022. /**
  130023. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  130024. */
  130025. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  130026. private _isImpostorInContact;
  130027. private _isImpostorPairInContact;
  130028. private _stepSimulation;
  130029. /**
  130030. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  130031. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  130032. * After the step the babylon meshes are set to the position of the physics imposters
  130033. * @param delta amount of time to step forward
  130034. * @param impostors array of imposters to update before/after the step
  130035. */
  130036. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  130037. /**
  130038. * Update babylon mesh to match physics world object
  130039. * @param impostor imposter to match
  130040. */
  130041. private _afterSoftStep;
  130042. /**
  130043. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130044. * @param impostor imposter to match
  130045. */
  130046. private _ropeStep;
  130047. /**
  130048. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130049. * @param impostor imposter to match
  130050. */
  130051. private _softbodyOrClothStep;
  130052. private _tmpMatrix;
  130053. /**
  130054. * Applies an impulse on the imposter
  130055. * @param impostor imposter to apply impulse to
  130056. * @param force amount of force to be applied to the imposter
  130057. * @param contactPoint the location to apply the impulse on the imposter
  130058. */
  130059. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130060. /**
  130061. * Applies a force on the imposter
  130062. * @param impostor imposter to apply force
  130063. * @param force amount of force to be applied to the imposter
  130064. * @param contactPoint the location to apply the force on the imposter
  130065. */
  130066. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130067. /**
  130068. * Creates a physics body using the plugin
  130069. * @param impostor the imposter to create the physics body on
  130070. */
  130071. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130072. /**
  130073. * Removes the physics body from the imposter and disposes of the body's memory
  130074. * @param impostor imposter to remove the physics body from
  130075. */
  130076. removePhysicsBody(impostor: PhysicsImpostor): void;
  130077. /**
  130078. * Generates a joint
  130079. * @param impostorJoint the imposter joint to create the joint with
  130080. */
  130081. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130082. /**
  130083. * Removes a joint
  130084. * @param impostorJoint the imposter joint to remove the joint from
  130085. */
  130086. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130087. private _addMeshVerts;
  130088. /**
  130089. * Initialise the soft body vertices to match its object's (mesh) vertices
  130090. * Softbody vertices (nodes) are in world space and to match this
  130091. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  130092. * @param impostor to create the softbody for
  130093. */
  130094. private _softVertexData;
  130095. /**
  130096. * Create an impostor's soft body
  130097. * @param impostor to create the softbody for
  130098. */
  130099. private _createSoftbody;
  130100. /**
  130101. * Create cloth for an impostor
  130102. * @param impostor to create the softbody for
  130103. */
  130104. private _createCloth;
  130105. /**
  130106. * Create rope for an impostor
  130107. * @param impostor to create the softbody for
  130108. */
  130109. private _createRope;
  130110. /**
  130111. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  130112. * @param impostor to create the custom physics shape for
  130113. */
  130114. private _createCustom;
  130115. private _addHullVerts;
  130116. private _createShape;
  130117. /**
  130118. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  130119. * @param impostor imposter containing the physics body and babylon object
  130120. */
  130121. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130122. /**
  130123. * Sets the babylon object's position/rotation from the physics body's position/rotation
  130124. * @param impostor imposter containing the physics body and babylon object
  130125. * @param newPosition new position
  130126. * @param newRotation new rotation
  130127. */
  130128. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130129. /**
  130130. * If this plugin is supported
  130131. * @returns true if its supported
  130132. */
  130133. isSupported(): boolean;
  130134. /**
  130135. * Sets the linear velocity of the physics body
  130136. * @param impostor imposter to set the velocity on
  130137. * @param velocity velocity to set
  130138. */
  130139. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130140. /**
  130141. * Sets the angular velocity of the physics body
  130142. * @param impostor imposter to set the velocity on
  130143. * @param velocity velocity to set
  130144. */
  130145. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130146. /**
  130147. * gets the linear velocity
  130148. * @param impostor imposter to get linear velocity from
  130149. * @returns linear velocity
  130150. */
  130151. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130152. /**
  130153. * gets the angular velocity
  130154. * @param impostor imposter to get angular velocity from
  130155. * @returns angular velocity
  130156. */
  130157. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130158. /**
  130159. * Sets the mass of physics body
  130160. * @param impostor imposter to set the mass on
  130161. * @param mass mass to set
  130162. */
  130163. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130164. /**
  130165. * Gets the mass of the physics body
  130166. * @param impostor imposter to get the mass from
  130167. * @returns mass
  130168. */
  130169. getBodyMass(impostor: PhysicsImpostor): number;
  130170. /**
  130171. * Gets friction of the impostor
  130172. * @param impostor impostor to get friction from
  130173. * @returns friction value
  130174. */
  130175. getBodyFriction(impostor: PhysicsImpostor): number;
  130176. /**
  130177. * Sets friction of the impostor
  130178. * @param impostor impostor to set friction on
  130179. * @param friction friction value
  130180. */
  130181. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130182. /**
  130183. * Gets restitution of the impostor
  130184. * @param impostor impostor to get restitution from
  130185. * @returns restitution value
  130186. */
  130187. getBodyRestitution(impostor: PhysicsImpostor): number;
  130188. /**
  130189. * Sets resitution of the impostor
  130190. * @param impostor impostor to set resitution on
  130191. * @param restitution resitution value
  130192. */
  130193. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130194. /**
  130195. * Gets pressure inside the impostor
  130196. * @param impostor impostor to get pressure from
  130197. * @returns pressure value
  130198. */
  130199. getBodyPressure(impostor: PhysicsImpostor): number;
  130200. /**
  130201. * Sets pressure inside a soft body impostor
  130202. * Cloth and rope must remain 0 pressure
  130203. * @param impostor impostor to set pressure on
  130204. * @param pressure pressure value
  130205. */
  130206. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  130207. /**
  130208. * Gets stiffness of the impostor
  130209. * @param impostor impostor to get stiffness from
  130210. * @returns pressure value
  130211. */
  130212. getBodyStiffness(impostor: PhysicsImpostor): number;
  130213. /**
  130214. * Sets stiffness of the impostor
  130215. * @param impostor impostor to set stiffness on
  130216. * @param stiffness stiffness value from 0 to 1
  130217. */
  130218. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  130219. /**
  130220. * Gets velocityIterations of the impostor
  130221. * @param impostor impostor to get velocity iterations from
  130222. * @returns velocityIterations value
  130223. */
  130224. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  130225. /**
  130226. * Sets velocityIterations of the impostor
  130227. * @param impostor impostor to set velocity iterations on
  130228. * @param velocityIterations velocityIterations value
  130229. */
  130230. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  130231. /**
  130232. * Gets positionIterations of the impostor
  130233. * @param impostor impostor to get position iterations from
  130234. * @returns positionIterations value
  130235. */
  130236. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  130237. /**
  130238. * Sets positionIterations of the impostor
  130239. * @param impostor impostor to set position on
  130240. * @param positionIterations positionIterations value
  130241. */
  130242. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  130243. /**
  130244. * Append an anchor to a cloth object
  130245. * @param impostor is the cloth impostor to add anchor to
  130246. * @param otherImpostor is the rigid impostor to anchor to
  130247. * @param width ratio across width from 0 to 1
  130248. * @param height ratio up height from 0 to 1
  130249. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  130250. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130251. */
  130252. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130253. /**
  130254. * Append an hook to a rope object
  130255. * @param impostor is the rope impostor to add hook to
  130256. * @param otherImpostor is the rigid impostor to hook to
  130257. * @param length ratio along the rope from 0 to 1
  130258. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  130259. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130260. */
  130261. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130262. /**
  130263. * Sleeps the physics body and stops it from being active
  130264. * @param impostor impostor to sleep
  130265. */
  130266. sleepBody(impostor: PhysicsImpostor): void;
  130267. /**
  130268. * Activates the physics body
  130269. * @param impostor impostor to activate
  130270. */
  130271. wakeUpBody(impostor: PhysicsImpostor): void;
  130272. /**
  130273. * Updates the distance parameters of the joint
  130274. * @param joint joint to update
  130275. * @param maxDistance maximum distance of the joint
  130276. * @param minDistance minimum distance of the joint
  130277. */
  130278. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  130279. /**
  130280. * Sets a motor on the joint
  130281. * @param joint joint to set motor on
  130282. * @param speed speed of the motor
  130283. * @param maxForce maximum force of the motor
  130284. * @param motorIndex index of the motor
  130285. */
  130286. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  130287. /**
  130288. * Sets the motors limit
  130289. * @param joint joint to set limit on
  130290. * @param upperLimit upper limit
  130291. * @param lowerLimit lower limit
  130292. */
  130293. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  130294. /**
  130295. * Syncs the position and rotation of a mesh with the impostor
  130296. * @param mesh mesh to sync
  130297. * @param impostor impostor to update the mesh with
  130298. */
  130299. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130300. /**
  130301. * Gets the radius of the impostor
  130302. * @param impostor impostor to get radius from
  130303. * @returns the radius
  130304. */
  130305. getRadius(impostor: PhysicsImpostor): number;
  130306. /**
  130307. * Gets the box size of the impostor
  130308. * @param impostor impostor to get box size from
  130309. * @param result the resulting box size
  130310. */
  130311. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130312. /**
  130313. * Disposes of the impostor
  130314. */
  130315. dispose(): void;
  130316. /**
  130317. * Does a raycast in the physics world
  130318. * @param from when should the ray start?
  130319. * @param to when should the ray end?
  130320. * @returns PhysicsRaycastResult
  130321. */
  130322. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130323. }
  130324. }
  130325. declare module BABYLON {
  130326. interface AbstractScene {
  130327. /**
  130328. * The list of reflection probes added to the scene
  130329. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130330. */
  130331. reflectionProbes: Array<ReflectionProbe>;
  130332. /**
  130333. * Removes the given reflection probe from this scene.
  130334. * @param toRemove The reflection probe to remove
  130335. * @returns The index of the removed reflection probe
  130336. */
  130337. removeReflectionProbe(toRemove: ReflectionProbe): number;
  130338. /**
  130339. * Adds the given reflection probe to this scene.
  130340. * @param newReflectionProbe The reflection probe to add
  130341. */
  130342. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  130343. }
  130344. /**
  130345. * Class used to generate realtime reflection / refraction cube textures
  130346. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130347. */
  130348. export class ReflectionProbe {
  130349. /** defines the name of the probe */
  130350. name: string;
  130351. private _scene;
  130352. private _renderTargetTexture;
  130353. private _projectionMatrix;
  130354. private _viewMatrix;
  130355. private _target;
  130356. private _add;
  130357. private _attachedMesh;
  130358. private _invertYAxis;
  130359. /** Gets or sets probe position (center of the cube map) */
  130360. position: Vector3;
  130361. /**
  130362. * Creates a new reflection probe
  130363. * @param name defines the name of the probe
  130364. * @param size defines the texture resolution (for each face)
  130365. * @param scene defines the hosting scene
  130366. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  130367. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  130368. */
  130369. constructor(
  130370. /** defines the name of the probe */
  130371. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  130372. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  130373. get samples(): number;
  130374. set samples(value: number);
  130375. /** Gets or sets the refresh rate to use (on every frame by default) */
  130376. get refreshRate(): number;
  130377. set refreshRate(value: number);
  130378. /**
  130379. * Gets the hosting scene
  130380. * @returns a Scene
  130381. */
  130382. getScene(): Scene;
  130383. /** Gets the internal CubeTexture used to render to */
  130384. get cubeTexture(): RenderTargetTexture;
  130385. /** Gets the list of meshes to render */
  130386. get renderList(): Nullable<AbstractMesh[]>;
  130387. /**
  130388. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  130389. * @param mesh defines the mesh to attach to
  130390. */
  130391. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130392. /**
  130393. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  130394. * @param renderingGroupId The rendering group id corresponding to its index
  130395. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130396. */
  130397. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  130398. /**
  130399. * Clean all associated resources
  130400. */
  130401. dispose(): void;
  130402. /**
  130403. * Converts the reflection probe information to a readable string for debug purpose.
  130404. * @param fullDetails Supports for multiple levels of logging within scene loading
  130405. * @returns the human readable reflection probe info
  130406. */
  130407. toString(fullDetails?: boolean): string;
  130408. /**
  130409. * Get the class name of the relfection probe.
  130410. * @returns "ReflectionProbe"
  130411. */
  130412. getClassName(): string;
  130413. /**
  130414. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  130415. * @returns The JSON representation of the texture
  130416. */
  130417. serialize(): any;
  130418. /**
  130419. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  130420. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  130421. * @param scene Define the scene the parsed reflection probe should be instantiated in
  130422. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  130423. * @returns The parsed reflection probe if successful
  130424. */
  130425. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  130426. }
  130427. }
  130428. declare module BABYLON {
  130429. /** @hidden */
  130430. export var _BabylonLoaderRegistered: boolean;
  130431. /**
  130432. * Helps setting up some configuration for the babylon file loader.
  130433. */
  130434. export class BabylonFileLoaderConfiguration {
  130435. /**
  130436. * The loader does not allow injecting custom physix engine into the plugins.
  130437. * Unfortunately in ES6, we need to manually inject them into the plugin.
  130438. * So you could set this variable to your engine import to make it work.
  130439. */
  130440. static LoaderInjectedPhysicsEngine: any;
  130441. }
  130442. }
  130443. declare module BABYLON {
  130444. /**
  130445. * The Physically based simple base material of BJS.
  130446. *
  130447. * This enables better naming and convention enforcements on top of the pbrMaterial.
  130448. * It is used as the base class for both the specGloss and metalRough conventions.
  130449. */
  130450. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  130451. /**
  130452. * Number of Simultaneous lights allowed on the material.
  130453. */
  130454. maxSimultaneousLights: number;
  130455. /**
  130456. * If sets to true, disables all the lights affecting the material.
  130457. */
  130458. disableLighting: boolean;
  130459. /**
  130460. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  130461. */
  130462. environmentTexture: BaseTexture;
  130463. /**
  130464. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  130465. */
  130466. invertNormalMapX: boolean;
  130467. /**
  130468. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  130469. */
  130470. invertNormalMapY: boolean;
  130471. /**
  130472. * Normal map used in the model.
  130473. */
  130474. normalTexture: BaseTexture;
  130475. /**
  130476. * Emissivie color used to self-illuminate the model.
  130477. */
  130478. emissiveColor: Color3;
  130479. /**
  130480. * Emissivie texture used to self-illuminate the model.
  130481. */
  130482. emissiveTexture: BaseTexture;
  130483. /**
  130484. * Occlusion Channel Strenght.
  130485. */
  130486. occlusionStrength: number;
  130487. /**
  130488. * Occlusion Texture of the material (adding extra occlusion effects).
  130489. */
  130490. occlusionTexture: BaseTexture;
  130491. /**
  130492. * Defines the alpha limits in alpha test mode.
  130493. */
  130494. alphaCutOff: number;
  130495. /**
  130496. * Gets the current double sided mode.
  130497. */
  130498. get doubleSided(): boolean;
  130499. /**
  130500. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  130501. */
  130502. set doubleSided(value: boolean);
  130503. /**
  130504. * Stores the pre-calculated light information of a mesh in a texture.
  130505. */
  130506. lightmapTexture: BaseTexture;
  130507. /**
  130508. * If true, the light map contains occlusion information instead of lighting info.
  130509. */
  130510. useLightmapAsShadowmap: boolean;
  130511. /**
  130512. * Instantiates a new PBRMaterial instance.
  130513. *
  130514. * @param name The material name
  130515. * @param scene The scene the material will be use in.
  130516. */
  130517. constructor(name: string, scene: Scene);
  130518. getClassName(): string;
  130519. }
  130520. }
  130521. declare module BABYLON {
  130522. /**
  130523. * The PBR material of BJS following the metal roughness convention.
  130524. *
  130525. * This fits to the PBR convention in the GLTF definition:
  130526. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  130527. */
  130528. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  130529. /**
  130530. * The base color has two different interpretations depending on the value of metalness.
  130531. * When the material is a metal, the base color is the specific measured reflectance value
  130532. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  130533. * of the material.
  130534. */
  130535. baseColor: Color3;
  130536. /**
  130537. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  130538. * well as opacity information in the alpha channel.
  130539. */
  130540. baseTexture: BaseTexture;
  130541. /**
  130542. * Specifies the metallic scalar value of the material.
  130543. * Can also be used to scale the metalness values of the metallic texture.
  130544. */
  130545. metallic: number;
  130546. /**
  130547. * Specifies the roughness scalar value of the material.
  130548. * Can also be used to scale the roughness values of the metallic texture.
  130549. */
  130550. roughness: number;
  130551. /**
  130552. * Texture containing both the metallic value in the B channel and the
  130553. * roughness value in the G channel to keep better precision.
  130554. */
  130555. metallicRoughnessTexture: BaseTexture;
  130556. /**
  130557. * Instantiates a new PBRMetalRoughnessMaterial instance.
  130558. *
  130559. * @param name The material name
  130560. * @param scene The scene the material will be use in.
  130561. */
  130562. constructor(name: string, scene: Scene);
  130563. /**
  130564. * Return the currrent class name of the material.
  130565. */
  130566. getClassName(): string;
  130567. /**
  130568. * Makes a duplicate of the current material.
  130569. * @param name - name to use for the new material.
  130570. */
  130571. clone(name: string): PBRMetallicRoughnessMaterial;
  130572. /**
  130573. * Serialize the material to a parsable JSON object.
  130574. */
  130575. serialize(): any;
  130576. /**
  130577. * Parses a JSON object correponding to the serialize function.
  130578. */
  130579. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  130580. }
  130581. }
  130582. declare module BABYLON {
  130583. /**
  130584. * The PBR material of BJS following the specular glossiness convention.
  130585. *
  130586. * This fits to the PBR convention in the GLTF definition:
  130587. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  130588. */
  130589. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  130590. /**
  130591. * Specifies the diffuse color of the material.
  130592. */
  130593. diffuseColor: Color3;
  130594. /**
  130595. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  130596. * channel.
  130597. */
  130598. diffuseTexture: BaseTexture;
  130599. /**
  130600. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  130601. */
  130602. specularColor: Color3;
  130603. /**
  130604. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  130605. */
  130606. glossiness: number;
  130607. /**
  130608. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  130609. */
  130610. specularGlossinessTexture: BaseTexture;
  130611. /**
  130612. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  130613. *
  130614. * @param name The material name
  130615. * @param scene The scene the material will be use in.
  130616. */
  130617. constructor(name: string, scene: Scene);
  130618. /**
  130619. * Return the currrent class name of the material.
  130620. */
  130621. getClassName(): string;
  130622. /**
  130623. * Makes a duplicate of the current material.
  130624. * @param name - name to use for the new material.
  130625. */
  130626. clone(name: string): PBRSpecularGlossinessMaterial;
  130627. /**
  130628. * Serialize the material to a parsable JSON object.
  130629. */
  130630. serialize(): any;
  130631. /**
  130632. * Parses a JSON object correponding to the serialize function.
  130633. */
  130634. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  130635. }
  130636. }
  130637. declare module BABYLON {
  130638. /**
  130639. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  130640. * It can help converting any input color in a desired output one. This can then be used to create effects
  130641. * from sepia, black and white to sixties or futuristic rendering...
  130642. *
  130643. * The only supported format is currently 3dl.
  130644. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  130645. */
  130646. export class ColorGradingTexture extends BaseTexture {
  130647. /**
  130648. * The current texture matrix. (will always be identity in color grading texture)
  130649. */
  130650. private _textureMatrix;
  130651. /**
  130652. * The texture URL.
  130653. */
  130654. url: string;
  130655. /**
  130656. * Empty line regex stored for GC.
  130657. */
  130658. private static _noneEmptyLineRegex;
  130659. private _engine;
  130660. /**
  130661. * Instantiates a ColorGradingTexture from the following parameters.
  130662. *
  130663. * @param url The location of the color gradind data (currently only supporting 3dl)
  130664. * @param scene The scene the texture will be used in
  130665. */
  130666. constructor(url: string, scene: Scene);
  130667. /**
  130668. * Returns the texture matrix used in most of the material.
  130669. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  130670. */
  130671. getTextureMatrix(): Matrix;
  130672. /**
  130673. * Occurs when the file being loaded is a .3dl LUT file.
  130674. */
  130675. private load3dlTexture;
  130676. /**
  130677. * Starts the loading process of the texture.
  130678. */
  130679. private loadTexture;
  130680. /**
  130681. * Clones the color gradind texture.
  130682. */
  130683. clone(): ColorGradingTexture;
  130684. /**
  130685. * Called during delayed load for textures.
  130686. */
  130687. delayLoad(): void;
  130688. /**
  130689. * Parses a color grading texture serialized by Babylon.
  130690. * @param parsedTexture The texture information being parsedTexture
  130691. * @param scene The scene to load the texture in
  130692. * @param rootUrl The root url of the data assets to load
  130693. * @return A color gradind texture
  130694. */
  130695. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  130696. /**
  130697. * Serializes the LUT texture to json format.
  130698. */
  130699. serialize(): any;
  130700. }
  130701. }
  130702. declare module BABYLON {
  130703. /**
  130704. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  130705. */
  130706. export class EquiRectangularCubeTexture extends BaseTexture {
  130707. /** The six faces of the cube. */
  130708. private static _FacesMapping;
  130709. private _noMipmap;
  130710. private _onLoad;
  130711. private _onError;
  130712. /** The size of the cubemap. */
  130713. private _size;
  130714. /** The buffer of the image. */
  130715. private _buffer;
  130716. /** The width of the input image. */
  130717. private _width;
  130718. /** The height of the input image. */
  130719. private _height;
  130720. /** The URL to the image. */
  130721. url: string;
  130722. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  130723. coordinatesMode: number;
  130724. /**
  130725. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  130726. * @param url The location of the image
  130727. * @param scene The scene the texture will be used in
  130728. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  130729. * @param noMipmap Forces to not generate the mipmap if true
  130730. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130731. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130732. * @param onLoad — defines a callback called when texture is loaded
  130733. * @param onError — defines a callback called if there is an error
  130734. */
  130735. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  130736. /**
  130737. * Load the image data, by putting the image on a canvas and extracting its buffer.
  130738. */
  130739. private loadImage;
  130740. /**
  130741. * Convert the image buffer into a cubemap and create a CubeTexture.
  130742. */
  130743. private loadTexture;
  130744. /**
  130745. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  130746. * @param buffer The ArrayBuffer that should be converted.
  130747. * @returns The buffer as Float32Array.
  130748. */
  130749. private getFloat32ArrayFromArrayBuffer;
  130750. /**
  130751. * Get the current class name of the texture useful for serialization or dynamic coding.
  130752. * @returns "EquiRectangularCubeTexture"
  130753. */
  130754. getClassName(): string;
  130755. /**
  130756. * Create a clone of the current EquiRectangularCubeTexture and return it.
  130757. * @returns A clone of the current EquiRectangularCubeTexture.
  130758. */
  130759. clone(): EquiRectangularCubeTexture;
  130760. }
  130761. }
  130762. declare module BABYLON {
  130763. /**
  130764. * Based on jsTGALoader - Javascript loader for TGA file
  130765. * By Vincent Thibault
  130766. * @see http://blog.robrowser.com/javascript-tga-loader.html
  130767. */
  130768. export class TGATools {
  130769. private static _TYPE_INDEXED;
  130770. private static _TYPE_RGB;
  130771. private static _TYPE_GREY;
  130772. private static _TYPE_RLE_INDEXED;
  130773. private static _TYPE_RLE_RGB;
  130774. private static _TYPE_RLE_GREY;
  130775. private static _ORIGIN_MASK;
  130776. private static _ORIGIN_SHIFT;
  130777. private static _ORIGIN_BL;
  130778. private static _ORIGIN_BR;
  130779. private static _ORIGIN_UL;
  130780. private static _ORIGIN_UR;
  130781. /**
  130782. * Gets the header of a TGA file
  130783. * @param data defines the TGA data
  130784. * @returns the header
  130785. */
  130786. static GetTGAHeader(data: Uint8Array): any;
  130787. /**
  130788. * Uploads TGA content to a Babylon Texture
  130789. * @hidden
  130790. */
  130791. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  130792. /** @hidden */
  130793. 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;
  130794. /** @hidden */
  130795. 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;
  130796. /** @hidden */
  130797. 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;
  130798. /** @hidden */
  130799. 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;
  130800. /** @hidden */
  130801. 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;
  130802. /** @hidden */
  130803. 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;
  130804. }
  130805. }
  130806. declare module BABYLON {
  130807. /**
  130808. * Implementation of the TGA Texture Loader.
  130809. * @hidden
  130810. */
  130811. export class _TGATextureLoader implements IInternalTextureLoader {
  130812. /**
  130813. * Defines wether the loader supports cascade loading the different faces.
  130814. */
  130815. readonly supportCascades: boolean;
  130816. /**
  130817. * This returns if the loader support the current file information.
  130818. * @param extension defines the file extension of the file being loaded
  130819. * @returns true if the loader can load the specified file
  130820. */
  130821. canLoad(extension: string): boolean;
  130822. /**
  130823. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130824. * @param data contains the texture data
  130825. * @param texture defines the BabylonJS internal texture
  130826. * @param createPolynomials will be true if polynomials have been requested
  130827. * @param onLoad defines the callback to trigger once the texture is ready
  130828. * @param onError defines the callback to trigger in case of error
  130829. */
  130830. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130831. /**
  130832. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130833. * @param data contains the texture data
  130834. * @param texture defines the BabylonJS internal texture
  130835. * @param callback defines the method to call once ready to upload
  130836. */
  130837. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130838. }
  130839. }
  130840. declare module BABYLON {
  130841. /**
  130842. * Info about the .basis files
  130843. */
  130844. class BasisFileInfo {
  130845. /**
  130846. * If the file has alpha
  130847. */
  130848. hasAlpha: boolean;
  130849. /**
  130850. * Info about each image of the basis file
  130851. */
  130852. images: Array<{
  130853. levels: Array<{
  130854. width: number;
  130855. height: number;
  130856. transcodedPixels: ArrayBufferView;
  130857. }>;
  130858. }>;
  130859. }
  130860. /**
  130861. * Result of transcoding a basis file
  130862. */
  130863. class TranscodeResult {
  130864. /**
  130865. * Info about the .basis file
  130866. */
  130867. fileInfo: BasisFileInfo;
  130868. /**
  130869. * Format to use when loading the file
  130870. */
  130871. format: number;
  130872. }
  130873. /**
  130874. * Configuration options for the Basis transcoder
  130875. */
  130876. export class BasisTranscodeConfiguration {
  130877. /**
  130878. * Supported compression formats used to determine the supported output format of the transcoder
  130879. */
  130880. supportedCompressionFormats?: {
  130881. /**
  130882. * etc1 compression format
  130883. */
  130884. etc1?: boolean;
  130885. /**
  130886. * s3tc compression format
  130887. */
  130888. s3tc?: boolean;
  130889. /**
  130890. * pvrtc compression format
  130891. */
  130892. pvrtc?: boolean;
  130893. /**
  130894. * etc2 compression format
  130895. */
  130896. etc2?: boolean;
  130897. };
  130898. /**
  130899. * If mipmap levels should be loaded for transcoded images (Default: true)
  130900. */
  130901. loadMipmapLevels?: boolean;
  130902. /**
  130903. * Index of a single image to load (Default: all images)
  130904. */
  130905. loadSingleImage?: number;
  130906. }
  130907. /**
  130908. * Used to load .Basis files
  130909. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  130910. */
  130911. export class BasisTools {
  130912. private static _IgnoreSupportedFormats;
  130913. /**
  130914. * URL to use when loading the basis transcoder
  130915. */
  130916. static JSModuleURL: string;
  130917. /**
  130918. * URL to use when loading the wasm module for the transcoder
  130919. */
  130920. static WasmModuleURL: string;
  130921. /**
  130922. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  130923. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  130924. * @returns internal format corresponding to the Basis format
  130925. */
  130926. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  130927. private static _WorkerPromise;
  130928. private static _Worker;
  130929. private static _actionId;
  130930. private static _CreateWorkerAsync;
  130931. /**
  130932. * Transcodes a loaded image file to compressed pixel data
  130933. * @param data image data to transcode
  130934. * @param config configuration options for the transcoding
  130935. * @returns a promise resulting in the transcoded image
  130936. */
  130937. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  130938. /**
  130939. * Loads a texture from the transcode result
  130940. * @param texture texture load to
  130941. * @param transcodeResult the result of transcoding the basis file to load from
  130942. */
  130943. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  130944. }
  130945. }
  130946. declare module BABYLON {
  130947. /**
  130948. * Loader for .basis file format
  130949. */
  130950. export class _BasisTextureLoader implements IInternalTextureLoader {
  130951. /**
  130952. * Defines whether the loader supports cascade loading the different faces.
  130953. */
  130954. readonly supportCascades: boolean;
  130955. /**
  130956. * This returns if the loader support the current file information.
  130957. * @param extension defines the file extension of the file being loaded
  130958. * @returns true if the loader can load the specified file
  130959. */
  130960. canLoad(extension: string): boolean;
  130961. /**
  130962. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130963. * @param data contains the texture data
  130964. * @param texture defines the BabylonJS internal texture
  130965. * @param createPolynomials will be true if polynomials have been requested
  130966. * @param onLoad defines the callback to trigger once the texture is ready
  130967. * @param onError defines the callback to trigger in case of error
  130968. */
  130969. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130970. /**
  130971. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130972. * @param data contains the texture data
  130973. * @param texture defines the BabylonJS internal texture
  130974. * @param callback defines the method to call once ready to upload
  130975. */
  130976. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130977. }
  130978. }
  130979. declare module BABYLON {
  130980. /**
  130981. * 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.
  130982. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130983. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130984. */
  130985. export class CustomProceduralTexture extends ProceduralTexture {
  130986. private _animate;
  130987. private _time;
  130988. private _config;
  130989. private _texturePath;
  130990. /**
  130991. * Instantiates a new Custom Procedural Texture.
  130992. * 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.
  130993. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  130994. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  130995. * @param name Define the name of the texture
  130996. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  130997. * @param size Define the size of the texture to create
  130998. * @param scene Define the scene the texture belongs to
  130999. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  131000. * @param generateMipMaps Define if the texture should creates mip maps or not
  131001. */
  131002. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131003. private _loadJson;
  131004. /**
  131005. * Is the texture ready to be used ? (rendered at least once)
  131006. * @returns true if ready, otherwise, false.
  131007. */
  131008. isReady(): boolean;
  131009. /**
  131010. * Render the texture to its associated render target.
  131011. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  131012. */
  131013. render(useCameraPostProcess?: boolean): void;
  131014. /**
  131015. * Update the list of dependant textures samplers in the shader.
  131016. */
  131017. updateTextures(): void;
  131018. /**
  131019. * Update the uniform values of the procedural texture in the shader.
  131020. */
  131021. updateShaderUniforms(): void;
  131022. /**
  131023. * Define if the texture animates or not.
  131024. */
  131025. get animate(): boolean;
  131026. set animate(value: boolean);
  131027. }
  131028. }
  131029. declare module BABYLON {
  131030. /** @hidden */
  131031. export var noisePixelShader: {
  131032. name: string;
  131033. shader: string;
  131034. };
  131035. }
  131036. declare module BABYLON {
  131037. /**
  131038. * Class used to generate noise procedural textures
  131039. */
  131040. export class NoiseProceduralTexture extends ProceduralTexture {
  131041. private _time;
  131042. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  131043. brightness: number;
  131044. /** Defines the number of octaves to process */
  131045. octaves: number;
  131046. /** Defines the level of persistence (0.8 by default) */
  131047. persistence: number;
  131048. /** Gets or sets animation speed factor (default is 1) */
  131049. animationSpeedFactor: number;
  131050. /**
  131051. * Creates a new NoiseProceduralTexture
  131052. * @param name defines the name fo the texture
  131053. * @param size defines the size of the texture (default is 256)
  131054. * @param scene defines the hosting scene
  131055. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  131056. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  131057. */
  131058. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131059. private _updateShaderUniforms;
  131060. protected _getDefines(): string;
  131061. /** Generate the current state of the procedural texture */
  131062. render(useCameraPostProcess?: boolean): void;
  131063. /**
  131064. * Serializes this noise procedural texture
  131065. * @returns a serialized noise procedural texture object
  131066. */
  131067. serialize(): any;
  131068. /**
  131069. * Clone the texture.
  131070. * @returns the cloned texture
  131071. */
  131072. clone(): NoiseProceduralTexture;
  131073. /**
  131074. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  131075. * @param parsedTexture defines parsed texture data
  131076. * @param scene defines the current scene
  131077. * @param rootUrl defines the root URL containing noise procedural texture information
  131078. * @returns a parsed NoiseProceduralTexture
  131079. */
  131080. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  131081. }
  131082. }
  131083. declare module BABYLON {
  131084. /**
  131085. * Raw cube texture where the raw buffers are passed in
  131086. */
  131087. export class RawCubeTexture extends CubeTexture {
  131088. /**
  131089. * Creates a cube texture where the raw buffers are passed in.
  131090. * @param scene defines the scene the texture is attached to
  131091. * @param data defines the array of data to use to create each face
  131092. * @param size defines the size of the textures
  131093. * @param format defines the format of the data
  131094. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131095. * @param generateMipMaps defines if the engine should generate the mip levels
  131096. * @param invertY defines if data must be stored with Y axis inverted
  131097. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131098. * @param compression defines the compression used (null by default)
  131099. */
  131100. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  131101. /**
  131102. * Updates the raw cube texture.
  131103. * @param data defines the data to store
  131104. * @param format defines the data format
  131105. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131106. * @param invertY defines if data must be stored with Y axis inverted
  131107. * @param compression defines the compression used (null by default)
  131108. * @param level defines which level of the texture to update
  131109. */
  131110. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  131111. /**
  131112. * Updates a raw cube texture with RGBD encoded data.
  131113. * @param data defines the array of data [mipmap][face] to use to create each face
  131114. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  131115. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131116. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131117. * @returns a promsie that resolves when the operation is complete
  131118. */
  131119. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  131120. /**
  131121. * Clones the raw cube texture.
  131122. * @return a new cube texture
  131123. */
  131124. clone(): CubeTexture;
  131125. /** @hidden */
  131126. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131127. }
  131128. }
  131129. declare module BABYLON {
  131130. /**
  131131. * Class used to store 3D textures containing user data
  131132. */
  131133. export class RawTexture3D extends Texture {
  131134. /** Gets or sets the texture format to use */
  131135. format: number;
  131136. private _engine;
  131137. /**
  131138. * Create a new RawTexture3D
  131139. * @param data defines the data of the texture
  131140. * @param width defines the width of the texture
  131141. * @param height defines the height of the texture
  131142. * @param depth defines the depth of the texture
  131143. * @param format defines the texture format to use
  131144. * @param scene defines the hosting scene
  131145. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131146. * @param invertY defines if texture must be stored with Y axis inverted
  131147. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131148. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131149. */
  131150. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131151. /** Gets or sets the texture format to use */
  131152. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131153. /**
  131154. * Update the texture with new data
  131155. * @param data defines the data to store in the texture
  131156. */
  131157. update(data: ArrayBufferView): void;
  131158. }
  131159. }
  131160. declare module BABYLON {
  131161. /**
  131162. * Class used to store 2D array textures containing user data
  131163. */
  131164. export class RawTexture2DArray extends Texture {
  131165. /** Gets or sets the texture format to use */
  131166. format: number;
  131167. private _engine;
  131168. /**
  131169. * Create a new RawTexture2DArray
  131170. * @param data defines the data of the texture
  131171. * @param width defines the width of the texture
  131172. * @param height defines the height of the texture
  131173. * @param depth defines the number of layers of the texture
  131174. * @param format defines the texture format to use
  131175. * @param scene defines the hosting scene
  131176. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131177. * @param invertY defines if texture must be stored with Y axis inverted
  131178. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131179. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131180. */
  131181. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131182. /** Gets or sets the texture format to use */
  131183. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131184. /**
  131185. * Update the texture with new data
  131186. * @param data defines the data to store in the texture
  131187. */
  131188. update(data: ArrayBufferView): void;
  131189. }
  131190. }
  131191. declare module BABYLON {
  131192. /**
  131193. * Creates a refraction texture used by refraction channel of the standard material.
  131194. * It is like a mirror but to see through a material.
  131195. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131196. */
  131197. export class RefractionTexture extends RenderTargetTexture {
  131198. /**
  131199. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  131200. * 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.
  131201. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131202. */
  131203. refractionPlane: Plane;
  131204. /**
  131205. * Define how deep under the surface we should see.
  131206. */
  131207. depth: number;
  131208. /**
  131209. * Creates a refraction texture used by refraction channel of the standard material.
  131210. * It is like a mirror but to see through a material.
  131211. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131212. * @param name Define the texture name
  131213. * @param size Define the size of the underlying texture
  131214. * @param scene Define the scene the refraction belongs to
  131215. * @param generateMipMaps Define if we need to generate mips level for the refraction
  131216. */
  131217. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  131218. /**
  131219. * Clone the refraction texture.
  131220. * @returns the cloned texture
  131221. */
  131222. clone(): RefractionTexture;
  131223. /**
  131224. * Serialize the texture to a JSON representation you could use in Parse later on
  131225. * @returns the serialized JSON representation
  131226. */
  131227. serialize(): any;
  131228. }
  131229. }
  131230. declare module BABYLON {
  131231. /**
  131232. * Defines the options related to the creation of an HtmlElementTexture
  131233. */
  131234. export interface IHtmlElementTextureOptions {
  131235. /**
  131236. * Defines wether mip maps should be created or not.
  131237. */
  131238. generateMipMaps?: boolean;
  131239. /**
  131240. * Defines the sampling mode of the texture.
  131241. */
  131242. samplingMode?: number;
  131243. /**
  131244. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  131245. */
  131246. engine: Nullable<ThinEngine>;
  131247. /**
  131248. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  131249. */
  131250. scene: Nullable<Scene>;
  131251. }
  131252. /**
  131253. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  131254. * To be as efficient as possible depending on your constraints nothing aside the first upload
  131255. * is automatically managed.
  131256. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  131257. * in your application.
  131258. *
  131259. * As the update is not automatic, you need to call them manually.
  131260. */
  131261. export class HtmlElementTexture extends BaseTexture {
  131262. /**
  131263. * The texture URL.
  131264. */
  131265. element: HTMLVideoElement | HTMLCanvasElement;
  131266. private static readonly DefaultOptions;
  131267. private _textureMatrix;
  131268. private _engine;
  131269. private _isVideo;
  131270. private _generateMipMaps;
  131271. private _samplingMode;
  131272. /**
  131273. * Instantiates a HtmlElementTexture from the following parameters.
  131274. *
  131275. * @param name Defines the name of the texture
  131276. * @param element Defines the video or canvas the texture is filled with
  131277. * @param options Defines the other none mandatory texture creation options
  131278. */
  131279. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  131280. private _createInternalTexture;
  131281. /**
  131282. * Returns the texture matrix used in most of the material.
  131283. */
  131284. getTextureMatrix(): Matrix;
  131285. /**
  131286. * Updates the content of the texture.
  131287. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  131288. */
  131289. update(invertY?: Nullable<boolean>): void;
  131290. }
  131291. }
  131292. declare module BABYLON {
  131293. /**
  131294. * Defines the basic options interface of a TexturePacker Frame
  131295. */
  131296. export interface ITexturePackerFrame {
  131297. /**
  131298. * The frame ID
  131299. */
  131300. id: number;
  131301. /**
  131302. * The frames Scale
  131303. */
  131304. scale: Vector2;
  131305. /**
  131306. * The Frames offset
  131307. */
  131308. offset: Vector2;
  131309. }
  131310. /**
  131311. * This is a support class for frame Data on texture packer sets.
  131312. */
  131313. export class TexturePackerFrame implements ITexturePackerFrame {
  131314. /**
  131315. * The frame ID
  131316. */
  131317. id: number;
  131318. /**
  131319. * The frames Scale
  131320. */
  131321. scale: Vector2;
  131322. /**
  131323. * The Frames offset
  131324. */
  131325. offset: Vector2;
  131326. /**
  131327. * Initializes a texture package frame.
  131328. * @param id The numerical frame identifier
  131329. * @param scale Scalar Vector2 for UV frame
  131330. * @param offset Vector2 for the frame position in UV units.
  131331. * @returns TexturePackerFrame
  131332. */
  131333. constructor(id: number, scale: Vector2, offset: Vector2);
  131334. }
  131335. }
  131336. declare module BABYLON {
  131337. /**
  131338. * Defines the basic options interface of a TexturePacker
  131339. */
  131340. export interface ITexturePackerOptions {
  131341. /**
  131342. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  131343. */
  131344. map?: string[];
  131345. /**
  131346. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131347. */
  131348. uvsIn?: string;
  131349. /**
  131350. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131351. */
  131352. uvsOut?: string;
  131353. /**
  131354. * number representing the layout style. Defaults to LAYOUT_STRIP
  131355. */
  131356. layout?: number;
  131357. /**
  131358. * number of columns if using custom column count layout(2). This defaults to 4.
  131359. */
  131360. colnum?: number;
  131361. /**
  131362. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  131363. */
  131364. updateInputMeshes?: boolean;
  131365. /**
  131366. * boolean flag to dispose all the source textures. Defaults to true.
  131367. */
  131368. disposeSources?: boolean;
  131369. /**
  131370. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  131371. */
  131372. fillBlanks?: boolean;
  131373. /**
  131374. * string value representing the context fill style color. Defaults to 'black'.
  131375. */
  131376. customFillColor?: string;
  131377. /**
  131378. * Width and Height Value of each Frame in the TexturePacker Sets
  131379. */
  131380. frameSize?: number;
  131381. /**
  131382. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  131383. */
  131384. paddingRatio?: number;
  131385. /**
  131386. * Number that declares the fill method for the padding gutter.
  131387. */
  131388. paddingMode?: number;
  131389. /**
  131390. * If in SUBUV_COLOR padding mode what color to use.
  131391. */
  131392. paddingColor?: Color3 | Color4;
  131393. }
  131394. /**
  131395. * Defines the basic interface of a TexturePacker JSON File
  131396. */
  131397. export interface ITexturePackerJSON {
  131398. /**
  131399. * The frame ID
  131400. */
  131401. name: string;
  131402. /**
  131403. * The base64 channel data
  131404. */
  131405. sets: any;
  131406. /**
  131407. * The options of the Packer
  131408. */
  131409. options: ITexturePackerOptions;
  131410. /**
  131411. * The frame data of the Packer
  131412. */
  131413. frames: Array<number>;
  131414. }
  131415. /**
  131416. * This is a support class that generates a series of packed texture sets.
  131417. * @see https://doc.babylonjs.com/babylon101/materials
  131418. */
  131419. export class TexturePacker {
  131420. /** Packer Layout Constant 0 */
  131421. static readonly LAYOUT_STRIP: number;
  131422. /** Packer Layout Constant 1 */
  131423. static readonly LAYOUT_POWER2: number;
  131424. /** Packer Layout Constant 2 */
  131425. static readonly LAYOUT_COLNUM: number;
  131426. /** Packer Layout Constant 0 */
  131427. static readonly SUBUV_WRAP: number;
  131428. /** Packer Layout Constant 1 */
  131429. static readonly SUBUV_EXTEND: number;
  131430. /** Packer Layout Constant 2 */
  131431. static readonly SUBUV_COLOR: number;
  131432. /** The Name of the Texture Package */
  131433. name: string;
  131434. /** The scene scope of the TexturePacker */
  131435. scene: Scene;
  131436. /** The Meshes to target */
  131437. meshes: AbstractMesh[];
  131438. /** Arguments passed with the Constructor */
  131439. options: ITexturePackerOptions;
  131440. /** The promise that is started upon initialization */
  131441. promise: Nullable<Promise<TexturePacker | string>>;
  131442. /** The Container object for the channel sets that are generated */
  131443. sets: object;
  131444. /** The Container array for the frames that are generated */
  131445. frames: TexturePackerFrame[];
  131446. /** The expected number of textures the system is parsing. */
  131447. private _expecting;
  131448. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  131449. private _paddingValue;
  131450. /**
  131451. * Initializes a texture package series from an array of meshes or a single mesh.
  131452. * @param name The name of the package
  131453. * @param meshes The target meshes to compose the package from
  131454. * @param options The arguments that texture packer should follow while building.
  131455. * @param scene The scene which the textures are scoped to.
  131456. * @returns TexturePacker
  131457. */
  131458. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  131459. /**
  131460. * Starts the package process
  131461. * @param resolve The promises resolution function
  131462. * @returns TexturePacker
  131463. */
  131464. private _createFrames;
  131465. /**
  131466. * Calculates the Size of the Channel Sets
  131467. * @returns Vector2
  131468. */
  131469. private _calculateSize;
  131470. /**
  131471. * Calculates the UV data for the frames.
  131472. * @param baseSize the base frameSize
  131473. * @param padding the base frame padding
  131474. * @param dtSize size of the Dynamic Texture for that channel
  131475. * @param dtUnits is 1/dtSize
  131476. * @param update flag to update the input meshes
  131477. */
  131478. private _calculateMeshUVFrames;
  131479. /**
  131480. * Calculates the frames Offset.
  131481. * @param index of the frame
  131482. * @returns Vector2
  131483. */
  131484. private _getFrameOffset;
  131485. /**
  131486. * Updates a Mesh to the frame data
  131487. * @param mesh that is the target
  131488. * @param frameID or the frame index
  131489. */
  131490. private _updateMeshUV;
  131491. /**
  131492. * Updates a Meshes materials to use the texture packer channels
  131493. * @param m is the mesh to target
  131494. * @param force all channels on the packer to be set.
  131495. */
  131496. private _updateTextureReferences;
  131497. /**
  131498. * Public method to set a Mesh to a frame
  131499. * @param m that is the target
  131500. * @param frameID or the frame index
  131501. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  131502. */
  131503. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  131504. /**
  131505. * Starts the async promise to compile the texture packer.
  131506. * @returns Promise<void>
  131507. */
  131508. processAsync(): Promise<void>;
  131509. /**
  131510. * Disposes all textures associated with this packer
  131511. */
  131512. dispose(): void;
  131513. /**
  131514. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  131515. * @param imageType is the image type to use.
  131516. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  131517. */
  131518. download(imageType?: string, quality?: number): void;
  131519. /**
  131520. * Public method to load a texturePacker JSON file.
  131521. * @param data of the JSON file in string format.
  131522. */
  131523. updateFromJSON(data: string): void;
  131524. }
  131525. }
  131526. declare module BABYLON {
  131527. /**
  131528. * Enum used to define the target of a block
  131529. */
  131530. export enum NodeMaterialBlockTargets {
  131531. /** Vertex shader */
  131532. Vertex = 1,
  131533. /** Fragment shader */
  131534. Fragment = 2,
  131535. /** Neutral */
  131536. Neutral = 4,
  131537. /** Vertex and Fragment */
  131538. VertexAndFragment = 3
  131539. }
  131540. }
  131541. declare module BABYLON {
  131542. /**
  131543. * Defines the kind of connection point for node based material
  131544. */
  131545. export enum NodeMaterialBlockConnectionPointTypes {
  131546. /** Float */
  131547. Float = 1,
  131548. /** Int */
  131549. Int = 2,
  131550. /** Vector2 */
  131551. Vector2 = 4,
  131552. /** Vector3 */
  131553. Vector3 = 8,
  131554. /** Vector4 */
  131555. Vector4 = 16,
  131556. /** Color3 */
  131557. Color3 = 32,
  131558. /** Color4 */
  131559. Color4 = 64,
  131560. /** Matrix */
  131561. Matrix = 128,
  131562. /** Detect type based on connection */
  131563. AutoDetect = 1024,
  131564. /** Output type that will be defined by input type */
  131565. BasedOnInput = 2048
  131566. }
  131567. }
  131568. declare module BABYLON {
  131569. /**
  131570. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  131571. */
  131572. export enum NodeMaterialBlockConnectionPointMode {
  131573. /** Value is an uniform */
  131574. Uniform = 0,
  131575. /** Value is a mesh attribute */
  131576. Attribute = 1,
  131577. /** Value is a varying between vertex and fragment shaders */
  131578. Varying = 2,
  131579. /** Mode is undefined */
  131580. Undefined = 3
  131581. }
  131582. }
  131583. declare module BABYLON {
  131584. /**
  131585. * Enum used to define system values e.g. values automatically provided by the system
  131586. */
  131587. export enum NodeMaterialSystemValues {
  131588. /** World */
  131589. World = 1,
  131590. /** View */
  131591. View = 2,
  131592. /** Projection */
  131593. Projection = 3,
  131594. /** ViewProjection */
  131595. ViewProjection = 4,
  131596. /** WorldView */
  131597. WorldView = 5,
  131598. /** WorldViewProjection */
  131599. WorldViewProjection = 6,
  131600. /** CameraPosition */
  131601. CameraPosition = 7,
  131602. /** Fog Color */
  131603. FogColor = 8,
  131604. /** Delta time */
  131605. DeltaTime = 9
  131606. }
  131607. }
  131608. declare module BABYLON {
  131609. /**
  131610. * Root class for all node material optimizers
  131611. */
  131612. export class NodeMaterialOptimizer {
  131613. /**
  131614. * Function used to optimize a NodeMaterial graph
  131615. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  131616. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  131617. */
  131618. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  131619. }
  131620. }
  131621. declare module BABYLON {
  131622. /**
  131623. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  131624. */
  131625. export class TransformBlock extends NodeMaterialBlock {
  131626. /**
  131627. * Defines the value to use to complement W value to transform it to a Vector4
  131628. */
  131629. complementW: number;
  131630. /**
  131631. * Defines the value to use to complement z value to transform it to a Vector4
  131632. */
  131633. complementZ: number;
  131634. /**
  131635. * Creates a new TransformBlock
  131636. * @param name defines the block name
  131637. */
  131638. constructor(name: string);
  131639. /**
  131640. * Gets the current class name
  131641. * @returns the class name
  131642. */
  131643. getClassName(): string;
  131644. /**
  131645. * Gets the vector input
  131646. */
  131647. get vector(): NodeMaterialConnectionPoint;
  131648. /**
  131649. * Gets the output component
  131650. */
  131651. get output(): NodeMaterialConnectionPoint;
  131652. /**
  131653. * Gets the xyz output component
  131654. */
  131655. get xyz(): NodeMaterialConnectionPoint;
  131656. /**
  131657. * Gets the matrix transform input
  131658. */
  131659. get transform(): NodeMaterialConnectionPoint;
  131660. protected _buildBlock(state: NodeMaterialBuildState): this;
  131661. serialize(): any;
  131662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131663. protected _dumpPropertiesCode(): string;
  131664. }
  131665. }
  131666. declare module BABYLON {
  131667. /**
  131668. * Block used to output the vertex position
  131669. */
  131670. export class VertexOutputBlock extends NodeMaterialBlock {
  131671. /**
  131672. * Creates a new VertexOutputBlock
  131673. * @param name defines the block name
  131674. */
  131675. constructor(name: string);
  131676. /**
  131677. * Gets the current class name
  131678. * @returns the class name
  131679. */
  131680. getClassName(): string;
  131681. /**
  131682. * Gets the vector input component
  131683. */
  131684. get vector(): NodeMaterialConnectionPoint;
  131685. protected _buildBlock(state: NodeMaterialBuildState): this;
  131686. }
  131687. }
  131688. declare module BABYLON {
  131689. /**
  131690. * Block used to output the final color
  131691. */
  131692. export class FragmentOutputBlock extends NodeMaterialBlock {
  131693. /**
  131694. * Create a new FragmentOutputBlock
  131695. * @param name defines the block name
  131696. */
  131697. constructor(name: string);
  131698. /**
  131699. * Gets the current class name
  131700. * @returns the class name
  131701. */
  131702. getClassName(): string;
  131703. /**
  131704. * Gets the rgba input component
  131705. */
  131706. get rgba(): NodeMaterialConnectionPoint;
  131707. /**
  131708. * Gets the rgb input component
  131709. */
  131710. get rgb(): NodeMaterialConnectionPoint;
  131711. /**
  131712. * Gets the a input component
  131713. */
  131714. get a(): NodeMaterialConnectionPoint;
  131715. protected _buildBlock(state: NodeMaterialBuildState): this;
  131716. }
  131717. }
  131718. declare module BABYLON {
  131719. /**
  131720. * Block used to read a reflection texture from a sampler
  131721. */
  131722. export class ReflectionTextureBlock extends NodeMaterialBlock {
  131723. private _define3DName;
  131724. private _defineCubicName;
  131725. private _defineExplicitName;
  131726. private _defineProjectionName;
  131727. private _defineLocalCubicName;
  131728. private _defineSphericalName;
  131729. private _definePlanarName;
  131730. private _defineEquirectangularName;
  131731. private _defineMirroredEquirectangularFixedName;
  131732. private _defineEquirectangularFixedName;
  131733. private _defineSkyboxName;
  131734. private _cubeSamplerName;
  131735. private _2DSamplerName;
  131736. private _positionUVWName;
  131737. private _directionWName;
  131738. private _reflectionCoordsName;
  131739. private _reflection2DCoordsName;
  131740. private _reflectionColorName;
  131741. private _reflectionMatrixName;
  131742. /**
  131743. * Gets or sets the texture associated with the node
  131744. */
  131745. texture: Nullable<BaseTexture>;
  131746. /**
  131747. * Create a new TextureBlock
  131748. * @param name defines the block name
  131749. */
  131750. constructor(name: string);
  131751. /**
  131752. * Gets the current class name
  131753. * @returns the class name
  131754. */
  131755. getClassName(): string;
  131756. /**
  131757. * Gets the world position input component
  131758. */
  131759. get position(): NodeMaterialConnectionPoint;
  131760. /**
  131761. * Gets the world position input component
  131762. */
  131763. get worldPosition(): NodeMaterialConnectionPoint;
  131764. /**
  131765. * Gets the world normal input component
  131766. */
  131767. get worldNormal(): NodeMaterialConnectionPoint;
  131768. /**
  131769. * Gets the world input component
  131770. */
  131771. get world(): NodeMaterialConnectionPoint;
  131772. /**
  131773. * Gets the camera (or eye) position component
  131774. */
  131775. get cameraPosition(): NodeMaterialConnectionPoint;
  131776. /**
  131777. * Gets the view input component
  131778. */
  131779. get view(): NodeMaterialConnectionPoint;
  131780. /**
  131781. * Gets the rgb output component
  131782. */
  131783. get rgb(): NodeMaterialConnectionPoint;
  131784. /**
  131785. * Gets the r output component
  131786. */
  131787. get r(): NodeMaterialConnectionPoint;
  131788. /**
  131789. * Gets the g output component
  131790. */
  131791. get g(): NodeMaterialConnectionPoint;
  131792. /**
  131793. * Gets the b output component
  131794. */
  131795. get b(): NodeMaterialConnectionPoint;
  131796. autoConfigure(material: NodeMaterial): void;
  131797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131798. isReady(): boolean;
  131799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131800. private _injectVertexCode;
  131801. private _writeOutput;
  131802. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131803. protected _dumpPropertiesCode(): string;
  131804. serialize(): any;
  131805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131806. }
  131807. }
  131808. declare module BABYLON {
  131809. /**
  131810. * Interface used to configure the node material editor
  131811. */
  131812. export interface INodeMaterialEditorOptions {
  131813. /** Define the URl to load node editor script */
  131814. editorURL?: string;
  131815. }
  131816. /** @hidden */
  131817. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  131818. NORMAL: boolean;
  131819. TANGENT: boolean;
  131820. UV1: boolean;
  131821. /** BONES */
  131822. NUM_BONE_INFLUENCERS: number;
  131823. BonesPerMesh: number;
  131824. BONETEXTURE: boolean;
  131825. /** MORPH TARGETS */
  131826. MORPHTARGETS: boolean;
  131827. MORPHTARGETS_NORMAL: boolean;
  131828. MORPHTARGETS_TANGENT: boolean;
  131829. MORPHTARGETS_UV: boolean;
  131830. NUM_MORPH_INFLUENCERS: number;
  131831. /** IMAGE PROCESSING */
  131832. IMAGEPROCESSING: boolean;
  131833. VIGNETTE: boolean;
  131834. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131835. VIGNETTEBLENDMODEOPAQUE: boolean;
  131836. TONEMAPPING: boolean;
  131837. TONEMAPPING_ACES: boolean;
  131838. CONTRAST: boolean;
  131839. EXPOSURE: boolean;
  131840. COLORCURVES: boolean;
  131841. COLORGRADING: boolean;
  131842. COLORGRADING3D: boolean;
  131843. SAMPLER3DGREENDEPTH: boolean;
  131844. SAMPLER3DBGRMAP: boolean;
  131845. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131846. /** MISC. */
  131847. BUMPDIRECTUV: number;
  131848. constructor();
  131849. setValue(name: string, value: boolean): void;
  131850. }
  131851. /**
  131852. * Class used to configure NodeMaterial
  131853. */
  131854. export interface INodeMaterialOptions {
  131855. /**
  131856. * Defines if blocks should emit comments
  131857. */
  131858. emitComments: boolean;
  131859. }
  131860. /**
  131861. * Class used to create a node based material built by assembling shader blocks
  131862. */
  131863. export class NodeMaterial extends PushMaterial {
  131864. private static _BuildIdGenerator;
  131865. private _options;
  131866. private _vertexCompilationState;
  131867. private _fragmentCompilationState;
  131868. private _sharedData;
  131869. private _buildId;
  131870. private _buildWasSuccessful;
  131871. private _cachedWorldViewMatrix;
  131872. private _cachedWorldViewProjectionMatrix;
  131873. private _optimizers;
  131874. private _animationFrame;
  131875. /** Define the Url to load node editor script */
  131876. static EditorURL: string;
  131877. /** Define the Url to load snippets */
  131878. static SnippetUrl: string;
  131879. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  131880. static IgnoreTexturesAtLoadTime: boolean;
  131881. private BJSNODEMATERIALEDITOR;
  131882. /** Get the inspector from bundle or global */
  131883. private _getGlobalNodeMaterialEditor;
  131884. /**
  131885. * Snippet ID if the material was created from the snippet server
  131886. */
  131887. snippetId: string;
  131888. /**
  131889. * Gets or sets data used by visual editor
  131890. * @see https://nme.babylonjs.com
  131891. */
  131892. editorData: any;
  131893. /**
  131894. * 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)
  131895. */
  131896. ignoreAlpha: boolean;
  131897. /**
  131898. * Defines the maximum number of lights that can be used in the material
  131899. */
  131900. maxSimultaneousLights: number;
  131901. /**
  131902. * Observable raised when the material is built
  131903. */
  131904. onBuildObservable: Observable<NodeMaterial>;
  131905. /**
  131906. * Gets or sets the root nodes of the material vertex shader
  131907. */
  131908. _vertexOutputNodes: NodeMaterialBlock[];
  131909. /**
  131910. * Gets or sets the root nodes of the material fragment (pixel) shader
  131911. */
  131912. _fragmentOutputNodes: NodeMaterialBlock[];
  131913. /** Gets or sets options to control the node material overall behavior */
  131914. get options(): INodeMaterialOptions;
  131915. set options(options: INodeMaterialOptions);
  131916. /**
  131917. * Default configuration related to image processing available in the standard Material.
  131918. */
  131919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131920. /**
  131921. * Gets the image processing configuration used either in this material.
  131922. */
  131923. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  131924. /**
  131925. * Sets the Default image processing configuration used either in the this material.
  131926. *
  131927. * If sets to null, the scene one is in use.
  131928. */
  131929. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  131930. /**
  131931. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  131932. */
  131933. attachedBlocks: NodeMaterialBlock[];
  131934. /**
  131935. * Create a new node based material
  131936. * @param name defines the material name
  131937. * @param scene defines the hosting scene
  131938. * @param options defines creation option
  131939. */
  131940. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  131941. /**
  131942. * Gets the current class name of the material e.g. "NodeMaterial"
  131943. * @returns the class name
  131944. */
  131945. getClassName(): string;
  131946. /**
  131947. * Keep track of the image processing observer to allow dispose and replace.
  131948. */
  131949. private _imageProcessingObserver;
  131950. /**
  131951. * Attaches a new image processing configuration to the Standard Material.
  131952. * @param configuration
  131953. */
  131954. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131955. /**
  131956. * Get a block by its name
  131957. * @param name defines the name of the block to retrieve
  131958. * @returns the required block or null if not found
  131959. */
  131960. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  131961. /**
  131962. * Get a block by its name
  131963. * @param predicate defines the predicate used to find the good candidate
  131964. * @returns the required block or null if not found
  131965. */
  131966. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  131967. /**
  131968. * Get an input block by its name
  131969. * @param predicate defines the predicate used to find the good candidate
  131970. * @returns the required input block or null if not found
  131971. */
  131972. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  131973. /**
  131974. * Gets the list of input blocks attached to this material
  131975. * @returns an array of InputBlocks
  131976. */
  131977. getInputBlocks(): InputBlock[];
  131978. /**
  131979. * Adds a new optimizer to the list of optimizers
  131980. * @param optimizer defines the optimizers to add
  131981. * @returns the current material
  131982. */
  131983. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131984. /**
  131985. * Remove an optimizer from the list of optimizers
  131986. * @param optimizer defines the optimizers to remove
  131987. * @returns the current material
  131988. */
  131989. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  131990. /**
  131991. * Add a new block to the list of output nodes
  131992. * @param node defines the node to add
  131993. * @returns the current material
  131994. */
  131995. addOutputNode(node: NodeMaterialBlock): this;
  131996. /**
  131997. * Remove a block from the list of root nodes
  131998. * @param node defines the node to remove
  131999. * @returns the current material
  132000. */
  132001. removeOutputNode(node: NodeMaterialBlock): this;
  132002. private _addVertexOutputNode;
  132003. private _removeVertexOutputNode;
  132004. private _addFragmentOutputNode;
  132005. private _removeFragmentOutputNode;
  132006. /**
  132007. * Specifies if the material will require alpha blending
  132008. * @returns a boolean specifying if alpha blending is needed
  132009. */
  132010. needAlphaBlending(): boolean;
  132011. /**
  132012. * Specifies if this material should be rendered in alpha test mode
  132013. * @returns a boolean specifying if an alpha test is needed.
  132014. */
  132015. needAlphaTesting(): boolean;
  132016. private _initializeBlock;
  132017. private _resetDualBlocks;
  132018. /**
  132019. * Remove a block from the current node material
  132020. * @param block defines the block to remove
  132021. */
  132022. removeBlock(block: NodeMaterialBlock): void;
  132023. /**
  132024. * Build the material and generates the inner effect
  132025. * @param verbose defines if the build should log activity
  132026. */
  132027. build(verbose?: boolean): void;
  132028. /**
  132029. * Runs an otpimization phase to try to improve the shader code
  132030. */
  132031. optimize(): void;
  132032. private _prepareDefinesForAttributes;
  132033. /**
  132034. * Get if the submesh is ready to be used and all its information available.
  132035. * Child classes can use it to update shaders
  132036. * @param mesh defines the mesh to check
  132037. * @param subMesh defines which submesh to check
  132038. * @param useInstances specifies that instances should be used
  132039. * @returns a boolean indicating that the submesh is ready or not
  132040. */
  132041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132042. /**
  132043. * Get a string representing the shaders built by the current node graph
  132044. */
  132045. get compiledShaders(): string;
  132046. /**
  132047. * Binds the world matrix to the material
  132048. * @param world defines the world transformation matrix
  132049. */
  132050. bindOnlyWorldMatrix(world: Matrix): void;
  132051. /**
  132052. * Binds the submesh to this material by preparing the effect and shader to draw
  132053. * @param world defines the world transformation matrix
  132054. * @param mesh defines the mesh containing the submesh
  132055. * @param subMesh defines the submesh to bind the material to
  132056. */
  132057. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132058. /**
  132059. * Gets the active textures from the material
  132060. * @returns an array of textures
  132061. */
  132062. getActiveTextures(): BaseTexture[];
  132063. /**
  132064. * Gets the list of texture blocks
  132065. * @returns an array of texture blocks
  132066. */
  132067. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  132068. /**
  132069. * Specifies if the material uses a texture
  132070. * @param texture defines the texture to check against the material
  132071. * @returns a boolean specifying if the material uses the texture
  132072. */
  132073. hasTexture(texture: BaseTexture): boolean;
  132074. /**
  132075. * Disposes the material
  132076. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  132077. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  132078. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  132079. */
  132080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  132081. /** Creates the node editor window. */
  132082. private _createNodeEditor;
  132083. /**
  132084. * Launch the node material editor
  132085. * @param config Define the configuration of the editor
  132086. * @return a promise fulfilled when the node editor is visible
  132087. */
  132088. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  132089. /**
  132090. * Clear the current material
  132091. */
  132092. clear(): void;
  132093. /**
  132094. * Clear the current material and set it to a default state
  132095. */
  132096. setToDefault(): void;
  132097. /**
  132098. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  132099. * @param url defines the url to load from
  132100. * @returns a promise that will fullfil when the material is fully loaded
  132101. */
  132102. loadAsync(url: string): Promise<void>;
  132103. private _gatherBlocks;
  132104. /**
  132105. * Generate a string containing the code declaration required to create an equivalent of this material
  132106. * @returns a string
  132107. */
  132108. generateCode(): string;
  132109. /**
  132110. * Serializes this material in a JSON representation
  132111. * @returns the serialized material object
  132112. */
  132113. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  132114. private _restoreConnections;
  132115. /**
  132116. * Clear the current graph and load a new one from a serialization object
  132117. * @param source defines the JSON representation of the material
  132118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132119. */
  132120. loadFromSerialization(source: any, rootUrl?: string): void;
  132121. /**
  132122. * Makes a duplicate of the current material.
  132123. * @param name - name to use for the new material.
  132124. */
  132125. clone(name: string): NodeMaterial;
  132126. /**
  132127. * Creates a node material from parsed material data
  132128. * @param source defines the JSON representation of the material
  132129. * @param scene defines the hosting scene
  132130. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132131. * @returns a new node material
  132132. */
  132133. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  132134. /**
  132135. * Creates a node material from a snippet saved in a remote file
  132136. * @param name defines the name of the material to create
  132137. * @param url defines the url to load from
  132138. * @param scene defines the hosting scene
  132139. * @returns a promise that will resolve to the new node material
  132140. */
  132141. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  132142. /**
  132143. * Creates a node material from a snippet saved by the node material editor
  132144. * @param snippetId defines the snippet to load
  132145. * @param scene defines the hosting scene
  132146. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132147. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  132148. * @returns a promise that will resolve to the new node material
  132149. */
  132150. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  132151. /**
  132152. * Creates a new node material set to default basic configuration
  132153. * @param name defines the name of the material
  132154. * @param scene defines the hosting scene
  132155. * @returns a new NodeMaterial
  132156. */
  132157. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  132158. }
  132159. }
  132160. declare module BABYLON {
  132161. /**
  132162. * Block used to read a texture from a sampler
  132163. */
  132164. export class TextureBlock extends NodeMaterialBlock {
  132165. private _defineName;
  132166. private _linearDefineName;
  132167. private _tempTextureRead;
  132168. private _samplerName;
  132169. private _transformedUVName;
  132170. private _textureTransformName;
  132171. private _textureInfoName;
  132172. private _mainUVName;
  132173. private _mainUVDefineName;
  132174. /**
  132175. * Gets or sets the texture associated with the node
  132176. */
  132177. texture: Nullable<Texture>;
  132178. /**
  132179. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  132180. */
  132181. convertToGammaSpace: boolean;
  132182. /**
  132183. * Create a new TextureBlock
  132184. * @param name defines the block name
  132185. */
  132186. constructor(name: string);
  132187. /**
  132188. * Gets the current class name
  132189. * @returns the class name
  132190. */
  132191. getClassName(): string;
  132192. /**
  132193. * Gets the uv input component
  132194. */
  132195. get uv(): NodeMaterialConnectionPoint;
  132196. /**
  132197. * Gets the rgba output component
  132198. */
  132199. get rgba(): NodeMaterialConnectionPoint;
  132200. /**
  132201. * Gets the rgb output component
  132202. */
  132203. get rgb(): NodeMaterialConnectionPoint;
  132204. /**
  132205. * Gets the r output component
  132206. */
  132207. get r(): NodeMaterialConnectionPoint;
  132208. /**
  132209. * Gets the g output component
  132210. */
  132211. get g(): NodeMaterialConnectionPoint;
  132212. /**
  132213. * Gets the b output component
  132214. */
  132215. get b(): NodeMaterialConnectionPoint;
  132216. /**
  132217. * Gets the a output component
  132218. */
  132219. get a(): NodeMaterialConnectionPoint;
  132220. get target(): NodeMaterialBlockTargets;
  132221. autoConfigure(material: NodeMaterial): void;
  132222. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132224. isReady(): boolean;
  132225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132226. private get _isMixed();
  132227. private _injectVertexCode;
  132228. private _writeTextureRead;
  132229. private _writeOutput;
  132230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132231. protected _dumpPropertiesCode(): string;
  132232. serialize(): any;
  132233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132234. }
  132235. }
  132236. declare module BABYLON {
  132237. /**
  132238. * Class used to store shared data between 2 NodeMaterialBuildState
  132239. */
  132240. export class NodeMaterialBuildStateSharedData {
  132241. /**
  132242. * Gets the list of emitted varyings
  132243. */
  132244. temps: string[];
  132245. /**
  132246. * Gets the list of emitted varyings
  132247. */
  132248. varyings: string[];
  132249. /**
  132250. * Gets the varying declaration string
  132251. */
  132252. varyingDeclaration: string;
  132253. /**
  132254. * Input blocks
  132255. */
  132256. inputBlocks: InputBlock[];
  132257. /**
  132258. * Input blocks
  132259. */
  132260. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  132261. /**
  132262. * Bindable blocks (Blocks that need to set data to the effect)
  132263. */
  132264. bindableBlocks: NodeMaterialBlock[];
  132265. /**
  132266. * List of blocks that can provide a compilation fallback
  132267. */
  132268. blocksWithFallbacks: NodeMaterialBlock[];
  132269. /**
  132270. * List of blocks that can provide a define update
  132271. */
  132272. blocksWithDefines: NodeMaterialBlock[];
  132273. /**
  132274. * List of blocks that can provide a repeatable content
  132275. */
  132276. repeatableContentBlocks: NodeMaterialBlock[];
  132277. /**
  132278. * List of blocks that can provide a dynamic list of uniforms
  132279. */
  132280. dynamicUniformBlocks: NodeMaterialBlock[];
  132281. /**
  132282. * List of blocks that can block the isReady function for the material
  132283. */
  132284. blockingBlocks: NodeMaterialBlock[];
  132285. /**
  132286. * Gets the list of animated inputs
  132287. */
  132288. animatedInputs: InputBlock[];
  132289. /**
  132290. * Build Id used to avoid multiple recompilations
  132291. */
  132292. buildId: number;
  132293. /** List of emitted variables */
  132294. variableNames: {
  132295. [key: string]: number;
  132296. };
  132297. /** List of emitted defines */
  132298. defineNames: {
  132299. [key: string]: number;
  132300. };
  132301. /** Should emit comments? */
  132302. emitComments: boolean;
  132303. /** Emit build activity */
  132304. verbose: boolean;
  132305. /** Gets or sets the hosting scene */
  132306. scene: Scene;
  132307. /**
  132308. * Gets the compilation hints emitted at compilation time
  132309. */
  132310. hints: {
  132311. needWorldViewMatrix: boolean;
  132312. needWorldViewProjectionMatrix: boolean;
  132313. needAlphaBlending: boolean;
  132314. needAlphaTesting: boolean;
  132315. };
  132316. /**
  132317. * List of compilation checks
  132318. */
  132319. checks: {
  132320. emitVertex: boolean;
  132321. emitFragment: boolean;
  132322. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  132323. };
  132324. /** Creates a new shared data */
  132325. constructor();
  132326. /**
  132327. * Emits console errors and exceptions if there is a failing check
  132328. */
  132329. emitErrors(): void;
  132330. }
  132331. }
  132332. declare module BABYLON {
  132333. /**
  132334. * Class used to store node based material build state
  132335. */
  132336. export class NodeMaterialBuildState {
  132337. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  132338. supportUniformBuffers: boolean;
  132339. /**
  132340. * Gets the list of emitted attributes
  132341. */
  132342. attributes: string[];
  132343. /**
  132344. * Gets the list of emitted uniforms
  132345. */
  132346. uniforms: string[];
  132347. /**
  132348. * Gets the list of emitted constants
  132349. */
  132350. constants: string[];
  132351. /**
  132352. * Gets the list of emitted samplers
  132353. */
  132354. samplers: string[];
  132355. /**
  132356. * Gets the list of emitted functions
  132357. */
  132358. functions: {
  132359. [key: string]: string;
  132360. };
  132361. /**
  132362. * Gets the list of emitted extensions
  132363. */
  132364. extensions: {
  132365. [key: string]: string;
  132366. };
  132367. /**
  132368. * Gets the target of the compilation state
  132369. */
  132370. target: NodeMaterialBlockTargets;
  132371. /**
  132372. * Gets the list of emitted counters
  132373. */
  132374. counters: {
  132375. [key: string]: number;
  132376. };
  132377. /**
  132378. * Shared data between multiple NodeMaterialBuildState instances
  132379. */
  132380. sharedData: NodeMaterialBuildStateSharedData;
  132381. /** @hidden */
  132382. _vertexState: NodeMaterialBuildState;
  132383. /** @hidden */
  132384. _attributeDeclaration: string;
  132385. /** @hidden */
  132386. _uniformDeclaration: string;
  132387. /** @hidden */
  132388. _constantDeclaration: string;
  132389. /** @hidden */
  132390. _samplerDeclaration: string;
  132391. /** @hidden */
  132392. _varyingTransfer: string;
  132393. private _repeatableContentAnchorIndex;
  132394. /** @hidden */
  132395. _builtCompilationString: string;
  132396. /**
  132397. * Gets the emitted compilation strings
  132398. */
  132399. compilationString: string;
  132400. /**
  132401. * Finalize the compilation strings
  132402. * @param state defines the current compilation state
  132403. */
  132404. finalize(state: NodeMaterialBuildState): void;
  132405. /** @hidden */
  132406. get _repeatableContentAnchor(): string;
  132407. /** @hidden */
  132408. _getFreeVariableName(prefix: string): string;
  132409. /** @hidden */
  132410. _getFreeDefineName(prefix: string): string;
  132411. /** @hidden */
  132412. _excludeVariableName(name: string): void;
  132413. /** @hidden */
  132414. _emit2DSampler(name: string): void;
  132415. /** @hidden */
  132416. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  132417. /** @hidden */
  132418. _emitExtension(name: string, extension: string): void;
  132419. /** @hidden */
  132420. _emitFunction(name: string, code: string, comments: string): void;
  132421. /** @hidden */
  132422. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  132423. replaceStrings?: {
  132424. search: RegExp;
  132425. replace: string;
  132426. }[];
  132427. repeatKey?: string;
  132428. }): string;
  132429. /** @hidden */
  132430. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  132431. repeatKey?: string;
  132432. removeAttributes?: boolean;
  132433. removeUniforms?: boolean;
  132434. removeVaryings?: boolean;
  132435. removeIfDef?: boolean;
  132436. replaceStrings?: {
  132437. search: RegExp;
  132438. replace: string;
  132439. }[];
  132440. }, storeKey?: string): void;
  132441. /** @hidden */
  132442. _registerTempVariable(name: string): boolean;
  132443. /** @hidden */
  132444. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  132445. /** @hidden */
  132446. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  132447. /** @hidden */
  132448. _emitFloat(value: number): string;
  132449. }
  132450. }
  132451. declare module BABYLON {
  132452. /**
  132453. * Defines a block that can be used inside a node based material
  132454. */
  132455. export class NodeMaterialBlock {
  132456. private _buildId;
  132457. private _buildTarget;
  132458. private _target;
  132459. private _isFinalMerger;
  132460. private _isInput;
  132461. protected _isUnique: boolean;
  132462. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  132463. inputsAreExclusive: boolean;
  132464. /** @hidden */
  132465. _codeVariableName: string;
  132466. /** @hidden */
  132467. _inputs: NodeMaterialConnectionPoint[];
  132468. /** @hidden */
  132469. _outputs: NodeMaterialConnectionPoint[];
  132470. /** @hidden */
  132471. _preparationId: number;
  132472. /**
  132473. * Gets or sets the name of the block
  132474. */
  132475. name: string;
  132476. /**
  132477. * Gets or sets the unique id of the node
  132478. */
  132479. uniqueId: number;
  132480. /**
  132481. * Gets or sets the comments associated with this block
  132482. */
  132483. comments: string;
  132484. /**
  132485. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  132486. */
  132487. get isUnique(): boolean;
  132488. /**
  132489. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  132490. */
  132491. get isFinalMerger(): boolean;
  132492. /**
  132493. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  132494. */
  132495. get isInput(): boolean;
  132496. /**
  132497. * Gets or sets the build Id
  132498. */
  132499. get buildId(): number;
  132500. set buildId(value: number);
  132501. /**
  132502. * Gets or sets the target of the block
  132503. */
  132504. get target(): NodeMaterialBlockTargets;
  132505. set target(value: NodeMaterialBlockTargets);
  132506. /**
  132507. * Gets the list of input points
  132508. */
  132509. get inputs(): NodeMaterialConnectionPoint[];
  132510. /** Gets the list of output points */
  132511. get outputs(): NodeMaterialConnectionPoint[];
  132512. /**
  132513. * Find an input by its name
  132514. * @param name defines the name of the input to look for
  132515. * @returns the input or null if not found
  132516. */
  132517. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132518. /**
  132519. * Find an output by its name
  132520. * @param name defines the name of the outputto look for
  132521. * @returns the output or null if not found
  132522. */
  132523. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132524. /**
  132525. * Creates a new NodeMaterialBlock
  132526. * @param name defines the block name
  132527. * @param target defines the target of that block (Vertex by default)
  132528. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  132529. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  132530. */
  132531. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  132532. /**
  132533. * Initialize the block and prepare the context for build
  132534. * @param state defines the state that will be used for the build
  132535. */
  132536. initialize(state: NodeMaterialBuildState): void;
  132537. /**
  132538. * Bind data to effect. Will only be called for blocks with isBindable === true
  132539. * @param effect defines the effect to bind data to
  132540. * @param nodeMaterial defines the hosting NodeMaterial
  132541. * @param mesh defines the mesh that will be rendered
  132542. */
  132543. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132544. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  132545. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  132546. protected _writeFloat(value: number): string;
  132547. /**
  132548. * Gets the current class name e.g. "NodeMaterialBlock"
  132549. * @returns the class name
  132550. */
  132551. getClassName(): string;
  132552. /**
  132553. * Register a new input. Must be called inside a block constructor
  132554. * @param name defines the connection point name
  132555. * @param type defines the connection point type
  132556. * @param isOptional defines a boolean indicating that this input can be omitted
  132557. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132558. * @returns the current block
  132559. */
  132560. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  132561. /**
  132562. * Register a new output. Must be called inside a block constructor
  132563. * @param name defines the connection point name
  132564. * @param type defines the connection point type
  132565. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132566. * @returns the current block
  132567. */
  132568. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  132569. /**
  132570. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  132571. * @param forOutput defines an optional connection point to check compatibility with
  132572. * @returns the first available input or null
  132573. */
  132574. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  132575. /**
  132576. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  132577. * @param forBlock defines an optional block to check compatibility with
  132578. * @returns the first available input or null
  132579. */
  132580. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  132581. /**
  132582. * Gets the sibling of the given output
  132583. * @param current defines the current output
  132584. * @returns the next output in the list or null
  132585. */
  132586. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  132587. /**
  132588. * Connect current block with another block
  132589. * @param other defines the block to connect with
  132590. * @param options define the various options to help pick the right connections
  132591. * @returns the current block
  132592. */
  132593. connectTo(other: NodeMaterialBlock, options?: {
  132594. input?: string;
  132595. output?: string;
  132596. outputSwizzle?: string;
  132597. }): this | undefined;
  132598. protected _buildBlock(state: NodeMaterialBuildState): void;
  132599. /**
  132600. * Add uniforms, samplers and uniform buffers at compilation time
  132601. * @param state defines the state to update
  132602. * @param nodeMaterial defines the node material requesting the update
  132603. * @param defines defines the material defines to update
  132604. * @param uniformBuffers defines the list of uniform buffer names
  132605. */
  132606. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132607. /**
  132608. * Add potential fallbacks if shader compilation fails
  132609. * @param mesh defines the mesh to be rendered
  132610. * @param fallbacks defines the current prioritized list of fallbacks
  132611. */
  132612. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132613. /**
  132614. * Initialize defines for shader compilation
  132615. * @param mesh defines the mesh to be rendered
  132616. * @param nodeMaterial defines the node material requesting the update
  132617. * @param defines defines the material defines to update
  132618. * @param useInstances specifies that instances should be used
  132619. */
  132620. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132621. /**
  132622. * Update defines for shader compilation
  132623. * @param mesh defines the mesh to be rendered
  132624. * @param nodeMaterial defines the node material requesting the update
  132625. * @param defines defines the material defines to update
  132626. * @param useInstances specifies that instances should be used
  132627. */
  132628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132629. /**
  132630. * Lets the block try to connect some inputs automatically
  132631. * @param material defines the hosting NodeMaterial
  132632. */
  132633. autoConfigure(material: NodeMaterial): void;
  132634. /**
  132635. * Function called when a block is declared as repeatable content generator
  132636. * @param vertexShaderState defines the current compilation state for the vertex shader
  132637. * @param fragmentShaderState defines the current compilation state for the fragment shader
  132638. * @param mesh defines the mesh to be rendered
  132639. * @param defines defines the material defines to update
  132640. */
  132641. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132642. /**
  132643. * Checks if the block is ready
  132644. * @param mesh defines the mesh to be rendered
  132645. * @param nodeMaterial defines the node material requesting the update
  132646. * @param defines defines the material defines to update
  132647. * @param useInstances specifies that instances should be used
  132648. * @returns true if the block is ready
  132649. */
  132650. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  132651. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  132652. private _processBuild;
  132653. /**
  132654. * Compile the current node and generate the shader code
  132655. * @param state defines the current compilation state (uniforms, samplers, current string)
  132656. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  132657. * @returns true if already built
  132658. */
  132659. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  132660. protected _inputRename(name: string): string;
  132661. protected _outputRename(name: string): string;
  132662. protected _dumpPropertiesCode(): string;
  132663. /** @hidden */
  132664. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  132665. /** @hidden */
  132666. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  132667. /**
  132668. * Clone the current block to a new identical block
  132669. * @param scene defines the hosting scene
  132670. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132671. * @returns a copy of the current block
  132672. */
  132673. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  132674. /**
  132675. * Serializes this block in a JSON representation
  132676. * @returns the serialized block object
  132677. */
  132678. serialize(): any;
  132679. /** @hidden */
  132680. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132681. /**
  132682. * Release resources
  132683. */
  132684. dispose(): void;
  132685. }
  132686. }
  132687. declare module BABYLON {
  132688. /**
  132689. * Enum defining the type of animations supported by InputBlock
  132690. */
  132691. export enum AnimatedInputBlockTypes {
  132692. /** No animation */
  132693. None = 0,
  132694. /** Time based animation. Will only work for floats */
  132695. Time = 1
  132696. }
  132697. }
  132698. declare module BABYLON {
  132699. /**
  132700. * Block used to expose an input value
  132701. */
  132702. export class InputBlock extends NodeMaterialBlock {
  132703. private _mode;
  132704. private _associatedVariableName;
  132705. private _storedValue;
  132706. private _valueCallback;
  132707. private _type;
  132708. private _animationType;
  132709. /** Gets or set a value used to limit the range of float values */
  132710. min: number;
  132711. /** Gets or set a value used to limit the range of float values */
  132712. max: number;
  132713. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  132714. isBoolean: boolean;
  132715. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  132716. matrixMode: number;
  132717. /** @hidden */
  132718. _systemValue: Nullable<NodeMaterialSystemValues>;
  132719. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  132720. visibleInInspector: boolean;
  132721. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  132722. isConstant: boolean;
  132723. /** Gets or sets the group to use to display this block in the Inspector */
  132724. groupInInspector: string;
  132725. /** Gets an observable raised when the value is changed */
  132726. onValueChangedObservable: Observable<InputBlock>;
  132727. /**
  132728. * Gets or sets the connection point type (default is float)
  132729. */
  132730. get type(): NodeMaterialBlockConnectionPointTypes;
  132731. /**
  132732. * Creates a new InputBlock
  132733. * @param name defines the block name
  132734. * @param target defines the target of that block (Vertex by default)
  132735. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  132736. */
  132737. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  132738. /**
  132739. * Gets the output component
  132740. */
  132741. get output(): NodeMaterialConnectionPoint;
  132742. /**
  132743. * Set the source of this connection point to a vertex attribute
  132744. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  132745. * @returns the current connection point
  132746. */
  132747. setAsAttribute(attributeName?: string): InputBlock;
  132748. /**
  132749. * Set the source of this connection point to a system value
  132750. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  132751. * @returns the current connection point
  132752. */
  132753. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  132754. /**
  132755. * Gets or sets the value of that point.
  132756. * Please note that this value will be ignored if valueCallback is defined
  132757. */
  132758. get value(): any;
  132759. set value(value: any);
  132760. /**
  132761. * Gets or sets a callback used to get the value of that point.
  132762. * Please note that setting this value will force the connection point to ignore the value property
  132763. */
  132764. get valueCallback(): () => any;
  132765. set valueCallback(value: () => any);
  132766. /**
  132767. * Gets or sets the associated variable name in the shader
  132768. */
  132769. get associatedVariableName(): string;
  132770. set associatedVariableName(value: string);
  132771. /** Gets or sets the type of animation applied to the input */
  132772. get animationType(): AnimatedInputBlockTypes;
  132773. set animationType(value: AnimatedInputBlockTypes);
  132774. /**
  132775. * Gets a boolean indicating that this connection point not defined yet
  132776. */
  132777. get isUndefined(): boolean;
  132778. /**
  132779. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  132780. * In this case the connection point name must be the name of the uniform to use.
  132781. * Can only be set on inputs
  132782. */
  132783. get isUniform(): boolean;
  132784. set isUniform(value: boolean);
  132785. /**
  132786. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  132787. * In this case the connection point name must be the name of the attribute to use
  132788. * Can only be set on inputs
  132789. */
  132790. get isAttribute(): boolean;
  132791. set isAttribute(value: boolean);
  132792. /**
  132793. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  132794. * Can only be set on exit points
  132795. */
  132796. get isVarying(): boolean;
  132797. set isVarying(value: boolean);
  132798. /**
  132799. * Gets a boolean indicating that the current connection point is a system value
  132800. */
  132801. get isSystemValue(): boolean;
  132802. /**
  132803. * Gets or sets the current well known value or null if not defined as a system value
  132804. */
  132805. get systemValue(): Nullable<NodeMaterialSystemValues>;
  132806. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  132807. /**
  132808. * Gets the current class name
  132809. * @returns the class name
  132810. */
  132811. getClassName(): string;
  132812. /**
  132813. * Animate the input if animationType !== None
  132814. * @param scene defines the rendering scene
  132815. */
  132816. animate(scene: Scene): void;
  132817. private _emitDefine;
  132818. initialize(state: NodeMaterialBuildState): void;
  132819. /**
  132820. * Set the input block to its default value (based on its type)
  132821. */
  132822. setDefaultValue(): void;
  132823. private _emitConstant;
  132824. private _emit;
  132825. /** @hidden */
  132826. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  132827. /** @hidden */
  132828. _transmit(effect: Effect, scene: Scene): void;
  132829. protected _buildBlock(state: NodeMaterialBuildState): void;
  132830. protected _dumpPropertiesCode(): string;
  132831. dispose(): void;
  132832. serialize(): any;
  132833. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132834. }
  132835. }
  132836. declare module BABYLON {
  132837. /**
  132838. * Enum used to define the compatibility state between two connection points
  132839. */
  132840. export enum NodeMaterialConnectionPointCompatibilityStates {
  132841. /** Points are compatibles */
  132842. Compatible = 0,
  132843. /** Points are incompatible because of their types */
  132844. TypeIncompatible = 1,
  132845. /** Points are incompatible because of their targets (vertex vs fragment) */
  132846. TargetIncompatible = 2
  132847. }
  132848. /**
  132849. * Defines the direction of a connection point
  132850. */
  132851. export enum NodeMaterialConnectionPointDirection {
  132852. /** Input */
  132853. Input = 0,
  132854. /** Output */
  132855. Output = 1
  132856. }
  132857. /**
  132858. * Defines a connection point for a block
  132859. */
  132860. export class NodeMaterialConnectionPoint {
  132861. /** @hidden */
  132862. _ownerBlock: NodeMaterialBlock;
  132863. /** @hidden */
  132864. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  132865. private _endpoints;
  132866. private _associatedVariableName;
  132867. private _direction;
  132868. /** @hidden */
  132869. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132870. /** @hidden */
  132871. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132872. private _type;
  132873. /** @hidden */
  132874. _enforceAssociatedVariableName: boolean;
  132875. /** Gets the direction of the point */
  132876. get direction(): NodeMaterialConnectionPointDirection;
  132877. /**
  132878. * Gets or sets the additional types supported by this connection point
  132879. */
  132880. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132881. /**
  132882. * Gets or sets the additional types excluded by this connection point
  132883. */
  132884. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132885. /**
  132886. * Observable triggered when this point is connected
  132887. */
  132888. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  132889. /**
  132890. * Gets or sets the associated variable name in the shader
  132891. */
  132892. get associatedVariableName(): string;
  132893. set associatedVariableName(value: string);
  132894. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  132895. get innerType(): NodeMaterialBlockConnectionPointTypes;
  132896. /**
  132897. * Gets or sets the connection point type (default is float)
  132898. */
  132899. get type(): NodeMaterialBlockConnectionPointTypes;
  132900. set type(value: NodeMaterialBlockConnectionPointTypes);
  132901. /**
  132902. * Gets or sets the connection point name
  132903. */
  132904. name: string;
  132905. /**
  132906. * Gets or sets a boolean indicating that this connection point can be omitted
  132907. */
  132908. isOptional: boolean;
  132909. /**
  132910. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  132911. */
  132912. define: string;
  132913. /** @hidden */
  132914. _prioritizeVertex: boolean;
  132915. private _target;
  132916. /** Gets or sets the target of that connection point */
  132917. get target(): NodeMaterialBlockTargets;
  132918. set target(value: NodeMaterialBlockTargets);
  132919. /**
  132920. * Gets a boolean indicating that the current point is connected
  132921. */
  132922. get isConnected(): boolean;
  132923. /**
  132924. * Gets a boolean indicating that the current point is connected to an input block
  132925. */
  132926. get isConnectedToInputBlock(): boolean;
  132927. /**
  132928. * Gets a the connected input block (if any)
  132929. */
  132930. get connectInputBlock(): Nullable<InputBlock>;
  132931. /** Get the other side of the connection (if any) */
  132932. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  132933. /** Get the block that owns this connection point */
  132934. get ownerBlock(): NodeMaterialBlock;
  132935. /** Get the block connected on the other side of this connection (if any) */
  132936. get sourceBlock(): Nullable<NodeMaterialBlock>;
  132937. /** Get the block connected on the endpoints of this connection (if any) */
  132938. get connectedBlocks(): Array<NodeMaterialBlock>;
  132939. /** Gets the list of connected endpoints */
  132940. get endpoints(): NodeMaterialConnectionPoint[];
  132941. /** Gets a boolean indicating if that output point is connected to at least one input */
  132942. get hasEndpoints(): boolean;
  132943. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  132944. get isConnectedInVertexShader(): boolean;
  132945. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  132946. get isConnectedInFragmentShader(): boolean;
  132947. /**
  132948. * Creates a new connection point
  132949. * @param name defines the connection point name
  132950. * @param ownerBlock defines the block hosting this connection point
  132951. * @param direction defines the direction of the connection point
  132952. */
  132953. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  132954. /**
  132955. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  132956. * @returns the class name
  132957. */
  132958. getClassName(): string;
  132959. /**
  132960. * Gets a boolean indicating if the current point can be connected to another point
  132961. * @param connectionPoint defines the other connection point
  132962. * @returns a boolean
  132963. */
  132964. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  132965. /**
  132966. * Gets a number indicating if the current point can be connected to another point
  132967. * @param connectionPoint defines the other connection point
  132968. * @returns a number defining the compatibility state
  132969. */
  132970. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  132971. /**
  132972. * Connect this point to another connection point
  132973. * @param connectionPoint defines the other connection point
  132974. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  132975. * @returns the current connection point
  132976. */
  132977. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  132978. /**
  132979. * Disconnect this point from one of his endpoint
  132980. * @param endpoint defines the other connection point
  132981. * @returns the current connection point
  132982. */
  132983. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  132984. /**
  132985. * Serializes this point in a JSON representation
  132986. * @returns the serialized point object
  132987. */
  132988. serialize(): any;
  132989. /**
  132990. * Release resources
  132991. */
  132992. dispose(): void;
  132993. }
  132994. }
  132995. declare module BABYLON {
  132996. /**
  132997. * Block used to add support for vertex skinning (bones)
  132998. */
  132999. export class BonesBlock extends NodeMaterialBlock {
  133000. /**
  133001. * Creates a new BonesBlock
  133002. * @param name defines the block name
  133003. */
  133004. constructor(name: string);
  133005. /**
  133006. * Initialize the block and prepare the context for build
  133007. * @param state defines the state that will be used for the build
  133008. */
  133009. initialize(state: NodeMaterialBuildState): void;
  133010. /**
  133011. * Gets the current class name
  133012. * @returns the class name
  133013. */
  133014. getClassName(): string;
  133015. /**
  133016. * Gets the matrix indices input component
  133017. */
  133018. get matricesIndices(): NodeMaterialConnectionPoint;
  133019. /**
  133020. * Gets the matrix weights input component
  133021. */
  133022. get matricesWeights(): NodeMaterialConnectionPoint;
  133023. /**
  133024. * Gets the extra matrix indices input component
  133025. */
  133026. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  133027. /**
  133028. * Gets the extra matrix weights input component
  133029. */
  133030. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  133031. /**
  133032. * Gets the world input component
  133033. */
  133034. get world(): NodeMaterialConnectionPoint;
  133035. /**
  133036. * Gets the output component
  133037. */
  133038. get output(): NodeMaterialConnectionPoint;
  133039. autoConfigure(material: NodeMaterial): void;
  133040. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  133041. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133043. protected _buildBlock(state: NodeMaterialBuildState): this;
  133044. }
  133045. }
  133046. declare module BABYLON {
  133047. /**
  133048. * Block used to add support for instances
  133049. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  133050. */
  133051. export class InstancesBlock extends NodeMaterialBlock {
  133052. /**
  133053. * Creates a new InstancesBlock
  133054. * @param name defines the block name
  133055. */
  133056. constructor(name: string);
  133057. /**
  133058. * Gets the current class name
  133059. * @returns the class name
  133060. */
  133061. getClassName(): string;
  133062. /**
  133063. * Gets the first world row input component
  133064. */
  133065. get world0(): NodeMaterialConnectionPoint;
  133066. /**
  133067. * Gets the second world row input component
  133068. */
  133069. get world1(): NodeMaterialConnectionPoint;
  133070. /**
  133071. * Gets the third world row input component
  133072. */
  133073. get world2(): NodeMaterialConnectionPoint;
  133074. /**
  133075. * Gets the forth world row input component
  133076. */
  133077. get world3(): NodeMaterialConnectionPoint;
  133078. /**
  133079. * Gets the world input component
  133080. */
  133081. get world(): NodeMaterialConnectionPoint;
  133082. /**
  133083. * Gets the output component
  133084. */
  133085. get output(): NodeMaterialConnectionPoint;
  133086. /**
  133087. * Gets the isntanceID component
  133088. */
  133089. get instanceID(): NodeMaterialConnectionPoint;
  133090. autoConfigure(material: NodeMaterial): void;
  133091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133092. protected _buildBlock(state: NodeMaterialBuildState): this;
  133093. }
  133094. }
  133095. declare module BABYLON {
  133096. /**
  133097. * Block used to add morph targets support to vertex shader
  133098. */
  133099. export class MorphTargetsBlock extends NodeMaterialBlock {
  133100. private _repeatableContentAnchor;
  133101. /**
  133102. * Create a new MorphTargetsBlock
  133103. * @param name defines the block name
  133104. */
  133105. constructor(name: string);
  133106. /**
  133107. * Gets the current class name
  133108. * @returns the class name
  133109. */
  133110. getClassName(): string;
  133111. /**
  133112. * Gets the position input component
  133113. */
  133114. get position(): NodeMaterialConnectionPoint;
  133115. /**
  133116. * Gets the normal input component
  133117. */
  133118. get normal(): NodeMaterialConnectionPoint;
  133119. /**
  133120. * Gets the tangent input component
  133121. */
  133122. get tangent(): NodeMaterialConnectionPoint;
  133123. /**
  133124. * Gets the tangent input component
  133125. */
  133126. get uv(): NodeMaterialConnectionPoint;
  133127. /**
  133128. * Gets the position output component
  133129. */
  133130. get positionOutput(): NodeMaterialConnectionPoint;
  133131. /**
  133132. * Gets the normal output component
  133133. */
  133134. get normalOutput(): NodeMaterialConnectionPoint;
  133135. /**
  133136. * Gets the tangent output component
  133137. */
  133138. get tangentOutput(): NodeMaterialConnectionPoint;
  133139. /**
  133140. * Gets the tangent output component
  133141. */
  133142. get uvOutput(): NodeMaterialConnectionPoint;
  133143. initialize(state: NodeMaterialBuildState): void;
  133144. autoConfigure(material: NodeMaterial): void;
  133145. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133146. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133147. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  133148. protected _buildBlock(state: NodeMaterialBuildState): this;
  133149. }
  133150. }
  133151. declare module BABYLON {
  133152. /**
  133153. * Block used to get data information from a light
  133154. */
  133155. export class LightInformationBlock extends NodeMaterialBlock {
  133156. private _lightDataUniformName;
  133157. private _lightColorUniformName;
  133158. private _lightTypeDefineName;
  133159. /**
  133160. * Gets or sets the light associated with this block
  133161. */
  133162. light: Nullable<Light>;
  133163. /**
  133164. * Creates a new LightInformationBlock
  133165. * @param name defines the block name
  133166. */
  133167. constructor(name: string);
  133168. /**
  133169. * Gets the current class name
  133170. * @returns the class name
  133171. */
  133172. getClassName(): string;
  133173. /**
  133174. * Gets the world position input component
  133175. */
  133176. get worldPosition(): NodeMaterialConnectionPoint;
  133177. /**
  133178. * Gets the direction output component
  133179. */
  133180. get direction(): NodeMaterialConnectionPoint;
  133181. /**
  133182. * Gets the direction output component
  133183. */
  133184. get color(): NodeMaterialConnectionPoint;
  133185. /**
  133186. * Gets the direction output component
  133187. */
  133188. get intensity(): NodeMaterialConnectionPoint;
  133189. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133190. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133191. protected _buildBlock(state: NodeMaterialBuildState): this;
  133192. serialize(): any;
  133193. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133194. }
  133195. }
  133196. declare module BABYLON {
  133197. /**
  133198. * Block used to add image processing support to fragment shader
  133199. */
  133200. export class ImageProcessingBlock extends NodeMaterialBlock {
  133201. /**
  133202. * Create a new ImageProcessingBlock
  133203. * @param name defines the block name
  133204. */
  133205. constructor(name: string);
  133206. /**
  133207. * Gets the current class name
  133208. * @returns the class name
  133209. */
  133210. getClassName(): string;
  133211. /**
  133212. * Gets the color input component
  133213. */
  133214. get color(): NodeMaterialConnectionPoint;
  133215. /**
  133216. * Gets the output component
  133217. */
  133218. get output(): NodeMaterialConnectionPoint;
  133219. /**
  133220. * Initialize the block and prepare the context for build
  133221. * @param state defines the state that will be used for the build
  133222. */
  133223. initialize(state: NodeMaterialBuildState): void;
  133224. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  133225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133226. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133227. protected _buildBlock(state: NodeMaterialBuildState): this;
  133228. }
  133229. }
  133230. declare module BABYLON {
  133231. /**
  133232. * Block used to pertub normals based on a normal map
  133233. */
  133234. export class PerturbNormalBlock extends NodeMaterialBlock {
  133235. private _tangentSpaceParameterName;
  133236. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133237. invertX: boolean;
  133238. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  133239. invertY: boolean;
  133240. /**
  133241. * Create a new PerturbNormalBlock
  133242. * @param name defines the block name
  133243. */
  133244. constructor(name: string);
  133245. /**
  133246. * Gets the current class name
  133247. * @returns the class name
  133248. */
  133249. getClassName(): string;
  133250. /**
  133251. * Gets the world position input component
  133252. */
  133253. get worldPosition(): NodeMaterialConnectionPoint;
  133254. /**
  133255. * Gets the world normal input component
  133256. */
  133257. get worldNormal(): NodeMaterialConnectionPoint;
  133258. /**
  133259. * Gets the world tangent input component
  133260. */
  133261. get worldTangent(): NodeMaterialConnectionPoint;
  133262. /**
  133263. * Gets the uv input component
  133264. */
  133265. get uv(): NodeMaterialConnectionPoint;
  133266. /**
  133267. * Gets the normal map color input component
  133268. */
  133269. get normalMapColor(): NodeMaterialConnectionPoint;
  133270. /**
  133271. * Gets the strength input component
  133272. */
  133273. get strength(): NodeMaterialConnectionPoint;
  133274. /**
  133275. * Gets the output component
  133276. */
  133277. get output(): NodeMaterialConnectionPoint;
  133278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133279. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133280. autoConfigure(material: NodeMaterial): void;
  133281. protected _buildBlock(state: NodeMaterialBuildState): this;
  133282. protected _dumpPropertiesCode(): string;
  133283. serialize(): any;
  133284. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133285. }
  133286. }
  133287. declare module BABYLON {
  133288. /**
  133289. * Block used to discard a pixel if a value is smaller than a cutoff
  133290. */
  133291. export class DiscardBlock extends NodeMaterialBlock {
  133292. /**
  133293. * Create a new DiscardBlock
  133294. * @param name defines the block name
  133295. */
  133296. constructor(name: string);
  133297. /**
  133298. * Gets the current class name
  133299. * @returns the class name
  133300. */
  133301. getClassName(): string;
  133302. /**
  133303. * Gets the color input component
  133304. */
  133305. get value(): NodeMaterialConnectionPoint;
  133306. /**
  133307. * Gets the cutoff input component
  133308. */
  133309. get cutoff(): NodeMaterialConnectionPoint;
  133310. protected _buildBlock(state: NodeMaterialBuildState): this;
  133311. }
  133312. }
  133313. declare module BABYLON {
  133314. /**
  133315. * Block used to test if the fragment shader is front facing
  133316. */
  133317. export class FrontFacingBlock extends NodeMaterialBlock {
  133318. /**
  133319. * Creates a new FrontFacingBlock
  133320. * @param name defines the block name
  133321. */
  133322. constructor(name: string);
  133323. /**
  133324. * Gets the current class name
  133325. * @returns the class name
  133326. */
  133327. getClassName(): string;
  133328. /**
  133329. * Gets the output component
  133330. */
  133331. get output(): NodeMaterialConnectionPoint;
  133332. protected _buildBlock(state: NodeMaterialBuildState): this;
  133333. }
  133334. }
  133335. declare module BABYLON {
  133336. /**
  133337. * Block used to get the derivative value on x and y of a given input
  133338. */
  133339. export class DerivativeBlock extends NodeMaterialBlock {
  133340. /**
  133341. * Create a new DerivativeBlock
  133342. * @param name defines the block name
  133343. */
  133344. constructor(name: string);
  133345. /**
  133346. * Gets the current class name
  133347. * @returns the class name
  133348. */
  133349. getClassName(): string;
  133350. /**
  133351. * Gets the input component
  133352. */
  133353. get input(): NodeMaterialConnectionPoint;
  133354. /**
  133355. * Gets the derivative output on x
  133356. */
  133357. get dx(): NodeMaterialConnectionPoint;
  133358. /**
  133359. * Gets the derivative output on y
  133360. */
  133361. get dy(): NodeMaterialConnectionPoint;
  133362. protected _buildBlock(state: NodeMaterialBuildState): this;
  133363. }
  133364. }
  133365. declare module BABYLON {
  133366. /**
  133367. * Block used to add support for scene fog
  133368. */
  133369. export class FogBlock extends NodeMaterialBlock {
  133370. private _fogDistanceName;
  133371. private _fogParameters;
  133372. /**
  133373. * Create a new FogBlock
  133374. * @param name defines the block name
  133375. */
  133376. constructor(name: string);
  133377. /**
  133378. * Gets the current class name
  133379. * @returns the class name
  133380. */
  133381. getClassName(): string;
  133382. /**
  133383. * Gets the world position input component
  133384. */
  133385. get worldPosition(): NodeMaterialConnectionPoint;
  133386. /**
  133387. * Gets the view input component
  133388. */
  133389. get view(): NodeMaterialConnectionPoint;
  133390. /**
  133391. * Gets the color input component
  133392. */
  133393. get input(): NodeMaterialConnectionPoint;
  133394. /**
  133395. * Gets the fog color input component
  133396. */
  133397. get fogColor(): NodeMaterialConnectionPoint;
  133398. /**
  133399. * Gets the output component
  133400. */
  133401. get output(): NodeMaterialConnectionPoint;
  133402. autoConfigure(material: NodeMaterial): void;
  133403. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133405. protected _buildBlock(state: NodeMaterialBuildState): this;
  133406. }
  133407. }
  133408. declare module BABYLON {
  133409. /**
  133410. * Block used to add light in the fragment shader
  133411. */
  133412. export class LightBlock extends NodeMaterialBlock {
  133413. private _lightId;
  133414. /**
  133415. * Gets or sets the light associated with this block
  133416. */
  133417. light: Nullable<Light>;
  133418. /**
  133419. * Create a new LightBlock
  133420. * @param name defines the block name
  133421. */
  133422. constructor(name: string);
  133423. /**
  133424. * Gets the current class name
  133425. * @returns the class name
  133426. */
  133427. getClassName(): string;
  133428. /**
  133429. * Gets the world position input component
  133430. */
  133431. get worldPosition(): NodeMaterialConnectionPoint;
  133432. /**
  133433. * Gets the world normal input component
  133434. */
  133435. get worldNormal(): NodeMaterialConnectionPoint;
  133436. /**
  133437. * Gets the camera (or eye) position component
  133438. */
  133439. get cameraPosition(): NodeMaterialConnectionPoint;
  133440. /**
  133441. * Gets the glossiness component
  133442. */
  133443. get glossiness(): NodeMaterialConnectionPoint;
  133444. /**
  133445. * Gets the glossinness power component
  133446. */
  133447. get glossPower(): NodeMaterialConnectionPoint;
  133448. /**
  133449. * Gets the diffuse color component
  133450. */
  133451. get diffuseColor(): NodeMaterialConnectionPoint;
  133452. /**
  133453. * Gets the specular color component
  133454. */
  133455. get specularColor(): NodeMaterialConnectionPoint;
  133456. /**
  133457. * Gets the diffuse output component
  133458. */
  133459. get diffuseOutput(): NodeMaterialConnectionPoint;
  133460. /**
  133461. * Gets the specular output component
  133462. */
  133463. get specularOutput(): NodeMaterialConnectionPoint;
  133464. /**
  133465. * Gets the shadow output component
  133466. */
  133467. get shadow(): NodeMaterialConnectionPoint;
  133468. autoConfigure(material: NodeMaterial): void;
  133469. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133470. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133471. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133472. private _injectVertexCode;
  133473. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133474. serialize(): any;
  133475. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133476. }
  133477. }
  133478. declare module BABYLON {
  133479. /**
  133480. * Block used to multiply 2 values
  133481. */
  133482. export class MultiplyBlock extends NodeMaterialBlock {
  133483. /**
  133484. * Creates a new MultiplyBlock
  133485. * @param name defines the block name
  133486. */
  133487. constructor(name: string);
  133488. /**
  133489. * Gets the current class name
  133490. * @returns the class name
  133491. */
  133492. getClassName(): string;
  133493. /**
  133494. * Gets the left operand input component
  133495. */
  133496. get left(): NodeMaterialConnectionPoint;
  133497. /**
  133498. * Gets the right operand input component
  133499. */
  133500. get right(): NodeMaterialConnectionPoint;
  133501. /**
  133502. * Gets the output component
  133503. */
  133504. get output(): NodeMaterialConnectionPoint;
  133505. protected _buildBlock(state: NodeMaterialBuildState): this;
  133506. }
  133507. }
  133508. declare module BABYLON {
  133509. /**
  133510. * Block used to add 2 vectors
  133511. */
  133512. export class AddBlock extends NodeMaterialBlock {
  133513. /**
  133514. * Creates a new AddBlock
  133515. * @param name defines the block name
  133516. */
  133517. constructor(name: string);
  133518. /**
  133519. * Gets the current class name
  133520. * @returns the class name
  133521. */
  133522. getClassName(): string;
  133523. /**
  133524. * Gets the left operand input component
  133525. */
  133526. get left(): NodeMaterialConnectionPoint;
  133527. /**
  133528. * Gets the right operand input component
  133529. */
  133530. get right(): NodeMaterialConnectionPoint;
  133531. /**
  133532. * Gets the output component
  133533. */
  133534. get output(): NodeMaterialConnectionPoint;
  133535. protected _buildBlock(state: NodeMaterialBuildState): this;
  133536. }
  133537. }
  133538. declare module BABYLON {
  133539. /**
  133540. * Block used to scale a vector by a float
  133541. */
  133542. export class ScaleBlock extends NodeMaterialBlock {
  133543. /**
  133544. * Creates a new ScaleBlock
  133545. * @param name defines the block name
  133546. */
  133547. constructor(name: string);
  133548. /**
  133549. * Gets the current class name
  133550. * @returns the class name
  133551. */
  133552. getClassName(): string;
  133553. /**
  133554. * Gets the input component
  133555. */
  133556. get input(): NodeMaterialConnectionPoint;
  133557. /**
  133558. * Gets the factor input component
  133559. */
  133560. get factor(): NodeMaterialConnectionPoint;
  133561. /**
  133562. * Gets the output component
  133563. */
  133564. get output(): NodeMaterialConnectionPoint;
  133565. protected _buildBlock(state: NodeMaterialBuildState): this;
  133566. }
  133567. }
  133568. declare module BABYLON {
  133569. /**
  133570. * Block used to clamp a float
  133571. */
  133572. export class ClampBlock extends NodeMaterialBlock {
  133573. /** Gets or sets the minimum range */
  133574. minimum: number;
  133575. /** Gets or sets the maximum range */
  133576. maximum: number;
  133577. /**
  133578. * Creates a new ClampBlock
  133579. * @param name defines the block name
  133580. */
  133581. constructor(name: string);
  133582. /**
  133583. * Gets the current class name
  133584. * @returns the class name
  133585. */
  133586. getClassName(): string;
  133587. /**
  133588. * Gets the value input component
  133589. */
  133590. get value(): NodeMaterialConnectionPoint;
  133591. /**
  133592. * Gets the output component
  133593. */
  133594. get output(): NodeMaterialConnectionPoint;
  133595. protected _buildBlock(state: NodeMaterialBuildState): this;
  133596. protected _dumpPropertiesCode(): string;
  133597. serialize(): any;
  133598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133599. }
  133600. }
  133601. declare module BABYLON {
  133602. /**
  133603. * Block used to apply a cross product between 2 vectors
  133604. */
  133605. export class CrossBlock extends NodeMaterialBlock {
  133606. /**
  133607. * Creates a new CrossBlock
  133608. * @param name defines the block name
  133609. */
  133610. constructor(name: string);
  133611. /**
  133612. * Gets the current class name
  133613. * @returns the class name
  133614. */
  133615. getClassName(): string;
  133616. /**
  133617. * Gets the left operand input component
  133618. */
  133619. get left(): NodeMaterialConnectionPoint;
  133620. /**
  133621. * Gets the right operand input component
  133622. */
  133623. get right(): NodeMaterialConnectionPoint;
  133624. /**
  133625. * Gets the output component
  133626. */
  133627. get output(): NodeMaterialConnectionPoint;
  133628. protected _buildBlock(state: NodeMaterialBuildState): this;
  133629. }
  133630. }
  133631. declare module BABYLON {
  133632. /**
  133633. * Block used to apply a dot product between 2 vectors
  133634. */
  133635. export class DotBlock extends NodeMaterialBlock {
  133636. /**
  133637. * Creates a new DotBlock
  133638. * @param name defines the block name
  133639. */
  133640. constructor(name: string);
  133641. /**
  133642. * Gets the current class name
  133643. * @returns the class name
  133644. */
  133645. getClassName(): string;
  133646. /**
  133647. * Gets the left operand input component
  133648. */
  133649. get left(): NodeMaterialConnectionPoint;
  133650. /**
  133651. * Gets the right operand input component
  133652. */
  133653. get right(): NodeMaterialConnectionPoint;
  133654. /**
  133655. * Gets the output component
  133656. */
  133657. get output(): NodeMaterialConnectionPoint;
  133658. protected _buildBlock(state: NodeMaterialBuildState): this;
  133659. }
  133660. }
  133661. declare module BABYLON {
  133662. /**
  133663. * Block used to remap a float from a range to a new one
  133664. */
  133665. export class RemapBlock extends NodeMaterialBlock {
  133666. /**
  133667. * Gets or sets the source range
  133668. */
  133669. sourceRange: Vector2;
  133670. /**
  133671. * Gets or sets the target range
  133672. */
  133673. targetRange: Vector2;
  133674. /**
  133675. * Creates a new RemapBlock
  133676. * @param name defines the block name
  133677. */
  133678. constructor(name: string);
  133679. /**
  133680. * Gets the current class name
  133681. * @returns the class name
  133682. */
  133683. getClassName(): string;
  133684. /**
  133685. * Gets the input component
  133686. */
  133687. get input(): NodeMaterialConnectionPoint;
  133688. /**
  133689. * Gets the source min input component
  133690. */
  133691. get sourceMin(): NodeMaterialConnectionPoint;
  133692. /**
  133693. * Gets the source max input component
  133694. */
  133695. get sourceMax(): NodeMaterialConnectionPoint;
  133696. /**
  133697. * Gets the target min input component
  133698. */
  133699. get targetMin(): NodeMaterialConnectionPoint;
  133700. /**
  133701. * Gets the target max input component
  133702. */
  133703. get targetMax(): NodeMaterialConnectionPoint;
  133704. /**
  133705. * Gets the output component
  133706. */
  133707. get output(): NodeMaterialConnectionPoint;
  133708. protected _buildBlock(state: NodeMaterialBuildState): this;
  133709. protected _dumpPropertiesCode(): string;
  133710. serialize(): any;
  133711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133712. }
  133713. }
  133714. declare module BABYLON {
  133715. /**
  133716. * Block used to normalize a vector
  133717. */
  133718. export class NormalizeBlock extends NodeMaterialBlock {
  133719. /**
  133720. * Creates a new NormalizeBlock
  133721. * @param name defines the block name
  133722. */
  133723. constructor(name: string);
  133724. /**
  133725. * Gets the current class name
  133726. * @returns the class name
  133727. */
  133728. getClassName(): string;
  133729. /**
  133730. * Gets the input component
  133731. */
  133732. get input(): NodeMaterialConnectionPoint;
  133733. /**
  133734. * Gets the output component
  133735. */
  133736. get output(): NodeMaterialConnectionPoint;
  133737. protected _buildBlock(state: NodeMaterialBuildState): this;
  133738. }
  133739. }
  133740. declare module BABYLON {
  133741. /**
  133742. * Operations supported by the Trigonometry block
  133743. */
  133744. export enum TrigonometryBlockOperations {
  133745. /** Cos */
  133746. Cos = 0,
  133747. /** Sin */
  133748. Sin = 1,
  133749. /** Abs */
  133750. Abs = 2,
  133751. /** Exp */
  133752. Exp = 3,
  133753. /** Exp2 */
  133754. Exp2 = 4,
  133755. /** Round */
  133756. Round = 5,
  133757. /** Floor */
  133758. Floor = 6,
  133759. /** Ceiling */
  133760. Ceiling = 7,
  133761. /** Square root */
  133762. Sqrt = 8,
  133763. /** Log */
  133764. Log = 9,
  133765. /** Tangent */
  133766. Tan = 10,
  133767. /** Arc tangent */
  133768. ArcTan = 11,
  133769. /** Arc cosinus */
  133770. ArcCos = 12,
  133771. /** Arc sinus */
  133772. ArcSin = 13,
  133773. /** Fraction */
  133774. Fract = 14,
  133775. /** Sign */
  133776. Sign = 15,
  133777. /** To radians (from degrees) */
  133778. Radians = 16,
  133779. /** To degrees (from radians) */
  133780. Degrees = 17
  133781. }
  133782. /**
  133783. * Block used to apply trigonometry operation to floats
  133784. */
  133785. export class TrigonometryBlock extends NodeMaterialBlock {
  133786. /**
  133787. * Gets or sets the operation applied by the block
  133788. */
  133789. operation: TrigonometryBlockOperations;
  133790. /**
  133791. * Creates a new TrigonometryBlock
  133792. * @param name defines the block name
  133793. */
  133794. constructor(name: string);
  133795. /**
  133796. * Gets the current class name
  133797. * @returns the class name
  133798. */
  133799. getClassName(): string;
  133800. /**
  133801. * Gets the input component
  133802. */
  133803. get input(): NodeMaterialConnectionPoint;
  133804. /**
  133805. * Gets the output component
  133806. */
  133807. get output(): NodeMaterialConnectionPoint;
  133808. protected _buildBlock(state: NodeMaterialBuildState): this;
  133809. serialize(): any;
  133810. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133811. protected _dumpPropertiesCode(): string;
  133812. }
  133813. }
  133814. declare module BABYLON {
  133815. /**
  133816. * Block used to create a Color3/4 out of individual inputs (one for each component)
  133817. */
  133818. export class ColorMergerBlock extends NodeMaterialBlock {
  133819. /**
  133820. * Create a new ColorMergerBlock
  133821. * @param name defines the block name
  133822. */
  133823. constructor(name: string);
  133824. /**
  133825. * Gets the current class name
  133826. * @returns the class name
  133827. */
  133828. getClassName(): string;
  133829. /**
  133830. * Gets the rgb component (input)
  133831. */
  133832. get rgbIn(): NodeMaterialConnectionPoint;
  133833. /**
  133834. * Gets the r component (input)
  133835. */
  133836. get r(): NodeMaterialConnectionPoint;
  133837. /**
  133838. * Gets the g component (input)
  133839. */
  133840. get g(): NodeMaterialConnectionPoint;
  133841. /**
  133842. * Gets the b component (input)
  133843. */
  133844. get b(): NodeMaterialConnectionPoint;
  133845. /**
  133846. * Gets the a component (input)
  133847. */
  133848. get a(): NodeMaterialConnectionPoint;
  133849. /**
  133850. * Gets the rgba component (output)
  133851. */
  133852. get rgba(): NodeMaterialConnectionPoint;
  133853. /**
  133854. * Gets the rgb component (output)
  133855. */
  133856. get rgbOut(): NodeMaterialConnectionPoint;
  133857. /**
  133858. * Gets the rgb component (output)
  133859. * @deprecated Please use rgbOut instead.
  133860. */
  133861. get rgb(): NodeMaterialConnectionPoint;
  133862. protected _buildBlock(state: NodeMaterialBuildState): this;
  133863. }
  133864. }
  133865. declare module BABYLON {
  133866. /**
  133867. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  133868. */
  133869. export class VectorMergerBlock extends NodeMaterialBlock {
  133870. /**
  133871. * Create a new VectorMergerBlock
  133872. * @param name defines the block name
  133873. */
  133874. constructor(name: string);
  133875. /**
  133876. * Gets the current class name
  133877. * @returns the class name
  133878. */
  133879. getClassName(): string;
  133880. /**
  133881. * Gets the xyz component (input)
  133882. */
  133883. get xyzIn(): NodeMaterialConnectionPoint;
  133884. /**
  133885. * Gets the xy component (input)
  133886. */
  133887. get xyIn(): NodeMaterialConnectionPoint;
  133888. /**
  133889. * Gets the x component (input)
  133890. */
  133891. get x(): NodeMaterialConnectionPoint;
  133892. /**
  133893. * Gets the y component (input)
  133894. */
  133895. get y(): NodeMaterialConnectionPoint;
  133896. /**
  133897. * Gets the z component (input)
  133898. */
  133899. get z(): NodeMaterialConnectionPoint;
  133900. /**
  133901. * Gets the w component (input)
  133902. */
  133903. get w(): NodeMaterialConnectionPoint;
  133904. /**
  133905. * Gets the xyzw component (output)
  133906. */
  133907. get xyzw(): NodeMaterialConnectionPoint;
  133908. /**
  133909. * Gets the xyz component (output)
  133910. */
  133911. get xyzOut(): NodeMaterialConnectionPoint;
  133912. /**
  133913. * Gets the xy component (output)
  133914. */
  133915. get xyOut(): NodeMaterialConnectionPoint;
  133916. /**
  133917. * Gets the xy component (output)
  133918. * @deprecated Please use xyOut instead.
  133919. */
  133920. get xy(): NodeMaterialConnectionPoint;
  133921. /**
  133922. * Gets the xyz component (output)
  133923. * @deprecated Please use xyzOut instead.
  133924. */
  133925. get xyz(): NodeMaterialConnectionPoint;
  133926. protected _buildBlock(state: NodeMaterialBuildState): this;
  133927. }
  133928. }
  133929. declare module BABYLON {
  133930. /**
  133931. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  133932. */
  133933. export class ColorSplitterBlock extends NodeMaterialBlock {
  133934. /**
  133935. * Create a new ColorSplitterBlock
  133936. * @param name defines the block name
  133937. */
  133938. constructor(name: string);
  133939. /**
  133940. * Gets the current class name
  133941. * @returns the class name
  133942. */
  133943. getClassName(): string;
  133944. /**
  133945. * Gets the rgba component (input)
  133946. */
  133947. get rgba(): NodeMaterialConnectionPoint;
  133948. /**
  133949. * Gets the rgb component (input)
  133950. */
  133951. get rgbIn(): NodeMaterialConnectionPoint;
  133952. /**
  133953. * Gets the rgb component (output)
  133954. */
  133955. get rgbOut(): NodeMaterialConnectionPoint;
  133956. /**
  133957. * Gets the r component (output)
  133958. */
  133959. get r(): NodeMaterialConnectionPoint;
  133960. /**
  133961. * Gets the g component (output)
  133962. */
  133963. get g(): NodeMaterialConnectionPoint;
  133964. /**
  133965. * Gets the b component (output)
  133966. */
  133967. get b(): NodeMaterialConnectionPoint;
  133968. /**
  133969. * Gets the a component (output)
  133970. */
  133971. get a(): NodeMaterialConnectionPoint;
  133972. protected _inputRename(name: string): string;
  133973. protected _outputRename(name: string): string;
  133974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133975. }
  133976. }
  133977. declare module BABYLON {
  133978. /**
  133979. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  133980. */
  133981. export class VectorSplitterBlock extends NodeMaterialBlock {
  133982. /**
  133983. * Create a new VectorSplitterBlock
  133984. * @param name defines the block name
  133985. */
  133986. constructor(name: string);
  133987. /**
  133988. * Gets the current class name
  133989. * @returns the class name
  133990. */
  133991. getClassName(): string;
  133992. /**
  133993. * Gets the xyzw component (input)
  133994. */
  133995. get xyzw(): NodeMaterialConnectionPoint;
  133996. /**
  133997. * Gets the xyz component (input)
  133998. */
  133999. get xyzIn(): NodeMaterialConnectionPoint;
  134000. /**
  134001. * Gets the xy component (input)
  134002. */
  134003. get xyIn(): NodeMaterialConnectionPoint;
  134004. /**
  134005. * Gets the xyz component (output)
  134006. */
  134007. get xyzOut(): NodeMaterialConnectionPoint;
  134008. /**
  134009. * Gets the xy component (output)
  134010. */
  134011. get xyOut(): NodeMaterialConnectionPoint;
  134012. /**
  134013. * Gets the x component (output)
  134014. */
  134015. get x(): NodeMaterialConnectionPoint;
  134016. /**
  134017. * Gets the y component (output)
  134018. */
  134019. get y(): NodeMaterialConnectionPoint;
  134020. /**
  134021. * Gets the z component (output)
  134022. */
  134023. get z(): NodeMaterialConnectionPoint;
  134024. /**
  134025. * Gets the w component (output)
  134026. */
  134027. get w(): NodeMaterialConnectionPoint;
  134028. protected _inputRename(name: string): string;
  134029. protected _outputRename(name: string): string;
  134030. protected _buildBlock(state: NodeMaterialBuildState): this;
  134031. }
  134032. }
  134033. declare module BABYLON {
  134034. /**
  134035. * Block used to lerp between 2 values
  134036. */
  134037. export class LerpBlock extends NodeMaterialBlock {
  134038. /**
  134039. * Creates a new LerpBlock
  134040. * @param name defines the block name
  134041. */
  134042. constructor(name: string);
  134043. /**
  134044. * Gets the current class name
  134045. * @returns the class name
  134046. */
  134047. getClassName(): string;
  134048. /**
  134049. * Gets the left operand input component
  134050. */
  134051. get left(): NodeMaterialConnectionPoint;
  134052. /**
  134053. * Gets the right operand input component
  134054. */
  134055. get right(): NodeMaterialConnectionPoint;
  134056. /**
  134057. * Gets the gradient operand input component
  134058. */
  134059. get gradient(): NodeMaterialConnectionPoint;
  134060. /**
  134061. * Gets the output component
  134062. */
  134063. get output(): NodeMaterialConnectionPoint;
  134064. protected _buildBlock(state: NodeMaterialBuildState): this;
  134065. }
  134066. }
  134067. declare module BABYLON {
  134068. /**
  134069. * Block used to divide 2 vectors
  134070. */
  134071. export class DivideBlock extends NodeMaterialBlock {
  134072. /**
  134073. * Creates a new DivideBlock
  134074. * @param name defines the block name
  134075. */
  134076. constructor(name: string);
  134077. /**
  134078. * Gets the current class name
  134079. * @returns the class name
  134080. */
  134081. getClassName(): string;
  134082. /**
  134083. * Gets the left operand input component
  134084. */
  134085. get left(): NodeMaterialConnectionPoint;
  134086. /**
  134087. * Gets the right operand input component
  134088. */
  134089. get right(): NodeMaterialConnectionPoint;
  134090. /**
  134091. * Gets the output component
  134092. */
  134093. get output(): NodeMaterialConnectionPoint;
  134094. protected _buildBlock(state: NodeMaterialBuildState): this;
  134095. }
  134096. }
  134097. declare module BABYLON {
  134098. /**
  134099. * Block used to subtract 2 vectors
  134100. */
  134101. export class SubtractBlock extends NodeMaterialBlock {
  134102. /**
  134103. * Creates a new SubtractBlock
  134104. * @param name defines the block name
  134105. */
  134106. constructor(name: string);
  134107. /**
  134108. * Gets the current class name
  134109. * @returns the class name
  134110. */
  134111. getClassName(): string;
  134112. /**
  134113. * Gets the left operand input component
  134114. */
  134115. get left(): NodeMaterialConnectionPoint;
  134116. /**
  134117. * Gets the right operand input component
  134118. */
  134119. get right(): NodeMaterialConnectionPoint;
  134120. /**
  134121. * Gets the output component
  134122. */
  134123. get output(): NodeMaterialConnectionPoint;
  134124. protected _buildBlock(state: NodeMaterialBuildState): this;
  134125. }
  134126. }
  134127. declare module BABYLON {
  134128. /**
  134129. * Block used to step a value
  134130. */
  134131. export class StepBlock extends NodeMaterialBlock {
  134132. /**
  134133. * Creates a new StepBlock
  134134. * @param name defines the block name
  134135. */
  134136. constructor(name: string);
  134137. /**
  134138. * Gets the current class name
  134139. * @returns the class name
  134140. */
  134141. getClassName(): string;
  134142. /**
  134143. * Gets the value operand input component
  134144. */
  134145. get value(): NodeMaterialConnectionPoint;
  134146. /**
  134147. * Gets the edge operand input component
  134148. */
  134149. get edge(): NodeMaterialConnectionPoint;
  134150. /**
  134151. * Gets the output component
  134152. */
  134153. get output(): NodeMaterialConnectionPoint;
  134154. protected _buildBlock(state: NodeMaterialBuildState): this;
  134155. }
  134156. }
  134157. declare module BABYLON {
  134158. /**
  134159. * Block used to get the opposite (1 - x) of a value
  134160. */
  134161. export class OneMinusBlock extends NodeMaterialBlock {
  134162. /**
  134163. * Creates a new OneMinusBlock
  134164. * @param name defines the block name
  134165. */
  134166. constructor(name: string);
  134167. /**
  134168. * Gets the current class name
  134169. * @returns the class name
  134170. */
  134171. getClassName(): string;
  134172. /**
  134173. * Gets the input component
  134174. */
  134175. get input(): NodeMaterialConnectionPoint;
  134176. /**
  134177. * Gets the output component
  134178. */
  134179. get output(): NodeMaterialConnectionPoint;
  134180. protected _buildBlock(state: NodeMaterialBuildState): this;
  134181. }
  134182. }
  134183. declare module BABYLON {
  134184. /**
  134185. * Block used to get the view direction
  134186. */
  134187. export class ViewDirectionBlock extends NodeMaterialBlock {
  134188. /**
  134189. * Creates a new ViewDirectionBlock
  134190. * @param name defines the block name
  134191. */
  134192. constructor(name: string);
  134193. /**
  134194. * Gets the current class name
  134195. * @returns the class name
  134196. */
  134197. getClassName(): string;
  134198. /**
  134199. * Gets the world position component
  134200. */
  134201. get worldPosition(): NodeMaterialConnectionPoint;
  134202. /**
  134203. * Gets the camera position component
  134204. */
  134205. get cameraPosition(): NodeMaterialConnectionPoint;
  134206. /**
  134207. * Gets the output component
  134208. */
  134209. get output(): NodeMaterialConnectionPoint;
  134210. autoConfigure(material: NodeMaterial): void;
  134211. protected _buildBlock(state: NodeMaterialBuildState): this;
  134212. }
  134213. }
  134214. declare module BABYLON {
  134215. /**
  134216. * Block used to compute fresnel value
  134217. */
  134218. export class FresnelBlock extends NodeMaterialBlock {
  134219. /**
  134220. * Create a new FresnelBlock
  134221. * @param name defines the block name
  134222. */
  134223. constructor(name: string);
  134224. /**
  134225. * Gets the current class name
  134226. * @returns the class name
  134227. */
  134228. getClassName(): string;
  134229. /**
  134230. * Gets the world normal input component
  134231. */
  134232. get worldNormal(): NodeMaterialConnectionPoint;
  134233. /**
  134234. * Gets the view direction input component
  134235. */
  134236. get viewDirection(): NodeMaterialConnectionPoint;
  134237. /**
  134238. * Gets the bias input component
  134239. */
  134240. get bias(): NodeMaterialConnectionPoint;
  134241. /**
  134242. * Gets the camera (or eye) position component
  134243. */
  134244. get power(): NodeMaterialConnectionPoint;
  134245. /**
  134246. * Gets the fresnel output component
  134247. */
  134248. get fresnel(): NodeMaterialConnectionPoint;
  134249. autoConfigure(material: NodeMaterial): void;
  134250. protected _buildBlock(state: NodeMaterialBuildState): this;
  134251. }
  134252. }
  134253. declare module BABYLON {
  134254. /**
  134255. * Block used to get the max of 2 values
  134256. */
  134257. export class MaxBlock extends NodeMaterialBlock {
  134258. /**
  134259. * Creates a new MaxBlock
  134260. * @param name defines the block name
  134261. */
  134262. constructor(name: string);
  134263. /**
  134264. * Gets the current class name
  134265. * @returns the class name
  134266. */
  134267. getClassName(): string;
  134268. /**
  134269. * Gets the left operand input component
  134270. */
  134271. get left(): NodeMaterialConnectionPoint;
  134272. /**
  134273. * Gets the right operand input component
  134274. */
  134275. get right(): NodeMaterialConnectionPoint;
  134276. /**
  134277. * Gets the output component
  134278. */
  134279. get output(): NodeMaterialConnectionPoint;
  134280. protected _buildBlock(state: NodeMaterialBuildState): this;
  134281. }
  134282. }
  134283. declare module BABYLON {
  134284. /**
  134285. * Block used to get the min of 2 values
  134286. */
  134287. export class MinBlock extends NodeMaterialBlock {
  134288. /**
  134289. * Creates a new MinBlock
  134290. * @param name defines the block name
  134291. */
  134292. constructor(name: string);
  134293. /**
  134294. * Gets the current class name
  134295. * @returns the class name
  134296. */
  134297. getClassName(): string;
  134298. /**
  134299. * Gets the left operand input component
  134300. */
  134301. get left(): NodeMaterialConnectionPoint;
  134302. /**
  134303. * Gets the right operand input component
  134304. */
  134305. get right(): NodeMaterialConnectionPoint;
  134306. /**
  134307. * Gets the output component
  134308. */
  134309. get output(): NodeMaterialConnectionPoint;
  134310. protected _buildBlock(state: NodeMaterialBuildState): this;
  134311. }
  134312. }
  134313. declare module BABYLON {
  134314. /**
  134315. * Block used to get the distance between 2 values
  134316. */
  134317. export class DistanceBlock extends NodeMaterialBlock {
  134318. /**
  134319. * Creates a new DistanceBlock
  134320. * @param name defines the block name
  134321. */
  134322. constructor(name: string);
  134323. /**
  134324. * Gets the current class name
  134325. * @returns the class name
  134326. */
  134327. getClassName(): string;
  134328. /**
  134329. * Gets the left operand input component
  134330. */
  134331. get left(): NodeMaterialConnectionPoint;
  134332. /**
  134333. * Gets the right operand input component
  134334. */
  134335. get right(): NodeMaterialConnectionPoint;
  134336. /**
  134337. * Gets the output component
  134338. */
  134339. get output(): NodeMaterialConnectionPoint;
  134340. protected _buildBlock(state: NodeMaterialBuildState): this;
  134341. }
  134342. }
  134343. declare module BABYLON {
  134344. /**
  134345. * Block used to get the length of a vector
  134346. */
  134347. export class LengthBlock extends NodeMaterialBlock {
  134348. /**
  134349. * Creates a new LengthBlock
  134350. * @param name defines the block name
  134351. */
  134352. constructor(name: string);
  134353. /**
  134354. * Gets the current class name
  134355. * @returns the class name
  134356. */
  134357. getClassName(): string;
  134358. /**
  134359. * Gets the value input component
  134360. */
  134361. get value(): NodeMaterialConnectionPoint;
  134362. /**
  134363. * Gets the output component
  134364. */
  134365. get output(): NodeMaterialConnectionPoint;
  134366. protected _buildBlock(state: NodeMaterialBuildState): this;
  134367. }
  134368. }
  134369. declare module BABYLON {
  134370. /**
  134371. * Block used to get negative version of a value (i.e. x * -1)
  134372. */
  134373. export class NegateBlock extends NodeMaterialBlock {
  134374. /**
  134375. * Creates a new NegateBlock
  134376. * @param name defines the block name
  134377. */
  134378. constructor(name: string);
  134379. /**
  134380. * Gets the current class name
  134381. * @returns the class name
  134382. */
  134383. getClassName(): string;
  134384. /**
  134385. * Gets the value input component
  134386. */
  134387. get value(): NodeMaterialConnectionPoint;
  134388. /**
  134389. * Gets the output component
  134390. */
  134391. get output(): NodeMaterialConnectionPoint;
  134392. protected _buildBlock(state: NodeMaterialBuildState): this;
  134393. }
  134394. }
  134395. declare module BABYLON {
  134396. /**
  134397. * Block used to get the value of the first parameter raised to the power of the second
  134398. */
  134399. export class PowBlock extends NodeMaterialBlock {
  134400. /**
  134401. * Creates a new PowBlock
  134402. * @param name defines the block name
  134403. */
  134404. constructor(name: string);
  134405. /**
  134406. * Gets the current class name
  134407. * @returns the class name
  134408. */
  134409. getClassName(): string;
  134410. /**
  134411. * Gets the value operand input component
  134412. */
  134413. get value(): NodeMaterialConnectionPoint;
  134414. /**
  134415. * Gets the power operand input component
  134416. */
  134417. get power(): NodeMaterialConnectionPoint;
  134418. /**
  134419. * Gets the output component
  134420. */
  134421. get output(): NodeMaterialConnectionPoint;
  134422. protected _buildBlock(state: NodeMaterialBuildState): this;
  134423. }
  134424. }
  134425. declare module BABYLON {
  134426. /**
  134427. * Block used to get a random number
  134428. */
  134429. export class RandomNumberBlock extends NodeMaterialBlock {
  134430. /**
  134431. * Creates a new RandomNumberBlock
  134432. * @param name defines the block name
  134433. */
  134434. constructor(name: string);
  134435. /**
  134436. * Gets the current class name
  134437. * @returns the class name
  134438. */
  134439. getClassName(): string;
  134440. /**
  134441. * Gets the seed input component
  134442. */
  134443. get seed(): NodeMaterialConnectionPoint;
  134444. /**
  134445. * Gets the output component
  134446. */
  134447. get output(): NodeMaterialConnectionPoint;
  134448. protected _buildBlock(state: NodeMaterialBuildState): this;
  134449. }
  134450. }
  134451. declare module BABYLON {
  134452. /**
  134453. * Block used to compute arc tangent of 2 values
  134454. */
  134455. export class ArcTan2Block extends NodeMaterialBlock {
  134456. /**
  134457. * Creates a new ArcTan2Block
  134458. * @param name defines the block name
  134459. */
  134460. constructor(name: string);
  134461. /**
  134462. * Gets the current class name
  134463. * @returns the class name
  134464. */
  134465. getClassName(): string;
  134466. /**
  134467. * Gets the x operand input component
  134468. */
  134469. get x(): NodeMaterialConnectionPoint;
  134470. /**
  134471. * Gets the y operand input component
  134472. */
  134473. get y(): NodeMaterialConnectionPoint;
  134474. /**
  134475. * Gets the output component
  134476. */
  134477. get output(): NodeMaterialConnectionPoint;
  134478. protected _buildBlock(state: NodeMaterialBuildState): this;
  134479. }
  134480. }
  134481. declare module BABYLON {
  134482. /**
  134483. * Block used to smooth step a value
  134484. */
  134485. export class SmoothStepBlock extends NodeMaterialBlock {
  134486. /**
  134487. * Creates a new SmoothStepBlock
  134488. * @param name defines the block name
  134489. */
  134490. constructor(name: string);
  134491. /**
  134492. * Gets the current class name
  134493. * @returns the class name
  134494. */
  134495. getClassName(): string;
  134496. /**
  134497. * Gets the value operand input component
  134498. */
  134499. get value(): NodeMaterialConnectionPoint;
  134500. /**
  134501. * Gets the first edge operand input component
  134502. */
  134503. get edge0(): NodeMaterialConnectionPoint;
  134504. /**
  134505. * Gets the second edge operand input component
  134506. */
  134507. get edge1(): NodeMaterialConnectionPoint;
  134508. /**
  134509. * Gets the output component
  134510. */
  134511. get output(): NodeMaterialConnectionPoint;
  134512. protected _buildBlock(state: NodeMaterialBuildState): this;
  134513. }
  134514. }
  134515. declare module BABYLON {
  134516. /**
  134517. * Block used to get the reciprocal (1 / x) of a value
  134518. */
  134519. export class ReciprocalBlock extends NodeMaterialBlock {
  134520. /**
  134521. * Creates a new ReciprocalBlock
  134522. * @param name defines the block name
  134523. */
  134524. constructor(name: string);
  134525. /**
  134526. * Gets the current class name
  134527. * @returns the class name
  134528. */
  134529. getClassName(): string;
  134530. /**
  134531. * Gets the input component
  134532. */
  134533. get input(): NodeMaterialConnectionPoint;
  134534. /**
  134535. * Gets the output component
  134536. */
  134537. get output(): NodeMaterialConnectionPoint;
  134538. protected _buildBlock(state: NodeMaterialBuildState): this;
  134539. }
  134540. }
  134541. declare module BABYLON {
  134542. /**
  134543. * Block used to replace a color by another one
  134544. */
  134545. export class ReplaceColorBlock extends NodeMaterialBlock {
  134546. /**
  134547. * Creates a new ReplaceColorBlock
  134548. * @param name defines the block name
  134549. */
  134550. constructor(name: string);
  134551. /**
  134552. * Gets the current class name
  134553. * @returns the class name
  134554. */
  134555. getClassName(): string;
  134556. /**
  134557. * Gets the value input component
  134558. */
  134559. get value(): NodeMaterialConnectionPoint;
  134560. /**
  134561. * Gets the reference input component
  134562. */
  134563. get reference(): NodeMaterialConnectionPoint;
  134564. /**
  134565. * Gets the distance input component
  134566. */
  134567. get distance(): NodeMaterialConnectionPoint;
  134568. /**
  134569. * Gets the replacement input component
  134570. */
  134571. get replacement(): NodeMaterialConnectionPoint;
  134572. /**
  134573. * Gets the output component
  134574. */
  134575. get output(): NodeMaterialConnectionPoint;
  134576. protected _buildBlock(state: NodeMaterialBuildState): this;
  134577. }
  134578. }
  134579. declare module BABYLON {
  134580. /**
  134581. * Block used to posterize a value
  134582. * @see https://en.wikipedia.org/wiki/Posterization
  134583. */
  134584. export class PosterizeBlock extends NodeMaterialBlock {
  134585. /**
  134586. * Creates a new PosterizeBlock
  134587. * @param name defines the block name
  134588. */
  134589. constructor(name: string);
  134590. /**
  134591. * Gets the current class name
  134592. * @returns the class name
  134593. */
  134594. getClassName(): string;
  134595. /**
  134596. * Gets the value input component
  134597. */
  134598. get value(): NodeMaterialConnectionPoint;
  134599. /**
  134600. * Gets the steps input component
  134601. */
  134602. get steps(): NodeMaterialConnectionPoint;
  134603. /**
  134604. * Gets the output component
  134605. */
  134606. get output(): NodeMaterialConnectionPoint;
  134607. protected _buildBlock(state: NodeMaterialBuildState): this;
  134608. }
  134609. }
  134610. declare module BABYLON {
  134611. /**
  134612. * Operations supported by the Wave block
  134613. */
  134614. export enum WaveBlockKind {
  134615. /** SawTooth */
  134616. SawTooth = 0,
  134617. /** Square */
  134618. Square = 1,
  134619. /** Triangle */
  134620. Triangle = 2
  134621. }
  134622. /**
  134623. * Block used to apply wave operation to floats
  134624. */
  134625. export class WaveBlock extends NodeMaterialBlock {
  134626. /**
  134627. * Gets or sets the kibnd of wave to be applied by the block
  134628. */
  134629. kind: WaveBlockKind;
  134630. /**
  134631. * Creates a new WaveBlock
  134632. * @param name defines the block name
  134633. */
  134634. constructor(name: string);
  134635. /**
  134636. * Gets the current class name
  134637. * @returns the class name
  134638. */
  134639. getClassName(): string;
  134640. /**
  134641. * Gets the input component
  134642. */
  134643. get input(): NodeMaterialConnectionPoint;
  134644. /**
  134645. * Gets the output component
  134646. */
  134647. get output(): NodeMaterialConnectionPoint;
  134648. protected _buildBlock(state: NodeMaterialBuildState): this;
  134649. serialize(): any;
  134650. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134651. }
  134652. }
  134653. declare module BABYLON {
  134654. /**
  134655. * Class used to store a color step for the GradientBlock
  134656. */
  134657. export class GradientBlockColorStep {
  134658. /**
  134659. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134660. */
  134661. step: number;
  134662. /**
  134663. * Gets or sets the color associated with this step
  134664. */
  134665. color: Color3;
  134666. /**
  134667. * Creates a new GradientBlockColorStep
  134668. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  134669. * @param color defines the color associated with this step
  134670. */
  134671. constructor(
  134672. /**
  134673. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134674. */
  134675. step: number,
  134676. /**
  134677. * Gets or sets the color associated with this step
  134678. */
  134679. color: Color3);
  134680. }
  134681. /**
  134682. * Block used to return a color from a gradient based on an input value between 0 and 1
  134683. */
  134684. export class GradientBlock extends NodeMaterialBlock {
  134685. /**
  134686. * Gets or sets the list of color steps
  134687. */
  134688. colorSteps: GradientBlockColorStep[];
  134689. /**
  134690. * Creates a new GradientBlock
  134691. * @param name defines the block name
  134692. */
  134693. constructor(name: string);
  134694. /**
  134695. * Gets the current class name
  134696. * @returns the class name
  134697. */
  134698. getClassName(): string;
  134699. /**
  134700. * Gets the gradient input component
  134701. */
  134702. get gradient(): NodeMaterialConnectionPoint;
  134703. /**
  134704. * Gets the output component
  134705. */
  134706. get output(): NodeMaterialConnectionPoint;
  134707. private _writeColorConstant;
  134708. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134709. serialize(): any;
  134710. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134711. protected _dumpPropertiesCode(): string;
  134712. }
  134713. }
  134714. declare module BABYLON {
  134715. /**
  134716. * Block used to normalize lerp between 2 values
  134717. */
  134718. export class NLerpBlock extends NodeMaterialBlock {
  134719. /**
  134720. * Creates a new NLerpBlock
  134721. * @param name defines the block name
  134722. */
  134723. constructor(name: string);
  134724. /**
  134725. * Gets the current class name
  134726. * @returns the class name
  134727. */
  134728. getClassName(): string;
  134729. /**
  134730. * Gets the left operand input component
  134731. */
  134732. get left(): NodeMaterialConnectionPoint;
  134733. /**
  134734. * Gets the right operand input component
  134735. */
  134736. get right(): NodeMaterialConnectionPoint;
  134737. /**
  134738. * Gets the gradient operand input component
  134739. */
  134740. get gradient(): NodeMaterialConnectionPoint;
  134741. /**
  134742. * Gets the output component
  134743. */
  134744. get output(): NodeMaterialConnectionPoint;
  134745. protected _buildBlock(state: NodeMaterialBuildState): this;
  134746. }
  134747. }
  134748. declare module BABYLON {
  134749. /**
  134750. * block used to Generate a Worley Noise 3D Noise Pattern
  134751. */
  134752. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  134753. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  134754. manhattanDistance: boolean;
  134755. /**
  134756. * Creates a new WorleyNoise3DBlock
  134757. * @param name defines the block name
  134758. */
  134759. constructor(name: string);
  134760. /**
  134761. * Gets the current class name
  134762. * @returns the class name
  134763. */
  134764. getClassName(): string;
  134765. /**
  134766. * Gets the seed input component
  134767. */
  134768. get seed(): NodeMaterialConnectionPoint;
  134769. /**
  134770. * Gets the jitter input component
  134771. */
  134772. get jitter(): NodeMaterialConnectionPoint;
  134773. /**
  134774. * Gets the output component
  134775. */
  134776. get output(): NodeMaterialConnectionPoint;
  134777. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134778. /**
  134779. * Exposes the properties to the UI?
  134780. */
  134781. protected _dumpPropertiesCode(): string;
  134782. /**
  134783. * Exposes the properties to the Seralize?
  134784. */
  134785. serialize(): any;
  134786. /**
  134787. * Exposes the properties to the deseralize?
  134788. */
  134789. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134790. }
  134791. }
  134792. declare module BABYLON {
  134793. /**
  134794. * block used to Generate a Simplex Perlin 3d Noise Pattern
  134795. */
  134796. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  134797. /**
  134798. * Creates a new SimplexPerlin3DBlock
  134799. * @param name defines the block name
  134800. */
  134801. constructor(name: string);
  134802. /**
  134803. * Gets the current class name
  134804. * @returns the class name
  134805. */
  134806. getClassName(): string;
  134807. /**
  134808. * Gets the seed operand input component
  134809. */
  134810. get seed(): NodeMaterialConnectionPoint;
  134811. /**
  134812. * Gets the output component
  134813. */
  134814. get output(): NodeMaterialConnectionPoint;
  134815. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134816. }
  134817. }
  134818. declare module BABYLON {
  134819. /**
  134820. * Block used to blend normals
  134821. */
  134822. export class NormalBlendBlock extends NodeMaterialBlock {
  134823. /**
  134824. * Creates a new NormalBlendBlock
  134825. * @param name defines the block name
  134826. */
  134827. constructor(name: string);
  134828. /**
  134829. * Gets the current class name
  134830. * @returns the class name
  134831. */
  134832. getClassName(): string;
  134833. /**
  134834. * Gets the first input component
  134835. */
  134836. get normalMap0(): NodeMaterialConnectionPoint;
  134837. /**
  134838. * Gets the second input component
  134839. */
  134840. get normalMap1(): NodeMaterialConnectionPoint;
  134841. /**
  134842. * Gets the output component
  134843. */
  134844. get output(): NodeMaterialConnectionPoint;
  134845. protected _buildBlock(state: NodeMaterialBuildState): this;
  134846. }
  134847. }
  134848. declare module BABYLON {
  134849. /**
  134850. * Block used to rotate a 2d vector by a given angle
  134851. */
  134852. export class Rotate2dBlock extends NodeMaterialBlock {
  134853. /**
  134854. * Creates a new Rotate2dBlock
  134855. * @param name defines the block name
  134856. */
  134857. constructor(name: string);
  134858. /**
  134859. * Gets the current class name
  134860. * @returns the class name
  134861. */
  134862. getClassName(): string;
  134863. /**
  134864. * Gets the input vector
  134865. */
  134866. get input(): NodeMaterialConnectionPoint;
  134867. /**
  134868. * Gets the input angle
  134869. */
  134870. get angle(): NodeMaterialConnectionPoint;
  134871. /**
  134872. * Gets the output component
  134873. */
  134874. get output(): NodeMaterialConnectionPoint;
  134875. autoConfigure(material: NodeMaterial): void;
  134876. protected _buildBlock(state: NodeMaterialBuildState): this;
  134877. }
  134878. }
  134879. declare module BABYLON {
  134880. /**
  134881. * Block used to get the reflected vector from a direction and a normal
  134882. */
  134883. export class ReflectBlock extends NodeMaterialBlock {
  134884. /**
  134885. * Creates a new ReflectBlock
  134886. * @param name defines the block name
  134887. */
  134888. constructor(name: string);
  134889. /**
  134890. * Gets the current class name
  134891. * @returns the class name
  134892. */
  134893. getClassName(): string;
  134894. /**
  134895. * Gets the incident component
  134896. */
  134897. get incident(): NodeMaterialConnectionPoint;
  134898. /**
  134899. * Gets the normal component
  134900. */
  134901. get normal(): NodeMaterialConnectionPoint;
  134902. /**
  134903. * Gets the output component
  134904. */
  134905. get output(): NodeMaterialConnectionPoint;
  134906. protected _buildBlock(state: NodeMaterialBuildState): this;
  134907. }
  134908. }
  134909. declare module BABYLON {
  134910. /**
  134911. * Block used to get the refracted vector from a direction and a normal
  134912. */
  134913. export class RefractBlock extends NodeMaterialBlock {
  134914. /**
  134915. * Creates a new RefractBlock
  134916. * @param name defines the block name
  134917. */
  134918. constructor(name: string);
  134919. /**
  134920. * Gets the current class name
  134921. * @returns the class name
  134922. */
  134923. getClassName(): string;
  134924. /**
  134925. * Gets the incident component
  134926. */
  134927. get incident(): NodeMaterialConnectionPoint;
  134928. /**
  134929. * Gets the normal component
  134930. */
  134931. get normal(): NodeMaterialConnectionPoint;
  134932. /**
  134933. * Gets the index of refraction component
  134934. */
  134935. get ior(): NodeMaterialConnectionPoint;
  134936. /**
  134937. * Gets the output component
  134938. */
  134939. get output(): NodeMaterialConnectionPoint;
  134940. protected _buildBlock(state: NodeMaterialBuildState): this;
  134941. }
  134942. }
  134943. declare module BABYLON {
  134944. /**
  134945. * Block used to desaturate a color
  134946. */
  134947. export class DesaturateBlock extends NodeMaterialBlock {
  134948. /**
  134949. * Creates a new DesaturateBlock
  134950. * @param name defines the block name
  134951. */
  134952. constructor(name: string);
  134953. /**
  134954. * Gets the current class name
  134955. * @returns the class name
  134956. */
  134957. getClassName(): string;
  134958. /**
  134959. * Gets the color operand input component
  134960. */
  134961. get color(): NodeMaterialConnectionPoint;
  134962. /**
  134963. * Gets the level operand input component
  134964. */
  134965. get level(): NodeMaterialConnectionPoint;
  134966. /**
  134967. * Gets the output component
  134968. */
  134969. get output(): NodeMaterialConnectionPoint;
  134970. protected _buildBlock(state: NodeMaterialBuildState): this;
  134971. }
  134972. }
  134973. declare module BABYLON {
  134974. /**
  134975. * Effect Render Options
  134976. */
  134977. export interface IEffectRendererOptions {
  134978. /**
  134979. * Defines the vertices positions.
  134980. */
  134981. positions?: number[];
  134982. /**
  134983. * Defines the indices.
  134984. */
  134985. indices?: number[];
  134986. }
  134987. /**
  134988. * Helper class to render one or more effects.
  134989. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  134990. */
  134991. export class EffectRenderer {
  134992. private engine;
  134993. private static _DefaultOptions;
  134994. private _vertexBuffers;
  134995. private _indexBuffer;
  134996. private _fullscreenViewport;
  134997. /**
  134998. * Creates an effect renderer
  134999. * @param engine the engine to use for rendering
  135000. * @param options defines the options of the effect renderer
  135001. */
  135002. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135003. /**
  135004. * Sets the current viewport in normalized coordinates 0-1
  135005. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135006. */
  135007. setViewport(viewport?: Viewport): void;
  135008. /**
  135009. * Binds the embedded attributes buffer to the effect.
  135010. * @param effect Defines the effect to bind the attributes for
  135011. */
  135012. bindBuffers(effect: Effect): void;
  135013. /**
  135014. * Sets the current effect wrapper to use during draw.
  135015. * The effect needs to be ready before calling this api.
  135016. * This also sets the default full screen position attribute.
  135017. * @param effectWrapper Defines the effect to draw with
  135018. */
  135019. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135020. /**
  135021. * Draws a full screen quad.
  135022. */
  135023. draw(): void;
  135024. private isRenderTargetTexture;
  135025. /**
  135026. * renders one or more effects to a specified texture
  135027. * @param effectWrapper the effect to renderer
  135028. * @param outputTexture texture to draw to, if null it will render to the screen.
  135029. */
  135030. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135031. /**
  135032. * Disposes of the effect renderer
  135033. */
  135034. dispose(): void;
  135035. }
  135036. /**
  135037. * Options to create an EffectWrapper
  135038. */
  135039. interface EffectWrapperCreationOptions {
  135040. /**
  135041. * Engine to use to create the effect
  135042. */
  135043. engine: ThinEngine;
  135044. /**
  135045. * Fragment shader for the effect
  135046. */
  135047. fragmentShader: string;
  135048. /**
  135049. * Vertex shader for the effect
  135050. */
  135051. vertexShader?: string;
  135052. /**
  135053. * Attributes to use in the shader
  135054. */
  135055. attributeNames?: Array<string>;
  135056. /**
  135057. * Uniforms to use in the shader
  135058. */
  135059. uniformNames?: Array<string>;
  135060. /**
  135061. * Texture sampler names to use in the shader
  135062. */
  135063. samplerNames?: Array<string>;
  135064. /**
  135065. * The friendly name of the effect displayed in Spector.
  135066. */
  135067. name?: string;
  135068. }
  135069. /**
  135070. * Wraps an effect to be used for rendering
  135071. */
  135072. export class EffectWrapper {
  135073. /**
  135074. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135075. */
  135076. onApplyObservable: Observable<{}>;
  135077. /**
  135078. * The underlying effect
  135079. */
  135080. effect: Effect;
  135081. /**
  135082. * Creates an effect to be renderer
  135083. * @param creationOptions options to create the effect
  135084. */
  135085. constructor(creationOptions: EffectWrapperCreationOptions);
  135086. /**
  135087. * Disposes of the effect wrapper
  135088. */
  135089. dispose(): void;
  135090. }
  135091. }
  135092. declare module BABYLON {
  135093. /**
  135094. * Helper class to push actions to a pool of workers.
  135095. */
  135096. export class WorkerPool implements IDisposable {
  135097. private _workerInfos;
  135098. private _pendingActions;
  135099. /**
  135100. * Constructor
  135101. * @param workers Array of workers to use for actions
  135102. */
  135103. constructor(workers: Array<Worker>);
  135104. /**
  135105. * Terminates all workers and clears any pending actions.
  135106. */
  135107. dispose(): void;
  135108. /**
  135109. * Pushes an action to the worker pool. If all the workers are active, the action will be
  135110. * pended until a worker has completed its action.
  135111. * @param action The action to perform. Call onComplete when the action is complete.
  135112. */
  135113. push(action: (worker: Worker, onComplete: () => void) => void): void;
  135114. private _execute;
  135115. }
  135116. }
  135117. declare module BABYLON {
  135118. /**
  135119. * Configuration for Draco compression
  135120. */
  135121. export interface IDracoCompressionConfiguration {
  135122. /**
  135123. * Configuration for the decoder.
  135124. */
  135125. decoder: {
  135126. /**
  135127. * The url to the WebAssembly module.
  135128. */
  135129. wasmUrl?: string;
  135130. /**
  135131. * The url to the WebAssembly binary.
  135132. */
  135133. wasmBinaryUrl?: string;
  135134. /**
  135135. * The url to the fallback JavaScript module.
  135136. */
  135137. fallbackUrl?: string;
  135138. };
  135139. }
  135140. /**
  135141. * Draco compression (https://google.github.io/draco/)
  135142. *
  135143. * This class wraps the Draco module.
  135144. *
  135145. * **Encoder**
  135146. *
  135147. * The encoder is not currently implemented.
  135148. *
  135149. * **Decoder**
  135150. *
  135151. * 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.
  135152. *
  135153. * To update the configuration, use the following code:
  135154. * ```javascript
  135155. * DracoCompression.Configuration = {
  135156. * decoder: {
  135157. * wasmUrl: "<url to the WebAssembly library>",
  135158. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  135159. * fallbackUrl: "<url to the fallback JavaScript library>",
  135160. * }
  135161. * };
  135162. * ```
  135163. *
  135164. * 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.
  135165. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  135166. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  135167. *
  135168. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  135169. * ```javascript
  135170. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  135171. * ```
  135172. *
  135173. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  135174. */
  135175. export class DracoCompression implements IDisposable {
  135176. private _workerPoolPromise?;
  135177. private _decoderModulePromise?;
  135178. /**
  135179. * The configuration. Defaults to the following urls:
  135180. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  135181. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  135182. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  135183. */
  135184. static Configuration: IDracoCompressionConfiguration;
  135185. /**
  135186. * Returns true if the decoder configuration is available.
  135187. */
  135188. static get DecoderAvailable(): boolean;
  135189. /**
  135190. * Default number of workers to create when creating the draco compression object.
  135191. */
  135192. static DefaultNumWorkers: number;
  135193. private static GetDefaultNumWorkers;
  135194. private static _Default;
  135195. /**
  135196. * Default instance for the draco compression object.
  135197. */
  135198. static get Default(): DracoCompression;
  135199. /**
  135200. * Constructor
  135201. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  135202. */
  135203. constructor(numWorkers?: number);
  135204. /**
  135205. * Stop all async operations and release resources.
  135206. */
  135207. dispose(): void;
  135208. /**
  135209. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  135210. * @returns a promise that resolves when ready
  135211. */
  135212. whenReadyAsync(): Promise<void>;
  135213. /**
  135214. * Decode Draco compressed mesh data to vertex data.
  135215. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  135216. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  135217. * @returns A promise that resolves with the decoded vertex data
  135218. */
  135219. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  135220. [kind: string]: number;
  135221. }): Promise<VertexData>;
  135222. }
  135223. }
  135224. declare module BABYLON {
  135225. /**
  135226. * Class for building Constructive Solid Geometry
  135227. */
  135228. export class CSG {
  135229. private polygons;
  135230. /**
  135231. * The world matrix
  135232. */
  135233. matrix: Matrix;
  135234. /**
  135235. * Stores the position
  135236. */
  135237. position: Vector3;
  135238. /**
  135239. * Stores the rotation
  135240. */
  135241. rotation: Vector3;
  135242. /**
  135243. * Stores the rotation quaternion
  135244. */
  135245. rotationQuaternion: Nullable<Quaternion>;
  135246. /**
  135247. * Stores the scaling vector
  135248. */
  135249. scaling: Vector3;
  135250. /**
  135251. * Convert the Mesh to CSG
  135252. * @param mesh The Mesh to convert to CSG
  135253. * @returns A new CSG from the Mesh
  135254. */
  135255. static FromMesh(mesh: Mesh): CSG;
  135256. /**
  135257. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  135258. * @param polygons Polygons used to construct a CSG solid
  135259. */
  135260. private static FromPolygons;
  135261. /**
  135262. * Clones, or makes a deep copy, of the CSG
  135263. * @returns A new CSG
  135264. */
  135265. clone(): CSG;
  135266. /**
  135267. * Unions this CSG with another CSG
  135268. * @param csg The CSG to union against this CSG
  135269. * @returns The unioned CSG
  135270. */
  135271. union(csg: CSG): CSG;
  135272. /**
  135273. * Unions this CSG with another CSG in place
  135274. * @param csg The CSG to union against this CSG
  135275. */
  135276. unionInPlace(csg: CSG): void;
  135277. /**
  135278. * Subtracts this CSG with another CSG
  135279. * @param csg The CSG to subtract against this CSG
  135280. * @returns A new CSG
  135281. */
  135282. subtract(csg: CSG): CSG;
  135283. /**
  135284. * Subtracts this CSG with another CSG in place
  135285. * @param csg The CSG to subtact against this CSG
  135286. */
  135287. subtractInPlace(csg: CSG): void;
  135288. /**
  135289. * Intersect this CSG with another CSG
  135290. * @param csg The CSG to intersect against this CSG
  135291. * @returns A new CSG
  135292. */
  135293. intersect(csg: CSG): CSG;
  135294. /**
  135295. * Intersects this CSG with another CSG in place
  135296. * @param csg The CSG to intersect against this CSG
  135297. */
  135298. intersectInPlace(csg: CSG): void;
  135299. /**
  135300. * Return a new CSG solid with solid and empty space switched. This solid is
  135301. * not modified.
  135302. * @returns A new CSG solid with solid and empty space switched
  135303. */
  135304. inverse(): CSG;
  135305. /**
  135306. * Inverses the CSG in place
  135307. */
  135308. inverseInPlace(): void;
  135309. /**
  135310. * This is used to keep meshes transformations so they can be restored
  135311. * when we build back a Babylon Mesh
  135312. * NB : All CSG operations are performed in world coordinates
  135313. * @param csg The CSG to copy the transform attributes from
  135314. * @returns This CSG
  135315. */
  135316. copyTransformAttributes(csg: CSG): CSG;
  135317. /**
  135318. * Build Raw mesh from CSG
  135319. * Coordinates here are in world space
  135320. * @param name The name of the mesh geometry
  135321. * @param scene The Scene
  135322. * @param keepSubMeshes Specifies if the submeshes should be kept
  135323. * @returns A new Mesh
  135324. */
  135325. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135326. /**
  135327. * Build Mesh from CSG taking material and transforms into account
  135328. * @param name The name of the Mesh
  135329. * @param material The material of the Mesh
  135330. * @param scene The Scene
  135331. * @param keepSubMeshes Specifies if submeshes should be kept
  135332. * @returns The new Mesh
  135333. */
  135334. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135335. }
  135336. }
  135337. declare module BABYLON {
  135338. /**
  135339. * Class used to create a trail following a mesh
  135340. */
  135341. export class TrailMesh extends Mesh {
  135342. private _generator;
  135343. private _autoStart;
  135344. private _running;
  135345. private _diameter;
  135346. private _length;
  135347. private _sectionPolygonPointsCount;
  135348. private _sectionVectors;
  135349. private _sectionNormalVectors;
  135350. private _beforeRenderObserver;
  135351. /**
  135352. * @constructor
  135353. * @param name The value used by scene.getMeshByName() to do a lookup.
  135354. * @param generator The mesh or transform node to generate a trail.
  135355. * @param scene The scene to add this mesh to.
  135356. * @param diameter Diameter of trailing mesh. Default is 1.
  135357. * @param length Length of trailing mesh. Default is 60.
  135358. * @param autoStart Automatically start trailing mesh. Default true.
  135359. */
  135360. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  135361. /**
  135362. * "TrailMesh"
  135363. * @returns "TrailMesh"
  135364. */
  135365. getClassName(): string;
  135366. private _createMesh;
  135367. /**
  135368. * Start trailing mesh.
  135369. */
  135370. start(): void;
  135371. /**
  135372. * Stop trailing mesh.
  135373. */
  135374. stop(): void;
  135375. /**
  135376. * Update trailing mesh geometry.
  135377. */
  135378. update(): void;
  135379. /**
  135380. * Returns a new TrailMesh object.
  135381. * @param name is a string, the name given to the new mesh
  135382. * @param newGenerator use new generator object for cloned trail mesh
  135383. * @returns a new mesh
  135384. */
  135385. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  135386. /**
  135387. * Serializes this trail mesh
  135388. * @param serializationObject object to write serialization to
  135389. */
  135390. serialize(serializationObject: any): void;
  135391. /**
  135392. * Parses a serialized trail mesh
  135393. * @param parsedMesh the serialized mesh
  135394. * @param scene the scene to create the trail mesh in
  135395. * @returns the created trail mesh
  135396. */
  135397. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  135398. }
  135399. }
  135400. declare module BABYLON {
  135401. /**
  135402. * Class containing static functions to help procedurally build meshes
  135403. */
  135404. export class TiledBoxBuilder {
  135405. /**
  135406. * Creates a box mesh
  135407. * 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)
  135408. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135412. * @param name defines the name of the mesh
  135413. * @param options defines the options used to create the mesh
  135414. * @param scene defines the hosting scene
  135415. * @returns the box mesh
  135416. */
  135417. static CreateTiledBox(name: string, options: {
  135418. pattern?: number;
  135419. width?: number;
  135420. height?: number;
  135421. depth?: number;
  135422. tileSize?: number;
  135423. tileWidth?: number;
  135424. tileHeight?: number;
  135425. alignHorizontal?: number;
  135426. alignVertical?: number;
  135427. faceUV?: Vector4[];
  135428. faceColors?: Color4[];
  135429. sideOrientation?: number;
  135430. updatable?: boolean;
  135431. }, scene?: Nullable<Scene>): Mesh;
  135432. }
  135433. }
  135434. declare module BABYLON {
  135435. /**
  135436. * Class containing static functions to help procedurally build meshes
  135437. */
  135438. export class TorusKnotBuilder {
  135439. /**
  135440. * Creates a torus knot mesh
  135441. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135442. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135443. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135444. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135445. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135446. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135448. * @param name defines the name of the mesh
  135449. * @param options defines the options used to create the mesh
  135450. * @param scene defines the hosting scene
  135451. * @returns the torus knot mesh
  135452. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135453. */
  135454. static CreateTorusKnot(name: string, options: {
  135455. radius?: number;
  135456. tube?: number;
  135457. radialSegments?: number;
  135458. tubularSegments?: number;
  135459. p?: number;
  135460. q?: number;
  135461. updatable?: boolean;
  135462. sideOrientation?: number;
  135463. frontUVs?: Vector4;
  135464. backUVs?: Vector4;
  135465. }, scene: any): Mesh;
  135466. }
  135467. }
  135468. declare module BABYLON {
  135469. /**
  135470. * Polygon
  135471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  135472. */
  135473. export class Polygon {
  135474. /**
  135475. * Creates a rectangle
  135476. * @param xmin bottom X coord
  135477. * @param ymin bottom Y coord
  135478. * @param xmax top X coord
  135479. * @param ymax top Y coord
  135480. * @returns points that make the resulting rectation
  135481. */
  135482. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  135483. /**
  135484. * Creates a circle
  135485. * @param radius radius of circle
  135486. * @param cx scale in x
  135487. * @param cy scale in y
  135488. * @param numberOfSides number of sides that make up the circle
  135489. * @returns points that make the resulting circle
  135490. */
  135491. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  135492. /**
  135493. * Creates a polygon from input string
  135494. * @param input Input polygon data
  135495. * @returns the parsed points
  135496. */
  135497. static Parse(input: string): Vector2[];
  135498. /**
  135499. * Starts building a polygon from x and y coordinates
  135500. * @param x x coordinate
  135501. * @param y y coordinate
  135502. * @returns the started path2
  135503. */
  135504. static StartingAt(x: number, y: number): Path2;
  135505. }
  135506. /**
  135507. * Builds a polygon
  135508. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  135509. */
  135510. export class PolygonMeshBuilder {
  135511. private _points;
  135512. private _outlinepoints;
  135513. private _holes;
  135514. private _name;
  135515. private _scene;
  135516. private _epoints;
  135517. private _eholes;
  135518. private _addToepoint;
  135519. /**
  135520. * Babylon reference to the earcut plugin.
  135521. */
  135522. bjsEarcut: any;
  135523. /**
  135524. * Creates a PolygonMeshBuilder
  135525. * @param name name of the builder
  135526. * @param contours Path of the polygon
  135527. * @param scene scene to add to when creating the mesh
  135528. * @param earcutInjection can be used to inject your own earcut reference
  135529. */
  135530. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  135531. /**
  135532. * Adds a whole within the polygon
  135533. * @param hole Array of points defining the hole
  135534. * @returns this
  135535. */
  135536. addHole(hole: Vector2[]): PolygonMeshBuilder;
  135537. /**
  135538. * Creates the polygon
  135539. * @param updatable If the mesh should be updatable
  135540. * @param depth The depth of the mesh created
  135541. * @returns the created mesh
  135542. */
  135543. build(updatable?: boolean, depth?: number): Mesh;
  135544. /**
  135545. * Creates the polygon
  135546. * @param depth The depth of the mesh created
  135547. * @returns the created VertexData
  135548. */
  135549. buildVertexData(depth?: number): VertexData;
  135550. /**
  135551. * Adds a side to the polygon
  135552. * @param positions points that make the polygon
  135553. * @param normals normals of the polygon
  135554. * @param uvs uvs of the polygon
  135555. * @param indices indices of the polygon
  135556. * @param bounds bounds of the polygon
  135557. * @param points points of the polygon
  135558. * @param depth depth of the polygon
  135559. * @param flip flip of the polygon
  135560. */
  135561. private addSide;
  135562. }
  135563. }
  135564. declare module BABYLON {
  135565. /**
  135566. * Class containing static functions to help procedurally build meshes
  135567. */
  135568. export class PolygonBuilder {
  135569. /**
  135570. * Creates a polygon mesh
  135571. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135572. * * 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
  135573. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135576. * * Remember you can only change the shape positions, not their number when updating a polygon
  135577. * @param name defines the name of the mesh
  135578. * @param options defines the options used to create the mesh
  135579. * @param scene defines the hosting scene
  135580. * @param earcutInjection can be used to inject your own earcut reference
  135581. * @returns the polygon mesh
  135582. */
  135583. static CreatePolygon(name: string, options: {
  135584. shape: Vector3[];
  135585. holes?: Vector3[][];
  135586. depth?: number;
  135587. faceUV?: Vector4[];
  135588. faceColors?: Color4[];
  135589. updatable?: boolean;
  135590. sideOrientation?: number;
  135591. frontUVs?: Vector4;
  135592. backUVs?: Vector4;
  135593. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135594. /**
  135595. * Creates an extruded polygon mesh, with depth in the Y direction.
  135596. * * 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)
  135597. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135598. * @param name defines the name of the mesh
  135599. * @param options defines the options used to create the mesh
  135600. * @param scene defines the hosting scene
  135601. * @param earcutInjection can be used to inject your own earcut reference
  135602. * @returns the polygon mesh
  135603. */
  135604. static ExtrudePolygon(name: string, options: {
  135605. shape: Vector3[];
  135606. holes?: Vector3[][];
  135607. depth?: number;
  135608. faceUV?: Vector4[];
  135609. faceColors?: Color4[];
  135610. updatable?: boolean;
  135611. sideOrientation?: number;
  135612. frontUVs?: Vector4;
  135613. backUVs?: Vector4;
  135614. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135615. }
  135616. }
  135617. declare module BABYLON {
  135618. /**
  135619. * Class containing static functions to help procedurally build meshes
  135620. */
  135621. export class LatheBuilder {
  135622. /**
  135623. * Creates lathe mesh.
  135624. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135625. * * 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
  135626. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135627. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135628. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135629. * * 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
  135630. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135631. * * 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
  135632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135633. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135634. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135636. * @param name defines the name of the mesh
  135637. * @param options defines the options used to create the mesh
  135638. * @param scene defines the hosting scene
  135639. * @returns the lathe mesh
  135640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135641. */
  135642. static CreateLathe(name: string, options: {
  135643. shape: Vector3[];
  135644. radius?: number;
  135645. tessellation?: number;
  135646. clip?: number;
  135647. arc?: number;
  135648. closed?: boolean;
  135649. updatable?: boolean;
  135650. sideOrientation?: number;
  135651. frontUVs?: Vector4;
  135652. backUVs?: Vector4;
  135653. cap?: number;
  135654. invertUV?: boolean;
  135655. }, scene?: Nullable<Scene>): Mesh;
  135656. }
  135657. }
  135658. declare module BABYLON {
  135659. /**
  135660. * Class containing static functions to help procedurally build meshes
  135661. */
  135662. export class TiledPlaneBuilder {
  135663. /**
  135664. * Creates a tiled plane mesh
  135665. * * The parameter `pattern` will, depending on value, do nothing or
  135666. * * * flip (reflect about central vertical) alternate tiles across and up
  135667. * * * flip every tile on alternate rows
  135668. * * * rotate (180 degs) alternate tiles across and up
  135669. * * * rotate every tile on alternate rows
  135670. * * * flip and rotate alternate tiles across and up
  135671. * * * flip and rotate every tile on alternate rows
  135672. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  135673. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  135674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135675. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135676. * * 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)
  135677. * * 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)
  135678. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135679. * @param name defines the name of the mesh
  135680. * @param options defines the options used to create the mesh
  135681. * @param scene defines the hosting scene
  135682. * @returns the box mesh
  135683. */
  135684. static CreateTiledPlane(name: string, options: {
  135685. pattern?: number;
  135686. tileSize?: number;
  135687. tileWidth?: number;
  135688. tileHeight?: number;
  135689. size?: number;
  135690. width?: number;
  135691. height?: number;
  135692. alignHorizontal?: number;
  135693. alignVertical?: number;
  135694. sideOrientation?: number;
  135695. frontUVs?: Vector4;
  135696. backUVs?: Vector4;
  135697. updatable?: boolean;
  135698. }, scene?: Nullable<Scene>): Mesh;
  135699. }
  135700. }
  135701. declare module BABYLON {
  135702. /**
  135703. * Class containing static functions to help procedurally build meshes
  135704. */
  135705. export class TubeBuilder {
  135706. /**
  135707. * Creates a tube mesh.
  135708. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135709. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135710. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135711. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135712. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135713. * * 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)
  135714. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135715. * * 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
  135716. * * 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
  135717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135719. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135721. * @param name defines the name of the mesh
  135722. * @param options defines the options used to create the mesh
  135723. * @param scene defines the hosting scene
  135724. * @returns the tube mesh
  135725. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135726. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135727. */
  135728. static CreateTube(name: string, options: {
  135729. path: Vector3[];
  135730. radius?: number;
  135731. tessellation?: number;
  135732. radiusFunction?: {
  135733. (i: number, distance: number): number;
  135734. };
  135735. cap?: number;
  135736. arc?: number;
  135737. updatable?: boolean;
  135738. sideOrientation?: number;
  135739. frontUVs?: Vector4;
  135740. backUVs?: Vector4;
  135741. instance?: Mesh;
  135742. invertUV?: boolean;
  135743. }, scene?: Nullable<Scene>): Mesh;
  135744. }
  135745. }
  135746. declare module BABYLON {
  135747. /**
  135748. * Class containing static functions to help procedurally build meshes
  135749. */
  135750. export class IcoSphereBuilder {
  135751. /**
  135752. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135753. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135754. * * 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`)
  135755. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135756. * * 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
  135757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135760. * @param name defines the name of the mesh
  135761. * @param options defines the options used to create the mesh
  135762. * @param scene defines the hosting scene
  135763. * @returns the icosahedron mesh
  135764. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135765. */
  135766. static CreateIcoSphere(name: string, options: {
  135767. radius?: number;
  135768. radiusX?: number;
  135769. radiusY?: number;
  135770. radiusZ?: number;
  135771. flat?: boolean;
  135772. subdivisions?: number;
  135773. sideOrientation?: number;
  135774. frontUVs?: Vector4;
  135775. backUVs?: Vector4;
  135776. updatable?: boolean;
  135777. }, scene?: Nullable<Scene>): Mesh;
  135778. }
  135779. }
  135780. declare module BABYLON {
  135781. /**
  135782. * Class containing static functions to help procedurally build meshes
  135783. */
  135784. export class DecalBuilder {
  135785. /**
  135786. * Creates a decal mesh.
  135787. * 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
  135788. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135789. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135790. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135791. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135792. * @param name defines the name of the mesh
  135793. * @param sourceMesh defines the mesh where the decal must be applied
  135794. * @param options defines the options used to create the mesh
  135795. * @param scene defines the hosting scene
  135796. * @returns the decal mesh
  135797. * @see https://doc.babylonjs.com/how_to/decals
  135798. */
  135799. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135800. position?: Vector3;
  135801. normal?: Vector3;
  135802. size?: Vector3;
  135803. angle?: number;
  135804. }): Mesh;
  135805. }
  135806. }
  135807. declare module BABYLON {
  135808. /**
  135809. * Class containing static functions to help procedurally build meshes
  135810. */
  135811. export class MeshBuilder {
  135812. /**
  135813. * Creates a box mesh
  135814. * * The parameter `size` sets the size (float) of each box side (default 1)
  135815. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135816. * * 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)
  135817. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135819. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135821. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135822. * @param name defines the name of the mesh
  135823. * @param options defines the options used to create the mesh
  135824. * @param scene defines the hosting scene
  135825. * @returns the box mesh
  135826. */
  135827. static CreateBox(name: string, options: {
  135828. size?: number;
  135829. width?: number;
  135830. height?: number;
  135831. depth?: number;
  135832. faceUV?: Vector4[];
  135833. faceColors?: Color4[];
  135834. sideOrientation?: number;
  135835. frontUVs?: Vector4;
  135836. backUVs?: Vector4;
  135837. wrap?: boolean;
  135838. topBaseAt?: number;
  135839. bottomBaseAt?: number;
  135840. updatable?: boolean;
  135841. }, scene?: Nullable<Scene>): Mesh;
  135842. /**
  135843. * Creates a tiled box mesh
  135844. * * faceTiles sets the pattern, tile size and number of tiles for a face
  135845. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135846. * @param name defines the name of the mesh
  135847. * @param options defines the options used to create the mesh
  135848. * @param scene defines the hosting scene
  135849. * @returns the tiled box mesh
  135850. */
  135851. static CreateTiledBox(name: string, options: {
  135852. pattern?: number;
  135853. size?: number;
  135854. width?: number;
  135855. height?: number;
  135856. depth: number;
  135857. tileSize?: number;
  135858. tileWidth?: number;
  135859. tileHeight?: number;
  135860. faceUV?: Vector4[];
  135861. faceColors?: Color4[];
  135862. alignHorizontal?: number;
  135863. alignVertical?: number;
  135864. sideOrientation?: number;
  135865. updatable?: boolean;
  135866. }, scene?: Nullable<Scene>): Mesh;
  135867. /**
  135868. * Creates a sphere mesh
  135869. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  135870. * * 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`)
  135871. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  135872. * * 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
  135873. * * 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)
  135874. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135875. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135877. * @param name defines the name of the mesh
  135878. * @param options defines the options used to create the mesh
  135879. * @param scene defines the hosting scene
  135880. * @returns the sphere mesh
  135881. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  135882. */
  135883. static CreateSphere(name: string, options: {
  135884. segments?: number;
  135885. diameter?: number;
  135886. diameterX?: number;
  135887. diameterY?: number;
  135888. diameterZ?: number;
  135889. arc?: number;
  135890. slice?: number;
  135891. sideOrientation?: number;
  135892. frontUVs?: Vector4;
  135893. backUVs?: Vector4;
  135894. updatable?: boolean;
  135895. }, scene?: Nullable<Scene>): Mesh;
  135896. /**
  135897. * Creates a plane polygonal mesh. By default, this is a disc
  135898. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  135899. * * 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
  135900. * * 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
  135901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135904. * @param name defines the name of the mesh
  135905. * @param options defines the options used to create the mesh
  135906. * @param scene defines the hosting scene
  135907. * @returns the plane polygonal mesh
  135908. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  135909. */
  135910. static CreateDisc(name: string, options: {
  135911. radius?: number;
  135912. tessellation?: number;
  135913. arc?: number;
  135914. updatable?: boolean;
  135915. sideOrientation?: number;
  135916. frontUVs?: Vector4;
  135917. backUVs?: Vector4;
  135918. }, scene?: Nullable<Scene>): Mesh;
  135919. /**
  135920. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135921. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135922. * * 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`)
  135923. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135924. * * 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
  135925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135928. * @param name defines the name of the mesh
  135929. * @param options defines the options used to create the mesh
  135930. * @param scene defines the hosting scene
  135931. * @returns the icosahedron mesh
  135932. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135933. */
  135934. static CreateIcoSphere(name: string, options: {
  135935. radius?: number;
  135936. radiusX?: number;
  135937. radiusY?: number;
  135938. radiusZ?: number;
  135939. flat?: boolean;
  135940. subdivisions?: number;
  135941. sideOrientation?: number;
  135942. frontUVs?: Vector4;
  135943. backUVs?: Vector4;
  135944. updatable?: boolean;
  135945. }, scene?: Nullable<Scene>): Mesh;
  135946. /**
  135947. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135948. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135949. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135950. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135951. * * 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
  135952. * * 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
  135953. * * 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
  135954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135956. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135957. * * 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
  135958. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135959. * * 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
  135960. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135962. * @param name defines the name of the mesh
  135963. * @param options defines the options used to create the mesh
  135964. * @param scene defines the hosting scene
  135965. * @returns the ribbon mesh
  135966. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135967. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135968. */
  135969. static CreateRibbon(name: string, options: {
  135970. pathArray: Vector3[][];
  135971. closeArray?: boolean;
  135972. closePath?: boolean;
  135973. offset?: number;
  135974. updatable?: boolean;
  135975. sideOrientation?: number;
  135976. frontUVs?: Vector4;
  135977. backUVs?: Vector4;
  135978. instance?: Mesh;
  135979. invertUV?: boolean;
  135980. uvs?: Vector2[];
  135981. colors?: Color4[];
  135982. }, scene?: Nullable<Scene>): Mesh;
  135983. /**
  135984. * Creates a cylinder or a cone mesh
  135985. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  135986. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  135987. * * 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.
  135988. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  135989. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  135990. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  135991. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  135992. * * 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).
  135993. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  135994. * * 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).
  135995. * * 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
  135996. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  135997. * * 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
  135998. * * 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.
  135999. * * If `enclose` is false, a ring surface is one element.
  136000. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  136001. * * 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
  136002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136005. * @param name defines the name of the mesh
  136006. * @param options defines the options used to create the mesh
  136007. * @param scene defines the hosting scene
  136008. * @returns the cylinder mesh
  136009. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  136010. */
  136011. static CreateCylinder(name: string, options: {
  136012. height?: number;
  136013. diameterTop?: number;
  136014. diameterBottom?: number;
  136015. diameter?: number;
  136016. tessellation?: number;
  136017. subdivisions?: number;
  136018. arc?: number;
  136019. faceColors?: Color4[];
  136020. faceUV?: Vector4[];
  136021. updatable?: boolean;
  136022. hasRings?: boolean;
  136023. enclose?: boolean;
  136024. cap?: number;
  136025. sideOrientation?: number;
  136026. frontUVs?: Vector4;
  136027. backUVs?: Vector4;
  136028. }, scene?: Nullable<Scene>): Mesh;
  136029. /**
  136030. * Creates a torus mesh
  136031. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  136032. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  136033. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  136034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136037. * @param name defines the name of the mesh
  136038. * @param options defines the options used to create the mesh
  136039. * @param scene defines the hosting scene
  136040. * @returns the torus mesh
  136041. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  136042. */
  136043. static CreateTorus(name: string, options: {
  136044. diameter?: number;
  136045. thickness?: number;
  136046. tessellation?: number;
  136047. updatable?: boolean;
  136048. sideOrientation?: number;
  136049. frontUVs?: Vector4;
  136050. backUVs?: Vector4;
  136051. }, scene?: Nullable<Scene>): Mesh;
  136052. /**
  136053. * Creates a torus knot mesh
  136054. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  136055. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  136056. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  136057. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  136058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136059. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136061. * @param name defines the name of the mesh
  136062. * @param options defines the options used to create the mesh
  136063. * @param scene defines the hosting scene
  136064. * @returns the torus knot mesh
  136065. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  136066. */
  136067. static CreateTorusKnot(name: string, options: {
  136068. radius?: number;
  136069. tube?: number;
  136070. radialSegments?: number;
  136071. tubularSegments?: number;
  136072. p?: number;
  136073. q?: number;
  136074. updatable?: boolean;
  136075. sideOrientation?: number;
  136076. frontUVs?: Vector4;
  136077. backUVs?: Vector4;
  136078. }, scene?: Nullable<Scene>): Mesh;
  136079. /**
  136080. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  136081. * * 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
  136082. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  136083. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  136084. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  136085. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  136086. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  136087. * * 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
  136088. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  136089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  136091. * @param name defines the name of the new line system
  136092. * @param options defines the options used to create the line system
  136093. * @param scene defines the hosting scene
  136094. * @returns a new line system mesh
  136095. */
  136096. static CreateLineSystem(name: string, options: {
  136097. lines: Vector3[][];
  136098. updatable?: boolean;
  136099. instance?: Nullable<LinesMesh>;
  136100. colors?: Nullable<Color4[][]>;
  136101. useVertexAlpha?: boolean;
  136102. }, scene: Nullable<Scene>): LinesMesh;
  136103. /**
  136104. * Creates a line mesh
  136105. * 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
  136106. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136107. * * The parameter `points` is an array successive Vector3
  136108. * * 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
  136109. * * The optional parameter `colors` is an array of successive Color4, one per line point
  136110. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  136111. * * When updating an instance, remember that only point positions can change, not the number of points
  136112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  136114. * @param name defines the name of the new line system
  136115. * @param options defines the options used to create the line system
  136116. * @param scene defines the hosting scene
  136117. * @returns a new line mesh
  136118. */
  136119. static CreateLines(name: string, options: {
  136120. points: Vector3[];
  136121. updatable?: boolean;
  136122. instance?: Nullable<LinesMesh>;
  136123. colors?: Color4[];
  136124. useVertexAlpha?: boolean;
  136125. }, scene?: Nullable<Scene>): LinesMesh;
  136126. /**
  136127. * Creates a dashed line mesh
  136128. * * 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
  136129. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136130. * * The parameter `points` is an array successive Vector3
  136131. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  136132. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  136133. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  136134. * * 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
  136135. * * When updating an instance, remember that only point positions can change, not the number of points
  136136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136137. * @param name defines the name of the mesh
  136138. * @param options defines the options used to create the mesh
  136139. * @param scene defines the hosting scene
  136140. * @returns the dashed line mesh
  136141. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  136142. */
  136143. static CreateDashedLines(name: string, options: {
  136144. points: Vector3[];
  136145. dashSize?: number;
  136146. gapSize?: number;
  136147. dashNb?: number;
  136148. updatable?: boolean;
  136149. instance?: LinesMesh;
  136150. }, scene?: Nullable<Scene>): LinesMesh;
  136151. /**
  136152. * 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.
  136153. * * 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.
  136154. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136155. * * 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.
  136156. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136157. * * 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
  136158. * * 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
  136159. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136162. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136163. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136164. * @param name defines the name of the mesh
  136165. * @param options defines the options used to create the mesh
  136166. * @param scene defines the hosting scene
  136167. * @returns the extruded shape mesh
  136168. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136169. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136170. */
  136171. static ExtrudeShape(name: string, options: {
  136172. shape: Vector3[];
  136173. path: Vector3[];
  136174. scale?: number;
  136175. rotation?: number;
  136176. cap?: number;
  136177. updatable?: boolean;
  136178. sideOrientation?: number;
  136179. frontUVs?: Vector4;
  136180. backUVs?: Vector4;
  136181. instance?: Mesh;
  136182. invertUV?: boolean;
  136183. }, scene?: Nullable<Scene>): Mesh;
  136184. /**
  136185. * Creates an custom extruded shape mesh.
  136186. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136187. * * 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.
  136188. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136189. * * 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
  136190. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136191. * * 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
  136192. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136193. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136194. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136195. * * 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
  136196. * * 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
  136197. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136198. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136199. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136200. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136202. * @param name defines the name of the mesh
  136203. * @param options defines the options used to create the mesh
  136204. * @param scene defines the hosting scene
  136205. * @returns the custom extruded shape mesh
  136206. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136207. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136209. */
  136210. static ExtrudeShapeCustom(name: string, options: {
  136211. shape: Vector3[];
  136212. path: Vector3[];
  136213. scaleFunction?: any;
  136214. rotationFunction?: any;
  136215. ribbonCloseArray?: boolean;
  136216. ribbonClosePath?: boolean;
  136217. cap?: number;
  136218. updatable?: boolean;
  136219. sideOrientation?: number;
  136220. frontUVs?: Vector4;
  136221. backUVs?: Vector4;
  136222. instance?: Mesh;
  136223. invertUV?: boolean;
  136224. }, scene?: Nullable<Scene>): Mesh;
  136225. /**
  136226. * Creates lathe mesh.
  136227. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  136228. * * 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
  136229. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  136230. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  136231. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  136232. * * 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
  136233. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  136234. * * 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
  136235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136239. * @param name defines the name of the mesh
  136240. * @param options defines the options used to create the mesh
  136241. * @param scene defines the hosting scene
  136242. * @returns the lathe mesh
  136243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  136244. */
  136245. static CreateLathe(name: string, options: {
  136246. shape: Vector3[];
  136247. radius?: number;
  136248. tessellation?: number;
  136249. clip?: number;
  136250. arc?: number;
  136251. closed?: boolean;
  136252. updatable?: boolean;
  136253. sideOrientation?: number;
  136254. frontUVs?: Vector4;
  136255. backUVs?: Vector4;
  136256. cap?: number;
  136257. invertUV?: boolean;
  136258. }, scene?: Nullable<Scene>): Mesh;
  136259. /**
  136260. * Creates a tiled plane mesh
  136261. * * You can set a limited pattern arrangement with the tiles
  136262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136265. * @param name defines the name of the mesh
  136266. * @param options defines the options used to create the mesh
  136267. * @param scene defines the hosting scene
  136268. * @returns the plane mesh
  136269. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136270. */
  136271. static CreateTiledPlane(name: string, options: {
  136272. pattern?: number;
  136273. tileSize?: number;
  136274. tileWidth?: number;
  136275. tileHeight?: number;
  136276. size?: number;
  136277. width?: number;
  136278. height?: number;
  136279. alignHorizontal?: number;
  136280. alignVertical?: number;
  136281. sideOrientation?: number;
  136282. frontUVs?: Vector4;
  136283. backUVs?: Vector4;
  136284. updatable?: boolean;
  136285. }, scene?: Nullable<Scene>): Mesh;
  136286. /**
  136287. * Creates a plane mesh
  136288. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  136289. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  136290. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  136291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136292. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136294. * @param name defines the name of the mesh
  136295. * @param options defines the options used to create the mesh
  136296. * @param scene defines the hosting scene
  136297. * @returns the plane mesh
  136298. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136299. */
  136300. static CreatePlane(name: string, options: {
  136301. size?: number;
  136302. width?: number;
  136303. height?: number;
  136304. sideOrientation?: number;
  136305. frontUVs?: Vector4;
  136306. backUVs?: Vector4;
  136307. updatable?: boolean;
  136308. sourcePlane?: Plane;
  136309. }, scene?: Nullable<Scene>): Mesh;
  136310. /**
  136311. * Creates a ground mesh
  136312. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  136313. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  136314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136315. * @param name defines the name of the mesh
  136316. * @param options defines the options used to create the mesh
  136317. * @param scene defines the hosting scene
  136318. * @returns the ground mesh
  136319. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  136320. */
  136321. static CreateGround(name: string, options: {
  136322. width?: number;
  136323. height?: number;
  136324. subdivisions?: number;
  136325. subdivisionsX?: number;
  136326. subdivisionsY?: number;
  136327. updatable?: boolean;
  136328. }, scene?: Nullable<Scene>): Mesh;
  136329. /**
  136330. * Creates a tiled ground mesh
  136331. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  136332. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  136333. * * 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
  136334. * * 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
  136335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136336. * @param name defines the name of the mesh
  136337. * @param options defines the options used to create the mesh
  136338. * @param scene defines the hosting scene
  136339. * @returns the tiled ground mesh
  136340. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  136341. */
  136342. static CreateTiledGround(name: string, options: {
  136343. xmin: number;
  136344. zmin: number;
  136345. xmax: number;
  136346. zmax: number;
  136347. subdivisions?: {
  136348. w: number;
  136349. h: number;
  136350. };
  136351. precision?: {
  136352. w: number;
  136353. h: number;
  136354. };
  136355. updatable?: boolean;
  136356. }, scene?: Nullable<Scene>): Mesh;
  136357. /**
  136358. * Creates a ground mesh from a height map
  136359. * * The parameter `url` sets the URL of the height map image resource.
  136360. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  136361. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  136362. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  136363. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  136364. * * 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.
  136365. * * 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).
  136366. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  136367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136368. * @param name defines the name of the mesh
  136369. * @param url defines the url to the height map
  136370. * @param options defines the options used to create the mesh
  136371. * @param scene defines the hosting scene
  136372. * @returns the ground mesh
  136373. * @see https://doc.babylonjs.com/babylon101/height_map
  136374. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  136375. */
  136376. static CreateGroundFromHeightMap(name: string, url: string, options: {
  136377. width?: number;
  136378. height?: number;
  136379. subdivisions?: number;
  136380. minHeight?: number;
  136381. maxHeight?: number;
  136382. colorFilter?: Color3;
  136383. alphaFilter?: number;
  136384. updatable?: boolean;
  136385. onReady?: (mesh: GroundMesh) => void;
  136386. }, scene?: Nullable<Scene>): GroundMesh;
  136387. /**
  136388. * Creates a polygon mesh
  136389. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136390. * * 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
  136391. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136394. * * Remember you can only change the shape positions, not their number when updating a polygon
  136395. * @param name defines the name of the mesh
  136396. * @param options defines the options used to create the mesh
  136397. * @param scene defines the hosting scene
  136398. * @param earcutInjection can be used to inject your own earcut reference
  136399. * @returns the polygon mesh
  136400. */
  136401. static CreatePolygon(name: string, options: {
  136402. shape: Vector3[];
  136403. holes?: Vector3[][];
  136404. depth?: number;
  136405. faceUV?: Vector4[];
  136406. faceColors?: Color4[];
  136407. updatable?: boolean;
  136408. sideOrientation?: number;
  136409. frontUVs?: Vector4;
  136410. backUVs?: Vector4;
  136411. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136412. /**
  136413. * Creates an extruded polygon mesh, with depth in the Y direction.
  136414. * * 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)
  136415. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136416. * @param name defines the name of the mesh
  136417. * @param options defines the options used to create the mesh
  136418. * @param scene defines the hosting scene
  136419. * @param earcutInjection can be used to inject your own earcut reference
  136420. * @returns the polygon mesh
  136421. */
  136422. static ExtrudePolygon(name: string, options: {
  136423. shape: Vector3[];
  136424. holes?: Vector3[][];
  136425. depth?: number;
  136426. faceUV?: Vector4[];
  136427. faceColors?: Color4[];
  136428. updatable?: boolean;
  136429. sideOrientation?: number;
  136430. frontUVs?: Vector4;
  136431. backUVs?: Vector4;
  136432. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136433. /**
  136434. * Creates a tube mesh.
  136435. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136436. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136437. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136438. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136439. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136440. * * 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)
  136441. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136442. * * 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
  136443. * * 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
  136444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136445. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136446. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136448. * @param name defines the name of the mesh
  136449. * @param options defines the options used to create the mesh
  136450. * @param scene defines the hosting scene
  136451. * @returns the tube mesh
  136452. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136453. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136454. */
  136455. static CreateTube(name: string, options: {
  136456. path: Vector3[];
  136457. radius?: number;
  136458. tessellation?: number;
  136459. radiusFunction?: {
  136460. (i: number, distance: number): number;
  136461. };
  136462. cap?: number;
  136463. arc?: number;
  136464. updatable?: boolean;
  136465. sideOrientation?: number;
  136466. frontUVs?: Vector4;
  136467. backUVs?: Vector4;
  136468. instance?: Mesh;
  136469. invertUV?: boolean;
  136470. }, scene?: Nullable<Scene>): Mesh;
  136471. /**
  136472. * Creates a polyhedron mesh
  136473. * * 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
  136474. * * The parameter `size` (positive float, default 1) sets the polygon size
  136475. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136476. * * 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`
  136477. * * 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
  136478. * * 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)`)
  136479. * * 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
  136480. * * 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
  136481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136484. * @param name defines the name of the mesh
  136485. * @param options defines the options used to create the mesh
  136486. * @param scene defines the hosting scene
  136487. * @returns the polyhedron mesh
  136488. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136489. */
  136490. static CreatePolyhedron(name: string, options: {
  136491. type?: number;
  136492. size?: number;
  136493. sizeX?: number;
  136494. sizeY?: number;
  136495. sizeZ?: number;
  136496. custom?: any;
  136497. faceUV?: Vector4[];
  136498. faceColors?: Color4[];
  136499. flat?: boolean;
  136500. updatable?: boolean;
  136501. sideOrientation?: number;
  136502. frontUVs?: Vector4;
  136503. backUVs?: Vector4;
  136504. }, scene?: Nullable<Scene>): Mesh;
  136505. /**
  136506. * Creates a decal mesh.
  136507. * 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
  136508. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136509. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136510. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136511. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136512. * @param name defines the name of the mesh
  136513. * @param sourceMesh defines the mesh where the decal must be applied
  136514. * @param options defines the options used to create the mesh
  136515. * @param scene defines the hosting scene
  136516. * @returns the decal mesh
  136517. * @see https://doc.babylonjs.com/how_to/decals
  136518. */
  136519. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136520. position?: Vector3;
  136521. normal?: Vector3;
  136522. size?: Vector3;
  136523. angle?: number;
  136524. }): Mesh;
  136525. }
  136526. }
  136527. declare module BABYLON {
  136528. /**
  136529. * A simplifier interface for future simplification implementations
  136530. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136531. */
  136532. export interface ISimplifier {
  136533. /**
  136534. * Simplification of a given mesh according to the given settings.
  136535. * Since this requires computation, it is assumed that the function runs async.
  136536. * @param settings The settings of the simplification, including quality and distance
  136537. * @param successCallback A callback that will be called after the mesh was simplified.
  136538. * @param errorCallback in case of an error, this callback will be called. optional.
  136539. */
  136540. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  136541. }
  136542. /**
  136543. * Expected simplification settings.
  136544. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  136545. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136546. */
  136547. export interface ISimplificationSettings {
  136548. /**
  136549. * Gets or sets the expected quality
  136550. */
  136551. quality: number;
  136552. /**
  136553. * Gets or sets the distance when this optimized version should be used
  136554. */
  136555. distance: number;
  136556. /**
  136557. * Gets an already optimized mesh
  136558. */
  136559. optimizeMesh?: boolean;
  136560. }
  136561. /**
  136562. * Class used to specify simplification options
  136563. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136564. */
  136565. export class SimplificationSettings implements ISimplificationSettings {
  136566. /** expected quality */
  136567. quality: number;
  136568. /** distance when this optimized version should be used */
  136569. distance: number;
  136570. /** already optimized mesh */
  136571. optimizeMesh?: boolean | undefined;
  136572. /**
  136573. * Creates a SimplificationSettings
  136574. * @param quality expected quality
  136575. * @param distance distance when this optimized version should be used
  136576. * @param optimizeMesh already optimized mesh
  136577. */
  136578. constructor(
  136579. /** expected quality */
  136580. quality: number,
  136581. /** distance when this optimized version should be used */
  136582. distance: number,
  136583. /** already optimized mesh */
  136584. optimizeMesh?: boolean | undefined);
  136585. }
  136586. /**
  136587. * Interface used to define a simplification task
  136588. */
  136589. export interface ISimplificationTask {
  136590. /**
  136591. * Array of settings
  136592. */
  136593. settings: Array<ISimplificationSettings>;
  136594. /**
  136595. * Simplification type
  136596. */
  136597. simplificationType: SimplificationType;
  136598. /**
  136599. * Mesh to simplify
  136600. */
  136601. mesh: Mesh;
  136602. /**
  136603. * Callback called on success
  136604. */
  136605. successCallback?: () => void;
  136606. /**
  136607. * Defines if parallel processing can be used
  136608. */
  136609. parallelProcessing: boolean;
  136610. }
  136611. /**
  136612. * Queue used to order the simplification tasks
  136613. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136614. */
  136615. export class SimplificationQueue {
  136616. private _simplificationArray;
  136617. /**
  136618. * Gets a boolean indicating that the process is still running
  136619. */
  136620. running: boolean;
  136621. /**
  136622. * Creates a new queue
  136623. */
  136624. constructor();
  136625. /**
  136626. * Adds a new simplification task
  136627. * @param task defines a task to add
  136628. */
  136629. addTask(task: ISimplificationTask): void;
  136630. /**
  136631. * Execute next task
  136632. */
  136633. executeNext(): void;
  136634. /**
  136635. * Execute a simplification task
  136636. * @param task defines the task to run
  136637. */
  136638. runSimplification(task: ISimplificationTask): void;
  136639. private getSimplifier;
  136640. }
  136641. /**
  136642. * The implemented types of simplification
  136643. * At the moment only Quadratic Error Decimation is implemented
  136644. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136645. */
  136646. export enum SimplificationType {
  136647. /** Quadratic error decimation */
  136648. QUADRATIC = 0
  136649. }
  136650. /**
  136651. * An implementation of the Quadratic Error simplification algorithm.
  136652. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  136653. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  136654. * @author RaananW
  136655. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136656. */
  136657. export class QuadraticErrorSimplification implements ISimplifier {
  136658. private _mesh;
  136659. private triangles;
  136660. private vertices;
  136661. private references;
  136662. private _reconstructedMesh;
  136663. /** Gets or sets the number pf sync interations */
  136664. syncIterations: number;
  136665. /** Gets or sets the aggressiveness of the simplifier */
  136666. aggressiveness: number;
  136667. /** Gets or sets the number of allowed iterations for decimation */
  136668. decimationIterations: number;
  136669. /** Gets or sets the espilon to use for bounding box computation */
  136670. boundingBoxEpsilon: number;
  136671. /**
  136672. * Creates a new QuadraticErrorSimplification
  136673. * @param _mesh defines the target mesh
  136674. */
  136675. constructor(_mesh: Mesh);
  136676. /**
  136677. * Simplification of a given mesh according to the given settings.
  136678. * Since this requires computation, it is assumed that the function runs async.
  136679. * @param settings The settings of the simplification, including quality and distance
  136680. * @param successCallback A callback that will be called after the mesh was simplified.
  136681. */
  136682. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  136683. private runDecimation;
  136684. private initWithMesh;
  136685. private init;
  136686. private reconstructMesh;
  136687. private initDecimatedMesh;
  136688. private isFlipped;
  136689. private updateTriangles;
  136690. private identifyBorder;
  136691. private updateMesh;
  136692. private vertexError;
  136693. private calculateError;
  136694. }
  136695. }
  136696. declare module BABYLON {
  136697. interface Scene {
  136698. /** @hidden (Backing field) */
  136699. _simplificationQueue: SimplificationQueue;
  136700. /**
  136701. * Gets or sets the simplification queue attached to the scene
  136702. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136703. */
  136704. simplificationQueue: SimplificationQueue;
  136705. }
  136706. interface Mesh {
  136707. /**
  136708. * Simplify the mesh according to the given array of settings.
  136709. * Function will return immediately and will simplify async
  136710. * @param settings a collection of simplification settings
  136711. * @param parallelProcessing should all levels calculate parallel or one after the other
  136712. * @param simplificationType the type of simplification to run
  136713. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  136714. * @returns the current mesh
  136715. */
  136716. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  136717. }
  136718. /**
  136719. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  136720. * created in a scene
  136721. */
  136722. export class SimplicationQueueSceneComponent implements ISceneComponent {
  136723. /**
  136724. * The component name helpfull to identify the component in the list of scene components.
  136725. */
  136726. readonly name: string;
  136727. /**
  136728. * The scene the component belongs to.
  136729. */
  136730. scene: Scene;
  136731. /**
  136732. * Creates a new instance of the component for the given scene
  136733. * @param scene Defines the scene to register the component in
  136734. */
  136735. constructor(scene: Scene);
  136736. /**
  136737. * Registers the component in a given scene
  136738. */
  136739. register(): void;
  136740. /**
  136741. * Rebuilds the elements related to this component in case of
  136742. * context lost for instance.
  136743. */
  136744. rebuild(): void;
  136745. /**
  136746. * Disposes the component and the associated ressources
  136747. */
  136748. dispose(): void;
  136749. private _beforeCameraUpdate;
  136750. }
  136751. }
  136752. declare module BABYLON {
  136753. /**
  136754. * Navigation plugin interface to add navigation constrained by a navigation mesh
  136755. */
  136756. export interface INavigationEnginePlugin {
  136757. /**
  136758. * plugin name
  136759. */
  136760. name: string;
  136761. /**
  136762. * Creates a navigation mesh
  136763. * @param meshes array of all the geometry used to compute the navigatio mesh
  136764. * @param parameters bunch of parameters used to filter geometry
  136765. */
  136766. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136767. /**
  136768. * Create a navigation mesh debug mesh
  136769. * @param scene is where the mesh will be added
  136770. * @returns debug display mesh
  136771. */
  136772. createDebugNavMesh(scene: Scene): Mesh;
  136773. /**
  136774. * Get a navigation mesh constrained position, closest to the parameter position
  136775. * @param position world position
  136776. * @returns the closest point to position constrained by the navigation mesh
  136777. */
  136778. getClosestPoint(position: Vector3): Vector3;
  136779. /**
  136780. * Get a navigation mesh constrained position, closest to the parameter position
  136781. * @param position world position
  136782. * @param result output the closest point to position constrained by the navigation mesh
  136783. */
  136784. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136785. /**
  136786. * Get a navigation mesh constrained position, within a particular radius
  136787. * @param position world position
  136788. * @param maxRadius the maximum distance to the constrained world position
  136789. * @returns the closest point to position constrained by the navigation mesh
  136790. */
  136791. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136792. /**
  136793. * Get a navigation mesh constrained position, within a particular radius
  136794. * @param position world position
  136795. * @param maxRadius the maximum distance to the constrained world position
  136796. * @param result output the closest point to position constrained by the navigation mesh
  136797. */
  136798. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136799. /**
  136800. * Compute the final position from a segment made of destination-position
  136801. * @param position world position
  136802. * @param destination world position
  136803. * @returns the resulting point along the navmesh
  136804. */
  136805. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136806. /**
  136807. * Compute the final position from a segment made of destination-position
  136808. * @param position world position
  136809. * @param destination world position
  136810. * @param result output the resulting point along the navmesh
  136811. */
  136812. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136813. /**
  136814. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136815. * @param start world position
  136816. * @param end world position
  136817. * @returns array containing world position composing the path
  136818. */
  136819. computePath(start: Vector3, end: Vector3): Vector3[];
  136820. /**
  136821. * If this plugin is supported
  136822. * @returns true if plugin is supported
  136823. */
  136824. isSupported(): boolean;
  136825. /**
  136826. * Create a new Crowd so you can add agents
  136827. * @param maxAgents the maximum agent count in the crowd
  136828. * @param maxAgentRadius the maximum radius an agent can have
  136829. * @param scene to attach the crowd to
  136830. * @returns the crowd you can add agents to
  136831. */
  136832. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136833. /**
  136834. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136835. * The queries will try to find a solution within those bounds
  136836. * default is (1,1,1)
  136837. * @param extent x,y,z value that define the extent around the queries point of reference
  136838. */
  136839. setDefaultQueryExtent(extent: Vector3): void;
  136840. /**
  136841. * Get the Bounding box extent specified by setDefaultQueryExtent
  136842. * @returns the box extent values
  136843. */
  136844. getDefaultQueryExtent(): Vector3;
  136845. /**
  136846. * build the navmesh from a previously saved state using getNavmeshData
  136847. * @param data the Uint8Array returned by getNavmeshData
  136848. */
  136849. buildFromNavmeshData(data: Uint8Array): void;
  136850. /**
  136851. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136852. * @returns data the Uint8Array that can be saved and reused
  136853. */
  136854. getNavmeshData(): Uint8Array;
  136855. /**
  136856. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136857. * @param result output the box extent values
  136858. */
  136859. getDefaultQueryExtentToRef(result: Vector3): void;
  136860. /**
  136861. * Release all resources
  136862. */
  136863. dispose(): void;
  136864. }
  136865. /**
  136866. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  136867. */
  136868. export interface ICrowd {
  136869. /**
  136870. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136871. * You can attach anything to that node. The node position is updated in the scene update tick.
  136872. * @param pos world position that will be constrained by the navigation mesh
  136873. * @param parameters agent parameters
  136874. * @param transform hooked to the agent that will be update by the scene
  136875. * @returns agent index
  136876. */
  136877. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136878. /**
  136879. * Returns the agent position in world space
  136880. * @param index agent index returned by addAgent
  136881. * @returns world space position
  136882. */
  136883. getAgentPosition(index: number): Vector3;
  136884. /**
  136885. * Gets the agent position result in world space
  136886. * @param index agent index returned by addAgent
  136887. * @param result output world space position
  136888. */
  136889. getAgentPositionToRef(index: number, result: Vector3): void;
  136890. /**
  136891. * Gets the agent velocity in world space
  136892. * @param index agent index returned by addAgent
  136893. * @returns world space velocity
  136894. */
  136895. getAgentVelocity(index: number): Vector3;
  136896. /**
  136897. * Gets the agent velocity result in world space
  136898. * @param index agent index returned by addAgent
  136899. * @param result output world space velocity
  136900. */
  136901. getAgentVelocityToRef(index: number, result: Vector3): void;
  136902. /**
  136903. * remove a particular agent previously created
  136904. * @param index agent index returned by addAgent
  136905. */
  136906. removeAgent(index: number): void;
  136907. /**
  136908. * get the list of all agents attached to this crowd
  136909. * @returns list of agent indices
  136910. */
  136911. getAgents(): number[];
  136912. /**
  136913. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136914. * @param deltaTime in seconds
  136915. */
  136916. update(deltaTime: number): void;
  136917. /**
  136918. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136919. * @param index agent index returned by addAgent
  136920. * @param destination targeted world position
  136921. */
  136922. agentGoto(index: number, destination: Vector3): void;
  136923. /**
  136924. * Teleport the agent to a new position
  136925. * @param index agent index returned by addAgent
  136926. * @param destination targeted world position
  136927. */
  136928. agentTeleport(index: number, destination: Vector3): void;
  136929. /**
  136930. * Update agent parameters
  136931. * @param index agent index returned by addAgent
  136932. * @param parameters agent parameters
  136933. */
  136934. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136935. /**
  136936. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136937. * The queries will try to find a solution within those bounds
  136938. * default is (1,1,1)
  136939. * @param extent x,y,z value that define the extent around the queries point of reference
  136940. */
  136941. setDefaultQueryExtent(extent: Vector3): void;
  136942. /**
  136943. * Get the Bounding box extent specified by setDefaultQueryExtent
  136944. * @returns the box extent values
  136945. */
  136946. getDefaultQueryExtent(): Vector3;
  136947. /**
  136948. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136949. * @param result output the box extent values
  136950. */
  136951. getDefaultQueryExtentToRef(result: Vector3): void;
  136952. /**
  136953. * Release all resources
  136954. */
  136955. dispose(): void;
  136956. }
  136957. /**
  136958. * Configures an agent
  136959. */
  136960. export interface IAgentParameters {
  136961. /**
  136962. * Agent radius. [Limit: >= 0]
  136963. */
  136964. radius: number;
  136965. /**
  136966. * Agent height. [Limit: > 0]
  136967. */
  136968. height: number;
  136969. /**
  136970. * Maximum allowed acceleration. [Limit: >= 0]
  136971. */
  136972. maxAcceleration: number;
  136973. /**
  136974. * Maximum allowed speed. [Limit: >= 0]
  136975. */
  136976. maxSpeed: number;
  136977. /**
  136978. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  136979. */
  136980. collisionQueryRange: number;
  136981. /**
  136982. * The path visibility optimization range. [Limit: > 0]
  136983. */
  136984. pathOptimizationRange: number;
  136985. /**
  136986. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  136987. */
  136988. separationWeight: number;
  136989. }
  136990. /**
  136991. * Configures the navigation mesh creation
  136992. */
  136993. export interface INavMeshParameters {
  136994. /**
  136995. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  136996. */
  136997. cs: number;
  136998. /**
  136999. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  137000. */
  137001. ch: number;
  137002. /**
  137003. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  137004. */
  137005. walkableSlopeAngle: number;
  137006. /**
  137007. * Minimum floor to 'ceiling' height that will still allow the floor area to
  137008. * be considered walkable. [Limit: >= 3] [Units: vx]
  137009. */
  137010. walkableHeight: number;
  137011. /**
  137012. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  137013. */
  137014. walkableClimb: number;
  137015. /**
  137016. * The distance to erode/shrink the walkable area of the heightfield away from
  137017. * obstructions. [Limit: >=0] [Units: vx]
  137018. */
  137019. walkableRadius: number;
  137020. /**
  137021. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  137022. */
  137023. maxEdgeLen: number;
  137024. /**
  137025. * The maximum distance a simplfied contour's border edges should deviate
  137026. * the original raw contour. [Limit: >=0] [Units: vx]
  137027. */
  137028. maxSimplificationError: number;
  137029. /**
  137030. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  137031. */
  137032. minRegionArea: number;
  137033. /**
  137034. * Any regions with a span count smaller than this value will, if possible,
  137035. * be merged with larger regions. [Limit: >=0] [Units: vx]
  137036. */
  137037. mergeRegionArea: number;
  137038. /**
  137039. * The maximum number of vertices allowed for polygons generated during the
  137040. * contour to polygon conversion process. [Limit: >= 3]
  137041. */
  137042. maxVertsPerPoly: number;
  137043. /**
  137044. * Sets the sampling distance to use when generating the detail mesh.
  137045. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  137046. */
  137047. detailSampleDist: number;
  137048. /**
  137049. * The maximum distance the detail mesh surface should deviate from heightfield
  137050. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  137051. */
  137052. detailSampleMaxError: number;
  137053. }
  137054. }
  137055. declare module BABYLON {
  137056. /**
  137057. * RecastJS navigation plugin
  137058. */
  137059. export class RecastJSPlugin implements INavigationEnginePlugin {
  137060. /**
  137061. * Reference to the Recast library
  137062. */
  137063. bjsRECAST: any;
  137064. /**
  137065. * plugin name
  137066. */
  137067. name: string;
  137068. /**
  137069. * the first navmesh created. We might extend this to support multiple navmeshes
  137070. */
  137071. navMesh: any;
  137072. /**
  137073. * Initializes the recastJS plugin
  137074. * @param recastInjection can be used to inject your own recast reference
  137075. */
  137076. constructor(recastInjection?: any);
  137077. /**
  137078. * Creates a navigation mesh
  137079. * @param meshes array of all the geometry used to compute the navigatio mesh
  137080. * @param parameters bunch of parameters used to filter geometry
  137081. */
  137082. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  137083. /**
  137084. * Create a navigation mesh debug mesh
  137085. * @param scene is where the mesh will be added
  137086. * @returns debug display mesh
  137087. */
  137088. createDebugNavMesh(scene: Scene): Mesh;
  137089. /**
  137090. * Get a navigation mesh constrained position, closest to the parameter position
  137091. * @param position world position
  137092. * @returns the closest point to position constrained by the navigation mesh
  137093. */
  137094. getClosestPoint(position: Vector3): Vector3;
  137095. /**
  137096. * Get a navigation mesh constrained position, closest to the parameter position
  137097. * @param position world position
  137098. * @param result output the closest point to position constrained by the navigation mesh
  137099. */
  137100. getClosestPointToRef(position: Vector3, result: Vector3): void;
  137101. /**
  137102. * Get a navigation mesh constrained position, within a particular radius
  137103. * @param position world position
  137104. * @param maxRadius the maximum distance to the constrained world position
  137105. * @returns the closest point to position constrained by the navigation mesh
  137106. */
  137107. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  137108. /**
  137109. * Get a navigation mesh constrained position, within a particular radius
  137110. * @param position world position
  137111. * @param maxRadius the maximum distance to the constrained world position
  137112. * @param result output the closest point to position constrained by the navigation mesh
  137113. */
  137114. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  137115. /**
  137116. * Compute the final position from a segment made of destination-position
  137117. * @param position world position
  137118. * @param destination world position
  137119. * @returns the resulting point along the navmesh
  137120. */
  137121. moveAlong(position: Vector3, destination: Vector3): Vector3;
  137122. /**
  137123. * Compute the final position from a segment made of destination-position
  137124. * @param position world position
  137125. * @param destination world position
  137126. * @param result output the resulting point along the navmesh
  137127. */
  137128. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  137129. /**
  137130. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  137131. * @param start world position
  137132. * @param end world position
  137133. * @returns array containing world position composing the path
  137134. */
  137135. computePath(start: Vector3, end: Vector3): Vector3[];
  137136. /**
  137137. * Create a new Crowd so you can add agents
  137138. * @param maxAgents the maximum agent count in the crowd
  137139. * @param maxAgentRadius the maximum radius an agent can have
  137140. * @param scene to attach the crowd to
  137141. * @returns the crowd you can add agents to
  137142. */
  137143. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  137144. /**
  137145. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137146. * The queries will try to find a solution within those bounds
  137147. * default is (1,1,1)
  137148. * @param extent x,y,z value that define the extent around the queries point of reference
  137149. */
  137150. setDefaultQueryExtent(extent: Vector3): void;
  137151. /**
  137152. * Get the Bounding box extent specified by setDefaultQueryExtent
  137153. * @returns the box extent values
  137154. */
  137155. getDefaultQueryExtent(): Vector3;
  137156. /**
  137157. * build the navmesh from a previously saved state using getNavmeshData
  137158. * @param data the Uint8Array returned by getNavmeshData
  137159. */
  137160. buildFromNavmeshData(data: Uint8Array): void;
  137161. /**
  137162. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  137163. * @returns data the Uint8Array that can be saved and reused
  137164. */
  137165. getNavmeshData(): Uint8Array;
  137166. /**
  137167. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137168. * @param result output the box extent values
  137169. */
  137170. getDefaultQueryExtentToRef(result: Vector3): void;
  137171. /**
  137172. * Disposes
  137173. */
  137174. dispose(): void;
  137175. /**
  137176. * If this plugin is supported
  137177. * @returns true if plugin is supported
  137178. */
  137179. isSupported(): boolean;
  137180. }
  137181. /**
  137182. * Recast detour crowd implementation
  137183. */
  137184. export class RecastJSCrowd implements ICrowd {
  137185. /**
  137186. * Recast/detour plugin
  137187. */
  137188. bjsRECASTPlugin: RecastJSPlugin;
  137189. /**
  137190. * Link to the detour crowd
  137191. */
  137192. recastCrowd: any;
  137193. /**
  137194. * One transform per agent
  137195. */
  137196. transforms: TransformNode[];
  137197. /**
  137198. * All agents created
  137199. */
  137200. agents: number[];
  137201. /**
  137202. * Link to the scene is kept to unregister the crowd from the scene
  137203. */
  137204. private _scene;
  137205. /**
  137206. * Observer for crowd updates
  137207. */
  137208. private _onBeforeAnimationsObserver;
  137209. /**
  137210. * Constructor
  137211. * @param plugin recastJS plugin
  137212. * @param maxAgents the maximum agent count in the crowd
  137213. * @param maxAgentRadius the maximum radius an agent can have
  137214. * @param scene to attach the crowd to
  137215. * @returns the crowd you can add agents to
  137216. */
  137217. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  137218. /**
  137219. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  137220. * You can attach anything to that node. The node position is updated in the scene update tick.
  137221. * @param pos world position that will be constrained by the navigation mesh
  137222. * @param parameters agent parameters
  137223. * @param transform hooked to the agent that will be update by the scene
  137224. * @returns agent index
  137225. */
  137226. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  137227. /**
  137228. * Returns the agent position in world space
  137229. * @param index agent index returned by addAgent
  137230. * @returns world space position
  137231. */
  137232. getAgentPosition(index: number): Vector3;
  137233. /**
  137234. * Returns the agent position result in world space
  137235. * @param index agent index returned by addAgent
  137236. * @param result output world space position
  137237. */
  137238. getAgentPositionToRef(index: number, result: Vector3): void;
  137239. /**
  137240. * Returns the agent velocity in world space
  137241. * @param index agent index returned by addAgent
  137242. * @returns world space velocity
  137243. */
  137244. getAgentVelocity(index: number): Vector3;
  137245. /**
  137246. * Returns the agent velocity result in world space
  137247. * @param index agent index returned by addAgent
  137248. * @param result output world space velocity
  137249. */
  137250. getAgentVelocityToRef(index: number, result: Vector3): void;
  137251. /**
  137252. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  137253. * @param index agent index returned by addAgent
  137254. * @param destination targeted world position
  137255. */
  137256. agentGoto(index: number, destination: Vector3): void;
  137257. /**
  137258. * Teleport the agent to a new position
  137259. * @param index agent index returned by addAgent
  137260. * @param destination targeted world position
  137261. */
  137262. agentTeleport(index: number, destination: Vector3): void;
  137263. /**
  137264. * Update agent parameters
  137265. * @param index agent index returned by addAgent
  137266. * @param parameters agent parameters
  137267. */
  137268. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  137269. /**
  137270. * remove a particular agent previously created
  137271. * @param index agent index returned by addAgent
  137272. */
  137273. removeAgent(index: number): void;
  137274. /**
  137275. * get the list of all agents attached to this crowd
  137276. * @returns list of agent indices
  137277. */
  137278. getAgents(): number[];
  137279. /**
  137280. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  137281. * @param deltaTime in seconds
  137282. */
  137283. update(deltaTime: number): void;
  137284. /**
  137285. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137286. * The queries will try to find a solution within those bounds
  137287. * default is (1,1,1)
  137288. * @param extent x,y,z value that define the extent around the queries point of reference
  137289. */
  137290. setDefaultQueryExtent(extent: Vector3): void;
  137291. /**
  137292. * Get the Bounding box extent specified by setDefaultQueryExtent
  137293. * @returns the box extent values
  137294. */
  137295. getDefaultQueryExtent(): Vector3;
  137296. /**
  137297. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137298. * @param result output the box extent values
  137299. */
  137300. getDefaultQueryExtentToRef(result: Vector3): void;
  137301. /**
  137302. * Release all resources
  137303. */
  137304. dispose(): void;
  137305. }
  137306. }
  137307. declare module BABYLON {
  137308. /**
  137309. * Class used to enable access to IndexedDB
  137310. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  137311. */
  137312. export class Database implements IOfflineProvider {
  137313. private _callbackManifestChecked;
  137314. private _currentSceneUrl;
  137315. private _db;
  137316. private _enableSceneOffline;
  137317. private _enableTexturesOffline;
  137318. private _manifestVersionFound;
  137319. private _mustUpdateRessources;
  137320. private _hasReachedQuota;
  137321. private _isSupported;
  137322. private _idbFactory;
  137323. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  137324. private static IsUASupportingBlobStorage;
  137325. /**
  137326. * Gets a boolean indicating if Database storate is enabled (off by default)
  137327. */
  137328. static IDBStorageEnabled: boolean;
  137329. /**
  137330. * Gets a boolean indicating if scene must be saved in the database
  137331. */
  137332. get enableSceneOffline(): boolean;
  137333. /**
  137334. * Gets a boolean indicating if textures must be saved in the database
  137335. */
  137336. get enableTexturesOffline(): boolean;
  137337. /**
  137338. * Creates a new Database
  137339. * @param urlToScene defines the url to load the scene
  137340. * @param callbackManifestChecked defines the callback to use when manifest is checked
  137341. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  137342. */
  137343. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  137344. private static _ParseURL;
  137345. private static _ReturnFullUrlLocation;
  137346. private _checkManifestFile;
  137347. /**
  137348. * Open the database and make it available
  137349. * @param successCallback defines the callback to call on success
  137350. * @param errorCallback defines the callback to call on error
  137351. */
  137352. open(successCallback: () => void, errorCallback: () => void): void;
  137353. /**
  137354. * Loads an image from the database
  137355. * @param url defines the url to load from
  137356. * @param image defines the target DOM image
  137357. */
  137358. loadImage(url: string, image: HTMLImageElement): void;
  137359. private _loadImageFromDBAsync;
  137360. private _saveImageIntoDBAsync;
  137361. private _checkVersionFromDB;
  137362. private _loadVersionFromDBAsync;
  137363. private _saveVersionIntoDBAsync;
  137364. /**
  137365. * Loads a file from database
  137366. * @param url defines the URL to load from
  137367. * @param sceneLoaded defines a callback to call on success
  137368. * @param progressCallBack defines a callback to call when progress changed
  137369. * @param errorCallback defines a callback to call on error
  137370. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  137371. */
  137372. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  137373. private _loadFileAsync;
  137374. private _saveFileAsync;
  137375. /**
  137376. * Validates if xhr data is correct
  137377. * @param xhr defines the request to validate
  137378. * @param dataType defines the expected data type
  137379. * @returns true if data is correct
  137380. */
  137381. private static _ValidateXHRData;
  137382. }
  137383. }
  137384. declare module BABYLON {
  137385. /** @hidden */
  137386. export var gpuUpdateParticlesPixelShader: {
  137387. name: string;
  137388. shader: string;
  137389. };
  137390. }
  137391. declare module BABYLON {
  137392. /** @hidden */
  137393. export var gpuUpdateParticlesVertexShader: {
  137394. name: string;
  137395. shader: string;
  137396. };
  137397. }
  137398. declare module BABYLON {
  137399. /** @hidden */
  137400. export var clipPlaneFragmentDeclaration2: {
  137401. name: string;
  137402. shader: string;
  137403. };
  137404. }
  137405. declare module BABYLON {
  137406. /** @hidden */
  137407. export var gpuRenderParticlesPixelShader: {
  137408. name: string;
  137409. shader: string;
  137410. };
  137411. }
  137412. declare module BABYLON {
  137413. /** @hidden */
  137414. export var clipPlaneVertexDeclaration2: {
  137415. name: string;
  137416. shader: string;
  137417. };
  137418. }
  137419. declare module BABYLON {
  137420. /** @hidden */
  137421. export var gpuRenderParticlesVertexShader: {
  137422. name: string;
  137423. shader: string;
  137424. };
  137425. }
  137426. declare module BABYLON {
  137427. /**
  137428. * This represents a GPU particle system in Babylon
  137429. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  137430. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  137431. */
  137432. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  137433. /**
  137434. * The layer mask we are rendering the particles through.
  137435. */
  137436. layerMask: number;
  137437. private _capacity;
  137438. private _activeCount;
  137439. private _currentActiveCount;
  137440. private _accumulatedCount;
  137441. private _renderEffect;
  137442. private _updateEffect;
  137443. private _buffer0;
  137444. private _buffer1;
  137445. private _spriteBuffer;
  137446. private _updateVAO;
  137447. private _renderVAO;
  137448. private _targetIndex;
  137449. private _sourceBuffer;
  137450. private _targetBuffer;
  137451. private _engine;
  137452. private _currentRenderId;
  137453. private _started;
  137454. private _stopped;
  137455. private _timeDelta;
  137456. private _randomTexture;
  137457. private _randomTexture2;
  137458. private _attributesStrideSize;
  137459. private _updateEffectOptions;
  137460. private _randomTextureSize;
  137461. private _actualFrame;
  137462. private readonly _rawTextureWidth;
  137463. /**
  137464. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  137465. */
  137466. static get IsSupported(): boolean;
  137467. /**
  137468. * An event triggered when the system is disposed.
  137469. */
  137470. onDisposeObservable: Observable<GPUParticleSystem>;
  137471. /**
  137472. * Gets the maximum number of particles active at the same time.
  137473. * @returns The max number of active particles.
  137474. */
  137475. getCapacity(): number;
  137476. /**
  137477. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  137478. * to override the particles.
  137479. */
  137480. forceDepthWrite: boolean;
  137481. /**
  137482. * Gets or set the number of active particles
  137483. */
  137484. get activeParticleCount(): number;
  137485. set activeParticleCount(value: number);
  137486. private _preWarmDone;
  137487. /**
  137488. * Specifies if the particles are updated in emitter local space or world space.
  137489. * This is always false for GPU particles
  137490. */
  137491. get isLocal(): boolean;
  137492. set isLocal(value: boolean);
  137493. /**
  137494. * Is this system ready to be used/rendered
  137495. * @return true if the system is ready
  137496. */
  137497. isReady(): boolean;
  137498. /**
  137499. * Gets if the system has been started. (Note: this will still be true after stop is called)
  137500. * @returns True if it has been started, otherwise false.
  137501. */
  137502. isStarted(): boolean;
  137503. /**
  137504. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  137505. * @returns True if it has been stopped, otherwise false.
  137506. */
  137507. isStopped(): boolean;
  137508. /**
  137509. * Gets a boolean indicating that the system is stopping
  137510. * @returns true if the system is currently stopping
  137511. */
  137512. isStopping(): boolean;
  137513. /**
  137514. * Gets the number of particles active at the same time.
  137515. * @returns The number of active particles.
  137516. */
  137517. getActiveCount(): number;
  137518. /**
  137519. * Starts the particle system and begins to emit
  137520. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  137521. */
  137522. start(delay?: number): void;
  137523. /**
  137524. * Stops the particle system.
  137525. */
  137526. stop(): void;
  137527. /**
  137528. * Remove all active particles
  137529. */
  137530. reset(): void;
  137531. /**
  137532. * Returns the string "GPUParticleSystem"
  137533. * @returns a string containing the class name
  137534. */
  137535. getClassName(): string;
  137536. private _colorGradientsTexture;
  137537. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  137538. /**
  137539. * Adds a new color gradient
  137540. * @param gradient defines the gradient to use (between 0 and 1)
  137541. * @param color1 defines the color to affect to the specified gradient
  137542. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  137543. * @returns the current particle system
  137544. */
  137545. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  137546. private _refreshColorGradient;
  137547. /** Force the system to rebuild all gradients that need to be resync */
  137548. forceRefreshGradients(): void;
  137549. /**
  137550. * Remove a specific color gradient
  137551. * @param gradient defines the gradient to remove
  137552. * @returns the current particle system
  137553. */
  137554. removeColorGradient(gradient: number): GPUParticleSystem;
  137555. private _angularSpeedGradientsTexture;
  137556. private _sizeGradientsTexture;
  137557. private _velocityGradientsTexture;
  137558. private _limitVelocityGradientsTexture;
  137559. private _dragGradientsTexture;
  137560. private _addFactorGradient;
  137561. /**
  137562. * Adds a new size gradient
  137563. * @param gradient defines the gradient to use (between 0 and 1)
  137564. * @param factor defines the size factor to affect to the specified gradient
  137565. * @returns the current particle system
  137566. */
  137567. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  137568. /**
  137569. * Remove a specific size gradient
  137570. * @param gradient defines the gradient to remove
  137571. * @returns the current particle system
  137572. */
  137573. removeSizeGradient(gradient: number): GPUParticleSystem;
  137574. private _refreshFactorGradient;
  137575. /**
  137576. * Adds a new angular speed gradient
  137577. * @param gradient defines the gradient to use (between 0 and 1)
  137578. * @param factor defines the angular speed to affect to the specified gradient
  137579. * @returns the current particle system
  137580. */
  137581. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  137582. /**
  137583. * Remove a specific angular speed gradient
  137584. * @param gradient defines the gradient to remove
  137585. * @returns the current particle system
  137586. */
  137587. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  137588. /**
  137589. * Adds a new velocity gradient
  137590. * @param gradient defines the gradient to use (between 0 and 1)
  137591. * @param factor defines the velocity to affect to the specified gradient
  137592. * @returns the current particle system
  137593. */
  137594. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137595. /**
  137596. * Remove a specific velocity gradient
  137597. * @param gradient defines the gradient to remove
  137598. * @returns the current particle system
  137599. */
  137600. removeVelocityGradient(gradient: number): GPUParticleSystem;
  137601. /**
  137602. * Adds a new limit velocity gradient
  137603. * @param gradient defines the gradient to use (between 0 and 1)
  137604. * @param factor defines the limit velocity value to affect to the specified gradient
  137605. * @returns the current particle system
  137606. */
  137607. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137608. /**
  137609. * Remove a specific limit velocity gradient
  137610. * @param gradient defines the gradient to remove
  137611. * @returns the current particle system
  137612. */
  137613. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  137614. /**
  137615. * Adds a new drag gradient
  137616. * @param gradient defines the gradient to use (between 0 and 1)
  137617. * @param factor defines the drag value to affect to the specified gradient
  137618. * @returns the current particle system
  137619. */
  137620. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  137621. /**
  137622. * Remove a specific drag gradient
  137623. * @param gradient defines the gradient to remove
  137624. * @returns the current particle system
  137625. */
  137626. removeDragGradient(gradient: number): GPUParticleSystem;
  137627. /**
  137628. * Not supported by GPUParticleSystem
  137629. * @param gradient defines the gradient to use (between 0 and 1)
  137630. * @param factor defines the emit rate value to affect to the specified gradient
  137631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137632. * @returns the current particle system
  137633. */
  137634. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137635. /**
  137636. * Not supported by GPUParticleSystem
  137637. * @param gradient defines the gradient to remove
  137638. * @returns the current particle system
  137639. */
  137640. removeEmitRateGradient(gradient: number): IParticleSystem;
  137641. /**
  137642. * Not supported by GPUParticleSystem
  137643. * @param gradient defines the gradient to use (between 0 and 1)
  137644. * @param factor defines the start size value to affect to the specified gradient
  137645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137646. * @returns the current particle system
  137647. */
  137648. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137649. /**
  137650. * Not supported by GPUParticleSystem
  137651. * @param gradient defines the gradient to remove
  137652. * @returns the current particle system
  137653. */
  137654. removeStartSizeGradient(gradient: number): IParticleSystem;
  137655. /**
  137656. * Not supported by GPUParticleSystem
  137657. * @param gradient defines the gradient to use (between 0 and 1)
  137658. * @param min defines the color remap minimal range
  137659. * @param max defines the color remap maximal range
  137660. * @returns the current particle system
  137661. */
  137662. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137663. /**
  137664. * Not supported by GPUParticleSystem
  137665. * @param gradient defines the gradient to remove
  137666. * @returns the current particle system
  137667. */
  137668. removeColorRemapGradient(): IParticleSystem;
  137669. /**
  137670. * Not supported by GPUParticleSystem
  137671. * @param gradient defines the gradient to use (between 0 and 1)
  137672. * @param min defines the alpha remap minimal range
  137673. * @param max defines the alpha remap maximal range
  137674. * @returns the current particle system
  137675. */
  137676. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137677. /**
  137678. * Not supported by GPUParticleSystem
  137679. * @param gradient defines the gradient to remove
  137680. * @returns the current particle system
  137681. */
  137682. removeAlphaRemapGradient(): IParticleSystem;
  137683. /**
  137684. * Not supported by GPUParticleSystem
  137685. * @param gradient defines the gradient to use (between 0 and 1)
  137686. * @param color defines the color to affect to the specified gradient
  137687. * @returns the current particle system
  137688. */
  137689. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  137690. /**
  137691. * Not supported by GPUParticleSystem
  137692. * @param gradient defines the gradient to remove
  137693. * @returns the current particle system
  137694. */
  137695. removeRampGradient(): IParticleSystem;
  137696. /**
  137697. * Not supported by GPUParticleSystem
  137698. * @returns the list of ramp gradients
  137699. */
  137700. getRampGradients(): Nullable<Array<Color3Gradient>>;
  137701. /**
  137702. * Not supported by GPUParticleSystem
  137703. * Gets or sets a boolean indicating that ramp gradients must be used
  137704. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  137705. */
  137706. get useRampGradients(): boolean;
  137707. set useRampGradients(value: boolean);
  137708. /**
  137709. * Not supported by GPUParticleSystem
  137710. * @param gradient defines the gradient to use (between 0 and 1)
  137711. * @param factor defines the life time factor to affect to the specified gradient
  137712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137713. * @returns the current particle system
  137714. */
  137715. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137716. /**
  137717. * Not supported by GPUParticleSystem
  137718. * @param gradient defines the gradient to remove
  137719. * @returns the current particle system
  137720. */
  137721. removeLifeTimeGradient(gradient: number): IParticleSystem;
  137722. /**
  137723. * Instantiates a GPU particle system.
  137724. * 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.
  137725. * @param name The name of the particle system
  137726. * @param options The options used to create the system
  137727. * @param scene The scene the particle system belongs to
  137728. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  137729. */
  137730. constructor(name: string, options: Partial<{
  137731. capacity: number;
  137732. randomTextureSize: number;
  137733. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  137734. protected _reset(): void;
  137735. private _createUpdateVAO;
  137736. private _createRenderVAO;
  137737. private _initialize;
  137738. /** @hidden */
  137739. _recreateUpdateEffect(): void;
  137740. /** @hidden */
  137741. _recreateRenderEffect(): void;
  137742. /**
  137743. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  137744. * @param preWarm defines if we are in the pre-warmimg phase
  137745. */
  137746. animate(preWarm?: boolean): void;
  137747. private _createFactorGradientTexture;
  137748. private _createSizeGradientTexture;
  137749. private _createAngularSpeedGradientTexture;
  137750. private _createVelocityGradientTexture;
  137751. private _createLimitVelocityGradientTexture;
  137752. private _createDragGradientTexture;
  137753. private _createColorGradientTexture;
  137754. /**
  137755. * Renders the particle system in its current state
  137756. * @param preWarm defines if the system should only update the particles but not render them
  137757. * @returns the current number of particles
  137758. */
  137759. render(preWarm?: boolean): number;
  137760. /**
  137761. * Rebuilds the particle system
  137762. */
  137763. rebuild(): void;
  137764. private _releaseBuffers;
  137765. private _releaseVAOs;
  137766. /**
  137767. * Disposes the particle system and free the associated resources
  137768. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  137769. */
  137770. dispose(disposeTexture?: boolean): void;
  137771. /**
  137772. * Clones the particle system.
  137773. * @param name The name of the cloned object
  137774. * @param newEmitter The new emitter to use
  137775. * @returns the cloned particle system
  137776. */
  137777. clone(name: string, newEmitter: any): GPUParticleSystem;
  137778. /**
  137779. * Serializes the particle system to a JSON object
  137780. * @param serializeTexture defines if the texture must be serialized as well
  137781. * @returns the JSON object
  137782. */
  137783. serialize(serializeTexture?: boolean): any;
  137784. /**
  137785. * Parses a JSON object to create a GPU particle system.
  137786. * @param parsedParticleSystem The JSON object to parse
  137787. * @param scene The scene to create the particle system in
  137788. * @param rootUrl The root url to use to load external dependencies like texture
  137789. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  137790. * @returns the parsed GPU particle system
  137791. */
  137792. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  137793. }
  137794. }
  137795. declare module BABYLON {
  137796. /**
  137797. * Represents a set of particle systems working together to create a specific effect
  137798. */
  137799. export class ParticleSystemSet implements IDisposable {
  137800. /**
  137801. * Gets or sets base Assets URL
  137802. */
  137803. static BaseAssetsUrl: string;
  137804. private _emitterCreationOptions;
  137805. private _emitterNode;
  137806. /**
  137807. * Gets the particle system list
  137808. */
  137809. systems: IParticleSystem[];
  137810. /**
  137811. * Gets the emitter node used with this set
  137812. */
  137813. get emitterNode(): Nullable<TransformNode>;
  137814. /**
  137815. * Creates a new emitter mesh as a sphere
  137816. * @param options defines the options used to create the sphere
  137817. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  137818. * @param scene defines the hosting scene
  137819. */
  137820. setEmitterAsSphere(options: {
  137821. diameter: number;
  137822. segments: number;
  137823. color: Color3;
  137824. }, renderingGroupId: number, scene: Scene): void;
  137825. /**
  137826. * Starts all particle systems of the set
  137827. * @param emitter defines an optional mesh to use as emitter for the particle systems
  137828. */
  137829. start(emitter?: AbstractMesh): void;
  137830. /**
  137831. * Release all associated resources
  137832. */
  137833. dispose(): void;
  137834. /**
  137835. * Serialize the set into a JSON compatible object
  137836. * @param serializeTexture defines if the texture must be serialized as well
  137837. * @returns a JSON compatible representation of the set
  137838. */
  137839. serialize(serializeTexture?: boolean): any;
  137840. /**
  137841. * Parse a new ParticleSystemSet from a serialized source
  137842. * @param data defines a JSON compatible representation of the set
  137843. * @param scene defines the hosting scene
  137844. * @param gpu defines if we want GPU particles or CPU particles
  137845. * @returns a new ParticleSystemSet
  137846. */
  137847. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  137848. }
  137849. }
  137850. declare module BABYLON {
  137851. /**
  137852. * This class is made for on one-liner static method to help creating particle system set.
  137853. */
  137854. export class ParticleHelper {
  137855. /**
  137856. * Gets or sets base Assets URL
  137857. */
  137858. static BaseAssetsUrl: string;
  137859. /** Define the Url to load snippets */
  137860. static SnippetUrl: string;
  137861. /**
  137862. * Create a default particle system that you can tweak
  137863. * @param emitter defines the emitter to use
  137864. * @param capacity defines the system capacity (default is 500 particles)
  137865. * @param scene defines the hosting scene
  137866. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  137867. * @returns the new Particle system
  137868. */
  137869. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  137870. /**
  137871. * This is the main static method (one-liner) of this helper to create different particle systems
  137872. * @param type This string represents the type to the particle system to create
  137873. * @param scene The scene where the particle system should live
  137874. * @param gpu If the system will use gpu
  137875. * @returns the ParticleSystemSet created
  137876. */
  137877. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  137878. /**
  137879. * Static function used to export a particle system to a ParticleSystemSet variable.
  137880. * Please note that the emitter shape is not exported
  137881. * @param systems defines the particle systems to export
  137882. * @returns the created particle system set
  137883. */
  137884. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  137885. /**
  137886. * Creates a particle system from a snippet saved in a remote file
  137887. * @param name defines the name of the particle system to create
  137888. * @param url defines the url to load from
  137889. * @param scene defines the hosting scene
  137890. * @param gpu If the system will use gpu
  137891. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137892. * @returns a promise that will resolve to the new particle system
  137893. */
  137894. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137895. /**
  137896. * Creates a particle system from a snippet saved by the particle system editor
  137897. * @param snippetId defines the snippet to load
  137898. * @param scene defines the hosting scene
  137899. * @param gpu If the system will use gpu
  137900. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137901. * @returns a promise that will resolve to the new particle system
  137902. */
  137903. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137904. }
  137905. }
  137906. declare module BABYLON {
  137907. interface Engine {
  137908. /**
  137909. * Create an effect to use with particle systems.
  137910. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  137911. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  137912. * @param uniformsNames defines a list of attribute names
  137913. * @param samplers defines an array of string used to represent textures
  137914. * @param defines defines the string containing the defines to use to compile the shaders
  137915. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  137916. * @param onCompiled defines a function to call when the effect creation is successful
  137917. * @param onError defines a function to call when the effect creation has failed
  137918. * @returns the new Effect
  137919. */
  137920. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  137921. }
  137922. interface Mesh {
  137923. /**
  137924. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  137925. * @returns an array of IParticleSystem
  137926. */
  137927. getEmittedParticleSystems(): IParticleSystem[];
  137928. /**
  137929. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  137930. * @returns an array of IParticleSystem
  137931. */
  137932. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  137933. }
  137934. /**
  137935. * @hidden
  137936. */
  137937. export var _IDoNeedToBeInTheBuild: number;
  137938. }
  137939. declare module BABYLON {
  137940. /** Defines the 4 color options */
  137941. export enum PointColor {
  137942. /** color value */
  137943. Color = 2,
  137944. /** uv value */
  137945. UV = 1,
  137946. /** random value */
  137947. Random = 0,
  137948. /** stated value */
  137949. Stated = 3
  137950. }
  137951. /**
  137952. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  137953. * 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.
  137954. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  137955. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  137956. *
  137957. * Full documentation here : TO BE ENTERED
  137958. */
  137959. export class PointsCloudSystem implements IDisposable {
  137960. /**
  137961. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  137962. * Example : var p = SPS.particles[i];
  137963. */
  137964. particles: CloudPoint[];
  137965. /**
  137966. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  137967. */
  137968. nbParticles: number;
  137969. /**
  137970. * This a counter for your own usage. It's not set by any SPS functions.
  137971. */
  137972. counter: number;
  137973. /**
  137974. * The PCS name. This name is also given to the underlying mesh.
  137975. */
  137976. name: string;
  137977. /**
  137978. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  137979. */
  137980. mesh: Mesh;
  137981. /**
  137982. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  137983. * Please read :
  137984. */
  137985. vars: any;
  137986. /**
  137987. * @hidden
  137988. */
  137989. _size: number;
  137990. private _scene;
  137991. private _promises;
  137992. private _positions;
  137993. private _indices;
  137994. private _normals;
  137995. private _colors;
  137996. private _uvs;
  137997. private _indices32;
  137998. private _positions32;
  137999. private _colors32;
  138000. private _uvs32;
  138001. private _updatable;
  138002. private _isVisibilityBoxLocked;
  138003. private _alwaysVisible;
  138004. private _groups;
  138005. private _groupCounter;
  138006. private _computeParticleColor;
  138007. private _computeParticleTexture;
  138008. private _computeParticleRotation;
  138009. private _computeBoundingBox;
  138010. private _isReady;
  138011. /**
  138012. * Creates a PCS (Points Cloud System) object
  138013. * @param name (String) is the PCS name, this will be the underlying mesh name
  138014. * @param pointSize (number) is the size for each point
  138015. * @param scene (Scene) is the scene in which the PCS is added
  138016. * @param options defines the options of the PCS e.g.
  138017. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  138018. */
  138019. constructor(name: string, pointSize: number, scene: Scene, options?: {
  138020. updatable?: boolean;
  138021. });
  138022. /**
  138023. * Builds the PCS underlying mesh. Returns a standard Mesh.
  138024. * If no points were added to the PCS, the returned mesh is just a single point.
  138025. * @returns a promise for the created mesh
  138026. */
  138027. buildMeshAsync(): Promise<Mesh>;
  138028. /**
  138029. * @hidden
  138030. */
  138031. private _buildMesh;
  138032. private _addParticle;
  138033. private _randomUnitVector;
  138034. private _getColorIndicesForCoord;
  138035. private _setPointsColorOrUV;
  138036. private _colorFromTexture;
  138037. private _calculateDensity;
  138038. /**
  138039. * Adds points to the PCS in random positions within a unit sphere
  138040. * @param nb (positive integer) the number of particles to be created from this model
  138041. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  138042. * @returns the number of groups in the system
  138043. */
  138044. addPoints(nb: number, pointFunction?: any): number;
  138045. /**
  138046. * Adds points to the PCS from the surface of the model shape
  138047. * @param mesh is any Mesh object that will be used as a surface model for the points
  138048. * @param nb (positive integer) the number of particles to be created from this model
  138049. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138050. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138051. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138052. * @returns the number of groups in the system
  138053. */
  138054. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138055. /**
  138056. * Adds points to the PCS inside the model shape
  138057. * @param mesh is any Mesh object that will be used as a surface model for the points
  138058. * @param nb (positive integer) the number of particles to be created from this model
  138059. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138060. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138061. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138062. * @returns the number of groups in the system
  138063. */
  138064. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138065. /**
  138066. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  138067. * This method calls `updateParticle()` for each particle of the SPS.
  138068. * For an animated SPS, it is usually called within the render loop.
  138069. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  138070. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  138071. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  138072. * @returns the PCS.
  138073. */
  138074. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  138075. /**
  138076. * Disposes the PCS.
  138077. */
  138078. dispose(): void;
  138079. /**
  138080. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  138081. * doc :
  138082. * @returns the PCS.
  138083. */
  138084. refreshVisibleSize(): PointsCloudSystem;
  138085. /**
  138086. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  138087. * @param size the size (float) of the visibility box
  138088. * note : this doesn't lock the PCS mesh bounding box.
  138089. * doc :
  138090. */
  138091. setVisibilityBox(size: number): void;
  138092. /**
  138093. * Gets whether the PCS is always visible or not
  138094. * doc :
  138095. */
  138096. get isAlwaysVisible(): boolean;
  138097. /**
  138098. * Sets the PCS as always visible or not
  138099. * doc :
  138100. */
  138101. set isAlwaysVisible(val: boolean);
  138102. /**
  138103. * Tells to `setParticles()` to compute the particle rotations or not
  138104. * Default value : false. The PCS is faster when it's set to false
  138105. * Note : particle rotations are only applied to parent particles
  138106. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  138107. */
  138108. set computeParticleRotation(val: boolean);
  138109. /**
  138110. * Tells to `setParticles()` to compute the particle colors or not.
  138111. * Default value : true. The PCS is faster when it's set to false.
  138112. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138113. */
  138114. set computeParticleColor(val: boolean);
  138115. set computeParticleTexture(val: boolean);
  138116. /**
  138117. * Gets if `setParticles()` computes the particle colors or not.
  138118. * Default value : false. The PCS is faster when it's set to false.
  138119. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138120. */
  138121. get computeParticleColor(): boolean;
  138122. /**
  138123. * Gets if `setParticles()` computes the particle textures or not.
  138124. * Default value : false. The PCS is faster when it's set to false.
  138125. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  138126. */
  138127. get computeParticleTexture(): boolean;
  138128. /**
  138129. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  138130. */
  138131. set computeBoundingBox(val: boolean);
  138132. /**
  138133. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  138134. */
  138135. get computeBoundingBox(): boolean;
  138136. /**
  138137. * This function does nothing. It may be overwritten to set all the particle first values.
  138138. * The PCS doesn't call this function, you may have to call it by your own.
  138139. * doc :
  138140. */
  138141. initParticles(): void;
  138142. /**
  138143. * This function does nothing. It may be overwritten to recycle a particle
  138144. * The PCS doesn't call this function, you can to call it
  138145. * doc :
  138146. * @param particle The particle to recycle
  138147. * @returns the recycled particle
  138148. */
  138149. recycleParticle(particle: CloudPoint): CloudPoint;
  138150. /**
  138151. * Updates a particle : this function should be overwritten by the user.
  138152. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  138153. * doc :
  138154. * @example : just set a particle position or velocity and recycle conditions
  138155. * @param particle The particle to update
  138156. * @returns the updated particle
  138157. */
  138158. updateParticle(particle: CloudPoint): CloudPoint;
  138159. /**
  138160. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  138161. * This does nothing and may be overwritten by the user.
  138162. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138163. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138164. * @param update the boolean update value actually passed to setParticles()
  138165. */
  138166. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138167. /**
  138168. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  138169. * This will be passed three parameters.
  138170. * This does nothing and may be overwritten by the user.
  138171. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138172. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138173. * @param update the boolean update value actually passed to setParticles()
  138174. */
  138175. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138176. }
  138177. }
  138178. declare module BABYLON {
  138179. /**
  138180. * Represents one particle of a points cloud system.
  138181. */
  138182. export class CloudPoint {
  138183. /**
  138184. * particle global index
  138185. */
  138186. idx: number;
  138187. /**
  138188. * The color of the particle
  138189. */
  138190. color: Nullable<Color4>;
  138191. /**
  138192. * The world space position of the particle.
  138193. */
  138194. position: Vector3;
  138195. /**
  138196. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  138197. */
  138198. rotation: Vector3;
  138199. /**
  138200. * The world space rotation quaternion of the particle.
  138201. */
  138202. rotationQuaternion: Nullable<Quaternion>;
  138203. /**
  138204. * The uv of the particle.
  138205. */
  138206. uv: Nullable<Vector2>;
  138207. /**
  138208. * The current speed of the particle.
  138209. */
  138210. velocity: Vector3;
  138211. /**
  138212. * The pivot point in the particle local space.
  138213. */
  138214. pivot: Vector3;
  138215. /**
  138216. * Must the particle be translated from its pivot point in its local space ?
  138217. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  138218. * Default : false
  138219. */
  138220. translateFromPivot: boolean;
  138221. /**
  138222. * Index of this particle in the global "positions" array (Internal use)
  138223. * @hidden
  138224. */
  138225. _pos: number;
  138226. /**
  138227. * @hidden Index of this particle in the global "indices" array (Internal use)
  138228. */
  138229. _ind: number;
  138230. /**
  138231. * Group this particle belongs to
  138232. */
  138233. _group: PointsGroup;
  138234. /**
  138235. * Group id of this particle
  138236. */
  138237. groupId: number;
  138238. /**
  138239. * Index of the particle in its group id (Internal use)
  138240. */
  138241. idxInGroup: number;
  138242. /**
  138243. * @hidden Particle BoundingInfo object (Internal use)
  138244. */
  138245. _boundingInfo: BoundingInfo;
  138246. /**
  138247. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  138248. */
  138249. _pcs: PointsCloudSystem;
  138250. /**
  138251. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  138252. */
  138253. _stillInvisible: boolean;
  138254. /**
  138255. * @hidden Last computed particle rotation matrix
  138256. */
  138257. _rotationMatrix: number[];
  138258. /**
  138259. * Parent particle Id, if any.
  138260. * Default null.
  138261. */
  138262. parentId: Nullable<number>;
  138263. /**
  138264. * @hidden Internal global position in the PCS.
  138265. */
  138266. _globalPosition: Vector3;
  138267. /**
  138268. * Creates a Point Cloud object.
  138269. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  138270. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  138271. * @param group (PointsGroup) is the group the particle belongs to
  138272. * @param groupId (integer) is the group identifier in the PCS.
  138273. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  138274. * @param pcs defines the PCS it is associated to
  138275. */
  138276. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  138277. /**
  138278. * get point size
  138279. */
  138280. get size(): Vector3;
  138281. /**
  138282. * Set point size
  138283. */
  138284. set size(scale: Vector3);
  138285. /**
  138286. * Legacy support, changed quaternion to rotationQuaternion
  138287. */
  138288. get quaternion(): Nullable<Quaternion>;
  138289. /**
  138290. * Legacy support, changed quaternion to rotationQuaternion
  138291. */
  138292. set quaternion(q: Nullable<Quaternion>);
  138293. /**
  138294. * Returns a boolean. True if the particle intersects a mesh, else false
  138295. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  138296. * @param target is the object (point or mesh) what the intersection is computed against
  138297. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  138298. * @returns true if it intersects
  138299. */
  138300. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  138301. /**
  138302. * get the rotation matrix of the particle
  138303. * @hidden
  138304. */
  138305. getRotationMatrix(m: Matrix): void;
  138306. }
  138307. /**
  138308. * Represents a group of points in a points cloud system
  138309. * * PCS internal tool, don't use it manually.
  138310. */
  138311. export class PointsGroup {
  138312. /**
  138313. * The group id
  138314. * @hidden
  138315. */
  138316. groupID: number;
  138317. /**
  138318. * image data for group (internal use)
  138319. * @hidden
  138320. */
  138321. _groupImageData: Nullable<ArrayBufferView>;
  138322. /**
  138323. * Image Width (internal use)
  138324. * @hidden
  138325. */
  138326. _groupImgWidth: number;
  138327. /**
  138328. * Image Height (internal use)
  138329. * @hidden
  138330. */
  138331. _groupImgHeight: number;
  138332. /**
  138333. * Custom position function (internal use)
  138334. * @hidden
  138335. */
  138336. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  138337. /**
  138338. * density per facet for surface points
  138339. * @hidden
  138340. */
  138341. _groupDensity: number[];
  138342. /**
  138343. * Only when points are colored by texture carries pointer to texture list array
  138344. * @hidden
  138345. */
  138346. _textureNb: number;
  138347. /**
  138348. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  138349. * PCS internal tool, don't use it manually.
  138350. * @hidden
  138351. */
  138352. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  138353. }
  138354. }
  138355. declare module BABYLON {
  138356. interface Scene {
  138357. /** @hidden (Backing field) */
  138358. _physicsEngine: Nullable<IPhysicsEngine>;
  138359. /** @hidden */
  138360. _physicsTimeAccumulator: number;
  138361. /**
  138362. * Gets the current physics engine
  138363. * @returns a IPhysicsEngine or null if none attached
  138364. */
  138365. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  138366. /**
  138367. * Enables physics to the current scene
  138368. * @param gravity defines the scene's gravity for the physics engine
  138369. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  138370. * @return a boolean indicating if the physics engine was initialized
  138371. */
  138372. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  138373. /**
  138374. * Disables and disposes the physics engine associated with the scene
  138375. */
  138376. disablePhysicsEngine(): void;
  138377. /**
  138378. * Gets a boolean indicating if there is an active physics engine
  138379. * @returns a boolean indicating if there is an active physics engine
  138380. */
  138381. isPhysicsEnabled(): boolean;
  138382. /**
  138383. * Deletes a physics compound impostor
  138384. * @param compound defines the compound to delete
  138385. */
  138386. deleteCompoundImpostor(compound: any): void;
  138387. /**
  138388. * An event triggered when physic simulation is about to be run
  138389. */
  138390. onBeforePhysicsObservable: Observable<Scene>;
  138391. /**
  138392. * An event triggered when physic simulation has been done
  138393. */
  138394. onAfterPhysicsObservable: Observable<Scene>;
  138395. }
  138396. interface AbstractMesh {
  138397. /** @hidden */
  138398. _physicsImpostor: Nullable<PhysicsImpostor>;
  138399. /**
  138400. * Gets or sets impostor used for physic simulation
  138401. * @see http://doc.babylonjs.com/features/physics_engine
  138402. */
  138403. physicsImpostor: Nullable<PhysicsImpostor>;
  138404. /**
  138405. * Gets the current physics impostor
  138406. * @see http://doc.babylonjs.com/features/physics_engine
  138407. * @returns a physics impostor or null
  138408. */
  138409. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  138410. /** Apply a physic impulse to the mesh
  138411. * @param force defines the force to apply
  138412. * @param contactPoint defines where to apply the force
  138413. * @returns the current mesh
  138414. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  138415. */
  138416. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  138417. /**
  138418. * Creates a physic joint between two meshes
  138419. * @param otherMesh defines the other mesh to use
  138420. * @param pivot1 defines the pivot to use on this mesh
  138421. * @param pivot2 defines the pivot to use on the other mesh
  138422. * @param options defines additional options (can be plugin dependent)
  138423. * @returns the current mesh
  138424. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  138425. */
  138426. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  138427. /** @hidden */
  138428. _disposePhysicsObserver: Nullable<Observer<Node>>;
  138429. }
  138430. /**
  138431. * Defines the physics engine scene component responsible to manage a physics engine
  138432. */
  138433. export class PhysicsEngineSceneComponent implements ISceneComponent {
  138434. /**
  138435. * The component name helpful to identify the component in the list of scene components.
  138436. */
  138437. readonly name: string;
  138438. /**
  138439. * The scene the component belongs to.
  138440. */
  138441. scene: Scene;
  138442. /**
  138443. * Creates a new instance of the component for the given scene
  138444. * @param scene Defines the scene to register the component in
  138445. */
  138446. constructor(scene: Scene);
  138447. /**
  138448. * Registers the component in a given scene
  138449. */
  138450. register(): void;
  138451. /**
  138452. * Rebuilds the elements related to this component in case of
  138453. * context lost for instance.
  138454. */
  138455. rebuild(): void;
  138456. /**
  138457. * Disposes the component and the associated ressources
  138458. */
  138459. dispose(): void;
  138460. }
  138461. }
  138462. declare module BABYLON {
  138463. /**
  138464. * A helper for physics simulations
  138465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138466. */
  138467. export class PhysicsHelper {
  138468. private _scene;
  138469. private _physicsEngine;
  138470. /**
  138471. * Initializes the Physics helper
  138472. * @param scene Babylon.js scene
  138473. */
  138474. constructor(scene: Scene);
  138475. /**
  138476. * Applies a radial explosion impulse
  138477. * @param origin the origin of the explosion
  138478. * @param radiusOrEventOptions the radius or the options of radial explosion
  138479. * @param strength the explosion strength
  138480. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138481. * @returns A physics radial explosion event, or null
  138482. */
  138483. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138484. /**
  138485. * Applies a radial explosion force
  138486. * @param origin the origin of the explosion
  138487. * @param radiusOrEventOptions the radius or the options of radial explosion
  138488. * @param strength the explosion strength
  138489. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138490. * @returns A physics radial explosion event, or null
  138491. */
  138492. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138493. /**
  138494. * Creates a gravitational field
  138495. * @param origin the origin of the explosion
  138496. * @param radiusOrEventOptions the radius or the options of radial explosion
  138497. * @param strength the explosion strength
  138498. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138499. * @returns A physics gravitational field event, or null
  138500. */
  138501. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  138502. /**
  138503. * Creates a physics updraft event
  138504. * @param origin the origin of the updraft
  138505. * @param radiusOrEventOptions the radius or the options of the updraft
  138506. * @param strength the strength of the updraft
  138507. * @param height the height of the updraft
  138508. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  138509. * @returns A physics updraft event, or null
  138510. */
  138511. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  138512. /**
  138513. * Creates a physics vortex event
  138514. * @param origin the of the vortex
  138515. * @param radiusOrEventOptions the radius or the options of the vortex
  138516. * @param strength the strength of the vortex
  138517. * @param height the height of the vortex
  138518. * @returns a Physics vortex event, or null
  138519. * A physics vortex event or null
  138520. */
  138521. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  138522. }
  138523. /**
  138524. * Represents a physics radial explosion event
  138525. */
  138526. class PhysicsRadialExplosionEvent {
  138527. private _scene;
  138528. private _options;
  138529. private _sphere;
  138530. private _dataFetched;
  138531. /**
  138532. * Initializes a radial explosioin event
  138533. * @param _scene BabylonJS scene
  138534. * @param _options The options for the vortex event
  138535. */
  138536. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  138537. /**
  138538. * Returns the data related to the radial explosion event (sphere).
  138539. * @returns The radial explosion event data
  138540. */
  138541. getData(): PhysicsRadialExplosionEventData;
  138542. /**
  138543. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  138544. * @param impostor A physics imposter
  138545. * @param origin the origin of the explosion
  138546. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  138547. */
  138548. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  138549. /**
  138550. * Triggers affecterd impostors callbacks
  138551. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  138552. */
  138553. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  138554. /**
  138555. * Disposes the sphere.
  138556. * @param force Specifies if the sphere should be disposed by force
  138557. */
  138558. dispose(force?: boolean): void;
  138559. /*** Helpers ***/
  138560. private _prepareSphere;
  138561. private _intersectsWithSphere;
  138562. }
  138563. /**
  138564. * Represents a gravitational field event
  138565. */
  138566. class PhysicsGravitationalFieldEvent {
  138567. private _physicsHelper;
  138568. private _scene;
  138569. private _origin;
  138570. private _options;
  138571. private _tickCallback;
  138572. private _sphere;
  138573. private _dataFetched;
  138574. /**
  138575. * Initializes the physics gravitational field event
  138576. * @param _physicsHelper A physics helper
  138577. * @param _scene BabylonJS scene
  138578. * @param _origin The origin position of the gravitational field event
  138579. * @param _options The options for the vortex event
  138580. */
  138581. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  138582. /**
  138583. * Returns the data related to the gravitational field event (sphere).
  138584. * @returns A gravitational field event
  138585. */
  138586. getData(): PhysicsGravitationalFieldEventData;
  138587. /**
  138588. * Enables the gravitational field.
  138589. */
  138590. enable(): void;
  138591. /**
  138592. * Disables the gravitational field.
  138593. */
  138594. disable(): void;
  138595. /**
  138596. * Disposes the sphere.
  138597. * @param force The force to dispose from the gravitational field event
  138598. */
  138599. dispose(force?: boolean): void;
  138600. private _tick;
  138601. }
  138602. /**
  138603. * Represents a physics updraft event
  138604. */
  138605. class PhysicsUpdraftEvent {
  138606. private _scene;
  138607. private _origin;
  138608. private _options;
  138609. private _physicsEngine;
  138610. private _originTop;
  138611. private _originDirection;
  138612. private _tickCallback;
  138613. private _cylinder;
  138614. private _cylinderPosition;
  138615. private _dataFetched;
  138616. /**
  138617. * Initializes the physics updraft event
  138618. * @param _scene BabylonJS scene
  138619. * @param _origin The origin position of the updraft
  138620. * @param _options The options for the updraft event
  138621. */
  138622. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  138623. /**
  138624. * Returns the data related to the updraft event (cylinder).
  138625. * @returns A physics updraft event
  138626. */
  138627. getData(): PhysicsUpdraftEventData;
  138628. /**
  138629. * Enables the updraft.
  138630. */
  138631. enable(): void;
  138632. /**
  138633. * Disables the updraft.
  138634. */
  138635. disable(): void;
  138636. /**
  138637. * Disposes the cylinder.
  138638. * @param force Specifies if the updraft should be disposed by force
  138639. */
  138640. dispose(force?: boolean): void;
  138641. private getImpostorHitData;
  138642. private _tick;
  138643. /*** Helpers ***/
  138644. private _prepareCylinder;
  138645. private _intersectsWithCylinder;
  138646. }
  138647. /**
  138648. * Represents a physics vortex event
  138649. */
  138650. class PhysicsVortexEvent {
  138651. private _scene;
  138652. private _origin;
  138653. private _options;
  138654. private _physicsEngine;
  138655. private _originTop;
  138656. private _tickCallback;
  138657. private _cylinder;
  138658. private _cylinderPosition;
  138659. private _dataFetched;
  138660. /**
  138661. * Initializes the physics vortex event
  138662. * @param _scene The BabylonJS scene
  138663. * @param _origin The origin position of the vortex
  138664. * @param _options The options for the vortex event
  138665. */
  138666. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  138667. /**
  138668. * Returns the data related to the vortex event (cylinder).
  138669. * @returns The physics vortex event data
  138670. */
  138671. getData(): PhysicsVortexEventData;
  138672. /**
  138673. * Enables the vortex.
  138674. */
  138675. enable(): void;
  138676. /**
  138677. * Disables the cortex.
  138678. */
  138679. disable(): void;
  138680. /**
  138681. * Disposes the sphere.
  138682. * @param force
  138683. */
  138684. dispose(force?: boolean): void;
  138685. private getImpostorHitData;
  138686. private _tick;
  138687. /*** Helpers ***/
  138688. private _prepareCylinder;
  138689. private _intersectsWithCylinder;
  138690. }
  138691. /**
  138692. * Options fot the radial explosion event
  138693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138694. */
  138695. export class PhysicsRadialExplosionEventOptions {
  138696. /**
  138697. * The radius of the sphere for the radial explosion.
  138698. */
  138699. radius: number;
  138700. /**
  138701. * The strenth of the explosion.
  138702. */
  138703. strength: number;
  138704. /**
  138705. * The strenght of the force in correspondence to the distance of the affected object
  138706. */
  138707. falloff: PhysicsRadialImpulseFalloff;
  138708. /**
  138709. * Sphere options for the radial explosion.
  138710. */
  138711. sphere: {
  138712. segments: number;
  138713. diameter: number;
  138714. };
  138715. /**
  138716. * Sphere options for the radial explosion.
  138717. */
  138718. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  138719. }
  138720. /**
  138721. * Options fot the updraft event
  138722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138723. */
  138724. export class PhysicsUpdraftEventOptions {
  138725. /**
  138726. * The radius of the cylinder for the vortex
  138727. */
  138728. radius: number;
  138729. /**
  138730. * The strenth of the updraft.
  138731. */
  138732. strength: number;
  138733. /**
  138734. * The height of the cylinder for the updraft.
  138735. */
  138736. height: number;
  138737. /**
  138738. * The mode for the the updraft.
  138739. */
  138740. updraftMode: PhysicsUpdraftMode;
  138741. }
  138742. /**
  138743. * Options fot the vortex event
  138744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138745. */
  138746. export class PhysicsVortexEventOptions {
  138747. /**
  138748. * The radius of the cylinder for the vortex
  138749. */
  138750. radius: number;
  138751. /**
  138752. * The strenth of the vortex.
  138753. */
  138754. strength: number;
  138755. /**
  138756. * The height of the cylinder for the vortex.
  138757. */
  138758. height: number;
  138759. /**
  138760. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  138761. */
  138762. centripetalForceThreshold: number;
  138763. /**
  138764. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  138765. */
  138766. centripetalForceMultiplier: number;
  138767. /**
  138768. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  138769. */
  138770. centrifugalForceMultiplier: number;
  138771. /**
  138772. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  138773. */
  138774. updraftForceMultiplier: number;
  138775. }
  138776. /**
  138777. * The strenght of the force in correspondence to the distance of the affected object
  138778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138779. */
  138780. export enum PhysicsRadialImpulseFalloff {
  138781. /** Defines that impulse is constant in strength across it's whole radius */
  138782. Constant = 0,
  138783. /** Defines that impulse gets weaker if it's further from the origin */
  138784. Linear = 1
  138785. }
  138786. /**
  138787. * The strength of the force in correspondence to the distance of the affected object
  138788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138789. */
  138790. export enum PhysicsUpdraftMode {
  138791. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  138792. Center = 0,
  138793. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  138794. Perpendicular = 1
  138795. }
  138796. /**
  138797. * Interface for a physics hit data
  138798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138799. */
  138800. export interface PhysicsHitData {
  138801. /**
  138802. * The force applied at the contact point
  138803. */
  138804. force: Vector3;
  138805. /**
  138806. * The contact point
  138807. */
  138808. contactPoint: Vector3;
  138809. /**
  138810. * The distance from the origin to the contact point
  138811. */
  138812. distanceFromOrigin: number;
  138813. }
  138814. /**
  138815. * Interface for radial explosion event data
  138816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138817. */
  138818. export interface PhysicsRadialExplosionEventData {
  138819. /**
  138820. * A sphere used for the radial explosion event
  138821. */
  138822. sphere: Mesh;
  138823. }
  138824. /**
  138825. * Interface for gravitational field event data
  138826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138827. */
  138828. export interface PhysicsGravitationalFieldEventData {
  138829. /**
  138830. * A sphere mesh used for the gravitational field event
  138831. */
  138832. sphere: Mesh;
  138833. }
  138834. /**
  138835. * Interface for updraft event data
  138836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138837. */
  138838. export interface PhysicsUpdraftEventData {
  138839. /**
  138840. * A cylinder used for the updraft event
  138841. */
  138842. cylinder: Mesh;
  138843. }
  138844. /**
  138845. * Interface for vortex event data
  138846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138847. */
  138848. export interface PhysicsVortexEventData {
  138849. /**
  138850. * A cylinder used for the vortex event
  138851. */
  138852. cylinder: Mesh;
  138853. }
  138854. /**
  138855. * Interface for an affected physics impostor
  138856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138857. */
  138858. export interface PhysicsAffectedImpostorWithData {
  138859. /**
  138860. * The impostor affected by the effect
  138861. */
  138862. impostor: PhysicsImpostor;
  138863. /**
  138864. * The data about the hit/horce from the explosion
  138865. */
  138866. hitData: PhysicsHitData;
  138867. }
  138868. }
  138869. declare module BABYLON {
  138870. /** @hidden */
  138871. export var blackAndWhitePixelShader: {
  138872. name: string;
  138873. shader: string;
  138874. };
  138875. }
  138876. declare module BABYLON {
  138877. /**
  138878. * Post process used to render in black and white
  138879. */
  138880. export class BlackAndWhitePostProcess extends PostProcess {
  138881. /**
  138882. * Linear about to convert he result to black and white (default: 1)
  138883. */
  138884. degree: number;
  138885. /**
  138886. * Creates a black and white post process
  138887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  138888. * @param name The name of the effect.
  138889. * @param options The required width/height ratio to downsize to before computing the render pass.
  138890. * @param camera The camera to apply the render pass to.
  138891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138892. * @param engine The engine which the post process will be applied. (default: current engine)
  138893. * @param reusable If the post process can be reused on the same frame. (default: false)
  138894. */
  138895. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138896. }
  138897. }
  138898. declare module BABYLON {
  138899. /**
  138900. * This represents a set of one or more post processes in Babylon.
  138901. * A post process can be used to apply a shader to a texture after it is rendered.
  138902. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138903. */
  138904. export class PostProcessRenderEffect {
  138905. private _postProcesses;
  138906. private _getPostProcesses;
  138907. private _singleInstance;
  138908. private _cameras;
  138909. private _indicesForCamera;
  138910. /**
  138911. * Name of the effect
  138912. * @hidden
  138913. */
  138914. _name: string;
  138915. /**
  138916. * Instantiates a post process render effect.
  138917. * A post process can be used to apply a shader to a texture after it is rendered.
  138918. * @param engine The engine the effect is tied to
  138919. * @param name The name of the effect
  138920. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  138921. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  138922. */
  138923. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  138924. /**
  138925. * Checks if all the post processes in the effect are supported.
  138926. */
  138927. get isSupported(): boolean;
  138928. /**
  138929. * Updates the current state of the effect
  138930. * @hidden
  138931. */
  138932. _update(): void;
  138933. /**
  138934. * Attaches the effect on cameras
  138935. * @param cameras The camera to attach to.
  138936. * @hidden
  138937. */
  138938. _attachCameras(cameras: Camera): void;
  138939. /**
  138940. * Attaches the effect on cameras
  138941. * @param cameras The camera to attach to.
  138942. * @hidden
  138943. */
  138944. _attachCameras(cameras: Camera[]): void;
  138945. /**
  138946. * Detaches the effect on cameras
  138947. * @param cameras The camera to detatch from.
  138948. * @hidden
  138949. */
  138950. _detachCameras(cameras: Camera): void;
  138951. /**
  138952. * Detatches the effect on cameras
  138953. * @param cameras The camera to detatch from.
  138954. * @hidden
  138955. */
  138956. _detachCameras(cameras: Camera[]): void;
  138957. /**
  138958. * Enables the effect on given cameras
  138959. * @param cameras The camera to enable.
  138960. * @hidden
  138961. */
  138962. _enable(cameras: Camera): void;
  138963. /**
  138964. * Enables the effect on given cameras
  138965. * @param cameras The camera to enable.
  138966. * @hidden
  138967. */
  138968. _enable(cameras: Nullable<Camera[]>): void;
  138969. /**
  138970. * Disables the effect on the given cameras
  138971. * @param cameras The camera to disable.
  138972. * @hidden
  138973. */
  138974. _disable(cameras: Camera): void;
  138975. /**
  138976. * Disables the effect on the given cameras
  138977. * @param cameras The camera to disable.
  138978. * @hidden
  138979. */
  138980. _disable(cameras: Nullable<Camera[]>): void;
  138981. /**
  138982. * Gets a list of the post processes contained in the effect.
  138983. * @param camera The camera to get the post processes on.
  138984. * @returns The list of the post processes in the effect.
  138985. */
  138986. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  138987. }
  138988. }
  138989. declare module BABYLON {
  138990. /** @hidden */
  138991. export var extractHighlightsPixelShader: {
  138992. name: string;
  138993. shader: string;
  138994. };
  138995. }
  138996. declare module BABYLON {
  138997. /**
  138998. * 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.
  138999. */
  139000. export class ExtractHighlightsPostProcess extends PostProcess {
  139001. /**
  139002. * The luminance threshold, pixels below this value will be set to black.
  139003. */
  139004. threshold: number;
  139005. /** @hidden */
  139006. _exposure: number;
  139007. /**
  139008. * Post process which has the input texture to be used when performing highlight extraction
  139009. * @hidden
  139010. */
  139011. _inputPostProcess: Nullable<PostProcess>;
  139012. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139013. }
  139014. }
  139015. declare module BABYLON {
  139016. /** @hidden */
  139017. export var bloomMergePixelShader: {
  139018. name: string;
  139019. shader: string;
  139020. };
  139021. }
  139022. declare module BABYLON {
  139023. /**
  139024. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139025. */
  139026. export class BloomMergePostProcess extends PostProcess {
  139027. /** Weight of the bloom to be added to the original input. */
  139028. weight: number;
  139029. /**
  139030. * Creates a new instance of @see BloomMergePostProcess
  139031. * @param name The name of the effect.
  139032. * @param originalFromInput Post process which's input will be used for the merge.
  139033. * @param blurred Blurred highlights post process which's output will be used.
  139034. * @param weight Weight of the bloom to be added to the original input.
  139035. * @param options The required width/height ratio to downsize to before computing the render pass.
  139036. * @param camera The camera to apply the render pass to.
  139037. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139038. * @param engine The engine which the post process will be applied. (default: current engine)
  139039. * @param reusable If the post process can be reused on the same frame. (default: false)
  139040. * @param textureType Type of textures used when performing the post process. (default: 0)
  139041. * @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)
  139042. */
  139043. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  139044. /** Weight of the bloom to be added to the original input. */
  139045. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139046. }
  139047. }
  139048. declare module BABYLON {
  139049. /**
  139050. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  139051. */
  139052. export class BloomEffect extends PostProcessRenderEffect {
  139053. private bloomScale;
  139054. /**
  139055. * @hidden Internal
  139056. */
  139057. _effects: Array<PostProcess>;
  139058. /**
  139059. * @hidden Internal
  139060. */
  139061. _downscale: ExtractHighlightsPostProcess;
  139062. private _blurX;
  139063. private _blurY;
  139064. private _merge;
  139065. /**
  139066. * The luminance threshold to find bright areas of the image to bloom.
  139067. */
  139068. get threshold(): number;
  139069. set threshold(value: number);
  139070. /**
  139071. * The strength of the bloom.
  139072. */
  139073. get weight(): number;
  139074. set weight(value: number);
  139075. /**
  139076. * Specifies the size of the bloom blur kernel, relative to the final output size
  139077. */
  139078. get kernel(): number;
  139079. set kernel(value: number);
  139080. /**
  139081. * Creates a new instance of @see BloomEffect
  139082. * @param scene The scene the effect belongs to.
  139083. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  139084. * @param bloomKernel The size of the kernel to be used when applying the blur.
  139085. * @param bloomWeight The the strength of bloom.
  139086. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139087. * @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)
  139088. */
  139089. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  139090. /**
  139091. * Disposes each of the internal effects for a given camera.
  139092. * @param camera The camera to dispose the effect on.
  139093. */
  139094. disposeEffects(camera: Camera): void;
  139095. /**
  139096. * @hidden Internal
  139097. */
  139098. _updateEffects(): void;
  139099. /**
  139100. * Internal
  139101. * @returns if all the contained post processes are ready.
  139102. * @hidden
  139103. */
  139104. _isReady(): boolean;
  139105. }
  139106. }
  139107. declare module BABYLON {
  139108. /** @hidden */
  139109. export var chromaticAberrationPixelShader: {
  139110. name: string;
  139111. shader: string;
  139112. };
  139113. }
  139114. declare module BABYLON {
  139115. /**
  139116. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  139117. */
  139118. export class ChromaticAberrationPostProcess extends PostProcess {
  139119. /**
  139120. * The amount of seperation of rgb channels (default: 30)
  139121. */
  139122. aberrationAmount: number;
  139123. /**
  139124. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  139125. */
  139126. radialIntensity: number;
  139127. /**
  139128. * 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))
  139129. */
  139130. direction: Vector2;
  139131. /**
  139132. * 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))
  139133. */
  139134. centerPosition: Vector2;
  139135. /**
  139136. * Creates a new instance ChromaticAberrationPostProcess
  139137. * @param name The name of the effect.
  139138. * @param screenWidth The width of the screen to apply the effect on.
  139139. * @param screenHeight The height of the screen to apply the effect on.
  139140. * @param options The required width/height ratio to downsize to before computing the render pass.
  139141. * @param camera The camera to apply the render pass to.
  139142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139143. * @param engine The engine which the post process will be applied. (default: current engine)
  139144. * @param reusable If the post process can be reused on the same frame. (default: false)
  139145. * @param textureType Type of textures used when performing the post process. (default: 0)
  139146. * @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)
  139147. */
  139148. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139149. }
  139150. }
  139151. declare module BABYLON {
  139152. /** @hidden */
  139153. export var circleOfConfusionPixelShader: {
  139154. name: string;
  139155. shader: string;
  139156. };
  139157. }
  139158. declare module BABYLON {
  139159. /**
  139160. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  139161. */
  139162. export class CircleOfConfusionPostProcess extends PostProcess {
  139163. /**
  139164. * 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.
  139165. */
  139166. lensSize: number;
  139167. /**
  139168. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139169. */
  139170. fStop: number;
  139171. /**
  139172. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139173. */
  139174. focusDistance: number;
  139175. /**
  139176. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  139177. */
  139178. focalLength: number;
  139179. private _depthTexture;
  139180. /**
  139181. * Creates a new instance CircleOfConfusionPostProcess
  139182. * @param name The name of the effect.
  139183. * @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.
  139184. * @param options The required width/height ratio to downsize to before computing the render pass.
  139185. * @param camera The camera to apply the render pass to.
  139186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139187. * @param engine The engine which the post process will be applied. (default: current engine)
  139188. * @param reusable If the post process can be reused on the same frame. (default: false)
  139189. * @param textureType Type of textures used when performing the post process. (default: 0)
  139190. * @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)
  139191. */
  139192. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139193. /**
  139194. * 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.
  139195. */
  139196. set depthTexture(value: RenderTargetTexture);
  139197. }
  139198. }
  139199. declare module BABYLON {
  139200. /** @hidden */
  139201. export var colorCorrectionPixelShader: {
  139202. name: string;
  139203. shader: string;
  139204. };
  139205. }
  139206. declare module BABYLON {
  139207. /**
  139208. *
  139209. * This post-process allows the modification of rendered colors by using
  139210. * a 'look-up table' (LUT). This effect is also called Color Grading.
  139211. *
  139212. * The object needs to be provided an url to a texture containing the color
  139213. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  139214. * Use an image editing software to tweak the LUT to match your needs.
  139215. *
  139216. * For an example of a color LUT, see here:
  139217. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  139218. * For explanations on color grading, see here:
  139219. * @see http://udn.epicgames.com/Three/ColorGrading.html
  139220. *
  139221. */
  139222. export class ColorCorrectionPostProcess extends PostProcess {
  139223. private _colorTableTexture;
  139224. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139225. }
  139226. }
  139227. declare module BABYLON {
  139228. /** @hidden */
  139229. export var convolutionPixelShader: {
  139230. name: string;
  139231. shader: string;
  139232. };
  139233. }
  139234. declare module BABYLON {
  139235. /**
  139236. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  139237. * input texture to perform effects such as edge detection or sharpening
  139238. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139239. */
  139240. export class ConvolutionPostProcess extends PostProcess {
  139241. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139242. kernel: number[];
  139243. /**
  139244. * Creates a new instance ConvolutionPostProcess
  139245. * @param name The name of the effect.
  139246. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  139247. * @param options The required width/height ratio to downsize to before computing the render pass.
  139248. * @param camera The camera to apply the render pass to.
  139249. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139250. * @param engine The engine which the post process will be applied. (default: current engine)
  139251. * @param reusable If the post process can be reused on the same frame. (default: false)
  139252. * @param textureType Type of textures used when performing the post process. (default: 0)
  139253. */
  139254. constructor(name: string,
  139255. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139256. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139257. /**
  139258. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139259. */
  139260. static EdgeDetect0Kernel: number[];
  139261. /**
  139262. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139263. */
  139264. static EdgeDetect1Kernel: number[];
  139265. /**
  139266. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139267. */
  139268. static EdgeDetect2Kernel: number[];
  139269. /**
  139270. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139271. */
  139272. static SharpenKernel: number[];
  139273. /**
  139274. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139275. */
  139276. static EmbossKernel: number[];
  139277. /**
  139278. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139279. */
  139280. static GaussianKernel: number[];
  139281. }
  139282. }
  139283. declare module BABYLON {
  139284. /**
  139285. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  139286. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  139287. * based on samples that have a large difference in distance than the center pixel.
  139288. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  139289. */
  139290. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  139291. direction: Vector2;
  139292. /**
  139293. * Creates a new instance CircleOfConfusionPostProcess
  139294. * @param name The name of the effect.
  139295. * @param scene The scene the effect belongs to.
  139296. * @param direction The direction the blur should be applied.
  139297. * @param kernel The size of the kernel used to blur.
  139298. * @param options The required width/height ratio to downsize to before computing the render pass.
  139299. * @param camera The camera to apply the render pass to.
  139300. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  139301. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  139302. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139303. * @param engine The engine which the post process will be applied. (default: current engine)
  139304. * @param reusable If the post process can be reused on the same frame. (default: false)
  139305. * @param textureType Type of textures used when performing the post process. (default: 0)
  139306. * @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)
  139307. */
  139308. 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);
  139309. }
  139310. }
  139311. declare module BABYLON {
  139312. /** @hidden */
  139313. export var depthOfFieldMergePixelShader: {
  139314. name: string;
  139315. shader: string;
  139316. };
  139317. }
  139318. declare module BABYLON {
  139319. /**
  139320. * Options to be set when merging outputs from the default pipeline.
  139321. */
  139322. export class DepthOfFieldMergePostProcessOptions {
  139323. /**
  139324. * The original image to merge on top of
  139325. */
  139326. originalFromInput: PostProcess;
  139327. /**
  139328. * Parameters to perform the merge of the depth of field effect
  139329. */
  139330. depthOfField?: {
  139331. circleOfConfusion: PostProcess;
  139332. blurSteps: Array<PostProcess>;
  139333. };
  139334. /**
  139335. * Parameters to perform the merge of bloom effect
  139336. */
  139337. bloom?: {
  139338. blurred: PostProcess;
  139339. weight: number;
  139340. };
  139341. }
  139342. /**
  139343. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139344. */
  139345. export class DepthOfFieldMergePostProcess extends PostProcess {
  139346. private blurSteps;
  139347. /**
  139348. * Creates a new instance of DepthOfFieldMergePostProcess
  139349. * @param name The name of the effect.
  139350. * @param originalFromInput Post process which's input will be used for the merge.
  139351. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  139352. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  139353. * @param options The required width/height ratio to downsize to before computing the render pass.
  139354. * @param camera The camera to apply the render pass to.
  139355. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139356. * @param engine The engine which the post process will be applied. (default: current engine)
  139357. * @param reusable If the post process can be reused on the same frame. (default: false)
  139358. * @param textureType Type of textures used when performing the post process. (default: 0)
  139359. * @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)
  139360. */
  139361. 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);
  139362. /**
  139363. * Updates the effect with the current post process compile time values and recompiles the shader.
  139364. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  139365. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  139366. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  139367. * @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
  139368. * @param onCompiled Called when the shader has been compiled.
  139369. * @param onError Called if there is an error when compiling a shader.
  139370. */
  139371. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  139372. }
  139373. }
  139374. declare module BABYLON {
  139375. /**
  139376. * Specifies the level of max blur that should be applied when using the depth of field effect
  139377. */
  139378. export enum DepthOfFieldEffectBlurLevel {
  139379. /**
  139380. * Subtle blur
  139381. */
  139382. Low = 0,
  139383. /**
  139384. * Medium blur
  139385. */
  139386. Medium = 1,
  139387. /**
  139388. * Large blur
  139389. */
  139390. High = 2
  139391. }
  139392. /**
  139393. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  139394. */
  139395. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  139396. private _circleOfConfusion;
  139397. /**
  139398. * @hidden Internal, blurs from high to low
  139399. */
  139400. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  139401. private _depthOfFieldBlurY;
  139402. private _dofMerge;
  139403. /**
  139404. * @hidden Internal post processes in depth of field effect
  139405. */
  139406. _effects: Array<PostProcess>;
  139407. /**
  139408. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  139409. */
  139410. set focalLength(value: number);
  139411. get focalLength(): number;
  139412. /**
  139413. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139414. */
  139415. set fStop(value: number);
  139416. get fStop(): number;
  139417. /**
  139418. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139419. */
  139420. set focusDistance(value: number);
  139421. get focusDistance(): number;
  139422. /**
  139423. * 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.
  139424. */
  139425. set lensSize(value: number);
  139426. get lensSize(): number;
  139427. /**
  139428. * Creates a new instance DepthOfFieldEffect
  139429. * @param scene The scene the effect belongs to.
  139430. * @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.
  139431. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139432. * @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)
  139433. */
  139434. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  139435. /**
  139436. * Get the current class name of the current effet
  139437. * @returns "DepthOfFieldEffect"
  139438. */
  139439. getClassName(): string;
  139440. /**
  139441. * 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.
  139442. */
  139443. set depthTexture(value: RenderTargetTexture);
  139444. /**
  139445. * Disposes each of the internal effects for a given camera.
  139446. * @param camera The camera to dispose the effect on.
  139447. */
  139448. disposeEffects(camera: Camera): void;
  139449. /**
  139450. * @hidden Internal
  139451. */
  139452. _updateEffects(): void;
  139453. /**
  139454. * Internal
  139455. * @returns if all the contained post processes are ready.
  139456. * @hidden
  139457. */
  139458. _isReady(): boolean;
  139459. }
  139460. }
  139461. declare module BABYLON {
  139462. /** @hidden */
  139463. export var displayPassPixelShader: {
  139464. name: string;
  139465. shader: string;
  139466. };
  139467. }
  139468. declare module BABYLON {
  139469. /**
  139470. * DisplayPassPostProcess which produces an output the same as it's input
  139471. */
  139472. export class DisplayPassPostProcess extends PostProcess {
  139473. /**
  139474. * Creates the DisplayPassPostProcess
  139475. * @param name The name of the effect.
  139476. * @param options The required width/height ratio to downsize to before computing the render pass.
  139477. * @param camera The camera to apply the render pass to.
  139478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139479. * @param engine The engine which the post process will be applied. (default: current engine)
  139480. * @param reusable If the post process can be reused on the same frame. (default: false)
  139481. */
  139482. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139483. }
  139484. }
  139485. declare module BABYLON {
  139486. /** @hidden */
  139487. export var filterPixelShader: {
  139488. name: string;
  139489. shader: string;
  139490. };
  139491. }
  139492. declare module BABYLON {
  139493. /**
  139494. * Applies a kernel filter to the image
  139495. */
  139496. export class FilterPostProcess extends PostProcess {
  139497. /** The matrix to be applied to the image */
  139498. kernelMatrix: Matrix;
  139499. /**
  139500. *
  139501. * @param name The name of the effect.
  139502. * @param kernelMatrix The matrix to be applied to the image
  139503. * @param options The required width/height ratio to downsize to before computing the render pass.
  139504. * @param camera The camera to apply the render pass to.
  139505. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139506. * @param engine The engine which the post process will be applied. (default: current engine)
  139507. * @param reusable If the post process can be reused on the same frame. (default: false)
  139508. */
  139509. constructor(name: string,
  139510. /** The matrix to be applied to the image */
  139511. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139512. }
  139513. }
  139514. declare module BABYLON {
  139515. /** @hidden */
  139516. export var fxaaPixelShader: {
  139517. name: string;
  139518. shader: string;
  139519. };
  139520. }
  139521. declare module BABYLON {
  139522. /** @hidden */
  139523. export var fxaaVertexShader: {
  139524. name: string;
  139525. shader: string;
  139526. };
  139527. }
  139528. declare module BABYLON {
  139529. /**
  139530. * Fxaa post process
  139531. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  139532. */
  139533. export class FxaaPostProcess extends PostProcess {
  139534. /** @hidden */
  139535. texelWidth: number;
  139536. /** @hidden */
  139537. texelHeight: number;
  139538. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139539. private _getDefines;
  139540. }
  139541. }
  139542. declare module BABYLON {
  139543. /** @hidden */
  139544. export var grainPixelShader: {
  139545. name: string;
  139546. shader: string;
  139547. };
  139548. }
  139549. declare module BABYLON {
  139550. /**
  139551. * The GrainPostProcess adds noise to the image at mid luminance levels
  139552. */
  139553. export class GrainPostProcess extends PostProcess {
  139554. /**
  139555. * The intensity of the grain added (default: 30)
  139556. */
  139557. intensity: number;
  139558. /**
  139559. * If the grain should be randomized on every frame
  139560. */
  139561. animated: boolean;
  139562. /**
  139563. * Creates a new instance of @see GrainPostProcess
  139564. * @param name The name of the effect.
  139565. * @param options The required width/height ratio to downsize to before computing the render pass.
  139566. * @param camera The camera to apply the render pass to.
  139567. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139568. * @param engine The engine which the post process will be applied. (default: current engine)
  139569. * @param reusable If the post process can be reused on the same frame. (default: false)
  139570. * @param textureType Type of textures used when performing the post process. (default: 0)
  139571. * @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)
  139572. */
  139573. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139574. }
  139575. }
  139576. declare module BABYLON {
  139577. /** @hidden */
  139578. export var highlightsPixelShader: {
  139579. name: string;
  139580. shader: string;
  139581. };
  139582. }
  139583. declare module BABYLON {
  139584. /**
  139585. * Extracts highlights from the image
  139586. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139587. */
  139588. export class HighlightsPostProcess extends PostProcess {
  139589. /**
  139590. * Extracts highlights from the image
  139591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139592. * @param name The name of the effect.
  139593. * @param options The required width/height ratio to downsize to before computing the render pass.
  139594. * @param camera The camera to apply the render pass to.
  139595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139596. * @param engine The engine which the post process will be applied. (default: current engine)
  139597. * @param reusable If the post process can be reused on the same frame. (default: false)
  139598. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  139599. */
  139600. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139601. }
  139602. }
  139603. declare module BABYLON {
  139604. /** @hidden */
  139605. export var mrtFragmentDeclaration: {
  139606. name: string;
  139607. shader: string;
  139608. };
  139609. }
  139610. declare module BABYLON {
  139611. /** @hidden */
  139612. export var geometryPixelShader: {
  139613. name: string;
  139614. shader: string;
  139615. };
  139616. }
  139617. declare module BABYLON {
  139618. /** @hidden */
  139619. export var geometryVertexShader: {
  139620. name: string;
  139621. shader: string;
  139622. };
  139623. }
  139624. declare module BABYLON {
  139625. /** @hidden */
  139626. interface ISavedTransformationMatrix {
  139627. world: Matrix;
  139628. viewProjection: Matrix;
  139629. }
  139630. /**
  139631. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  139632. */
  139633. export class GeometryBufferRenderer {
  139634. /**
  139635. * Constant used to retrieve the position texture index in the G-Buffer textures array
  139636. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  139637. */
  139638. static readonly POSITION_TEXTURE_TYPE: number;
  139639. /**
  139640. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  139641. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  139642. */
  139643. static readonly VELOCITY_TEXTURE_TYPE: number;
  139644. /**
  139645. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  139646. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  139647. */
  139648. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  139649. /**
  139650. * Dictionary used to store the previous transformation matrices of each rendered mesh
  139651. * in order to compute objects velocities when enableVelocity is set to "true"
  139652. * @hidden
  139653. */
  139654. _previousTransformationMatrices: {
  139655. [index: number]: ISavedTransformationMatrix;
  139656. };
  139657. /**
  139658. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  139659. * in order to compute objects velocities when enableVelocity is set to "true"
  139660. * @hidden
  139661. */
  139662. _previousBonesTransformationMatrices: {
  139663. [index: number]: Float32Array;
  139664. };
  139665. /**
  139666. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  139667. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  139668. */
  139669. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  139670. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  139671. renderTransparentMeshes: boolean;
  139672. private _scene;
  139673. private _multiRenderTarget;
  139674. private _ratio;
  139675. private _enablePosition;
  139676. private _enableVelocity;
  139677. private _enableReflectivity;
  139678. private _positionIndex;
  139679. private _velocityIndex;
  139680. private _reflectivityIndex;
  139681. protected _effect: Effect;
  139682. protected _cachedDefines: string;
  139683. /**
  139684. * Set the render list (meshes to be rendered) used in the G buffer.
  139685. */
  139686. set renderList(meshes: Mesh[]);
  139687. /**
  139688. * Gets wether or not G buffer are supported by the running hardware.
  139689. * This requires draw buffer supports
  139690. */
  139691. get isSupported(): boolean;
  139692. /**
  139693. * Returns the index of the given texture type in the G-Buffer textures array
  139694. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  139695. * @returns the index of the given texture type in the G-Buffer textures array
  139696. */
  139697. getTextureIndex(textureType: number): number;
  139698. /**
  139699. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  139700. */
  139701. get enablePosition(): boolean;
  139702. /**
  139703. * Sets whether or not objects positions are enabled for the G buffer.
  139704. */
  139705. set enablePosition(enable: boolean);
  139706. /**
  139707. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  139708. */
  139709. get enableVelocity(): boolean;
  139710. /**
  139711. * Sets wether or not objects velocities are enabled for the G buffer.
  139712. */
  139713. set enableVelocity(enable: boolean);
  139714. /**
  139715. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  139716. */
  139717. get enableReflectivity(): boolean;
  139718. /**
  139719. * Sets wether or not objects roughness are enabled for the G buffer.
  139720. */
  139721. set enableReflectivity(enable: boolean);
  139722. /**
  139723. * Gets the scene associated with the buffer.
  139724. */
  139725. get scene(): Scene;
  139726. /**
  139727. * Gets the ratio used by the buffer during its creation.
  139728. * How big is the buffer related to the main canvas.
  139729. */
  139730. get ratio(): number;
  139731. /** @hidden */
  139732. static _SceneComponentInitialization: (scene: Scene) => void;
  139733. /**
  139734. * Creates a new G Buffer for the scene
  139735. * @param scene The scene the buffer belongs to
  139736. * @param ratio How big is the buffer related to the main canvas.
  139737. */
  139738. constructor(scene: Scene, ratio?: number);
  139739. /**
  139740. * Checks wether everything is ready to render a submesh to the G buffer.
  139741. * @param subMesh the submesh to check readiness for
  139742. * @param useInstances is the mesh drawn using instance or not
  139743. * @returns true if ready otherwise false
  139744. */
  139745. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139746. /**
  139747. * Gets the current underlying G Buffer.
  139748. * @returns the buffer
  139749. */
  139750. getGBuffer(): MultiRenderTarget;
  139751. /**
  139752. * Gets the number of samples used to render the buffer (anti aliasing).
  139753. */
  139754. get samples(): number;
  139755. /**
  139756. * Sets the number of samples used to render the buffer (anti aliasing).
  139757. */
  139758. set samples(value: number);
  139759. /**
  139760. * Disposes the renderer and frees up associated resources.
  139761. */
  139762. dispose(): void;
  139763. protected _createRenderTargets(): void;
  139764. private _copyBonesTransformationMatrices;
  139765. }
  139766. }
  139767. declare module BABYLON {
  139768. interface Scene {
  139769. /** @hidden (Backing field) */
  139770. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139771. /**
  139772. * Gets or Sets the current geometry buffer associated to the scene.
  139773. */
  139774. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139775. /**
  139776. * Enables a GeometryBufferRender and associates it with the scene
  139777. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  139778. * @returns the GeometryBufferRenderer
  139779. */
  139780. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  139781. /**
  139782. * Disables the GeometryBufferRender associated with the scene
  139783. */
  139784. disableGeometryBufferRenderer(): void;
  139785. }
  139786. /**
  139787. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  139788. * in several rendering techniques.
  139789. */
  139790. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  139791. /**
  139792. * The component name helpful to identify the component in the list of scene components.
  139793. */
  139794. readonly name: string;
  139795. /**
  139796. * The scene the component belongs to.
  139797. */
  139798. scene: Scene;
  139799. /**
  139800. * Creates a new instance of the component for the given scene
  139801. * @param scene Defines the scene to register the component in
  139802. */
  139803. constructor(scene: Scene);
  139804. /**
  139805. * Registers the component in a given scene
  139806. */
  139807. register(): void;
  139808. /**
  139809. * Rebuilds the elements related to this component in case of
  139810. * context lost for instance.
  139811. */
  139812. rebuild(): void;
  139813. /**
  139814. * Disposes the component and the associated ressources
  139815. */
  139816. dispose(): void;
  139817. private _gatherRenderTargets;
  139818. }
  139819. }
  139820. declare module BABYLON {
  139821. /** @hidden */
  139822. export var motionBlurPixelShader: {
  139823. name: string;
  139824. shader: string;
  139825. };
  139826. }
  139827. declare module BABYLON {
  139828. /**
  139829. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  139830. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  139831. * As an example, all you have to do is to create the post-process:
  139832. * var mb = new BABYLON.MotionBlurPostProcess(
  139833. * 'mb', // The name of the effect.
  139834. * scene, // The scene containing the objects to blur according to their velocity.
  139835. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  139836. * camera // The camera to apply the render pass to.
  139837. * );
  139838. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  139839. */
  139840. export class MotionBlurPostProcess extends PostProcess {
  139841. /**
  139842. * Defines how much the image is blurred by the movement. Default value is equal to 1
  139843. */
  139844. motionStrength: number;
  139845. /**
  139846. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  139847. */
  139848. get motionBlurSamples(): number;
  139849. /**
  139850. * Sets the number of iterations to be used for motion blur quality
  139851. */
  139852. set motionBlurSamples(samples: number);
  139853. private _motionBlurSamples;
  139854. private _geometryBufferRenderer;
  139855. /**
  139856. * Creates a new instance MotionBlurPostProcess
  139857. * @param name The name of the effect.
  139858. * @param scene The scene containing the objects to blur according to their velocity.
  139859. * @param options The required width/height ratio to downsize to before computing the render pass.
  139860. * @param camera The camera to apply the render pass to.
  139861. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139862. * @param engine The engine which the post process will be applied. (default: current engine)
  139863. * @param reusable If the post process can be reused on the same frame. (default: false)
  139864. * @param textureType Type of textures used when performing the post process. (default: 0)
  139865. * @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)
  139866. */
  139867. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139868. /**
  139869. * Excludes the given skinned mesh from computing bones velocities.
  139870. * 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.
  139871. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  139872. */
  139873. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139874. /**
  139875. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  139876. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  139877. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  139878. */
  139879. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139880. /**
  139881. * Disposes the post process.
  139882. * @param camera The camera to dispose the post process on.
  139883. */
  139884. dispose(camera?: Camera): void;
  139885. }
  139886. }
  139887. declare module BABYLON {
  139888. /** @hidden */
  139889. export var refractionPixelShader: {
  139890. name: string;
  139891. shader: string;
  139892. };
  139893. }
  139894. declare module BABYLON {
  139895. /**
  139896. * Post process which applies a refractin texture
  139897. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139898. */
  139899. export class RefractionPostProcess extends PostProcess {
  139900. /** the base color of the refraction (used to taint the rendering) */
  139901. color: Color3;
  139902. /** simulated refraction depth */
  139903. depth: number;
  139904. /** the coefficient of the base color (0 to remove base color tainting) */
  139905. colorLevel: number;
  139906. private _refTexture;
  139907. private _ownRefractionTexture;
  139908. /**
  139909. * Gets or sets the refraction texture
  139910. * Please note that you are responsible for disposing the texture if you set it manually
  139911. */
  139912. get refractionTexture(): Texture;
  139913. set refractionTexture(value: Texture);
  139914. /**
  139915. * Initializes the RefractionPostProcess
  139916. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139917. * @param name The name of the effect.
  139918. * @param refractionTextureUrl Url of the refraction texture to use
  139919. * @param color the base color of the refraction (used to taint the rendering)
  139920. * @param depth simulated refraction depth
  139921. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  139922. * @param camera The camera to apply the render pass to.
  139923. * @param options The required width/height ratio to downsize to before computing the render pass.
  139924. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139925. * @param engine The engine which the post process will be applied. (default: current engine)
  139926. * @param reusable If the post process can be reused on the same frame. (default: false)
  139927. */
  139928. constructor(name: string, refractionTextureUrl: string,
  139929. /** the base color of the refraction (used to taint the rendering) */
  139930. color: Color3,
  139931. /** simulated refraction depth */
  139932. depth: number,
  139933. /** the coefficient of the base color (0 to remove base color tainting) */
  139934. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139935. /**
  139936. * Disposes of the post process
  139937. * @param camera Camera to dispose post process on
  139938. */
  139939. dispose(camera: Camera): void;
  139940. }
  139941. }
  139942. declare module BABYLON {
  139943. /** @hidden */
  139944. export var sharpenPixelShader: {
  139945. name: string;
  139946. shader: string;
  139947. };
  139948. }
  139949. declare module BABYLON {
  139950. /**
  139951. * The SharpenPostProcess applies a sharpen kernel to every pixel
  139952. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139953. */
  139954. export class SharpenPostProcess extends PostProcess {
  139955. /**
  139956. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  139957. */
  139958. colorAmount: number;
  139959. /**
  139960. * How much sharpness should be applied (default: 0.3)
  139961. */
  139962. edgeAmount: number;
  139963. /**
  139964. * Creates a new instance ConvolutionPostProcess
  139965. * @param name The name of the effect.
  139966. * @param options The required width/height ratio to downsize to before computing the render pass.
  139967. * @param camera The camera to apply the render pass to.
  139968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139969. * @param engine The engine which the post process will be applied. (default: current engine)
  139970. * @param reusable If the post process can be reused on the same frame. (default: false)
  139971. * @param textureType Type of textures used when performing the post process. (default: 0)
  139972. * @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)
  139973. */
  139974. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139975. }
  139976. }
  139977. declare module BABYLON {
  139978. /**
  139979. * PostProcessRenderPipeline
  139980. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139981. */
  139982. export class PostProcessRenderPipeline {
  139983. private engine;
  139984. private _renderEffects;
  139985. private _renderEffectsForIsolatedPass;
  139986. /**
  139987. * List of inspectable custom properties (used by the Inspector)
  139988. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  139989. */
  139990. inspectableCustomProperties: IInspectable[];
  139991. /**
  139992. * @hidden
  139993. */
  139994. protected _cameras: Camera[];
  139995. /** @hidden */
  139996. _name: string;
  139997. /**
  139998. * Gets pipeline name
  139999. */
  140000. get name(): string;
  140001. /** Gets the list of attached cameras */
  140002. get cameras(): Camera[];
  140003. /**
  140004. * Initializes a PostProcessRenderPipeline
  140005. * @param engine engine to add the pipeline to
  140006. * @param name name of the pipeline
  140007. */
  140008. constructor(engine: Engine, name: string);
  140009. /**
  140010. * Gets the class name
  140011. * @returns "PostProcessRenderPipeline"
  140012. */
  140013. getClassName(): string;
  140014. /**
  140015. * If all the render effects in the pipeline are supported
  140016. */
  140017. get isSupported(): boolean;
  140018. /**
  140019. * Adds an effect to the pipeline
  140020. * @param renderEffect the effect to add
  140021. */
  140022. addEffect(renderEffect: PostProcessRenderEffect): void;
  140023. /** @hidden */
  140024. _rebuild(): void;
  140025. /** @hidden */
  140026. _enableEffect(renderEffectName: string, cameras: Camera): void;
  140027. /** @hidden */
  140028. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  140029. /** @hidden */
  140030. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140031. /** @hidden */
  140032. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140033. /** @hidden */
  140034. _attachCameras(cameras: Camera, unique: boolean): void;
  140035. /** @hidden */
  140036. _attachCameras(cameras: Camera[], unique: boolean): void;
  140037. /** @hidden */
  140038. _detachCameras(cameras: Camera): void;
  140039. /** @hidden */
  140040. _detachCameras(cameras: Nullable<Camera[]>): void;
  140041. /** @hidden */
  140042. _update(): void;
  140043. /** @hidden */
  140044. _reset(): void;
  140045. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  140046. /**
  140047. * Disposes of the pipeline
  140048. */
  140049. dispose(): void;
  140050. }
  140051. }
  140052. declare module BABYLON {
  140053. /**
  140054. * PostProcessRenderPipelineManager class
  140055. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140056. */
  140057. export class PostProcessRenderPipelineManager {
  140058. private _renderPipelines;
  140059. /**
  140060. * Initializes a PostProcessRenderPipelineManager
  140061. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140062. */
  140063. constructor();
  140064. /**
  140065. * Gets the list of supported render pipelines
  140066. */
  140067. get supportedPipelines(): PostProcessRenderPipeline[];
  140068. /**
  140069. * Adds a pipeline to the manager
  140070. * @param renderPipeline The pipeline to add
  140071. */
  140072. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  140073. /**
  140074. * Attaches a camera to the pipeline
  140075. * @param renderPipelineName The name of the pipeline to attach to
  140076. * @param cameras the camera to attach
  140077. * @param unique if the camera can be attached multiple times to the pipeline
  140078. */
  140079. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  140080. /**
  140081. * Detaches a camera from the pipeline
  140082. * @param renderPipelineName The name of the pipeline to detach from
  140083. * @param cameras the camera to detach
  140084. */
  140085. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  140086. /**
  140087. * Enables an effect by name on a pipeline
  140088. * @param renderPipelineName the name of the pipeline to enable the effect in
  140089. * @param renderEffectName the name of the effect to enable
  140090. * @param cameras the cameras that the effect should be enabled on
  140091. */
  140092. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140093. /**
  140094. * Disables an effect by name on a pipeline
  140095. * @param renderPipelineName the name of the pipeline to disable the effect in
  140096. * @param renderEffectName the name of the effect to disable
  140097. * @param cameras the cameras that the effect should be disabled on
  140098. */
  140099. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140100. /**
  140101. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  140102. */
  140103. update(): void;
  140104. /** @hidden */
  140105. _rebuild(): void;
  140106. /**
  140107. * Disposes of the manager and pipelines
  140108. */
  140109. dispose(): void;
  140110. }
  140111. }
  140112. declare module BABYLON {
  140113. interface Scene {
  140114. /** @hidden (Backing field) */
  140115. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140116. /**
  140117. * Gets the postprocess render pipeline manager
  140118. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140119. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140120. */
  140121. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140122. }
  140123. /**
  140124. * Defines the Render Pipeline scene component responsible to rendering pipelines
  140125. */
  140126. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  140127. /**
  140128. * The component name helpfull to identify the component in the list of scene components.
  140129. */
  140130. readonly name: string;
  140131. /**
  140132. * The scene the component belongs to.
  140133. */
  140134. scene: Scene;
  140135. /**
  140136. * Creates a new instance of the component for the given scene
  140137. * @param scene Defines the scene to register the component in
  140138. */
  140139. constructor(scene: Scene);
  140140. /**
  140141. * Registers the component in a given scene
  140142. */
  140143. register(): void;
  140144. /**
  140145. * Rebuilds the elements related to this component in case of
  140146. * context lost for instance.
  140147. */
  140148. rebuild(): void;
  140149. /**
  140150. * Disposes the component and the associated ressources
  140151. */
  140152. dispose(): void;
  140153. private _gatherRenderTargets;
  140154. }
  140155. }
  140156. declare module BABYLON {
  140157. /**
  140158. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  140159. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140160. */
  140161. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140162. private _scene;
  140163. private _camerasToBeAttached;
  140164. /**
  140165. * ID of the sharpen post process,
  140166. */
  140167. private readonly SharpenPostProcessId;
  140168. /**
  140169. * @ignore
  140170. * ID of the image processing post process;
  140171. */
  140172. readonly ImageProcessingPostProcessId: string;
  140173. /**
  140174. * @ignore
  140175. * ID of the Fast Approximate Anti-Aliasing post process;
  140176. */
  140177. readonly FxaaPostProcessId: string;
  140178. /**
  140179. * ID of the chromatic aberration post process,
  140180. */
  140181. private readonly ChromaticAberrationPostProcessId;
  140182. /**
  140183. * ID of the grain post process
  140184. */
  140185. private readonly GrainPostProcessId;
  140186. /**
  140187. * Sharpen post process which will apply a sharpen convolution to enhance edges
  140188. */
  140189. sharpen: SharpenPostProcess;
  140190. private _sharpenEffect;
  140191. private bloom;
  140192. /**
  140193. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  140194. */
  140195. depthOfField: DepthOfFieldEffect;
  140196. /**
  140197. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140198. */
  140199. fxaa: FxaaPostProcess;
  140200. /**
  140201. * Image post processing pass used to perform operations such as tone mapping or color grading.
  140202. */
  140203. imageProcessing: ImageProcessingPostProcess;
  140204. /**
  140205. * Chromatic aberration post process which will shift rgb colors in the image
  140206. */
  140207. chromaticAberration: ChromaticAberrationPostProcess;
  140208. private _chromaticAberrationEffect;
  140209. /**
  140210. * Grain post process which add noise to the image
  140211. */
  140212. grain: GrainPostProcess;
  140213. private _grainEffect;
  140214. /**
  140215. * Glow post process which adds a glow to emissive areas of the image
  140216. */
  140217. private _glowLayer;
  140218. /**
  140219. * Animations which can be used to tweak settings over a period of time
  140220. */
  140221. animations: Animation[];
  140222. private _imageProcessingConfigurationObserver;
  140223. private _sharpenEnabled;
  140224. private _bloomEnabled;
  140225. private _depthOfFieldEnabled;
  140226. private _depthOfFieldBlurLevel;
  140227. private _fxaaEnabled;
  140228. private _imageProcessingEnabled;
  140229. private _defaultPipelineTextureType;
  140230. private _bloomScale;
  140231. private _chromaticAberrationEnabled;
  140232. private _grainEnabled;
  140233. private _buildAllowed;
  140234. /**
  140235. * Gets active scene
  140236. */
  140237. get scene(): Scene;
  140238. /**
  140239. * Enable or disable the sharpen process from the pipeline
  140240. */
  140241. set sharpenEnabled(enabled: boolean);
  140242. get sharpenEnabled(): boolean;
  140243. private _resizeObserver;
  140244. private _hardwareScaleLevel;
  140245. private _bloomKernel;
  140246. /**
  140247. * Specifies the size of the bloom blur kernel, relative to the final output size
  140248. */
  140249. get bloomKernel(): number;
  140250. set bloomKernel(value: number);
  140251. /**
  140252. * Specifies the weight of the bloom in the final rendering
  140253. */
  140254. private _bloomWeight;
  140255. /**
  140256. * Specifies the luma threshold for the area that will be blurred by the bloom
  140257. */
  140258. private _bloomThreshold;
  140259. private _hdr;
  140260. /**
  140261. * The strength of the bloom.
  140262. */
  140263. set bloomWeight(value: number);
  140264. get bloomWeight(): number;
  140265. /**
  140266. * The strength of the bloom.
  140267. */
  140268. set bloomThreshold(value: number);
  140269. get bloomThreshold(): number;
  140270. /**
  140271. * The scale of the bloom, lower value will provide better performance.
  140272. */
  140273. set bloomScale(value: number);
  140274. get bloomScale(): number;
  140275. /**
  140276. * Enable or disable the bloom from the pipeline
  140277. */
  140278. set bloomEnabled(enabled: boolean);
  140279. get bloomEnabled(): boolean;
  140280. private _rebuildBloom;
  140281. /**
  140282. * If the depth of field is enabled.
  140283. */
  140284. get depthOfFieldEnabled(): boolean;
  140285. set depthOfFieldEnabled(enabled: boolean);
  140286. /**
  140287. * Blur level of the depth of field effect. (Higher blur will effect performance)
  140288. */
  140289. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  140290. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  140291. /**
  140292. * If the anti aliasing is enabled.
  140293. */
  140294. set fxaaEnabled(enabled: boolean);
  140295. get fxaaEnabled(): boolean;
  140296. private _samples;
  140297. /**
  140298. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140299. */
  140300. set samples(sampleCount: number);
  140301. get samples(): number;
  140302. /**
  140303. * If image processing is enabled.
  140304. */
  140305. set imageProcessingEnabled(enabled: boolean);
  140306. get imageProcessingEnabled(): boolean;
  140307. /**
  140308. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  140309. */
  140310. set glowLayerEnabled(enabled: boolean);
  140311. get glowLayerEnabled(): boolean;
  140312. /**
  140313. * Gets the glow layer (or null if not defined)
  140314. */
  140315. get glowLayer(): Nullable<GlowLayer>;
  140316. /**
  140317. * Enable or disable the chromaticAberration process from the pipeline
  140318. */
  140319. set chromaticAberrationEnabled(enabled: boolean);
  140320. get chromaticAberrationEnabled(): boolean;
  140321. /**
  140322. * Enable or disable the grain process from the pipeline
  140323. */
  140324. set grainEnabled(enabled: boolean);
  140325. get grainEnabled(): boolean;
  140326. /**
  140327. * @constructor
  140328. * @param name - The rendering pipeline name (default: "")
  140329. * @param hdr - If high dynamic range textures should be used (default: true)
  140330. * @param scene - The scene linked to this pipeline (default: the last created scene)
  140331. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  140332. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  140333. */
  140334. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  140335. /**
  140336. * Get the class name
  140337. * @returns "DefaultRenderingPipeline"
  140338. */
  140339. getClassName(): string;
  140340. /**
  140341. * Force the compilation of the entire pipeline.
  140342. */
  140343. prepare(): void;
  140344. private _hasCleared;
  140345. private _prevPostProcess;
  140346. private _prevPrevPostProcess;
  140347. private _setAutoClearAndTextureSharing;
  140348. private _depthOfFieldSceneObserver;
  140349. private _buildPipeline;
  140350. private _disposePostProcesses;
  140351. /**
  140352. * Adds a camera to the pipeline
  140353. * @param camera the camera to be added
  140354. */
  140355. addCamera(camera: Camera): void;
  140356. /**
  140357. * Removes a camera from the pipeline
  140358. * @param camera the camera to remove
  140359. */
  140360. removeCamera(camera: Camera): void;
  140361. /**
  140362. * Dispose of the pipeline and stop all post processes
  140363. */
  140364. dispose(): void;
  140365. /**
  140366. * Serialize the rendering pipeline (Used when exporting)
  140367. * @returns the serialized object
  140368. */
  140369. serialize(): any;
  140370. /**
  140371. * Parse the serialized pipeline
  140372. * @param source Source pipeline.
  140373. * @param scene The scene to load the pipeline to.
  140374. * @param rootUrl The URL of the serialized pipeline.
  140375. * @returns An instantiated pipeline from the serialized object.
  140376. */
  140377. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  140378. }
  140379. }
  140380. declare module BABYLON {
  140381. /** @hidden */
  140382. export var lensHighlightsPixelShader: {
  140383. name: string;
  140384. shader: string;
  140385. };
  140386. }
  140387. declare module BABYLON {
  140388. /** @hidden */
  140389. export var depthOfFieldPixelShader: {
  140390. name: string;
  140391. shader: string;
  140392. };
  140393. }
  140394. declare module BABYLON {
  140395. /**
  140396. * BABYLON.JS Chromatic Aberration GLSL Shader
  140397. * Author: Olivier Guyot
  140398. * Separates very slightly R, G and B colors on the edges of the screen
  140399. * Inspired by Francois Tarlier & Martins Upitis
  140400. */
  140401. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  140402. /**
  140403. * @ignore
  140404. * The chromatic aberration PostProcess id in the pipeline
  140405. */
  140406. LensChromaticAberrationEffect: string;
  140407. /**
  140408. * @ignore
  140409. * The highlights enhancing PostProcess id in the pipeline
  140410. */
  140411. HighlightsEnhancingEffect: string;
  140412. /**
  140413. * @ignore
  140414. * The depth-of-field PostProcess id in the pipeline
  140415. */
  140416. LensDepthOfFieldEffect: string;
  140417. private _scene;
  140418. private _depthTexture;
  140419. private _grainTexture;
  140420. private _chromaticAberrationPostProcess;
  140421. private _highlightsPostProcess;
  140422. private _depthOfFieldPostProcess;
  140423. private _edgeBlur;
  140424. private _grainAmount;
  140425. private _chromaticAberration;
  140426. private _distortion;
  140427. private _highlightsGain;
  140428. private _highlightsThreshold;
  140429. private _dofDistance;
  140430. private _dofAperture;
  140431. private _dofDarken;
  140432. private _dofPentagon;
  140433. private _blurNoise;
  140434. /**
  140435. * @constructor
  140436. *
  140437. * Effect parameters are as follow:
  140438. * {
  140439. * chromatic_aberration: number; // from 0 to x (1 for realism)
  140440. * edge_blur: number; // from 0 to x (1 for realism)
  140441. * distortion: number; // from 0 to x (1 for realism)
  140442. * grain_amount: number; // from 0 to 1
  140443. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  140444. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  140445. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  140446. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  140447. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  140448. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  140449. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  140450. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  140451. * }
  140452. * Note: if an effect parameter is unset, effect is disabled
  140453. *
  140454. * @param name The rendering pipeline name
  140455. * @param parameters - An object containing all parameters (see above)
  140456. * @param scene The scene linked to this pipeline
  140457. * @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)
  140458. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140459. */
  140460. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  140461. /**
  140462. * Get the class name
  140463. * @returns "LensRenderingPipeline"
  140464. */
  140465. getClassName(): string;
  140466. /**
  140467. * Gets associated scene
  140468. */
  140469. get scene(): Scene;
  140470. /**
  140471. * Gets or sets the edge blur
  140472. */
  140473. get edgeBlur(): number;
  140474. set edgeBlur(value: number);
  140475. /**
  140476. * Gets or sets the grain amount
  140477. */
  140478. get grainAmount(): number;
  140479. set grainAmount(value: number);
  140480. /**
  140481. * Gets or sets the chromatic aberration amount
  140482. */
  140483. get chromaticAberration(): number;
  140484. set chromaticAberration(value: number);
  140485. /**
  140486. * Gets or sets the depth of field aperture
  140487. */
  140488. get dofAperture(): number;
  140489. set dofAperture(value: number);
  140490. /**
  140491. * Gets or sets the edge distortion
  140492. */
  140493. get edgeDistortion(): number;
  140494. set edgeDistortion(value: number);
  140495. /**
  140496. * Gets or sets the depth of field distortion
  140497. */
  140498. get dofDistortion(): number;
  140499. set dofDistortion(value: number);
  140500. /**
  140501. * Gets or sets the darken out of focus amount
  140502. */
  140503. get darkenOutOfFocus(): number;
  140504. set darkenOutOfFocus(value: number);
  140505. /**
  140506. * Gets or sets a boolean indicating if blur noise is enabled
  140507. */
  140508. get blurNoise(): boolean;
  140509. set blurNoise(value: boolean);
  140510. /**
  140511. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  140512. */
  140513. get pentagonBokeh(): boolean;
  140514. set pentagonBokeh(value: boolean);
  140515. /**
  140516. * Gets or sets the highlight grain amount
  140517. */
  140518. get highlightsGain(): number;
  140519. set highlightsGain(value: number);
  140520. /**
  140521. * Gets or sets the highlight threshold
  140522. */
  140523. get highlightsThreshold(): number;
  140524. set highlightsThreshold(value: number);
  140525. /**
  140526. * Sets the amount of blur at the edges
  140527. * @param amount blur amount
  140528. */
  140529. setEdgeBlur(amount: number): void;
  140530. /**
  140531. * Sets edge blur to 0
  140532. */
  140533. disableEdgeBlur(): void;
  140534. /**
  140535. * Sets the amout of grain
  140536. * @param amount Amount of grain
  140537. */
  140538. setGrainAmount(amount: number): void;
  140539. /**
  140540. * Set grain amount to 0
  140541. */
  140542. disableGrain(): void;
  140543. /**
  140544. * Sets the chromatic aberration amount
  140545. * @param amount amount of chromatic aberration
  140546. */
  140547. setChromaticAberration(amount: number): void;
  140548. /**
  140549. * Sets chromatic aberration amount to 0
  140550. */
  140551. disableChromaticAberration(): void;
  140552. /**
  140553. * Sets the EdgeDistortion amount
  140554. * @param amount amount of EdgeDistortion
  140555. */
  140556. setEdgeDistortion(amount: number): void;
  140557. /**
  140558. * Sets edge distortion to 0
  140559. */
  140560. disableEdgeDistortion(): void;
  140561. /**
  140562. * Sets the FocusDistance amount
  140563. * @param amount amount of FocusDistance
  140564. */
  140565. setFocusDistance(amount: number): void;
  140566. /**
  140567. * Disables depth of field
  140568. */
  140569. disableDepthOfField(): void;
  140570. /**
  140571. * Sets the Aperture amount
  140572. * @param amount amount of Aperture
  140573. */
  140574. setAperture(amount: number): void;
  140575. /**
  140576. * Sets the DarkenOutOfFocus amount
  140577. * @param amount amount of DarkenOutOfFocus
  140578. */
  140579. setDarkenOutOfFocus(amount: number): void;
  140580. private _pentagonBokehIsEnabled;
  140581. /**
  140582. * Creates a pentagon bokeh effect
  140583. */
  140584. enablePentagonBokeh(): void;
  140585. /**
  140586. * Disables the pentagon bokeh effect
  140587. */
  140588. disablePentagonBokeh(): void;
  140589. /**
  140590. * Enables noise blur
  140591. */
  140592. enableNoiseBlur(): void;
  140593. /**
  140594. * Disables noise blur
  140595. */
  140596. disableNoiseBlur(): void;
  140597. /**
  140598. * Sets the HighlightsGain amount
  140599. * @param amount amount of HighlightsGain
  140600. */
  140601. setHighlightsGain(amount: number): void;
  140602. /**
  140603. * Sets the HighlightsThreshold amount
  140604. * @param amount amount of HighlightsThreshold
  140605. */
  140606. setHighlightsThreshold(amount: number): void;
  140607. /**
  140608. * Disables highlights
  140609. */
  140610. disableHighlights(): void;
  140611. /**
  140612. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  140613. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  140614. */
  140615. dispose(disableDepthRender?: boolean): void;
  140616. private _createChromaticAberrationPostProcess;
  140617. private _createHighlightsPostProcess;
  140618. private _createDepthOfFieldPostProcess;
  140619. private _createGrainTexture;
  140620. }
  140621. }
  140622. declare module BABYLON {
  140623. /** @hidden */
  140624. export var ssao2PixelShader: {
  140625. name: string;
  140626. shader: string;
  140627. };
  140628. }
  140629. declare module BABYLON {
  140630. /** @hidden */
  140631. export var ssaoCombinePixelShader: {
  140632. name: string;
  140633. shader: string;
  140634. };
  140635. }
  140636. declare module BABYLON {
  140637. /**
  140638. * Render pipeline to produce ssao effect
  140639. */
  140640. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  140641. /**
  140642. * @ignore
  140643. * The PassPostProcess id in the pipeline that contains the original scene color
  140644. */
  140645. SSAOOriginalSceneColorEffect: string;
  140646. /**
  140647. * @ignore
  140648. * The SSAO PostProcess id in the pipeline
  140649. */
  140650. SSAORenderEffect: string;
  140651. /**
  140652. * @ignore
  140653. * The horizontal blur PostProcess id in the pipeline
  140654. */
  140655. SSAOBlurHRenderEffect: string;
  140656. /**
  140657. * @ignore
  140658. * The vertical blur PostProcess id in the pipeline
  140659. */
  140660. SSAOBlurVRenderEffect: string;
  140661. /**
  140662. * @ignore
  140663. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140664. */
  140665. SSAOCombineRenderEffect: string;
  140666. /**
  140667. * The output strength of the SSAO post-process. Default value is 1.0.
  140668. */
  140669. totalStrength: number;
  140670. /**
  140671. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  140672. */
  140673. maxZ: number;
  140674. /**
  140675. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  140676. */
  140677. minZAspect: number;
  140678. private _samples;
  140679. /**
  140680. * Number of samples used for the SSAO calculations. Default value is 8
  140681. */
  140682. set samples(n: number);
  140683. get samples(): number;
  140684. private _textureSamples;
  140685. /**
  140686. * Number of samples to use for antialiasing
  140687. */
  140688. set textureSamples(n: number);
  140689. get textureSamples(): number;
  140690. /**
  140691. * Ratio object used for SSAO ratio and blur ratio
  140692. */
  140693. private _ratio;
  140694. /**
  140695. * Dynamically generated sphere sampler.
  140696. */
  140697. private _sampleSphere;
  140698. /**
  140699. * Blur filter offsets
  140700. */
  140701. private _samplerOffsets;
  140702. private _expensiveBlur;
  140703. /**
  140704. * If bilateral blur should be used
  140705. */
  140706. set expensiveBlur(b: boolean);
  140707. get expensiveBlur(): boolean;
  140708. /**
  140709. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  140710. */
  140711. radius: number;
  140712. /**
  140713. * The base color of the SSAO post-process
  140714. * The final result is "base + ssao" between [0, 1]
  140715. */
  140716. base: number;
  140717. /**
  140718. * Support test.
  140719. */
  140720. static get IsSupported(): boolean;
  140721. private _scene;
  140722. private _depthTexture;
  140723. private _normalTexture;
  140724. private _randomTexture;
  140725. private _originalColorPostProcess;
  140726. private _ssaoPostProcess;
  140727. private _blurHPostProcess;
  140728. private _blurVPostProcess;
  140729. private _ssaoCombinePostProcess;
  140730. /**
  140731. * Gets active scene
  140732. */
  140733. get scene(): Scene;
  140734. /**
  140735. * @constructor
  140736. * @param name The rendering pipeline name
  140737. * @param scene The scene linked to this pipeline
  140738. * @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 }
  140739. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140740. */
  140741. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140742. /**
  140743. * Get the class name
  140744. * @returns "SSAO2RenderingPipeline"
  140745. */
  140746. getClassName(): string;
  140747. /**
  140748. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140749. */
  140750. dispose(disableGeometryBufferRenderer?: boolean): void;
  140751. private _createBlurPostProcess;
  140752. /** @hidden */
  140753. _rebuild(): void;
  140754. private _bits;
  140755. private _radicalInverse_VdC;
  140756. private _hammersley;
  140757. private _hemisphereSample_uniform;
  140758. private _generateHemisphere;
  140759. private _createSSAOPostProcess;
  140760. private _createSSAOCombinePostProcess;
  140761. private _createRandomTexture;
  140762. /**
  140763. * Serialize the rendering pipeline (Used when exporting)
  140764. * @returns the serialized object
  140765. */
  140766. serialize(): any;
  140767. /**
  140768. * Parse the serialized pipeline
  140769. * @param source Source pipeline.
  140770. * @param scene The scene to load the pipeline to.
  140771. * @param rootUrl The URL of the serialized pipeline.
  140772. * @returns An instantiated pipeline from the serialized object.
  140773. */
  140774. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  140775. }
  140776. }
  140777. declare module BABYLON {
  140778. /** @hidden */
  140779. export var ssaoPixelShader: {
  140780. name: string;
  140781. shader: string;
  140782. };
  140783. }
  140784. declare module BABYLON {
  140785. /**
  140786. * Render pipeline to produce ssao effect
  140787. */
  140788. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  140789. /**
  140790. * @ignore
  140791. * The PassPostProcess id in the pipeline that contains the original scene color
  140792. */
  140793. SSAOOriginalSceneColorEffect: string;
  140794. /**
  140795. * @ignore
  140796. * The SSAO PostProcess id in the pipeline
  140797. */
  140798. SSAORenderEffect: string;
  140799. /**
  140800. * @ignore
  140801. * The horizontal blur PostProcess id in the pipeline
  140802. */
  140803. SSAOBlurHRenderEffect: string;
  140804. /**
  140805. * @ignore
  140806. * The vertical blur PostProcess id in the pipeline
  140807. */
  140808. SSAOBlurVRenderEffect: string;
  140809. /**
  140810. * @ignore
  140811. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140812. */
  140813. SSAOCombineRenderEffect: string;
  140814. /**
  140815. * The output strength of the SSAO post-process. Default value is 1.0.
  140816. */
  140817. totalStrength: number;
  140818. /**
  140819. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  140820. */
  140821. radius: number;
  140822. /**
  140823. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  140824. * Must not be equal to fallOff and superior to fallOff.
  140825. * Default value is 0.0075
  140826. */
  140827. area: number;
  140828. /**
  140829. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  140830. * Must not be equal to area and inferior to area.
  140831. * Default value is 0.000001
  140832. */
  140833. fallOff: number;
  140834. /**
  140835. * The base color of the SSAO post-process
  140836. * The final result is "base + ssao" between [0, 1]
  140837. */
  140838. base: number;
  140839. private _scene;
  140840. private _depthTexture;
  140841. private _randomTexture;
  140842. private _originalColorPostProcess;
  140843. private _ssaoPostProcess;
  140844. private _blurHPostProcess;
  140845. private _blurVPostProcess;
  140846. private _ssaoCombinePostProcess;
  140847. private _firstUpdate;
  140848. /**
  140849. * Gets active scene
  140850. */
  140851. get scene(): Scene;
  140852. /**
  140853. * @constructor
  140854. * @param name - The rendering pipeline name
  140855. * @param scene - The scene linked to this pipeline
  140856. * @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 }
  140857. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  140858. */
  140859. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140860. /**
  140861. * Get the class name
  140862. * @returns "SSAORenderingPipeline"
  140863. */
  140864. getClassName(): string;
  140865. /**
  140866. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140867. */
  140868. dispose(disableDepthRender?: boolean): void;
  140869. private _createBlurPostProcess;
  140870. /** @hidden */
  140871. _rebuild(): void;
  140872. private _createSSAOPostProcess;
  140873. private _createSSAOCombinePostProcess;
  140874. private _createRandomTexture;
  140875. }
  140876. }
  140877. declare module BABYLON {
  140878. /** @hidden */
  140879. export var screenSpaceReflectionPixelShader: {
  140880. name: string;
  140881. shader: string;
  140882. };
  140883. }
  140884. declare module BABYLON {
  140885. /**
  140886. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  140887. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  140888. */
  140889. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  140890. /**
  140891. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  140892. */
  140893. threshold: number;
  140894. /**
  140895. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  140896. */
  140897. strength: number;
  140898. /**
  140899. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  140900. */
  140901. reflectionSpecularFalloffExponent: number;
  140902. /**
  140903. * 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]
  140904. */
  140905. step: number;
  140906. /**
  140907. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  140908. */
  140909. roughnessFactor: number;
  140910. private _geometryBufferRenderer;
  140911. private _enableSmoothReflections;
  140912. private _reflectionSamples;
  140913. private _smoothSteps;
  140914. /**
  140915. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  140916. * @param name The name of the effect.
  140917. * @param scene The scene containing the objects to calculate reflections.
  140918. * @param options The required width/height ratio to downsize to before computing the render pass.
  140919. * @param camera The camera to apply the render pass to.
  140920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140921. * @param engine The engine which the post process will be applied. (default: current engine)
  140922. * @param reusable If the post process can be reused on the same frame. (default: false)
  140923. * @param textureType Type of textures used when performing the post process. (default: 0)
  140924. * @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)
  140925. */
  140926. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140927. /**
  140928. * Gets wether or not smoothing reflections is enabled.
  140929. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140930. */
  140931. get enableSmoothReflections(): boolean;
  140932. /**
  140933. * Sets wether or not smoothing reflections is enabled.
  140934. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140935. */
  140936. set enableSmoothReflections(enabled: boolean);
  140937. /**
  140938. * Gets the number of samples taken while computing reflections. More samples count is high,
  140939. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140940. */
  140941. get reflectionSamples(): number;
  140942. /**
  140943. * Sets the number of samples taken while computing reflections. More samples count is high,
  140944. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140945. */
  140946. set reflectionSamples(samples: number);
  140947. /**
  140948. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  140949. * more the post-process will require GPU power and can generate a drop in FPS.
  140950. * Default value (5.0) work pretty well in all cases but can be adjusted.
  140951. */
  140952. get smoothSteps(): number;
  140953. set smoothSteps(steps: number);
  140954. private _updateEffectDefines;
  140955. }
  140956. }
  140957. declare module BABYLON {
  140958. /** @hidden */
  140959. export var standardPixelShader: {
  140960. name: string;
  140961. shader: string;
  140962. };
  140963. }
  140964. declare module BABYLON {
  140965. /**
  140966. * Standard rendering pipeline
  140967. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140968. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  140969. */
  140970. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140971. /**
  140972. * Public members
  140973. */
  140974. /**
  140975. * Post-process which contains the original scene color before the pipeline applies all the effects
  140976. */
  140977. originalPostProcess: Nullable<PostProcess>;
  140978. /**
  140979. * Post-process used to down scale an image x4
  140980. */
  140981. downSampleX4PostProcess: Nullable<PostProcess>;
  140982. /**
  140983. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  140984. */
  140985. brightPassPostProcess: Nullable<PostProcess>;
  140986. /**
  140987. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  140988. */
  140989. blurHPostProcesses: PostProcess[];
  140990. /**
  140991. * Post-process array storing all the vertical blur post-processes used by the pipeline
  140992. */
  140993. blurVPostProcesses: PostProcess[];
  140994. /**
  140995. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  140996. */
  140997. textureAdderPostProcess: Nullable<PostProcess>;
  140998. /**
  140999. * Post-process used to create volumetric lighting effect
  141000. */
  141001. volumetricLightPostProcess: Nullable<PostProcess>;
  141002. /**
  141003. * Post-process used to smooth the previous volumetric light post-process on the X axis
  141004. */
  141005. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  141006. /**
  141007. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  141008. */
  141009. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  141010. /**
  141011. * Post-process used to merge the volumetric light effect and the real scene color
  141012. */
  141013. volumetricLightMergePostProces: Nullable<PostProcess>;
  141014. /**
  141015. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  141016. */
  141017. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  141018. /**
  141019. * Base post-process used to calculate the average luminance of the final image for HDR
  141020. */
  141021. luminancePostProcess: Nullable<PostProcess>;
  141022. /**
  141023. * Post-processes used to create down sample post-processes in order to get
  141024. * the average luminance of the final image for HDR
  141025. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  141026. */
  141027. luminanceDownSamplePostProcesses: PostProcess[];
  141028. /**
  141029. * Post-process used to create a HDR effect (light adaptation)
  141030. */
  141031. hdrPostProcess: Nullable<PostProcess>;
  141032. /**
  141033. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  141034. */
  141035. textureAdderFinalPostProcess: Nullable<PostProcess>;
  141036. /**
  141037. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  141038. */
  141039. lensFlareFinalPostProcess: Nullable<PostProcess>;
  141040. /**
  141041. * Post-process used to merge the final HDR post-process and the real scene color
  141042. */
  141043. hdrFinalPostProcess: Nullable<PostProcess>;
  141044. /**
  141045. * Post-process used to create a lens flare effect
  141046. */
  141047. lensFlarePostProcess: Nullable<PostProcess>;
  141048. /**
  141049. * Post-process that merges the result of the lens flare post-process and the real scene color
  141050. */
  141051. lensFlareComposePostProcess: Nullable<PostProcess>;
  141052. /**
  141053. * Post-process used to create a motion blur effect
  141054. */
  141055. motionBlurPostProcess: Nullable<PostProcess>;
  141056. /**
  141057. * Post-process used to create a depth of field effect
  141058. */
  141059. depthOfFieldPostProcess: Nullable<PostProcess>;
  141060. /**
  141061. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  141062. */
  141063. fxaaPostProcess: Nullable<FxaaPostProcess>;
  141064. /**
  141065. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  141066. */
  141067. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  141068. /**
  141069. * Represents the brightness threshold in order to configure the illuminated surfaces
  141070. */
  141071. brightThreshold: number;
  141072. /**
  141073. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  141074. */
  141075. blurWidth: number;
  141076. /**
  141077. * Sets if the blur for highlighted surfaces must be only horizontal
  141078. */
  141079. horizontalBlur: boolean;
  141080. /**
  141081. * Gets the overall exposure used by the pipeline
  141082. */
  141083. get exposure(): number;
  141084. /**
  141085. * Sets the overall exposure used by the pipeline
  141086. */
  141087. set exposure(value: number);
  141088. /**
  141089. * Texture used typically to simulate "dirty" on camera lens
  141090. */
  141091. lensTexture: Nullable<Texture>;
  141092. /**
  141093. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  141094. */
  141095. volumetricLightCoefficient: number;
  141096. /**
  141097. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  141098. */
  141099. volumetricLightPower: number;
  141100. /**
  141101. * Used the set the blur intensity to smooth the volumetric lights
  141102. */
  141103. volumetricLightBlurScale: number;
  141104. /**
  141105. * Light (spot or directional) used to generate the volumetric lights rays
  141106. * The source light must have a shadow generate so the pipeline can get its
  141107. * depth map
  141108. */
  141109. sourceLight: Nullable<SpotLight | DirectionalLight>;
  141110. /**
  141111. * For eye adaptation, represents the minimum luminance the eye can see
  141112. */
  141113. hdrMinimumLuminance: number;
  141114. /**
  141115. * For eye adaptation, represents the decrease luminance speed
  141116. */
  141117. hdrDecreaseRate: number;
  141118. /**
  141119. * For eye adaptation, represents the increase luminance speed
  141120. */
  141121. hdrIncreaseRate: number;
  141122. /**
  141123. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141124. */
  141125. get hdrAutoExposure(): boolean;
  141126. /**
  141127. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141128. */
  141129. set hdrAutoExposure(value: boolean);
  141130. /**
  141131. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  141132. */
  141133. lensColorTexture: Nullable<Texture>;
  141134. /**
  141135. * The overall strengh for the lens flare effect
  141136. */
  141137. lensFlareStrength: number;
  141138. /**
  141139. * Dispersion coefficient for lens flare ghosts
  141140. */
  141141. lensFlareGhostDispersal: number;
  141142. /**
  141143. * Main lens flare halo width
  141144. */
  141145. lensFlareHaloWidth: number;
  141146. /**
  141147. * Based on the lens distortion effect, defines how much the lens flare result
  141148. * is distorted
  141149. */
  141150. lensFlareDistortionStrength: number;
  141151. /**
  141152. * Configures the blur intensity used for for lens flare (halo)
  141153. */
  141154. lensFlareBlurWidth: number;
  141155. /**
  141156. * Lens star texture must be used to simulate rays on the flares and is available
  141157. * in the documentation
  141158. */
  141159. lensStarTexture: Nullable<Texture>;
  141160. /**
  141161. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  141162. * flare effect by taking account of the dirt texture
  141163. */
  141164. lensFlareDirtTexture: Nullable<Texture>;
  141165. /**
  141166. * Represents the focal length for the depth of field effect
  141167. */
  141168. depthOfFieldDistance: number;
  141169. /**
  141170. * Represents the blur intensity for the blurred part of the depth of field effect
  141171. */
  141172. depthOfFieldBlurWidth: number;
  141173. /**
  141174. * Gets how much the image is blurred by the movement while using the motion blur post-process
  141175. */
  141176. get motionStrength(): number;
  141177. /**
  141178. * Sets how much the image is blurred by the movement while using the motion blur post-process
  141179. */
  141180. set motionStrength(strength: number);
  141181. /**
  141182. * Gets wether or not the motion blur post-process is object based or screen based.
  141183. */
  141184. get objectBasedMotionBlur(): boolean;
  141185. /**
  141186. * Sets wether or not the motion blur post-process should be object based or screen based
  141187. */
  141188. set objectBasedMotionBlur(value: boolean);
  141189. /**
  141190. * List of animations for the pipeline (IAnimatable implementation)
  141191. */
  141192. animations: Animation[];
  141193. /**
  141194. * Private members
  141195. */
  141196. private _scene;
  141197. private _currentDepthOfFieldSource;
  141198. private _basePostProcess;
  141199. private _fixedExposure;
  141200. private _currentExposure;
  141201. private _hdrAutoExposure;
  141202. private _hdrCurrentLuminance;
  141203. private _motionStrength;
  141204. private _isObjectBasedMotionBlur;
  141205. private _floatTextureType;
  141206. private _camerasToBeAttached;
  141207. private _ratio;
  141208. private _bloomEnabled;
  141209. private _depthOfFieldEnabled;
  141210. private _vlsEnabled;
  141211. private _lensFlareEnabled;
  141212. private _hdrEnabled;
  141213. private _motionBlurEnabled;
  141214. private _fxaaEnabled;
  141215. private _screenSpaceReflectionsEnabled;
  141216. private _motionBlurSamples;
  141217. private _volumetricLightStepsCount;
  141218. private _samples;
  141219. /**
  141220. * @ignore
  141221. * Specifies if the bloom pipeline is enabled
  141222. */
  141223. get BloomEnabled(): boolean;
  141224. set BloomEnabled(enabled: boolean);
  141225. /**
  141226. * @ignore
  141227. * Specifies if the depth of field pipeline is enabed
  141228. */
  141229. get DepthOfFieldEnabled(): boolean;
  141230. set DepthOfFieldEnabled(enabled: boolean);
  141231. /**
  141232. * @ignore
  141233. * Specifies if the lens flare pipeline is enabed
  141234. */
  141235. get LensFlareEnabled(): boolean;
  141236. set LensFlareEnabled(enabled: boolean);
  141237. /**
  141238. * @ignore
  141239. * Specifies if the HDR pipeline is enabled
  141240. */
  141241. get HDREnabled(): boolean;
  141242. set HDREnabled(enabled: boolean);
  141243. /**
  141244. * @ignore
  141245. * Specifies if the volumetric lights scattering effect is enabled
  141246. */
  141247. get VLSEnabled(): boolean;
  141248. set VLSEnabled(enabled: boolean);
  141249. /**
  141250. * @ignore
  141251. * Specifies if the motion blur effect is enabled
  141252. */
  141253. get MotionBlurEnabled(): boolean;
  141254. set MotionBlurEnabled(enabled: boolean);
  141255. /**
  141256. * Specifies if anti-aliasing is enabled
  141257. */
  141258. get fxaaEnabled(): boolean;
  141259. set fxaaEnabled(enabled: boolean);
  141260. /**
  141261. * Specifies if screen space reflections are enabled.
  141262. */
  141263. get screenSpaceReflectionsEnabled(): boolean;
  141264. set screenSpaceReflectionsEnabled(enabled: boolean);
  141265. /**
  141266. * Specifies the number of steps used to calculate the volumetric lights
  141267. * Typically in interval [50, 200]
  141268. */
  141269. get volumetricLightStepsCount(): number;
  141270. set volumetricLightStepsCount(count: number);
  141271. /**
  141272. * Specifies the number of samples used for the motion blur effect
  141273. * Typically in interval [16, 64]
  141274. */
  141275. get motionBlurSamples(): number;
  141276. set motionBlurSamples(samples: number);
  141277. /**
  141278. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  141279. */
  141280. get samples(): number;
  141281. set samples(sampleCount: number);
  141282. /**
  141283. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  141284. * @constructor
  141285. * @param name The rendering pipeline name
  141286. * @param scene The scene linked to this pipeline
  141287. * @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)
  141288. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  141289. * @param cameras The array of cameras that the rendering pipeline will be attached to
  141290. */
  141291. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  141292. private _buildPipeline;
  141293. private _createDownSampleX4PostProcess;
  141294. private _createBrightPassPostProcess;
  141295. private _createBlurPostProcesses;
  141296. private _createTextureAdderPostProcess;
  141297. private _createVolumetricLightPostProcess;
  141298. private _createLuminancePostProcesses;
  141299. private _createHdrPostProcess;
  141300. private _createLensFlarePostProcess;
  141301. private _createDepthOfFieldPostProcess;
  141302. private _createMotionBlurPostProcess;
  141303. private _getDepthTexture;
  141304. private _disposePostProcesses;
  141305. /**
  141306. * Dispose of the pipeline and stop all post processes
  141307. */
  141308. dispose(): void;
  141309. /**
  141310. * Serialize the rendering pipeline (Used when exporting)
  141311. * @returns the serialized object
  141312. */
  141313. serialize(): any;
  141314. /**
  141315. * Parse the serialized pipeline
  141316. * @param source Source pipeline.
  141317. * @param scene The scene to load the pipeline to.
  141318. * @param rootUrl The URL of the serialized pipeline.
  141319. * @returns An instantiated pipeline from the serialized object.
  141320. */
  141321. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  141322. /**
  141323. * Luminance steps
  141324. */
  141325. static LuminanceSteps: number;
  141326. }
  141327. }
  141328. declare module BABYLON {
  141329. /** @hidden */
  141330. export var tonemapPixelShader: {
  141331. name: string;
  141332. shader: string;
  141333. };
  141334. }
  141335. declare module BABYLON {
  141336. /** Defines operator used for tonemapping */
  141337. export enum TonemappingOperator {
  141338. /** Hable */
  141339. Hable = 0,
  141340. /** Reinhard */
  141341. Reinhard = 1,
  141342. /** HejiDawson */
  141343. HejiDawson = 2,
  141344. /** Photographic */
  141345. Photographic = 3
  141346. }
  141347. /**
  141348. * Defines a post process to apply tone mapping
  141349. */
  141350. export class TonemapPostProcess extends PostProcess {
  141351. private _operator;
  141352. /** Defines the required exposure adjustement */
  141353. exposureAdjustment: number;
  141354. /**
  141355. * Creates a new TonemapPostProcess
  141356. * @param name defines the name of the postprocess
  141357. * @param _operator defines the operator to use
  141358. * @param exposureAdjustment defines the required exposure adjustement
  141359. * @param camera defines the camera to use (can be null)
  141360. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  141361. * @param engine defines the hosting engine (can be ignore if camera is set)
  141362. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141363. */
  141364. constructor(name: string, _operator: TonemappingOperator,
  141365. /** Defines the required exposure adjustement */
  141366. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  141367. }
  141368. }
  141369. declare module BABYLON {
  141370. /** @hidden */
  141371. export var volumetricLightScatteringPixelShader: {
  141372. name: string;
  141373. shader: string;
  141374. };
  141375. }
  141376. declare module BABYLON {
  141377. /** @hidden */
  141378. export var volumetricLightScatteringPassVertexShader: {
  141379. name: string;
  141380. shader: string;
  141381. };
  141382. }
  141383. declare module BABYLON {
  141384. /** @hidden */
  141385. export var volumetricLightScatteringPassPixelShader: {
  141386. name: string;
  141387. shader: string;
  141388. };
  141389. }
  141390. declare module BABYLON {
  141391. /**
  141392. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  141393. */
  141394. export class VolumetricLightScatteringPostProcess extends PostProcess {
  141395. private _volumetricLightScatteringPass;
  141396. private _volumetricLightScatteringRTT;
  141397. private _viewPort;
  141398. private _screenCoordinates;
  141399. private _cachedDefines;
  141400. /**
  141401. * If not undefined, the mesh position is computed from the attached node position
  141402. */
  141403. attachedNode: {
  141404. position: Vector3;
  141405. };
  141406. /**
  141407. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  141408. */
  141409. customMeshPosition: Vector3;
  141410. /**
  141411. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  141412. */
  141413. useCustomMeshPosition: boolean;
  141414. /**
  141415. * If the post-process should inverse the light scattering direction
  141416. */
  141417. invert: boolean;
  141418. /**
  141419. * The internal mesh used by the post-process
  141420. */
  141421. mesh: Mesh;
  141422. /**
  141423. * @hidden
  141424. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  141425. */
  141426. get useDiffuseColor(): boolean;
  141427. set useDiffuseColor(useDiffuseColor: boolean);
  141428. /**
  141429. * Array containing the excluded meshes not rendered in the internal pass
  141430. */
  141431. excludedMeshes: AbstractMesh[];
  141432. /**
  141433. * Controls the overall intensity of the post-process
  141434. */
  141435. exposure: number;
  141436. /**
  141437. * Dissipates each sample's contribution in range [0, 1]
  141438. */
  141439. decay: number;
  141440. /**
  141441. * Controls the overall intensity of each sample
  141442. */
  141443. weight: number;
  141444. /**
  141445. * Controls the density of each sample
  141446. */
  141447. density: number;
  141448. /**
  141449. * @constructor
  141450. * @param name The post-process name
  141451. * @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)
  141452. * @param camera The camera that the post-process will be attached to
  141453. * @param mesh The mesh used to create the light scattering
  141454. * @param samples The post-process quality, default 100
  141455. * @param samplingModeThe post-process filtering mode
  141456. * @param engine The babylon engine
  141457. * @param reusable If the post-process is reusable
  141458. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  141459. */
  141460. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  141461. /**
  141462. * Returns the string "VolumetricLightScatteringPostProcess"
  141463. * @returns "VolumetricLightScatteringPostProcess"
  141464. */
  141465. getClassName(): string;
  141466. private _isReady;
  141467. /**
  141468. * Sets the new light position for light scattering effect
  141469. * @param position The new custom light position
  141470. */
  141471. setCustomMeshPosition(position: Vector3): void;
  141472. /**
  141473. * Returns the light position for light scattering effect
  141474. * @return Vector3 The custom light position
  141475. */
  141476. getCustomMeshPosition(): Vector3;
  141477. /**
  141478. * Disposes the internal assets and detaches the post-process from the camera
  141479. */
  141480. dispose(camera: Camera): void;
  141481. /**
  141482. * Returns the render target texture used by the post-process
  141483. * @return the render target texture used by the post-process
  141484. */
  141485. getPass(): RenderTargetTexture;
  141486. private _meshExcluded;
  141487. private _createPass;
  141488. private _updateMeshScreenCoordinates;
  141489. /**
  141490. * Creates a default mesh for the Volumeric Light Scattering post-process
  141491. * @param name The mesh name
  141492. * @param scene The scene where to create the mesh
  141493. * @return the default mesh
  141494. */
  141495. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  141496. }
  141497. }
  141498. declare module BABYLON {
  141499. interface Scene {
  141500. /** @hidden (Backing field) */
  141501. _boundingBoxRenderer: BoundingBoxRenderer;
  141502. /** @hidden (Backing field) */
  141503. _forceShowBoundingBoxes: boolean;
  141504. /**
  141505. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  141506. */
  141507. forceShowBoundingBoxes: boolean;
  141508. /**
  141509. * Gets the bounding box renderer associated with the scene
  141510. * @returns a BoundingBoxRenderer
  141511. */
  141512. getBoundingBoxRenderer(): BoundingBoxRenderer;
  141513. }
  141514. interface AbstractMesh {
  141515. /** @hidden (Backing field) */
  141516. _showBoundingBox: boolean;
  141517. /**
  141518. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  141519. */
  141520. showBoundingBox: boolean;
  141521. }
  141522. /**
  141523. * Component responsible of rendering the bounding box of the meshes in a scene.
  141524. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  141525. */
  141526. export class BoundingBoxRenderer implements ISceneComponent {
  141527. /**
  141528. * The component name helpfull to identify the component in the list of scene components.
  141529. */
  141530. readonly name: string;
  141531. /**
  141532. * The scene the component belongs to.
  141533. */
  141534. scene: Scene;
  141535. /**
  141536. * Color of the bounding box lines placed in front of an object
  141537. */
  141538. frontColor: Color3;
  141539. /**
  141540. * Color of the bounding box lines placed behind an object
  141541. */
  141542. backColor: Color3;
  141543. /**
  141544. * Defines if the renderer should show the back lines or not
  141545. */
  141546. showBackLines: boolean;
  141547. /**
  141548. * @hidden
  141549. */
  141550. renderList: SmartArray<BoundingBox>;
  141551. private _colorShader;
  141552. private _vertexBuffers;
  141553. private _indexBuffer;
  141554. private _fillIndexBuffer;
  141555. private _fillIndexData;
  141556. /**
  141557. * Instantiates a new bounding box renderer in a scene.
  141558. * @param scene the scene the renderer renders in
  141559. */
  141560. constructor(scene: Scene);
  141561. /**
  141562. * Registers the component in a given scene
  141563. */
  141564. register(): void;
  141565. private _evaluateSubMesh;
  141566. private _activeMesh;
  141567. private _prepareRessources;
  141568. private _createIndexBuffer;
  141569. /**
  141570. * Rebuilds the elements related to this component in case of
  141571. * context lost for instance.
  141572. */
  141573. rebuild(): void;
  141574. /**
  141575. * @hidden
  141576. */
  141577. reset(): void;
  141578. /**
  141579. * Render the bounding boxes of a specific rendering group
  141580. * @param renderingGroupId defines the rendering group to render
  141581. */
  141582. render(renderingGroupId: number): void;
  141583. /**
  141584. * In case of occlusion queries, we can render the occlusion bounding box through this method
  141585. * @param mesh Define the mesh to render the occlusion bounding box for
  141586. */
  141587. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  141588. /**
  141589. * Dispose and release the resources attached to this renderer.
  141590. */
  141591. dispose(): void;
  141592. }
  141593. }
  141594. declare module BABYLON {
  141595. interface Scene {
  141596. /** @hidden (Backing field) */
  141597. _depthRenderer: {
  141598. [id: string]: DepthRenderer;
  141599. };
  141600. /**
  141601. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  141602. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  141603. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141604. * @returns the created depth renderer
  141605. */
  141606. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  141607. /**
  141608. * Disables a depth renderer for a given camera
  141609. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  141610. */
  141611. disableDepthRenderer(camera?: Nullable<Camera>): void;
  141612. }
  141613. /**
  141614. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  141615. * in several rendering techniques.
  141616. */
  141617. export class DepthRendererSceneComponent implements ISceneComponent {
  141618. /**
  141619. * The component name helpfull to identify the component in the list of scene components.
  141620. */
  141621. readonly name: string;
  141622. /**
  141623. * The scene the component belongs to.
  141624. */
  141625. scene: Scene;
  141626. /**
  141627. * Creates a new instance of the component for the given scene
  141628. * @param scene Defines the scene to register the component in
  141629. */
  141630. constructor(scene: Scene);
  141631. /**
  141632. * Registers the component in a given scene
  141633. */
  141634. register(): void;
  141635. /**
  141636. * Rebuilds the elements related to this component in case of
  141637. * context lost for instance.
  141638. */
  141639. rebuild(): void;
  141640. /**
  141641. * Disposes the component and the associated ressources
  141642. */
  141643. dispose(): void;
  141644. private _gatherRenderTargets;
  141645. private _gatherActiveCameraRenderTargets;
  141646. }
  141647. }
  141648. declare module BABYLON {
  141649. /** @hidden */
  141650. export var outlinePixelShader: {
  141651. name: string;
  141652. shader: string;
  141653. };
  141654. }
  141655. declare module BABYLON {
  141656. /** @hidden */
  141657. export var outlineVertexShader: {
  141658. name: string;
  141659. shader: string;
  141660. };
  141661. }
  141662. declare module BABYLON {
  141663. interface Scene {
  141664. /** @hidden */
  141665. _outlineRenderer: OutlineRenderer;
  141666. /**
  141667. * Gets the outline renderer associated with the scene
  141668. * @returns a OutlineRenderer
  141669. */
  141670. getOutlineRenderer(): OutlineRenderer;
  141671. }
  141672. interface AbstractMesh {
  141673. /** @hidden (Backing field) */
  141674. _renderOutline: boolean;
  141675. /**
  141676. * Gets or sets a boolean indicating if the outline must be rendered as well
  141677. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  141678. */
  141679. renderOutline: boolean;
  141680. /** @hidden (Backing field) */
  141681. _renderOverlay: boolean;
  141682. /**
  141683. * Gets or sets a boolean indicating if the overlay must be rendered as well
  141684. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  141685. */
  141686. renderOverlay: boolean;
  141687. }
  141688. /**
  141689. * This class is responsible to draw bothe outline/overlay of meshes.
  141690. * It should not be used directly but through the available method on mesh.
  141691. */
  141692. export class OutlineRenderer implements ISceneComponent {
  141693. /**
  141694. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  141695. */
  141696. private static _StencilReference;
  141697. /**
  141698. * The name of the component. Each component must have a unique name.
  141699. */
  141700. name: string;
  141701. /**
  141702. * The scene the component belongs to.
  141703. */
  141704. scene: Scene;
  141705. /**
  141706. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  141707. */
  141708. zOffset: number;
  141709. private _engine;
  141710. private _effect;
  141711. private _cachedDefines;
  141712. private _savedDepthWrite;
  141713. /**
  141714. * Instantiates a new outline renderer. (There could be only one per scene).
  141715. * @param scene Defines the scene it belongs to
  141716. */
  141717. constructor(scene: Scene);
  141718. /**
  141719. * Register the component to one instance of a scene.
  141720. */
  141721. register(): void;
  141722. /**
  141723. * Rebuilds the elements related to this component in case of
  141724. * context lost for instance.
  141725. */
  141726. rebuild(): void;
  141727. /**
  141728. * Disposes the component and the associated ressources.
  141729. */
  141730. dispose(): void;
  141731. /**
  141732. * Renders the outline in the canvas.
  141733. * @param subMesh Defines the sumesh to render
  141734. * @param batch Defines the batch of meshes in case of instances
  141735. * @param useOverlay Defines if the rendering is for the overlay or the outline
  141736. */
  141737. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  141738. /**
  141739. * Returns whether or not the outline renderer is ready for a given submesh.
  141740. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  141741. * @param subMesh Defines the submesh to check readyness for
  141742. * @param useInstances Defines wheter wee are trying to render instances or not
  141743. * @returns true if ready otherwise false
  141744. */
  141745. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141746. private _beforeRenderingMesh;
  141747. private _afterRenderingMesh;
  141748. }
  141749. }
  141750. declare module BABYLON {
  141751. /**
  141752. * Defines the basic options interface of a Sprite Frame Source Size.
  141753. */
  141754. export interface ISpriteJSONSpriteSourceSize {
  141755. /**
  141756. * number of the original width of the Frame
  141757. */
  141758. w: number;
  141759. /**
  141760. * number of the original height of the Frame
  141761. */
  141762. h: number;
  141763. }
  141764. /**
  141765. * Defines the basic options interface of a Sprite Frame Data.
  141766. */
  141767. export interface ISpriteJSONSpriteFrameData {
  141768. /**
  141769. * number of the x offset of the Frame
  141770. */
  141771. x: number;
  141772. /**
  141773. * number of the y offset of the Frame
  141774. */
  141775. y: number;
  141776. /**
  141777. * number of the width of the Frame
  141778. */
  141779. w: number;
  141780. /**
  141781. * number of the height of the Frame
  141782. */
  141783. h: number;
  141784. }
  141785. /**
  141786. * Defines the basic options interface of a JSON Sprite.
  141787. */
  141788. export interface ISpriteJSONSprite {
  141789. /**
  141790. * string name of the Frame
  141791. */
  141792. filename: string;
  141793. /**
  141794. * ISpriteJSONSpriteFrame basic object of the frame data
  141795. */
  141796. frame: ISpriteJSONSpriteFrameData;
  141797. /**
  141798. * boolean to flag is the frame was rotated.
  141799. */
  141800. rotated: boolean;
  141801. /**
  141802. * boolean to flag is the frame was trimmed.
  141803. */
  141804. trimmed: boolean;
  141805. /**
  141806. * ISpriteJSONSpriteFrame basic object of the source data
  141807. */
  141808. spriteSourceSize: ISpriteJSONSpriteFrameData;
  141809. /**
  141810. * ISpriteJSONSpriteFrame basic object of the source data
  141811. */
  141812. sourceSize: ISpriteJSONSpriteSourceSize;
  141813. }
  141814. /**
  141815. * Defines the basic options interface of a JSON atlas.
  141816. */
  141817. export interface ISpriteJSONAtlas {
  141818. /**
  141819. * Array of objects that contain the frame data.
  141820. */
  141821. frames: Array<ISpriteJSONSprite>;
  141822. /**
  141823. * object basic object containing the sprite meta data.
  141824. */
  141825. meta?: object;
  141826. }
  141827. }
  141828. declare module BABYLON {
  141829. /** @hidden */
  141830. export var spriteMapPixelShader: {
  141831. name: string;
  141832. shader: string;
  141833. };
  141834. }
  141835. declare module BABYLON {
  141836. /** @hidden */
  141837. export var spriteMapVertexShader: {
  141838. name: string;
  141839. shader: string;
  141840. };
  141841. }
  141842. declare module BABYLON {
  141843. /**
  141844. * Defines the basic options interface of a SpriteMap
  141845. */
  141846. export interface ISpriteMapOptions {
  141847. /**
  141848. * Vector2 of the number of cells in the grid.
  141849. */
  141850. stageSize?: Vector2;
  141851. /**
  141852. * Vector2 of the size of the output plane in World Units.
  141853. */
  141854. outputSize?: Vector2;
  141855. /**
  141856. * Vector3 of the position of the output plane in World Units.
  141857. */
  141858. outputPosition?: Vector3;
  141859. /**
  141860. * Vector3 of the rotation of the output plane.
  141861. */
  141862. outputRotation?: Vector3;
  141863. /**
  141864. * number of layers that the system will reserve in resources.
  141865. */
  141866. layerCount?: number;
  141867. /**
  141868. * number of max animation frames a single cell will reserve in resources.
  141869. */
  141870. maxAnimationFrames?: number;
  141871. /**
  141872. * number cell index of the base tile when the system compiles.
  141873. */
  141874. baseTile?: number;
  141875. /**
  141876. * boolean flip the sprite after its been repositioned by the framing data.
  141877. */
  141878. flipU?: boolean;
  141879. /**
  141880. * Vector3 scalar of the global RGB values of the SpriteMap.
  141881. */
  141882. colorMultiply?: Vector3;
  141883. }
  141884. /**
  141885. * Defines the IDisposable interface in order to be cleanable from resources.
  141886. */
  141887. export interface ISpriteMap extends IDisposable {
  141888. /**
  141889. * String name of the SpriteMap.
  141890. */
  141891. name: string;
  141892. /**
  141893. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  141894. */
  141895. atlasJSON: ISpriteJSONAtlas;
  141896. /**
  141897. * Texture of the SpriteMap.
  141898. */
  141899. spriteSheet: Texture;
  141900. /**
  141901. * The parameters to initialize the SpriteMap with.
  141902. */
  141903. options: ISpriteMapOptions;
  141904. }
  141905. /**
  141906. * Class used to manage a grid restricted sprite deployment on an Output plane.
  141907. */
  141908. export class SpriteMap implements ISpriteMap {
  141909. /** The Name of the spriteMap */
  141910. name: string;
  141911. /** The JSON file with the frame and meta data */
  141912. atlasJSON: ISpriteJSONAtlas;
  141913. /** The systems Sprite Sheet Texture */
  141914. spriteSheet: Texture;
  141915. /** Arguments passed with the Constructor */
  141916. options: ISpriteMapOptions;
  141917. /** Public Sprite Storage array, parsed from atlasJSON */
  141918. sprites: Array<ISpriteJSONSprite>;
  141919. /** Returns the Number of Sprites in the System */
  141920. get spriteCount(): number;
  141921. /** Returns the Position of Output Plane*/
  141922. get position(): Vector3;
  141923. /** Returns the Position of Output Plane*/
  141924. set position(v: Vector3);
  141925. /** Returns the Rotation of Output Plane*/
  141926. get rotation(): Vector3;
  141927. /** Returns the Rotation of Output Plane*/
  141928. set rotation(v: Vector3);
  141929. /** Sets the AnimationMap*/
  141930. get animationMap(): RawTexture;
  141931. /** Sets the AnimationMap*/
  141932. set animationMap(v: RawTexture);
  141933. /** Scene that the SpriteMap was created in */
  141934. private _scene;
  141935. /** Texture Buffer of Float32 that holds tile frame data*/
  141936. private _frameMap;
  141937. /** Texture Buffers of Float32 that holds tileMap data*/
  141938. private _tileMaps;
  141939. /** Texture Buffer of Float32 that holds Animation Data*/
  141940. private _animationMap;
  141941. /** Custom ShaderMaterial Central to the System*/
  141942. private _material;
  141943. /** Custom ShaderMaterial Central to the System*/
  141944. private _output;
  141945. /** Systems Time Ticker*/
  141946. private _time;
  141947. /**
  141948. * Creates a new SpriteMap
  141949. * @param name defines the SpriteMaps Name
  141950. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  141951. * @param spriteSheet is the Texture that the Sprites are on.
  141952. * @param options a basic deployment configuration
  141953. * @param scene The Scene that the map is deployed on
  141954. */
  141955. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  141956. /**
  141957. * Returns tileID location
  141958. * @returns Vector2 the cell position ID
  141959. */
  141960. getTileID(): Vector2;
  141961. /**
  141962. * Gets the UV location of the mouse over the SpriteMap.
  141963. * @returns Vector2 the UV position of the mouse interaction
  141964. */
  141965. getMousePosition(): Vector2;
  141966. /**
  141967. * Creates the "frame" texture Buffer
  141968. * -------------------------------------
  141969. * Structure of frames
  141970. * "filename": "Falling-Water-2.png",
  141971. * "frame": {"x":69,"y":103,"w":24,"h":32},
  141972. * "rotated": true,
  141973. * "trimmed": true,
  141974. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  141975. * "sourceSize": {"w":32,"h":32}
  141976. * @returns RawTexture of the frameMap
  141977. */
  141978. private _createFrameBuffer;
  141979. /**
  141980. * Creates the tileMap texture Buffer
  141981. * @param buffer normally and array of numbers, or a false to generate from scratch
  141982. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  141983. * @returns RawTexture of the tileMap
  141984. */
  141985. private _createTileBuffer;
  141986. /**
  141987. * Modifies the data of the tileMaps
  141988. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  141989. * @param pos is the iVector2 Coordinates of the Tile
  141990. * @param tile The SpriteIndex of the new Tile
  141991. */
  141992. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  141993. /**
  141994. * Creates the animationMap texture Buffer
  141995. * @param buffer normally and array of numbers, or a false to generate from scratch
  141996. * @returns RawTexture of the animationMap
  141997. */
  141998. private _createTileAnimationBuffer;
  141999. /**
  142000. * Modifies the data of the animationMap
  142001. * @param cellID is the Index of the Sprite
  142002. * @param _frame is the target Animation frame
  142003. * @param toCell is the Target Index of the next frame of the animation
  142004. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  142005. * @param speed is a global scalar of the time variable on the map.
  142006. */
  142007. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  142008. /**
  142009. * Exports the .tilemaps file
  142010. */
  142011. saveTileMaps(): void;
  142012. /**
  142013. * Imports the .tilemaps file
  142014. * @param url of the .tilemaps file
  142015. */
  142016. loadTileMaps(url: string): void;
  142017. /**
  142018. * Release associated resources
  142019. */
  142020. dispose(): void;
  142021. }
  142022. }
  142023. declare module BABYLON {
  142024. /**
  142025. * Class used to manage multiple sprites of different sizes on the same spritesheet
  142026. * @see http://doc.babylonjs.com/babylon101/sprites
  142027. */
  142028. export class SpritePackedManager extends SpriteManager {
  142029. /** defines the packed manager's name */
  142030. name: string;
  142031. /**
  142032. * Creates a new sprite manager from a packed sprite sheet
  142033. * @param name defines the manager's name
  142034. * @param imgUrl defines the sprite sheet url
  142035. * @param capacity defines the maximum allowed number of sprites
  142036. * @param scene defines the hosting scene
  142037. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  142038. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  142039. * @param samplingMode defines the smapling mode to use with spritesheet
  142040. * @param fromPacked set to true; do not alter
  142041. */
  142042. constructor(
  142043. /** defines the packed manager's name */
  142044. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  142045. }
  142046. }
  142047. declare module BABYLON {
  142048. /**
  142049. * Defines the list of states available for a task inside a AssetsManager
  142050. */
  142051. export enum AssetTaskState {
  142052. /**
  142053. * Initialization
  142054. */
  142055. INIT = 0,
  142056. /**
  142057. * Running
  142058. */
  142059. RUNNING = 1,
  142060. /**
  142061. * Done
  142062. */
  142063. DONE = 2,
  142064. /**
  142065. * Error
  142066. */
  142067. ERROR = 3
  142068. }
  142069. /**
  142070. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  142071. */
  142072. export abstract class AbstractAssetTask {
  142073. /**
  142074. * Task name
  142075. */ name: string;
  142076. /**
  142077. * Callback called when the task is successful
  142078. */
  142079. onSuccess: (task: any) => void;
  142080. /**
  142081. * Callback called when the task is not successful
  142082. */
  142083. onError: (task: any, message?: string, exception?: any) => void;
  142084. /**
  142085. * Creates a new AssetsManager
  142086. * @param name defines the name of the task
  142087. */
  142088. constructor(
  142089. /**
  142090. * Task name
  142091. */ name: string);
  142092. private _isCompleted;
  142093. private _taskState;
  142094. private _errorObject;
  142095. /**
  142096. * Get if the task is completed
  142097. */
  142098. get isCompleted(): boolean;
  142099. /**
  142100. * Gets the current state of the task
  142101. */
  142102. get taskState(): AssetTaskState;
  142103. /**
  142104. * Gets the current error object (if task is in error)
  142105. */
  142106. get errorObject(): {
  142107. message?: string;
  142108. exception?: any;
  142109. };
  142110. /**
  142111. * Internal only
  142112. * @hidden
  142113. */
  142114. _setErrorObject(message?: string, exception?: any): void;
  142115. /**
  142116. * Execute the current task
  142117. * @param scene defines the scene where you want your assets to be loaded
  142118. * @param onSuccess is a callback called when the task is successfully executed
  142119. * @param onError is a callback called if an error occurs
  142120. */
  142121. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142122. /**
  142123. * Execute the current task
  142124. * @param scene defines the scene where you want your assets to be loaded
  142125. * @param onSuccess is a callback called when the task is successfully executed
  142126. * @param onError is a callback called if an error occurs
  142127. */
  142128. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142129. /**
  142130. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  142131. * This can be used with failed tasks that have the reason for failure fixed.
  142132. */
  142133. reset(): void;
  142134. private onErrorCallback;
  142135. private onDoneCallback;
  142136. }
  142137. /**
  142138. * Define the interface used by progress events raised during assets loading
  142139. */
  142140. export interface IAssetsProgressEvent {
  142141. /**
  142142. * Defines the number of remaining tasks to process
  142143. */
  142144. remainingCount: number;
  142145. /**
  142146. * Defines the total number of tasks
  142147. */
  142148. totalCount: number;
  142149. /**
  142150. * Defines the task that was just processed
  142151. */
  142152. task: AbstractAssetTask;
  142153. }
  142154. /**
  142155. * Class used to share progress information about assets loading
  142156. */
  142157. export class AssetsProgressEvent implements IAssetsProgressEvent {
  142158. /**
  142159. * Defines the number of remaining tasks to process
  142160. */
  142161. remainingCount: number;
  142162. /**
  142163. * Defines the total number of tasks
  142164. */
  142165. totalCount: number;
  142166. /**
  142167. * Defines the task that was just processed
  142168. */
  142169. task: AbstractAssetTask;
  142170. /**
  142171. * Creates a AssetsProgressEvent
  142172. * @param remainingCount defines the number of remaining tasks to process
  142173. * @param totalCount defines the total number of tasks
  142174. * @param task defines the task that was just processed
  142175. */
  142176. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  142177. }
  142178. /**
  142179. * Define a task used by AssetsManager to load meshes
  142180. */
  142181. export class MeshAssetTask extends AbstractAssetTask {
  142182. /**
  142183. * Defines the name of the task
  142184. */
  142185. name: string;
  142186. /**
  142187. * Defines the list of mesh's names you want to load
  142188. */
  142189. meshesNames: any;
  142190. /**
  142191. * Defines the root url to use as a base to load your meshes and associated resources
  142192. */
  142193. rootUrl: string;
  142194. /**
  142195. * Defines the filename of the scene to load from
  142196. */
  142197. sceneFilename: string;
  142198. /**
  142199. * Gets the list of loaded meshes
  142200. */
  142201. loadedMeshes: Array<AbstractMesh>;
  142202. /**
  142203. * Gets the list of loaded particle systems
  142204. */
  142205. loadedParticleSystems: Array<IParticleSystem>;
  142206. /**
  142207. * Gets the list of loaded skeletons
  142208. */
  142209. loadedSkeletons: Array<Skeleton>;
  142210. /**
  142211. * Gets the list of loaded animation groups
  142212. */
  142213. loadedAnimationGroups: Array<AnimationGroup>;
  142214. /**
  142215. * Callback called when the task is successful
  142216. */
  142217. onSuccess: (task: MeshAssetTask) => void;
  142218. /**
  142219. * Callback called when the task is successful
  142220. */
  142221. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  142222. /**
  142223. * Creates a new MeshAssetTask
  142224. * @param name defines the name of the task
  142225. * @param meshesNames defines the list of mesh's names you want to load
  142226. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  142227. * @param sceneFilename defines the filename of the scene to load from
  142228. */
  142229. constructor(
  142230. /**
  142231. * Defines the name of the task
  142232. */
  142233. name: string,
  142234. /**
  142235. * Defines the list of mesh's names you want to load
  142236. */
  142237. meshesNames: any,
  142238. /**
  142239. * Defines the root url to use as a base to load your meshes and associated resources
  142240. */
  142241. rootUrl: string,
  142242. /**
  142243. * Defines the filename of the scene to load from
  142244. */
  142245. sceneFilename: string);
  142246. /**
  142247. * Execute the current task
  142248. * @param scene defines the scene where you want your assets to be loaded
  142249. * @param onSuccess is a callback called when the task is successfully executed
  142250. * @param onError is a callback called if an error occurs
  142251. */
  142252. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142253. }
  142254. /**
  142255. * Define a task used by AssetsManager to load text content
  142256. */
  142257. export class TextFileAssetTask extends AbstractAssetTask {
  142258. /**
  142259. * Defines the name of the task
  142260. */
  142261. name: string;
  142262. /**
  142263. * Defines the location of the file to load
  142264. */
  142265. url: string;
  142266. /**
  142267. * Gets the loaded text string
  142268. */
  142269. text: string;
  142270. /**
  142271. * Callback called when the task is successful
  142272. */
  142273. onSuccess: (task: TextFileAssetTask) => void;
  142274. /**
  142275. * Callback called when the task is successful
  142276. */
  142277. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  142278. /**
  142279. * Creates a new TextFileAssetTask object
  142280. * @param name defines the name of the task
  142281. * @param url defines the location of the file to load
  142282. */
  142283. constructor(
  142284. /**
  142285. * Defines the name of the task
  142286. */
  142287. name: string,
  142288. /**
  142289. * Defines the location of the file to load
  142290. */
  142291. url: string);
  142292. /**
  142293. * Execute the current task
  142294. * @param scene defines the scene where you want your assets to be loaded
  142295. * @param onSuccess is a callback called when the task is successfully executed
  142296. * @param onError is a callback called if an error occurs
  142297. */
  142298. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142299. }
  142300. /**
  142301. * Define a task used by AssetsManager to load binary data
  142302. */
  142303. export class BinaryFileAssetTask extends AbstractAssetTask {
  142304. /**
  142305. * Defines the name of the task
  142306. */
  142307. name: string;
  142308. /**
  142309. * Defines the location of the file to load
  142310. */
  142311. url: string;
  142312. /**
  142313. * Gets the lodaded data (as an array buffer)
  142314. */
  142315. data: ArrayBuffer;
  142316. /**
  142317. * Callback called when the task is successful
  142318. */
  142319. onSuccess: (task: BinaryFileAssetTask) => void;
  142320. /**
  142321. * Callback called when the task is successful
  142322. */
  142323. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  142324. /**
  142325. * Creates a new BinaryFileAssetTask object
  142326. * @param name defines the name of the new task
  142327. * @param url defines the location of the file to load
  142328. */
  142329. constructor(
  142330. /**
  142331. * Defines the name of the task
  142332. */
  142333. name: string,
  142334. /**
  142335. * Defines the location of the file to load
  142336. */
  142337. url: string);
  142338. /**
  142339. * Execute the current task
  142340. * @param scene defines the scene where you want your assets to be loaded
  142341. * @param onSuccess is a callback called when the task is successfully executed
  142342. * @param onError is a callback called if an error occurs
  142343. */
  142344. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142345. }
  142346. /**
  142347. * Define a task used by AssetsManager to load images
  142348. */
  142349. export class ImageAssetTask extends AbstractAssetTask {
  142350. /**
  142351. * Defines the name of the task
  142352. */
  142353. name: string;
  142354. /**
  142355. * Defines the location of the image to load
  142356. */
  142357. url: string;
  142358. /**
  142359. * Gets the loaded images
  142360. */
  142361. image: HTMLImageElement;
  142362. /**
  142363. * Callback called when the task is successful
  142364. */
  142365. onSuccess: (task: ImageAssetTask) => void;
  142366. /**
  142367. * Callback called when the task is successful
  142368. */
  142369. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  142370. /**
  142371. * Creates a new ImageAssetTask
  142372. * @param name defines the name of the task
  142373. * @param url defines the location of the image to load
  142374. */
  142375. constructor(
  142376. /**
  142377. * Defines the name of the task
  142378. */
  142379. name: string,
  142380. /**
  142381. * Defines the location of the image to load
  142382. */
  142383. url: string);
  142384. /**
  142385. * Execute the current task
  142386. * @param scene defines the scene where you want your assets to be loaded
  142387. * @param onSuccess is a callback called when the task is successfully executed
  142388. * @param onError is a callback called if an error occurs
  142389. */
  142390. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142391. }
  142392. /**
  142393. * Defines the interface used by texture loading tasks
  142394. */
  142395. export interface ITextureAssetTask<TEX extends BaseTexture> {
  142396. /**
  142397. * Gets the loaded texture
  142398. */
  142399. texture: TEX;
  142400. }
  142401. /**
  142402. * Define a task used by AssetsManager to load 2D textures
  142403. */
  142404. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  142405. /**
  142406. * Defines the name of the task
  142407. */
  142408. name: string;
  142409. /**
  142410. * Defines the location of the file to load
  142411. */
  142412. url: string;
  142413. /**
  142414. * Defines if mipmap should not be generated (default is false)
  142415. */
  142416. noMipmap?: boolean | undefined;
  142417. /**
  142418. * Defines if texture must be inverted on Y axis (default is true)
  142419. */
  142420. invertY: boolean;
  142421. /**
  142422. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142423. */
  142424. samplingMode: number;
  142425. /**
  142426. * Gets the loaded texture
  142427. */
  142428. texture: Texture;
  142429. /**
  142430. * Callback called when the task is successful
  142431. */
  142432. onSuccess: (task: TextureAssetTask) => void;
  142433. /**
  142434. * Callback called when the task is successful
  142435. */
  142436. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  142437. /**
  142438. * Creates a new TextureAssetTask object
  142439. * @param name defines the name of the task
  142440. * @param url defines the location of the file to load
  142441. * @param noMipmap defines if mipmap should not be generated (default is false)
  142442. * @param invertY defines if texture must be inverted on Y axis (default is true)
  142443. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142444. */
  142445. constructor(
  142446. /**
  142447. * Defines the name of the task
  142448. */
  142449. name: string,
  142450. /**
  142451. * Defines the location of the file to load
  142452. */
  142453. url: string,
  142454. /**
  142455. * Defines if mipmap should not be generated (default is false)
  142456. */
  142457. noMipmap?: boolean | undefined,
  142458. /**
  142459. * Defines if texture must be inverted on Y axis (default is true)
  142460. */
  142461. invertY?: boolean,
  142462. /**
  142463. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142464. */
  142465. samplingMode?: number);
  142466. /**
  142467. * Execute the current task
  142468. * @param scene defines the scene where you want your assets to be loaded
  142469. * @param onSuccess is a callback called when the task is successfully executed
  142470. * @param onError is a callback called if an error occurs
  142471. */
  142472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142473. }
  142474. /**
  142475. * Define a task used by AssetsManager to load cube textures
  142476. */
  142477. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  142478. /**
  142479. * Defines the name of the task
  142480. */
  142481. name: string;
  142482. /**
  142483. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142484. */
  142485. url: string;
  142486. /**
  142487. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142488. */
  142489. extensions?: string[] | undefined;
  142490. /**
  142491. * Defines if mipmaps should not be generated (default is false)
  142492. */
  142493. noMipmap?: boolean | undefined;
  142494. /**
  142495. * Defines the explicit list of files (undefined by default)
  142496. */
  142497. files?: string[] | undefined;
  142498. /**
  142499. * Gets the loaded texture
  142500. */
  142501. texture: CubeTexture;
  142502. /**
  142503. * Callback called when the task is successful
  142504. */
  142505. onSuccess: (task: CubeTextureAssetTask) => void;
  142506. /**
  142507. * Callback called when the task is successful
  142508. */
  142509. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  142510. /**
  142511. * Creates a new CubeTextureAssetTask
  142512. * @param name defines the name of the task
  142513. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142514. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142515. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142516. * @param files defines the explicit list of files (undefined by default)
  142517. */
  142518. constructor(
  142519. /**
  142520. * Defines the name of the task
  142521. */
  142522. name: string,
  142523. /**
  142524. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142525. */
  142526. url: string,
  142527. /**
  142528. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142529. */
  142530. extensions?: string[] | undefined,
  142531. /**
  142532. * Defines if mipmaps should not be generated (default is false)
  142533. */
  142534. noMipmap?: boolean | undefined,
  142535. /**
  142536. * Defines the explicit list of files (undefined by default)
  142537. */
  142538. files?: string[] | undefined);
  142539. /**
  142540. * Execute the current task
  142541. * @param scene defines the scene where you want your assets to be loaded
  142542. * @param onSuccess is a callback called when the task is successfully executed
  142543. * @param onError is a callback called if an error occurs
  142544. */
  142545. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142546. }
  142547. /**
  142548. * Define a task used by AssetsManager to load HDR cube textures
  142549. */
  142550. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  142551. /**
  142552. * Defines the name of the task
  142553. */
  142554. name: string;
  142555. /**
  142556. * Defines the location of the file to load
  142557. */
  142558. url: string;
  142559. /**
  142560. * Defines the desired size (the more it increases the longer the generation will be)
  142561. */
  142562. size: number;
  142563. /**
  142564. * Defines if mipmaps should not be generated (default is false)
  142565. */
  142566. noMipmap: boolean;
  142567. /**
  142568. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142569. */
  142570. generateHarmonics: boolean;
  142571. /**
  142572. * 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)
  142573. */
  142574. gammaSpace: boolean;
  142575. /**
  142576. * Internal Use Only
  142577. */
  142578. reserved: boolean;
  142579. /**
  142580. * Gets the loaded texture
  142581. */
  142582. texture: HDRCubeTexture;
  142583. /**
  142584. * Callback called when the task is successful
  142585. */
  142586. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  142587. /**
  142588. * Callback called when the task is successful
  142589. */
  142590. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  142591. /**
  142592. * Creates a new HDRCubeTextureAssetTask object
  142593. * @param name defines the name of the task
  142594. * @param url defines the location of the file to load
  142595. * @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.
  142596. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142597. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142598. * @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)
  142599. * @param reserved Internal use only
  142600. */
  142601. constructor(
  142602. /**
  142603. * Defines the name of the task
  142604. */
  142605. name: string,
  142606. /**
  142607. * Defines the location of the file to load
  142608. */
  142609. url: string,
  142610. /**
  142611. * Defines the desired size (the more it increases the longer the generation will be)
  142612. */
  142613. size: number,
  142614. /**
  142615. * Defines if mipmaps should not be generated (default is false)
  142616. */
  142617. noMipmap?: boolean,
  142618. /**
  142619. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142620. */
  142621. generateHarmonics?: boolean,
  142622. /**
  142623. * 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)
  142624. */
  142625. gammaSpace?: boolean,
  142626. /**
  142627. * Internal Use Only
  142628. */
  142629. reserved?: boolean);
  142630. /**
  142631. * Execute the current task
  142632. * @param scene defines the scene where you want your assets to be loaded
  142633. * @param onSuccess is a callback called when the task is successfully executed
  142634. * @param onError is a callback called if an error occurs
  142635. */
  142636. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142637. }
  142638. /**
  142639. * Define a task used by AssetsManager to load Equirectangular cube textures
  142640. */
  142641. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  142642. /**
  142643. * Defines the name of the task
  142644. */
  142645. name: string;
  142646. /**
  142647. * Defines the location of the file to load
  142648. */
  142649. url: string;
  142650. /**
  142651. * Defines the desired size (the more it increases the longer the generation will be)
  142652. */
  142653. size: number;
  142654. /**
  142655. * Defines if mipmaps should not be generated (default is false)
  142656. */
  142657. noMipmap: boolean;
  142658. /**
  142659. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142660. * but the standard material would require them in Gamma space) (default is true)
  142661. */
  142662. gammaSpace: boolean;
  142663. /**
  142664. * Gets the loaded texture
  142665. */
  142666. texture: EquiRectangularCubeTexture;
  142667. /**
  142668. * Callback called when the task is successful
  142669. */
  142670. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  142671. /**
  142672. * Callback called when the task is successful
  142673. */
  142674. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  142675. /**
  142676. * Creates a new EquiRectangularCubeTextureAssetTask object
  142677. * @param name defines the name of the task
  142678. * @param url defines the location of the file to load
  142679. * @param size defines the desired size (the more it increases the longer the generation will be)
  142680. * If the size is omitted this implies you are using a preprocessed cubemap.
  142681. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142682. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  142683. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  142684. * (default is true)
  142685. */
  142686. constructor(
  142687. /**
  142688. * Defines the name of the task
  142689. */
  142690. name: string,
  142691. /**
  142692. * Defines the location of the file to load
  142693. */
  142694. url: string,
  142695. /**
  142696. * Defines the desired size (the more it increases the longer the generation will be)
  142697. */
  142698. size: number,
  142699. /**
  142700. * Defines if mipmaps should not be generated (default is false)
  142701. */
  142702. noMipmap?: boolean,
  142703. /**
  142704. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142705. * but the standard material would require them in Gamma space) (default is true)
  142706. */
  142707. gammaSpace?: boolean);
  142708. /**
  142709. * Execute the current task
  142710. * @param scene defines the scene where you want your assets to be loaded
  142711. * @param onSuccess is a callback called when the task is successfully executed
  142712. * @param onError is a callback called if an error occurs
  142713. */
  142714. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142715. }
  142716. /**
  142717. * This class can be used to easily import assets into a scene
  142718. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  142719. */
  142720. export class AssetsManager {
  142721. private _scene;
  142722. private _isLoading;
  142723. protected _tasks: AbstractAssetTask[];
  142724. protected _waitingTasksCount: number;
  142725. protected _totalTasksCount: number;
  142726. /**
  142727. * Callback called when all tasks are processed
  142728. */
  142729. onFinish: (tasks: AbstractAssetTask[]) => void;
  142730. /**
  142731. * Callback called when a task is successful
  142732. */
  142733. onTaskSuccess: (task: AbstractAssetTask) => void;
  142734. /**
  142735. * Callback called when a task had an error
  142736. */
  142737. onTaskError: (task: AbstractAssetTask) => void;
  142738. /**
  142739. * Callback called when a task is done (whatever the result is)
  142740. */
  142741. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  142742. /**
  142743. * Observable called when all tasks are processed
  142744. */
  142745. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  142746. /**
  142747. * Observable called when a task had an error
  142748. */
  142749. onTaskErrorObservable: Observable<AbstractAssetTask>;
  142750. /**
  142751. * Observable called when all tasks were executed
  142752. */
  142753. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  142754. /**
  142755. * Observable called when a task is done (whatever the result is)
  142756. */
  142757. onProgressObservable: Observable<IAssetsProgressEvent>;
  142758. /**
  142759. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  142760. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  142761. */
  142762. useDefaultLoadingScreen: boolean;
  142763. /**
  142764. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  142765. * when all assets have been downloaded.
  142766. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  142767. */
  142768. autoHideLoadingUI: boolean;
  142769. /**
  142770. * Creates a new AssetsManager
  142771. * @param scene defines the scene to work on
  142772. */
  142773. constructor(scene: Scene);
  142774. /**
  142775. * Add a MeshAssetTask to the list of active tasks
  142776. * @param taskName defines the name of the new task
  142777. * @param meshesNames defines the name of meshes to load
  142778. * @param rootUrl defines the root url to use to locate files
  142779. * @param sceneFilename defines the filename of the scene file
  142780. * @returns a new MeshAssetTask object
  142781. */
  142782. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  142783. /**
  142784. * Add a TextFileAssetTask to the list of active tasks
  142785. * @param taskName defines the name of the new task
  142786. * @param url defines the url of the file to load
  142787. * @returns a new TextFileAssetTask object
  142788. */
  142789. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  142790. /**
  142791. * Add a BinaryFileAssetTask to the list of active tasks
  142792. * @param taskName defines the name of the new task
  142793. * @param url defines the url of the file to load
  142794. * @returns a new BinaryFileAssetTask object
  142795. */
  142796. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  142797. /**
  142798. * Add a ImageAssetTask to the list of active tasks
  142799. * @param taskName defines the name of the new task
  142800. * @param url defines the url of the file to load
  142801. * @returns a new ImageAssetTask object
  142802. */
  142803. addImageTask(taskName: string, url: string): ImageAssetTask;
  142804. /**
  142805. * Add a TextureAssetTask to the list of active tasks
  142806. * @param taskName defines the name of the new task
  142807. * @param url defines the url of the file to load
  142808. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142809. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  142810. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142811. * @returns a new TextureAssetTask object
  142812. */
  142813. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  142814. /**
  142815. * Add a CubeTextureAssetTask to the list of active tasks
  142816. * @param taskName defines the name of the new task
  142817. * @param url defines the url of the file to load
  142818. * @param extensions defines the extension to use to load the cube map (can be null)
  142819. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142820. * @param files defines the list of files to load (can be null)
  142821. * @returns a new CubeTextureAssetTask object
  142822. */
  142823. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  142824. /**
  142825. *
  142826. * Add a HDRCubeTextureAssetTask to the list of active tasks
  142827. * @param taskName defines the name of the new task
  142828. * @param url defines the url of the file to load
  142829. * @param size defines the size you want for the cubemap (can be null)
  142830. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142831. * @param generateHarmonics defines if you want to automatically generate (true by default)
  142832. * @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)
  142833. * @param reserved Internal use only
  142834. * @returns a new HDRCubeTextureAssetTask object
  142835. */
  142836. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  142837. /**
  142838. *
  142839. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  142840. * @param taskName defines the name of the new task
  142841. * @param url defines the url of the file to load
  142842. * @param size defines the size you want for the cubemap (can be null)
  142843. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142844. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142845. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142846. * @returns a new EquiRectangularCubeTextureAssetTask object
  142847. */
  142848. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  142849. /**
  142850. * Remove a task from the assets manager.
  142851. * @param task the task to remove
  142852. */
  142853. removeTask(task: AbstractAssetTask): void;
  142854. private _decreaseWaitingTasksCount;
  142855. private _runTask;
  142856. /**
  142857. * Reset the AssetsManager and remove all tasks
  142858. * @return the current instance of the AssetsManager
  142859. */
  142860. reset(): AssetsManager;
  142861. /**
  142862. * Start the loading process
  142863. * @return the current instance of the AssetsManager
  142864. */
  142865. load(): AssetsManager;
  142866. /**
  142867. * Start the loading process as an async operation
  142868. * @return a promise returning the list of failed tasks
  142869. */
  142870. loadAsync(): Promise<void>;
  142871. }
  142872. }
  142873. declare module BABYLON {
  142874. /**
  142875. * Wrapper class for promise with external resolve and reject.
  142876. */
  142877. export class Deferred<T> {
  142878. /**
  142879. * The promise associated with this deferred object.
  142880. */
  142881. readonly promise: Promise<T>;
  142882. private _resolve;
  142883. private _reject;
  142884. /**
  142885. * The resolve method of the promise associated with this deferred object.
  142886. */
  142887. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  142888. /**
  142889. * The reject method of the promise associated with this deferred object.
  142890. */
  142891. get reject(): (reason?: any) => void;
  142892. /**
  142893. * Constructor for this deferred object.
  142894. */
  142895. constructor();
  142896. }
  142897. }
  142898. declare module BABYLON {
  142899. /**
  142900. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  142901. */
  142902. export class MeshExploder {
  142903. private _centerMesh;
  142904. private _meshes;
  142905. private _meshesOrigins;
  142906. private _toCenterVectors;
  142907. private _scaledDirection;
  142908. private _newPosition;
  142909. private _centerPosition;
  142910. /**
  142911. * Explodes meshes from a center mesh.
  142912. * @param meshes The meshes to explode.
  142913. * @param centerMesh The mesh to be center of explosion.
  142914. */
  142915. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  142916. private _setCenterMesh;
  142917. /**
  142918. * Get class name
  142919. * @returns "MeshExploder"
  142920. */
  142921. getClassName(): string;
  142922. /**
  142923. * "Exploded meshes"
  142924. * @returns Array of meshes with the centerMesh at index 0.
  142925. */
  142926. getMeshes(): Array<Mesh>;
  142927. /**
  142928. * Explodes meshes giving a specific direction
  142929. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  142930. */
  142931. explode(direction?: number): void;
  142932. }
  142933. }
  142934. declare module BABYLON {
  142935. /**
  142936. * Class used to help managing file picking and drag'n'drop
  142937. */
  142938. export class FilesInput {
  142939. /**
  142940. * List of files ready to be loaded
  142941. */
  142942. static get FilesToLoad(): {
  142943. [key: string]: File;
  142944. };
  142945. /**
  142946. * Callback called when a file is processed
  142947. */
  142948. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  142949. private _engine;
  142950. private _currentScene;
  142951. private _sceneLoadedCallback;
  142952. private _progressCallback;
  142953. private _additionalRenderLoopLogicCallback;
  142954. private _textureLoadingCallback;
  142955. private _startingProcessingFilesCallback;
  142956. private _onReloadCallback;
  142957. private _errorCallback;
  142958. private _elementToMonitor;
  142959. private _sceneFileToLoad;
  142960. private _filesToLoad;
  142961. /**
  142962. * Creates a new FilesInput
  142963. * @param engine defines the rendering engine
  142964. * @param scene defines the hosting scene
  142965. * @param sceneLoadedCallback callback called when scene is loaded
  142966. * @param progressCallback callback called to track progress
  142967. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  142968. * @param textureLoadingCallback callback called when a texture is loading
  142969. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  142970. * @param onReloadCallback callback called when a reload is requested
  142971. * @param errorCallback callback call if an error occurs
  142972. */
  142973. 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);
  142974. private _dragEnterHandler;
  142975. private _dragOverHandler;
  142976. private _dropHandler;
  142977. /**
  142978. * Calls this function to listen to drag'n'drop events on a specific DOM element
  142979. * @param elementToMonitor defines the DOM element to track
  142980. */
  142981. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  142982. /**
  142983. * Release all associated resources
  142984. */
  142985. dispose(): void;
  142986. private renderFunction;
  142987. private drag;
  142988. private drop;
  142989. private _traverseFolder;
  142990. private _processFiles;
  142991. /**
  142992. * Load files from a drop event
  142993. * @param event defines the drop event to use as source
  142994. */
  142995. loadFiles(event: any): void;
  142996. private _processReload;
  142997. /**
  142998. * Reload the current scene from the loaded files
  142999. */
  143000. reload(): void;
  143001. }
  143002. }
  143003. declare module BABYLON {
  143004. /**
  143005. * Defines the root class used to create scene optimization to use with SceneOptimizer
  143006. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143007. */
  143008. export class SceneOptimization {
  143009. /**
  143010. * Defines the priority of this optimization (0 by default which means first in the list)
  143011. */
  143012. priority: number;
  143013. /**
  143014. * Gets a string describing the action executed by the current optimization
  143015. * @returns description string
  143016. */
  143017. getDescription(): string;
  143018. /**
  143019. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143020. * @param scene defines the current scene where to apply this optimization
  143021. * @param optimizer defines the current optimizer
  143022. * @returns true if everything that can be done was applied
  143023. */
  143024. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143025. /**
  143026. * Creates the SceneOptimization object
  143027. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143028. * @param desc defines the description associated with the optimization
  143029. */
  143030. constructor(
  143031. /**
  143032. * Defines the priority of this optimization (0 by default which means first in the list)
  143033. */
  143034. priority?: number);
  143035. }
  143036. /**
  143037. * Defines an optimization used to reduce the size of render target textures
  143038. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143039. */
  143040. export class TextureOptimization extends SceneOptimization {
  143041. /**
  143042. * Defines the priority of this optimization (0 by default which means first in the list)
  143043. */
  143044. priority: number;
  143045. /**
  143046. * 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
  143047. */
  143048. maximumSize: number;
  143049. /**
  143050. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143051. */
  143052. step: number;
  143053. /**
  143054. * Gets a string describing the action executed by the current optimization
  143055. * @returns description string
  143056. */
  143057. getDescription(): string;
  143058. /**
  143059. * Creates the TextureOptimization object
  143060. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143061. * @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
  143062. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143063. */
  143064. constructor(
  143065. /**
  143066. * Defines the priority of this optimization (0 by default which means first in the list)
  143067. */
  143068. priority?: number,
  143069. /**
  143070. * 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
  143071. */
  143072. maximumSize?: number,
  143073. /**
  143074. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143075. */
  143076. step?: number);
  143077. /**
  143078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143079. * @param scene defines the current scene where to apply this optimization
  143080. * @param optimizer defines the current optimizer
  143081. * @returns true if everything that can be done was applied
  143082. */
  143083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143084. }
  143085. /**
  143086. * Defines an optimization used to increase or decrease the rendering resolution
  143087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143088. */
  143089. export class HardwareScalingOptimization extends SceneOptimization {
  143090. /**
  143091. * Defines the priority of this optimization (0 by default which means first in the list)
  143092. */
  143093. priority: number;
  143094. /**
  143095. * Defines the maximum scale to use (2 by default)
  143096. */
  143097. maximumScale: number;
  143098. /**
  143099. * Defines the step to use between two passes (0.5 by default)
  143100. */
  143101. step: number;
  143102. private _currentScale;
  143103. private _directionOffset;
  143104. /**
  143105. * Gets a string describing the action executed by the current optimization
  143106. * @return description string
  143107. */
  143108. getDescription(): string;
  143109. /**
  143110. * Creates the HardwareScalingOptimization object
  143111. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143112. * @param maximumScale defines the maximum scale to use (2 by default)
  143113. * @param step defines the step to use between two passes (0.5 by default)
  143114. */
  143115. constructor(
  143116. /**
  143117. * Defines the priority of this optimization (0 by default which means first in the list)
  143118. */
  143119. priority?: number,
  143120. /**
  143121. * Defines the maximum scale to use (2 by default)
  143122. */
  143123. maximumScale?: number,
  143124. /**
  143125. * Defines the step to use between two passes (0.5 by default)
  143126. */
  143127. step?: number);
  143128. /**
  143129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143130. * @param scene defines the current scene where to apply this optimization
  143131. * @param optimizer defines the current optimizer
  143132. * @returns true if everything that can be done was applied
  143133. */
  143134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143135. }
  143136. /**
  143137. * Defines an optimization used to remove shadows
  143138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143139. */
  143140. export class ShadowsOptimization extends SceneOptimization {
  143141. /**
  143142. * Gets a string describing the action executed by the current optimization
  143143. * @return description string
  143144. */
  143145. getDescription(): string;
  143146. /**
  143147. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143148. * @param scene defines the current scene where to apply this optimization
  143149. * @param optimizer defines the current optimizer
  143150. * @returns true if everything that can be done was applied
  143151. */
  143152. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143153. }
  143154. /**
  143155. * Defines an optimization used to turn post-processes off
  143156. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143157. */
  143158. export class PostProcessesOptimization extends SceneOptimization {
  143159. /**
  143160. * Gets a string describing the action executed by the current optimization
  143161. * @return description string
  143162. */
  143163. getDescription(): string;
  143164. /**
  143165. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143166. * @param scene defines the current scene where to apply this optimization
  143167. * @param optimizer defines the current optimizer
  143168. * @returns true if everything that can be done was applied
  143169. */
  143170. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143171. }
  143172. /**
  143173. * Defines an optimization used to turn lens flares off
  143174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143175. */
  143176. export class LensFlaresOptimization extends SceneOptimization {
  143177. /**
  143178. * Gets a string describing the action executed by the current optimization
  143179. * @return description string
  143180. */
  143181. getDescription(): string;
  143182. /**
  143183. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143184. * @param scene defines the current scene where to apply this optimization
  143185. * @param optimizer defines the current optimizer
  143186. * @returns true if everything that can be done was applied
  143187. */
  143188. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143189. }
  143190. /**
  143191. * Defines an optimization based on user defined callback.
  143192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143193. */
  143194. export class CustomOptimization extends SceneOptimization {
  143195. /**
  143196. * Callback called to apply the custom optimization.
  143197. */
  143198. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  143199. /**
  143200. * Callback called to get custom description
  143201. */
  143202. onGetDescription: () => string;
  143203. /**
  143204. * Gets a string describing the action executed by the current optimization
  143205. * @returns description string
  143206. */
  143207. getDescription(): string;
  143208. /**
  143209. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143210. * @param scene defines the current scene where to apply this optimization
  143211. * @param optimizer defines the current optimizer
  143212. * @returns true if everything that can be done was applied
  143213. */
  143214. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143215. }
  143216. /**
  143217. * Defines an optimization used to turn particles off
  143218. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143219. */
  143220. export class ParticlesOptimization extends SceneOptimization {
  143221. /**
  143222. * Gets a string describing the action executed by the current optimization
  143223. * @return description string
  143224. */
  143225. getDescription(): string;
  143226. /**
  143227. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143228. * @param scene defines the current scene where to apply this optimization
  143229. * @param optimizer defines the current optimizer
  143230. * @returns true if everything that can be done was applied
  143231. */
  143232. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143233. }
  143234. /**
  143235. * Defines an optimization used to turn render targets off
  143236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143237. */
  143238. export class RenderTargetsOptimization extends SceneOptimization {
  143239. /**
  143240. * Gets a string describing the action executed by the current optimization
  143241. * @return description string
  143242. */
  143243. getDescription(): string;
  143244. /**
  143245. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143246. * @param scene defines the current scene where to apply this optimization
  143247. * @param optimizer defines the current optimizer
  143248. * @returns true if everything that can be done was applied
  143249. */
  143250. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143251. }
  143252. /**
  143253. * Defines an optimization used to merge meshes with compatible materials
  143254. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143255. */
  143256. export class MergeMeshesOptimization extends SceneOptimization {
  143257. private static _UpdateSelectionTree;
  143258. /**
  143259. * Gets or sets a boolean which defines if optimization octree has to be updated
  143260. */
  143261. static get UpdateSelectionTree(): boolean;
  143262. /**
  143263. * Gets or sets a boolean which defines if optimization octree has to be updated
  143264. */
  143265. static set UpdateSelectionTree(value: boolean);
  143266. /**
  143267. * Gets a string describing the action executed by the current optimization
  143268. * @return description string
  143269. */
  143270. getDescription(): string;
  143271. private _canBeMerged;
  143272. /**
  143273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143274. * @param scene defines the current scene where to apply this optimization
  143275. * @param optimizer defines the current optimizer
  143276. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  143277. * @returns true if everything that can be done was applied
  143278. */
  143279. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  143280. }
  143281. /**
  143282. * Defines a list of options used by SceneOptimizer
  143283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143284. */
  143285. export class SceneOptimizerOptions {
  143286. /**
  143287. * Defines the target frame rate to reach (60 by default)
  143288. */
  143289. targetFrameRate: number;
  143290. /**
  143291. * Defines the interval between two checkes (2000ms by default)
  143292. */
  143293. trackerDuration: number;
  143294. /**
  143295. * Gets the list of optimizations to apply
  143296. */
  143297. optimizations: SceneOptimization[];
  143298. /**
  143299. * Creates a new list of options used by SceneOptimizer
  143300. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  143301. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  143302. */
  143303. constructor(
  143304. /**
  143305. * Defines the target frame rate to reach (60 by default)
  143306. */
  143307. targetFrameRate?: number,
  143308. /**
  143309. * Defines the interval between two checkes (2000ms by default)
  143310. */
  143311. trackerDuration?: number);
  143312. /**
  143313. * Add a new optimization
  143314. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  143315. * @returns the current SceneOptimizerOptions
  143316. */
  143317. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  143318. /**
  143319. * Add a new custom optimization
  143320. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  143321. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  143322. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143323. * @returns the current SceneOptimizerOptions
  143324. */
  143325. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  143326. /**
  143327. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  143328. * @param targetFrameRate defines the target frame rate (60 by default)
  143329. * @returns a SceneOptimizerOptions object
  143330. */
  143331. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143332. /**
  143333. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  143334. * @param targetFrameRate defines the target frame rate (60 by default)
  143335. * @returns a SceneOptimizerOptions object
  143336. */
  143337. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143338. /**
  143339. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  143340. * @param targetFrameRate defines the target frame rate (60 by default)
  143341. * @returns a SceneOptimizerOptions object
  143342. */
  143343. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143344. }
  143345. /**
  143346. * Class used to run optimizations in order to reach a target frame rate
  143347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143348. */
  143349. export class SceneOptimizer implements IDisposable {
  143350. private _isRunning;
  143351. private _options;
  143352. private _scene;
  143353. private _currentPriorityLevel;
  143354. private _targetFrameRate;
  143355. private _trackerDuration;
  143356. private _currentFrameRate;
  143357. private _sceneDisposeObserver;
  143358. private _improvementMode;
  143359. /**
  143360. * Defines an observable called when the optimizer reaches the target frame rate
  143361. */
  143362. onSuccessObservable: Observable<SceneOptimizer>;
  143363. /**
  143364. * Defines an observable called when the optimizer enables an optimization
  143365. */
  143366. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  143367. /**
  143368. * Defines an observable called when the optimizer is not able to reach the target frame rate
  143369. */
  143370. onFailureObservable: Observable<SceneOptimizer>;
  143371. /**
  143372. * Gets a boolean indicating if the optimizer is in improvement mode
  143373. */
  143374. get isInImprovementMode(): boolean;
  143375. /**
  143376. * Gets the current priority level (0 at start)
  143377. */
  143378. get currentPriorityLevel(): number;
  143379. /**
  143380. * Gets the current frame rate checked by the SceneOptimizer
  143381. */
  143382. get currentFrameRate(): number;
  143383. /**
  143384. * Gets or sets the current target frame rate (60 by default)
  143385. */
  143386. get targetFrameRate(): number;
  143387. /**
  143388. * Gets or sets the current target frame rate (60 by default)
  143389. */
  143390. set targetFrameRate(value: number);
  143391. /**
  143392. * Gets or sets the current interval between two checks (every 2000ms by default)
  143393. */
  143394. get trackerDuration(): number;
  143395. /**
  143396. * Gets or sets the current interval between two checks (every 2000ms by default)
  143397. */
  143398. set trackerDuration(value: number);
  143399. /**
  143400. * Gets the list of active optimizations
  143401. */
  143402. get optimizations(): SceneOptimization[];
  143403. /**
  143404. * Creates a new SceneOptimizer
  143405. * @param scene defines the scene to work on
  143406. * @param options defines the options to use with the SceneOptimizer
  143407. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  143408. * @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)
  143409. */
  143410. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  143411. /**
  143412. * Stops the current optimizer
  143413. */
  143414. stop(): void;
  143415. /**
  143416. * Reset the optimizer to initial step (current priority level = 0)
  143417. */
  143418. reset(): void;
  143419. /**
  143420. * Start the optimizer. By default it will try to reach a specific framerate
  143421. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  143422. */
  143423. start(): void;
  143424. private _checkCurrentState;
  143425. /**
  143426. * Release all resources
  143427. */
  143428. dispose(): void;
  143429. /**
  143430. * Helper function to create a SceneOptimizer with one single line of code
  143431. * @param scene defines the scene to work on
  143432. * @param options defines the options to use with the SceneOptimizer
  143433. * @param onSuccess defines a callback to call on success
  143434. * @param onFailure defines a callback to call on failure
  143435. * @returns the new SceneOptimizer object
  143436. */
  143437. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  143438. }
  143439. }
  143440. declare module BABYLON {
  143441. /**
  143442. * Class used to serialize a scene into a string
  143443. */
  143444. export class SceneSerializer {
  143445. /**
  143446. * Clear cache used by a previous serialization
  143447. */
  143448. static ClearCache(): void;
  143449. /**
  143450. * Serialize a scene into a JSON compatible object
  143451. * @param scene defines the scene to serialize
  143452. * @returns a JSON compatible object
  143453. */
  143454. static Serialize(scene: Scene): any;
  143455. /**
  143456. * Serialize a mesh into a JSON compatible object
  143457. * @param toSerialize defines the mesh to serialize
  143458. * @param withParents defines if parents must be serialized as well
  143459. * @param withChildren defines if children must be serialized as well
  143460. * @returns a JSON compatible object
  143461. */
  143462. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  143463. }
  143464. }
  143465. declare module BABYLON {
  143466. /**
  143467. * Class used to host texture specific utilities
  143468. */
  143469. export class TextureTools {
  143470. /**
  143471. * Uses the GPU to create a copy texture rescaled at a given size
  143472. * @param texture Texture to copy from
  143473. * @param width defines the desired width
  143474. * @param height defines the desired height
  143475. * @param useBilinearMode defines if bilinear mode has to be used
  143476. * @return the generated texture
  143477. */
  143478. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  143479. }
  143480. }
  143481. declare module BABYLON {
  143482. /**
  143483. * This represents the different options available for the video capture.
  143484. */
  143485. export interface VideoRecorderOptions {
  143486. /** Defines the mime type of the video. */
  143487. mimeType: string;
  143488. /** Defines the FPS the video should be recorded at. */
  143489. fps: number;
  143490. /** Defines the chunk size for the recording data. */
  143491. recordChunckSize: number;
  143492. /** The audio tracks to attach to the recording. */
  143493. audioTracks?: MediaStreamTrack[];
  143494. }
  143495. /**
  143496. * This can help with recording videos from BabylonJS.
  143497. * This is based on the available WebRTC functionalities of the browser.
  143498. *
  143499. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  143500. */
  143501. export class VideoRecorder {
  143502. private static readonly _defaultOptions;
  143503. /**
  143504. * Returns whether or not the VideoRecorder is available in your browser.
  143505. * @param engine Defines the Babylon Engine.
  143506. * @returns true if supported otherwise false.
  143507. */
  143508. static IsSupported(engine: Engine): boolean;
  143509. private readonly _options;
  143510. private _canvas;
  143511. private _mediaRecorder;
  143512. private _recordedChunks;
  143513. private _fileName;
  143514. private _resolve;
  143515. private _reject;
  143516. /**
  143517. * True when a recording is already in progress.
  143518. */
  143519. get isRecording(): boolean;
  143520. /**
  143521. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  143522. * @param engine Defines the BabylonJS Engine you wish to record.
  143523. * @param options Defines options that can be used to customize the capture.
  143524. */
  143525. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  143526. /**
  143527. * Stops the current recording before the default capture timeout passed in the startRecording function.
  143528. */
  143529. stopRecording(): void;
  143530. /**
  143531. * Starts recording the canvas for a max duration specified in parameters.
  143532. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  143533. * If null no automatic download will start and you can rely on the promise to get the data back.
  143534. * @param maxDuration Defines the maximum recording time in seconds.
  143535. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  143536. * @return A promise callback at the end of the recording with the video data in Blob.
  143537. */
  143538. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  143539. /**
  143540. * Releases internal resources used during the recording.
  143541. */
  143542. dispose(): void;
  143543. private _handleDataAvailable;
  143544. private _handleError;
  143545. private _handleStop;
  143546. }
  143547. }
  143548. declare module BABYLON {
  143549. /**
  143550. * Class containing a set of static utilities functions for screenshots
  143551. */
  143552. export class ScreenshotTools {
  143553. /**
  143554. * Captures a screenshot of the current rendering
  143555. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143556. * @param engine defines the rendering engine
  143557. * @param camera defines the source camera
  143558. * @param size This parameter can be set to a single number or to an object with the
  143559. * following (optional) properties: precision, width, height. If a single number is passed,
  143560. * it will be used for both width and height. If an object is passed, the screenshot size
  143561. * will be derived from the parameters. The precision property is a multiplier allowing
  143562. * rendering at a higher or lower resolution
  143563. * @param successCallback defines the callback receives a single parameter which contains the
  143564. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143565. * src parameter of an <img> to display it
  143566. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143567. * Check your browser for supported MIME types
  143568. */
  143569. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  143570. /**
  143571. * Captures a screenshot of the current rendering
  143572. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143573. * @param engine defines the rendering engine
  143574. * @param camera defines the source camera
  143575. * @param size This parameter can be set to a single number or to an object with the
  143576. * following (optional) properties: precision, width, height. If a single number is passed,
  143577. * it will be used for both width and height. If an object is passed, the screenshot size
  143578. * will be derived from the parameters. The precision property is a multiplier allowing
  143579. * rendering at a higher or lower resolution
  143580. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143581. * Check your browser for supported MIME types
  143582. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143583. * to the src parameter of an <img> to display it
  143584. */
  143585. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  143586. /**
  143587. * Generates an image screenshot from the specified camera.
  143588. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143589. * @param engine The engine to use for rendering
  143590. * @param camera The camera to use for rendering
  143591. * @param size This parameter can be set to a single number or to an object with the
  143592. * following (optional) properties: precision, width, height. If a single number is passed,
  143593. * it will be used for both width and height. If an object is passed, the screenshot size
  143594. * will be derived from the parameters. The precision property is a multiplier allowing
  143595. * rendering at a higher or lower resolution
  143596. * @param successCallback The callback receives a single parameter which contains the
  143597. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143598. * src parameter of an <img> to display it
  143599. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143600. * Check your browser for supported MIME types
  143601. * @param samples Texture samples (default: 1)
  143602. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143603. * @param fileName A name for for the downloaded file.
  143604. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143605. */
  143606. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  143607. /**
  143608. * Generates an image screenshot from the specified camera.
  143609. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143610. * @param engine The engine to use for rendering
  143611. * @param camera The camera to use for rendering
  143612. * @param size This parameter can be set to a single number or to an object with the
  143613. * following (optional) properties: precision, width, height. If a single number is passed,
  143614. * it will be used for both width and height. If an object is passed, the screenshot size
  143615. * will be derived from the parameters. The precision property is a multiplier allowing
  143616. * rendering at a higher or lower resolution
  143617. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143618. * Check your browser for supported MIME types
  143619. * @param samples Texture samples (default: 1)
  143620. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143621. * @param fileName A name for for the downloaded file.
  143622. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143623. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143624. * to the src parameter of an <img> to display it
  143625. */
  143626. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  143627. /**
  143628. * Gets height and width for screenshot size
  143629. * @private
  143630. */
  143631. private static _getScreenshotSize;
  143632. }
  143633. }
  143634. declare module BABYLON {
  143635. /**
  143636. * Interface for a data buffer
  143637. */
  143638. export interface IDataBuffer {
  143639. /**
  143640. * Reads bytes from the data buffer.
  143641. * @param byteOffset The byte offset to read
  143642. * @param byteLength The byte length to read
  143643. * @returns A promise that resolves when the bytes are read
  143644. */
  143645. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  143646. /**
  143647. * The byte length of the buffer.
  143648. */
  143649. readonly byteLength: number;
  143650. }
  143651. /**
  143652. * Utility class for reading from a data buffer
  143653. */
  143654. export class DataReader {
  143655. /**
  143656. * The data buffer associated with this data reader.
  143657. */
  143658. readonly buffer: IDataBuffer;
  143659. /**
  143660. * The current byte offset from the beginning of the data buffer.
  143661. */
  143662. byteOffset: number;
  143663. private _dataView;
  143664. private _dataByteOffset;
  143665. /**
  143666. * Constructor
  143667. * @param buffer The buffer to read
  143668. */
  143669. constructor(buffer: IDataBuffer);
  143670. /**
  143671. * Loads the given byte length.
  143672. * @param byteLength The byte length to load
  143673. * @returns A promise that resolves when the load is complete
  143674. */
  143675. loadAsync(byteLength: number): Promise<void>;
  143676. /**
  143677. * Read a unsigned 32-bit integer from the currently loaded data range.
  143678. * @returns The 32-bit integer read
  143679. */
  143680. readUint32(): number;
  143681. /**
  143682. * Read a byte array from the currently loaded data range.
  143683. * @param byteLength The byte length to read
  143684. * @returns The byte array read
  143685. */
  143686. readUint8Array(byteLength: number): Uint8Array;
  143687. /**
  143688. * Read a string from the currently loaded data range.
  143689. * @param byteLength The byte length to read
  143690. * @returns The string read
  143691. */
  143692. readString(byteLength: number): string;
  143693. /**
  143694. * Skips the given byte length the currently loaded data range.
  143695. * @param byteLength The byte length to skip
  143696. */
  143697. skipBytes(byteLength: number): void;
  143698. }
  143699. }
  143700. declare module BABYLON {
  143701. /**
  143702. * Class for storing data to local storage if available or in-memory storage otherwise
  143703. */
  143704. export class DataStorage {
  143705. private static _Storage;
  143706. private static _GetStorage;
  143707. /**
  143708. * Reads a string from the data storage
  143709. * @param key The key to read
  143710. * @param defaultValue The value if the key doesn't exist
  143711. * @returns The string value
  143712. */
  143713. static ReadString(key: string, defaultValue: string): string;
  143714. /**
  143715. * Writes a string to the data storage
  143716. * @param key The key to write
  143717. * @param value The value to write
  143718. */
  143719. static WriteString(key: string, value: string): void;
  143720. /**
  143721. * Reads a boolean from the data storage
  143722. * @param key The key to read
  143723. * @param defaultValue The value if the key doesn't exist
  143724. * @returns The boolean value
  143725. */
  143726. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  143727. /**
  143728. * Writes a boolean to the data storage
  143729. * @param key The key to write
  143730. * @param value The value to write
  143731. */
  143732. static WriteBoolean(key: string, value: boolean): void;
  143733. /**
  143734. * Reads a number from the data storage
  143735. * @param key The key to read
  143736. * @param defaultValue The value if the key doesn't exist
  143737. * @returns The number value
  143738. */
  143739. static ReadNumber(key: string, defaultValue: number): number;
  143740. /**
  143741. * Writes a number to the data storage
  143742. * @param key The key to write
  143743. * @param value The value to write
  143744. */
  143745. static WriteNumber(key: string, value: number): void;
  143746. }
  143747. }
  143748. declare module BABYLON {
  143749. /**
  143750. * Options used for hit testing
  143751. */
  143752. export interface IWebXRLegacyHitTestOptions {
  143753. /**
  143754. * Only test when user interacted with the scene. Default - hit test every frame
  143755. */
  143756. testOnPointerDownOnly?: boolean;
  143757. /**
  143758. * The node to use to transform the local results to world coordinates
  143759. */
  143760. worldParentNode?: TransformNode;
  143761. }
  143762. /**
  143763. * Interface defining the babylon result of raycasting/hit-test
  143764. */
  143765. export interface IWebXRLegacyHitResult {
  143766. /**
  143767. * Transformation matrix that can be applied to a node that will put it in the hit point location
  143768. */
  143769. transformationMatrix: Matrix;
  143770. /**
  143771. * The native hit test result
  143772. */
  143773. xrHitResult: XRHitResult | XRHitTestResult;
  143774. }
  143775. /**
  143776. * The currently-working hit-test module.
  143777. * Hit test (or Ray-casting) is used to interact with the real world.
  143778. * For further information read here - https://github.com/immersive-web/hit-test
  143779. */
  143780. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  143781. /**
  143782. * options to use when constructing this feature
  143783. */
  143784. readonly options: IWebXRLegacyHitTestOptions;
  143785. private _direction;
  143786. private _mat;
  143787. private _onSelectEnabled;
  143788. private _origin;
  143789. /**
  143790. * The module's name
  143791. */
  143792. static readonly Name: string;
  143793. /**
  143794. * The (Babylon) version of this module.
  143795. * This is an integer representing the implementation version.
  143796. * This number does not correspond to the WebXR specs version
  143797. */
  143798. static readonly Version: number;
  143799. /**
  143800. * Populated with the last native XR Hit Results
  143801. */
  143802. lastNativeXRHitResults: XRHitResult[];
  143803. /**
  143804. * Triggered when new babylon (transformed) hit test results are available
  143805. */
  143806. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  143807. /**
  143808. * Creates a new instance of the (legacy version) hit test feature
  143809. * @param _xrSessionManager an instance of WebXRSessionManager
  143810. * @param options options to use when constructing this feature
  143811. */
  143812. constructor(_xrSessionManager: WebXRSessionManager,
  143813. /**
  143814. * options to use when constructing this feature
  143815. */
  143816. options?: IWebXRLegacyHitTestOptions);
  143817. /**
  143818. * execute a hit test with an XR Ray
  143819. *
  143820. * @param xrSession a native xrSession that will execute this hit test
  143821. * @param xrRay the ray (position and direction) to use for ray-casting
  143822. * @param referenceSpace native XR reference space to use for the hit-test
  143823. * @param filter filter function that will filter the results
  143824. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143825. */
  143826. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  143827. /**
  143828. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  143829. * @param event the (select) event to use to select with
  143830. * @param referenceSpace the reference space to use for this hit test
  143831. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143832. */
  143833. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143834. /**
  143835. * attach this feature
  143836. * Will usually be called by the features manager
  143837. *
  143838. * @returns true if successful.
  143839. */
  143840. attach(): boolean;
  143841. /**
  143842. * detach this feature.
  143843. * Will usually be called by the features manager
  143844. *
  143845. * @returns true if successful.
  143846. */
  143847. detach(): boolean;
  143848. /**
  143849. * Dispose this feature and all of the resources attached
  143850. */
  143851. dispose(): void;
  143852. protected _onXRFrame(frame: XRFrame): void;
  143853. private _onHitTestResults;
  143854. private _onSelect;
  143855. }
  143856. }
  143857. declare module BABYLON {
  143858. /**
  143859. * Options used in the plane detector module
  143860. */
  143861. export interface IWebXRPlaneDetectorOptions {
  143862. /**
  143863. * The node to use to transform the local results to world coordinates
  143864. */
  143865. worldParentNode?: TransformNode;
  143866. }
  143867. /**
  143868. * A babylon interface for a WebXR plane.
  143869. * A Plane is actually a polygon, built from N points in space
  143870. *
  143871. * Supported in chrome 79, not supported in canary 81 ATM
  143872. */
  143873. export interface IWebXRPlane {
  143874. /**
  143875. * a babylon-assigned ID for this polygon
  143876. */
  143877. id: number;
  143878. /**
  143879. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  143880. */
  143881. polygonDefinition: Array<Vector3>;
  143882. /**
  143883. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  143884. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  143885. */
  143886. transformationMatrix: Matrix;
  143887. /**
  143888. * the native xr-plane object
  143889. */
  143890. xrPlane: XRPlane;
  143891. }
  143892. /**
  143893. * The plane detector is used to detect planes in the real world when in AR
  143894. * For more information see https://github.com/immersive-web/real-world-geometry/
  143895. */
  143896. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  143897. private _options;
  143898. private _detectedPlanes;
  143899. private _enabled;
  143900. private _lastFrameDetected;
  143901. /**
  143902. * The module's name
  143903. */
  143904. static readonly Name: string;
  143905. /**
  143906. * The (Babylon) version of this module.
  143907. * This is an integer representing the implementation version.
  143908. * This number does not correspond to the WebXR specs version
  143909. */
  143910. static readonly Version: number;
  143911. /**
  143912. * Observers registered here will be executed when a new plane was added to the session
  143913. */
  143914. onPlaneAddedObservable: Observable<IWebXRPlane>;
  143915. /**
  143916. * Observers registered here will be executed when a plane is no longer detected in the session
  143917. */
  143918. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  143919. /**
  143920. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  143921. * This can execute N times every frame
  143922. */
  143923. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  143924. /**
  143925. * construct a new Plane Detector
  143926. * @param _xrSessionManager an instance of xr Session manager
  143927. * @param _options configuration to use when constructing this feature
  143928. */
  143929. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  143930. /**
  143931. * Dispose this feature and all of the resources attached
  143932. */
  143933. dispose(): void;
  143934. protected _onXRFrame(frame: XRFrame): void;
  143935. private _init;
  143936. private _updatePlaneWithXRPlane;
  143937. /**
  143938. * avoiding using Array.find for global support.
  143939. * @param xrPlane the plane to find in the array
  143940. */
  143941. private findIndexInPlaneArray;
  143942. }
  143943. }
  143944. declare module BABYLON {
  143945. /**
  143946. * Configuration options of the anchor system
  143947. */
  143948. export interface IWebXRAnchorSystemOptions {
  143949. /**
  143950. * Should a new anchor be added every time a select event is triggered
  143951. */
  143952. addAnchorOnSelect?: boolean;
  143953. /**
  143954. * should the anchor system use plane detection.
  143955. * If set to true, the plane-detection feature should be set using setPlaneDetector
  143956. */
  143957. usePlaneDetection?: boolean;
  143958. /**
  143959. * a node that will be used to convert local to world coordinates
  143960. */
  143961. worldParentNode?: TransformNode;
  143962. }
  143963. /**
  143964. * A babylon container for an XR Anchor
  143965. */
  143966. export interface IWebXRAnchor {
  143967. /**
  143968. * A babylon-assigned ID for this anchor
  143969. */
  143970. id: number;
  143971. /**
  143972. * Transformation matrix to apply to an object attached to this anchor
  143973. */
  143974. transformationMatrix: Matrix;
  143975. /**
  143976. * The native anchor object
  143977. */
  143978. xrAnchor: XRAnchor;
  143979. }
  143980. /**
  143981. * An implementation of the anchor system of WebXR.
  143982. * Note that the current documented implementation is not available in any browser. Future implementations
  143983. * will use the frame to create an anchor and not the session or a detected plane
  143984. * For further information see https://github.com/immersive-web/anchors/
  143985. */
  143986. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  143987. private _options;
  143988. private _enabled;
  143989. private _hitTestModule;
  143990. private _lastFrameDetected;
  143991. private _onSelect;
  143992. private _planeDetector;
  143993. private _trackedAnchors;
  143994. /**
  143995. * The module's name
  143996. */
  143997. static readonly Name: string;
  143998. /**
  143999. * The (Babylon) version of this module.
  144000. * This is an integer representing the implementation version.
  144001. * This number does not correspond to the WebXR specs version
  144002. */
  144003. static readonly Version: number;
  144004. /**
  144005. * Observers registered here will be executed when a new anchor was added to the session
  144006. */
  144007. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  144008. /**
  144009. * Observers registered here will be executed when an anchor was removed from the session
  144010. */
  144011. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  144012. /**
  144013. * Observers registered here will be executed when an existing anchor updates
  144014. * This can execute N times every frame
  144015. */
  144016. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  144017. /**
  144018. * constructs a new anchor system
  144019. * @param _xrSessionManager an instance of WebXRSessionManager
  144020. * @param _options configuration object for this feature
  144021. */
  144022. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  144023. /**
  144024. * Add anchor at a specific XR point.
  144025. *
  144026. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  144027. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  144028. * @returns a promise the fulfills when the anchor was created
  144029. */
  144030. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  144031. /**
  144032. * attach this feature
  144033. * Will usually be called by the features manager
  144034. *
  144035. * @returns true if successful.
  144036. */
  144037. attach(): boolean;
  144038. /**
  144039. * detach this feature.
  144040. * Will usually be called by the features manager
  144041. *
  144042. * @returns true if successful.
  144043. */
  144044. detach(): boolean;
  144045. /**
  144046. * Dispose this feature and all of the resources attached
  144047. */
  144048. dispose(): void;
  144049. /**
  144050. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  144051. * @param hitTestModule the hit-test module to use.
  144052. */
  144053. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  144054. /**
  144055. * set the plane detector to use in order to create anchors from frames
  144056. * @param planeDetector the plane-detector module to use
  144057. * @param enable enable plane-anchors. default is true
  144058. */
  144059. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  144060. protected _onXRFrame(frame: XRFrame): void;
  144061. /**
  144062. * avoiding using Array.find for global support.
  144063. * @param xrAnchor the plane to find in the array
  144064. */
  144065. private _findIndexInAnchorArray;
  144066. private _updateAnchorWithXRFrame;
  144067. }
  144068. }
  144069. declare module BABYLON {
  144070. /**
  144071. * Options interface for the background remover plugin
  144072. */
  144073. export interface IWebXRBackgroundRemoverOptions {
  144074. /**
  144075. * Further background meshes to disable when entering AR
  144076. */
  144077. backgroundMeshes?: AbstractMesh[];
  144078. /**
  144079. * flags to configure the removal of the environment helper.
  144080. * If not set, the entire background will be removed. If set, flags should be set as well.
  144081. */
  144082. environmentHelperRemovalFlags?: {
  144083. /**
  144084. * Should the skybox be removed (default false)
  144085. */
  144086. skyBox?: boolean;
  144087. /**
  144088. * Should the ground be removed (default false)
  144089. */
  144090. ground?: boolean;
  144091. };
  144092. /**
  144093. * don't disable the environment helper
  144094. */
  144095. ignoreEnvironmentHelper?: boolean;
  144096. }
  144097. /**
  144098. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  144099. */
  144100. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  144101. /**
  144102. * read-only options to be used in this module
  144103. */
  144104. readonly options: IWebXRBackgroundRemoverOptions;
  144105. /**
  144106. * The module's name
  144107. */
  144108. static readonly Name: string;
  144109. /**
  144110. * The (Babylon) version of this module.
  144111. * This is an integer representing the implementation version.
  144112. * This number does not correspond to the WebXR specs version
  144113. */
  144114. static readonly Version: number;
  144115. /**
  144116. * registered observers will be triggered when the background state changes
  144117. */
  144118. onBackgroundStateChangedObservable: Observable<boolean>;
  144119. /**
  144120. * constructs a new background remover module
  144121. * @param _xrSessionManager the session manager for this module
  144122. * @param options read-only options to be used in this module
  144123. */
  144124. constructor(_xrSessionManager: WebXRSessionManager,
  144125. /**
  144126. * read-only options to be used in this module
  144127. */
  144128. options?: IWebXRBackgroundRemoverOptions);
  144129. /**
  144130. * attach this feature
  144131. * Will usually be called by the features manager
  144132. *
  144133. * @returns true if successful.
  144134. */
  144135. attach(): boolean;
  144136. /**
  144137. * detach this feature.
  144138. * Will usually be called by the features manager
  144139. *
  144140. * @returns true if successful.
  144141. */
  144142. detach(): boolean;
  144143. /**
  144144. * Dispose this feature and all of the resources attached
  144145. */
  144146. dispose(): void;
  144147. protected _onXRFrame(_xrFrame: XRFrame): void;
  144148. private _setBackgroundState;
  144149. }
  144150. }
  144151. declare module BABYLON {
  144152. /**
  144153. * Options for the controller physics feature
  144154. */
  144155. export class IWebXRControllerPhysicsOptions {
  144156. /**
  144157. * Should the headset get its own impostor
  144158. */
  144159. enableHeadsetImpostor?: boolean;
  144160. /**
  144161. * Optional parameters for the headset impostor
  144162. */
  144163. headsetImpostorParams?: {
  144164. /**
  144165. * The type of impostor to create. Default is sphere
  144166. */
  144167. impostorType: number;
  144168. /**
  144169. * the size of the impostor. Defaults to 10cm
  144170. */
  144171. impostorSize?: number | {
  144172. width: number;
  144173. height: number;
  144174. depth: number;
  144175. };
  144176. /**
  144177. * Friction definitions
  144178. */
  144179. friction?: number;
  144180. /**
  144181. * Restitution
  144182. */
  144183. restitution?: number;
  144184. };
  144185. /**
  144186. * The physics properties of the future impostors
  144187. */
  144188. physicsProperties?: {
  144189. /**
  144190. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  144191. * Note that this requires a physics engine that supports mesh impostors!
  144192. */
  144193. useControllerMesh?: boolean;
  144194. /**
  144195. * The type of impostor to create. Default is sphere
  144196. */
  144197. impostorType?: number;
  144198. /**
  144199. * the size of the impostor. Defaults to 10cm
  144200. */
  144201. impostorSize?: number | {
  144202. width: number;
  144203. height: number;
  144204. depth: number;
  144205. };
  144206. /**
  144207. * Friction definitions
  144208. */
  144209. friction?: number;
  144210. /**
  144211. * Restitution
  144212. */
  144213. restitution?: number;
  144214. };
  144215. /**
  144216. * the xr input to use with this pointer selection
  144217. */
  144218. xrInput: WebXRInput;
  144219. }
  144220. /**
  144221. * Add physics impostor to your webxr controllers,
  144222. * including naive calculation of their linear and angular velocity
  144223. */
  144224. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  144225. private readonly _options;
  144226. private _attachController;
  144227. private _controllers;
  144228. private _debugMode;
  144229. private _delta;
  144230. private _headsetImpostor?;
  144231. private _headsetMesh?;
  144232. private _lastTimestamp;
  144233. private _tmpQuaternion;
  144234. private _tmpVector;
  144235. /**
  144236. * The module's name
  144237. */
  144238. static readonly Name: string;
  144239. /**
  144240. * The (Babylon) version of this module.
  144241. * This is an integer representing the implementation version.
  144242. * This number does not correspond to the webxr specs version
  144243. */
  144244. static readonly Version: number;
  144245. /**
  144246. * Construct a new Controller Physics Feature
  144247. * @param _xrSessionManager the corresponding xr session manager
  144248. * @param _options options to create this feature with
  144249. */
  144250. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  144251. /**
  144252. * @hidden
  144253. * enable debugging - will show console outputs and the impostor mesh
  144254. */
  144255. _enablePhysicsDebug(): void;
  144256. /**
  144257. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  144258. * @param xrController the controller to add
  144259. */
  144260. addController(xrController: WebXRInputSource): void;
  144261. /**
  144262. * attach this feature
  144263. * Will usually be called by the features manager
  144264. *
  144265. * @returns true if successful.
  144266. */
  144267. attach(): boolean;
  144268. /**
  144269. * detach this feature.
  144270. * Will usually be called by the features manager
  144271. *
  144272. * @returns true if successful.
  144273. */
  144274. detach(): boolean;
  144275. /**
  144276. * Get the headset impostor, if enabled
  144277. * @returns the impostor
  144278. */
  144279. getHeadsetImpostor(): PhysicsImpostor | undefined;
  144280. /**
  144281. * Get the physics impostor of a specific controller.
  144282. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  144283. * @param controller the controller or the controller id of which to get the impostor
  144284. * @returns the impostor or null
  144285. */
  144286. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  144287. /**
  144288. * Update the physics properties provided in the constructor
  144289. * @param newProperties the new properties object
  144290. */
  144291. setPhysicsProperties(newProperties: {
  144292. impostorType?: number;
  144293. impostorSize?: number | {
  144294. width: number;
  144295. height: number;
  144296. depth: number;
  144297. };
  144298. friction?: number;
  144299. restitution?: number;
  144300. }): void;
  144301. protected _onXRFrame(_xrFrame: any): void;
  144302. private _detachController;
  144303. }
  144304. }
  144305. declare module BABYLON {
  144306. /**
  144307. * Options used for hit testing (version 2)
  144308. */
  144309. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  144310. /**
  144311. * Do not create a permanent hit test. Will usually be used when only
  144312. * transient inputs are needed.
  144313. */
  144314. disablePermanentHitTest?: boolean;
  144315. /**
  144316. * Enable transient (for example touch-based) hit test inspections
  144317. */
  144318. enableTransientHitTest?: boolean;
  144319. /**
  144320. * Offset ray for the permanent hit test
  144321. */
  144322. offsetRay?: Vector3;
  144323. /**
  144324. * Offset ray for the transient hit test
  144325. */
  144326. transientOffsetRay?: Vector3;
  144327. /**
  144328. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  144329. */
  144330. useReferenceSpace?: boolean;
  144331. }
  144332. /**
  144333. * Interface defining the babylon result of hit-test
  144334. */
  144335. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  144336. /**
  144337. * The input source that generated this hit test (if transient)
  144338. */
  144339. inputSource?: XRInputSource;
  144340. /**
  144341. * Is this a transient hit test
  144342. */
  144343. isTransient?: boolean;
  144344. /**
  144345. * Position of the hit test result
  144346. */
  144347. position: Vector3;
  144348. /**
  144349. * Rotation of the hit test result
  144350. */
  144351. rotationQuaternion: Quaternion;
  144352. }
  144353. /**
  144354. * The currently-working hit-test module.
  144355. * Hit test (or Ray-casting) is used to interact with the real world.
  144356. * For further information read here - https://github.com/immersive-web/hit-test
  144357. *
  144358. * Tested on chrome (mobile) 80.
  144359. */
  144360. export class WebXRHitTest extends WebXRAbstractFeature {
  144361. /**
  144362. * options to use when constructing this feature
  144363. */
  144364. readonly options: IWebXRHitTestOptions;
  144365. private _tmpMat;
  144366. private _tmpPos;
  144367. private _tmpQuat;
  144368. private _transientXrHitTestSource;
  144369. private _xrHitTestSource;
  144370. private initHitTestSource;
  144371. /**
  144372. * The module's name
  144373. */
  144374. static readonly Name: string;
  144375. /**
  144376. * The (Babylon) version of this module.
  144377. * This is an integer representing the implementation version.
  144378. * This number does not correspond to the WebXR specs version
  144379. */
  144380. static readonly Version: number;
  144381. /**
  144382. * When set to true, each hit test will have its own position/rotation objects
  144383. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  144384. * the developers will clone them or copy them as they see fit.
  144385. */
  144386. autoCloneTransformation: boolean;
  144387. /**
  144388. * Populated with the last native XR Hit Results
  144389. */
  144390. lastNativeXRHitResults: XRHitResult[];
  144391. /**
  144392. * Triggered when new babylon (transformed) hit test results are available
  144393. */
  144394. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  144395. /**
  144396. * Use this to temporarily pause hit test checks.
  144397. */
  144398. paused: boolean;
  144399. /**
  144400. * Creates a new instance of the hit test feature
  144401. * @param _xrSessionManager an instance of WebXRSessionManager
  144402. * @param options options to use when constructing this feature
  144403. */
  144404. constructor(_xrSessionManager: WebXRSessionManager,
  144405. /**
  144406. * options to use when constructing this feature
  144407. */
  144408. options?: IWebXRHitTestOptions);
  144409. /**
  144410. * attach this feature
  144411. * Will usually be called by the features manager
  144412. *
  144413. * @returns true if successful.
  144414. */
  144415. attach(): boolean;
  144416. /**
  144417. * detach this feature.
  144418. * Will usually be called by the features manager
  144419. *
  144420. * @returns true if successful.
  144421. */
  144422. detach(): boolean;
  144423. /**
  144424. * Dispose this feature and all of the resources attached
  144425. */
  144426. dispose(): void;
  144427. protected _onXRFrame(frame: XRFrame): void;
  144428. private _processWebXRHitTestResult;
  144429. }
  144430. }
  144431. declare module BABYLON {
  144432. /**
  144433. * The motion controller class for all microsoft mixed reality controllers
  144434. */
  144435. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  144436. protected readonly _mapping: {
  144437. defaultButton: {
  144438. valueNodeName: string;
  144439. unpressedNodeName: string;
  144440. pressedNodeName: string;
  144441. };
  144442. defaultAxis: {
  144443. valueNodeName: string;
  144444. minNodeName: string;
  144445. maxNodeName: string;
  144446. };
  144447. buttons: {
  144448. "xr-standard-trigger": {
  144449. rootNodeName: string;
  144450. componentProperty: string;
  144451. states: string[];
  144452. };
  144453. "xr-standard-squeeze": {
  144454. rootNodeName: string;
  144455. componentProperty: string;
  144456. states: string[];
  144457. };
  144458. "xr-standard-touchpad": {
  144459. rootNodeName: string;
  144460. labelAnchorNodeName: string;
  144461. touchPointNodeName: string;
  144462. };
  144463. "xr-standard-thumbstick": {
  144464. rootNodeName: string;
  144465. componentProperty: string;
  144466. states: string[];
  144467. };
  144468. };
  144469. axes: {
  144470. "xr-standard-touchpad": {
  144471. "x-axis": {
  144472. rootNodeName: string;
  144473. };
  144474. "y-axis": {
  144475. rootNodeName: string;
  144476. };
  144477. };
  144478. "xr-standard-thumbstick": {
  144479. "x-axis": {
  144480. rootNodeName: string;
  144481. };
  144482. "y-axis": {
  144483. rootNodeName: string;
  144484. };
  144485. };
  144486. };
  144487. };
  144488. /**
  144489. * The base url used to load the left and right controller models
  144490. */
  144491. static MODEL_BASE_URL: string;
  144492. /**
  144493. * The name of the left controller model file
  144494. */
  144495. static MODEL_LEFT_FILENAME: string;
  144496. /**
  144497. * The name of the right controller model file
  144498. */
  144499. static MODEL_RIGHT_FILENAME: string;
  144500. profileId: string;
  144501. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144502. protected _getFilenameAndPath(): {
  144503. filename: string;
  144504. path: string;
  144505. };
  144506. protected _getModelLoadingConstraints(): boolean;
  144507. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144508. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144509. protected _updateModel(): void;
  144510. }
  144511. }
  144512. declare module BABYLON {
  144513. /**
  144514. * The motion controller class for oculus touch (quest, rift).
  144515. * This class supports legacy mapping as well the standard xr mapping
  144516. */
  144517. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  144518. private _forceLegacyControllers;
  144519. private _modelRootNode;
  144520. /**
  144521. * The base url used to load the left and right controller models
  144522. */
  144523. static MODEL_BASE_URL: string;
  144524. /**
  144525. * The name of the left controller model file
  144526. */
  144527. static MODEL_LEFT_FILENAME: string;
  144528. /**
  144529. * The name of the right controller model file
  144530. */
  144531. static MODEL_RIGHT_FILENAME: string;
  144532. /**
  144533. * Base Url for the Quest controller model.
  144534. */
  144535. static QUEST_MODEL_BASE_URL: string;
  144536. profileId: string;
  144537. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  144538. protected _getFilenameAndPath(): {
  144539. filename: string;
  144540. path: string;
  144541. };
  144542. protected _getModelLoadingConstraints(): boolean;
  144543. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144544. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144545. protected _updateModel(): void;
  144546. /**
  144547. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  144548. * between the touch and touch 2.
  144549. */
  144550. private _isQuest;
  144551. }
  144552. }
  144553. declare module BABYLON {
  144554. /**
  144555. * The motion controller class for the standard HTC-Vive controllers
  144556. */
  144557. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  144558. private _modelRootNode;
  144559. /**
  144560. * The base url used to load the left and right controller models
  144561. */
  144562. static MODEL_BASE_URL: string;
  144563. /**
  144564. * File name for the controller model.
  144565. */
  144566. static MODEL_FILENAME: string;
  144567. profileId: string;
  144568. /**
  144569. * Create a new Vive motion controller object
  144570. * @param scene the scene to use to create this controller
  144571. * @param gamepadObject the corresponding gamepad object
  144572. * @param handness the handness of the controller
  144573. */
  144574. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144575. protected _getFilenameAndPath(): {
  144576. filename: string;
  144577. path: string;
  144578. };
  144579. protected _getModelLoadingConstraints(): boolean;
  144580. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144581. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144582. protected _updateModel(): void;
  144583. }
  144584. }
  144585. declare module BABYLON {
  144586. /**
  144587. * A cursor which tracks a point on a path
  144588. */
  144589. export class PathCursor {
  144590. private path;
  144591. /**
  144592. * Stores path cursor callbacks for when an onchange event is triggered
  144593. */
  144594. private _onchange;
  144595. /**
  144596. * The value of the path cursor
  144597. */
  144598. value: number;
  144599. /**
  144600. * The animation array of the path cursor
  144601. */
  144602. animations: Animation[];
  144603. /**
  144604. * Initializes the path cursor
  144605. * @param path The path to track
  144606. */
  144607. constructor(path: Path2);
  144608. /**
  144609. * Gets the cursor point on the path
  144610. * @returns A point on the path cursor at the cursor location
  144611. */
  144612. getPoint(): Vector3;
  144613. /**
  144614. * Moves the cursor ahead by the step amount
  144615. * @param step The amount to move the cursor forward
  144616. * @returns This path cursor
  144617. */
  144618. moveAhead(step?: number): PathCursor;
  144619. /**
  144620. * Moves the cursor behind by the step amount
  144621. * @param step The amount to move the cursor back
  144622. * @returns This path cursor
  144623. */
  144624. moveBack(step?: number): PathCursor;
  144625. /**
  144626. * Moves the cursor by the step amount
  144627. * If the step amount is greater than one, an exception is thrown
  144628. * @param step The amount to move the cursor
  144629. * @returns This path cursor
  144630. */
  144631. move(step: number): PathCursor;
  144632. /**
  144633. * Ensures that the value is limited between zero and one
  144634. * @returns This path cursor
  144635. */
  144636. private ensureLimits;
  144637. /**
  144638. * Runs onchange callbacks on change (used by the animation engine)
  144639. * @returns This path cursor
  144640. */
  144641. private raiseOnChange;
  144642. /**
  144643. * Executes a function on change
  144644. * @param f A path cursor onchange callback
  144645. * @returns This path cursor
  144646. */
  144647. onchange(f: (cursor: PathCursor) => void): PathCursor;
  144648. }
  144649. }
  144650. declare module BABYLON {
  144651. /** @hidden */
  144652. export var blurPixelShader: {
  144653. name: string;
  144654. shader: string;
  144655. };
  144656. }
  144657. declare module BABYLON {
  144658. /** @hidden */
  144659. export var pointCloudVertexDeclaration: {
  144660. name: string;
  144661. shader: string;
  144662. };
  144663. }
  144664. // Mixins
  144665. interface Window {
  144666. mozIndexedDB: IDBFactory;
  144667. webkitIndexedDB: IDBFactory;
  144668. msIndexedDB: IDBFactory;
  144669. webkitURL: typeof URL;
  144670. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  144671. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  144672. WebGLRenderingContext: WebGLRenderingContext;
  144673. MSGesture: MSGesture;
  144674. CANNON: any;
  144675. AudioContext: AudioContext;
  144676. webkitAudioContext: AudioContext;
  144677. PointerEvent: any;
  144678. Math: Math;
  144679. Uint8Array: Uint8ArrayConstructor;
  144680. Float32Array: Float32ArrayConstructor;
  144681. mozURL: typeof URL;
  144682. msURL: typeof URL;
  144683. VRFrameData: any; // WebVR, from specs 1.1
  144684. DracoDecoderModule: any;
  144685. setImmediate(handler: (...args: any[]) => void): number;
  144686. }
  144687. interface HTMLCanvasElement {
  144688. requestPointerLock(): void;
  144689. msRequestPointerLock?(): void;
  144690. mozRequestPointerLock?(): void;
  144691. webkitRequestPointerLock?(): void;
  144692. /** Track wether a record is in progress */
  144693. isRecording: boolean;
  144694. /** Capture Stream method defined by some browsers */
  144695. captureStream(fps?: number): MediaStream;
  144696. }
  144697. interface CanvasRenderingContext2D {
  144698. msImageSmoothingEnabled: boolean;
  144699. }
  144700. interface MouseEvent {
  144701. mozMovementX: number;
  144702. mozMovementY: number;
  144703. webkitMovementX: number;
  144704. webkitMovementY: number;
  144705. msMovementX: number;
  144706. msMovementY: number;
  144707. }
  144708. interface Navigator {
  144709. mozGetVRDevices: (any: any) => any;
  144710. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144711. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144712. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144713. webkitGetGamepads(): Gamepad[];
  144714. msGetGamepads(): Gamepad[];
  144715. webkitGamepads(): Gamepad[];
  144716. }
  144717. interface HTMLVideoElement {
  144718. mozSrcObject: any;
  144719. }
  144720. interface Math {
  144721. fround(x: number): number;
  144722. imul(a: number, b: number): number;
  144723. }
  144724. interface WebGLRenderingContext {
  144725. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  144726. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  144727. vertexAttribDivisor(index: number, divisor: number): void;
  144728. createVertexArray(): any;
  144729. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  144730. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  144731. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  144732. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  144733. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  144734. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  144735. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  144736. // Queries
  144737. createQuery(): WebGLQuery;
  144738. deleteQuery(query: WebGLQuery): void;
  144739. beginQuery(target: number, query: WebGLQuery): void;
  144740. endQuery(target: number): void;
  144741. getQueryParameter(query: WebGLQuery, pname: number): any;
  144742. getQuery(target: number, pname: number): any;
  144743. MAX_SAMPLES: number;
  144744. RGBA8: number;
  144745. READ_FRAMEBUFFER: number;
  144746. DRAW_FRAMEBUFFER: number;
  144747. UNIFORM_BUFFER: number;
  144748. HALF_FLOAT_OES: number;
  144749. RGBA16F: number;
  144750. RGBA32F: number;
  144751. R32F: number;
  144752. RG32F: number;
  144753. RGB32F: number;
  144754. R16F: number;
  144755. RG16F: number;
  144756. RGB16F: number;
  144757. RED: number;
  144758. RG: number;
  144759. R8: number;
  144760. RG8: number;
  144761. UNSIGNED_INT_24_8: number;
  144762. DEPTH24_STENCIL8: number;
  144763. MIN: number;
  144764. MAX: number;
  144765. /* Multiple Render Targets */
  144766. drawBuffers(buffers: number[]): void;
  144767. readBuffer(src: number): void;
  144768. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  144769. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  144770. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  144771. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  144772. // Occlusion Query
  144773. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  144774. ANY_SAMPLES_PASSED: number;
  144775. QUERY_RESULT_AVAILABLE: number;
  144776. QUERY_RESULT: number;
  144777. }
  144778. interface WebGLProgram {
  144779. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  144780. }
  144781. interface EXT_disjoint_timer_query {
  144782. QUERY_COUNTER_BITS_EXT: number;
  144783. TIME_ELAPSED_EXT: number;
  144784. TIMESTAMP_EXT: number;
  144785. GPU_DISJOINT_EXT: number;
  144786. QUERY_RESULT_EXT: number;
  144787. QUERY_RESULT_AVAILABLE_EXT: number;
  144788. queryCounterEXT(query: WebGLQuery, target: number): void;
  144789. createQueryEXT(): WebGLQuery;
  144790. beginQueryEXT(target: number, query: WebGLQuery): void;
  144791. endQueryEXT(target: number): void;
  144792. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  144793. deleteQueryEXT(query: WebGLQuery): void;
  144794. }
  144795. interface WebGLUniformLocation {
  144796. _currentState: any;
  144797. }
  144798. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  144799. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  144800. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  144801. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144802. interface WebGLRenderingContext {
  144803. readonly RASTERIZER_DISCARD: number;
  144804. readonly DEPTH_COMPONENT24: number;
  144805. readonly TEXTURE_3D: number;
  144806. readonly TEXTURE_2D_ARRAY: number;
  144807. readonly TEXTURE_COMPARE_FUNC: number;
  144808. readonly TEXTURE_COMPARE_MODE: number;
  144809. readonly COMPARE_REF_TO_TEXTURE: number;
  144810. readonly TEXTURE_WRAP_R: number;
  144811. readonly HALF_FLOAT: number;
  144812. readonly RGB8: number;
  144813. readonly RED_INTEGER: number;
  144814. readonly RG_INTEGER: number;
  144815. readonly RGB_INTEGER: number;
  144816. readonly RGBA_INTEGER: number;
  144817. readonly R8_SNORM: number;
  144818. readonly RG8_SNORM: number;
  144819. readonly RGB8_SNORM: number;
  144820. readonly RGBA8_SNORM: number;
  144821. readonly R8I: number;
  144822. readonly RG8I: number;
  144823. readonly RGB8I: number;
  144824. readonly RGBA8I: number;
  144825. readonly R8UI: number;
  144826. readonly RG8UI: number;
  144827. readonly RGB8UI: number;
  144828. readonly RGBA8UI: number;
  144829. readonly R16I: number;
  144830. readonly RG16I: number;
  144831. readonly RGB16I: number;
  144832. readonly RGBA16I: number;
  144833. readonly R16UI: number;
  144834. readonly RG16UI: number;
  144835. readonly RGB16UI: number;
  144836. readonly RGBA16UI: number;
  144837. readonly R32I: number;
  144838. readonly RG32I: number;
  144839. readonly RGB32I: number;
  144840. readonly RGBA32I: number;
  144841. readonly R32UI: number;
  144842. readonly RG32UI: number;
  144843. readonly RGB32UI: number;
  144844. readonly RGBA32UI: number;
  144845. readonly RGB10_A2UI: number;
  144846. readonly R11F_G11F_B10F: number;
  144847. readonly RGB9_E5: number;
  144848. readonly RGB10_A2: number;
  144849. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  144850. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  144851. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  144852. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  144853. readonly DEPTH_COMPONENT32F: number;
  144854. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  144855. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  144856. 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;
  144857. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  144858. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  144859. readonly TRANSFORM_FEEDBACK: number;
  144860. readonly INTERLEAVED_ATTRIBS: number;
  144861. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  144862. createTransformFeedback(): WebGLTransformFeedback;
  144863. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  144864. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  144865. beginTransformFeedback(primitiveMode: number): void;
  144866. endTransformFeedback(): void;
  144867. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  144868. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144869. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144870. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144871. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  144872. }
  144873. interface ImageBitmap {
  144874. readonly width: number;
  144875. readonly height: number;
  144876. close(): void;
  144877. }
  144878. interface WebGLQuery extends WebGLObject {
  144879. }
  144880. declare var WebGLQuery: {
  144881. prototype: WebGLQuery;
  144882. new(): WebGLQuery;
  144883. };
  144884. interface WebGLSampler extends WebGLObject {
  144885. }
  144886. declare var WebGLSampler: {
  144887. prototype: WebGLSampler;
  144888. new(): WebGLSampler;
  144889. };
  144890. interface WebGLSync extends WebGLObject {
  144891. }
  144892. declare var WebGLSync: {
  144893. prototype: WebGLSync;
  144894. new(): WebGLSync;
  144895. };
  144896. interface WebGLTransformFeedback extends WebGLObject {
  144897. }
  144898. declare var WebGLTransformFeedback: {
  144899. prototype: WebGLTransformFeedback;
  144900. new(): WebGLTransformFeedback;
  144901. };
  144902. interface WebGLVertexArrayObject extends WebGLObject {
  144903. }
  144904. declare var WebGLVertexArrayObject: {
  144905. prototype: WebGLVertexArrayObject;
  144906. new(): WebGLVertexArrayObject;
  144907. };
  144908. // Type definitions for WebVR API
  144909. // Project: https://w3c.github.io/webvr/
  144910. // Definitions by: six a <https://github.com/lostfictions>
  144911. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144912. interface VRDisplay extends EventTarget {
  144913. /**
  144914. * Dictionary of capabilities describing the VRDisplay.
  144915. */
  144916. readonly capabilities: VRDisplayCapabilities;
  144917. /**
  144918. * z-depth defining the far plane of the eye view frustum
  144919. * enables mapping of values in the render target depth
  144920. * attachment to scene coordinates. Initially set to 10000.0.
  144921. */
  144922. depthFar: number;
  144923. /**
  144924. * z-depth defining the near plane of the eye view frustum
  144925. * enables mapping of values in the render target depth
  144926. * attachment to scene coordinates. Initially set to 0.01.
  144927. */
  144928. depthNear: number;
  144929. /**
  144930. * An identifier for this distinct VRDisplay. Used as an
  144931. * association point in the Gamepad API.
  144932. */
  144933. readonly displayId: number;
  144934. /**
  144935. * A display name, a user-readable name identifying it.
  144936. */
  144937. readonly displayName: string;
  144938. readonly isConnected: boolean;
  144939. readonly isPresenting: boolean;
  144940. /**
  144941. * If this VRDisplay supports room-scale experiences, the optional
  144942. * stage attribute contains details on the room-scale parameters.
  144943. */
  144944. readonly stageParameters: VRStageParameters | null;
  144945. /**
  144946. * Passing the value returned by `requestAnimationFrame` to
  144947. * `cancelAnimationFrame` will unregister the callback.
  144948. * @param handle Define the hanle of the request to cancel
  144949. */
  144950. cancelAnimationFrame(handle: number): void;
  144951. /**
  144952. * Stops presenting to the VRDisplay.
  144953. * @returns a promise to know when it stopped
  144954. */
  144955. exitPresent(): Promise<void>;
  144956. /**
  144957. * Return the current VREyeParameters for the given eye.
  144958. * @param whichEye Define the eye we want the parameter for
  144959. * @returns the eye parameters
  144960. */
  144961. getEyeParameters(whichEye: string): VREyeParameters;
  144962. /**
  144963. * Populates the passed VRFrameData with the information required to render
  144964. * the current frame.
  144965. * @param frameData Define the data structure to populate
  144966. * @returns true if ok otherwise false
  144967. */
  144968. getFrameData(frameData: VRFrameData): boolean;
  144969. /**
  144970. * Get the layers currently being presented.
  144971. * @returns the list of VR layers
  144972. */
  144973. getLayers(): VRLayer[];
  144974. /**
  144975. * Return a VRPose containing the future predicted pose of the VRDisplay
  144976. * when the current frame will be presented. The value returned will not
  144977. * change until JavaScript has returned control to the browser.
  144978. *
  144979. * The VRPose will contain the position, orientation, velocity,
  144980. * and acceleration of each of these properties.
  144981. * @returns the pose object
  144982. */
  144983. getPose(): VRPose;
  144984. /**
  144985. * Return the current instantaneous pose of the VRDisplay, with no
  144986. * prediction applied.
  144987. * @returns the current instantaneous pose
  144988. */
  144989. getImmediatePose(): VRPose;
  144990. /**
  144991. * The callback passed to `requestAnimationFrame` will be called
  144992. * any time a new frame should be rendered. When the VRDisplay is
  144993. * presenting the callback will be called at the native refresh
  144994. * rate of the HMD. When not presenting this function acts
  144995. * identically to how window.requestAnimationFrame acts. Content should
  144996. * make no assumptions of frame rate or vsync behavior as the HMD runs
  144997. * asynchronously from other displays and at differing refresh rates.
  144998. * @param callback Define the eaction to run next frame
  144999. * @returns the request handle it
  145000. */
  145001. requestAnimationFrame(callback: FrameRequestCallback): number;
  145002. /**
  145003. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  145004. * Repeat calls while already presenting will update the VRLayers being displayed.
  145005. * @param layers Define the list of layer to present
  145006. * @returns a promise to know when the request has been fulfilled
  145007. */
  145008. requestPresent(layers: VRLayer[]): Promise<void>;
  145009. /**
  145010. * Reset the pose for this display, treating its current position and
  145011. * orientation as the "origin/zero" values. VRPose.position,
  145012. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  145013. * updated when calling resetPose(). This should be called in only
  145014. * sitting-space experiences.
  145015. */
  145016. resetPose(): void;
  145017. /**
  145018. * The VRLayer provided to the VRDisplay will be captured and presented
  145019. * in the HMD. Calling this function has the same effect on the source
  145020. * canvas as any other operation that uses its source image, and canvases
  145021. * created without preserveDrawingBuffer set to true will be cleared.
  145022. * @param pose Define the pose to submit
  145023. */
  145024. submitFrame(pose?: VRPose): void;
  145025. }
  145026. declare var VRDisplay: {
  145027. prototype: VRDisplay;
  145028. new(): VRDisplay;
  145029. };
  145030. interface VRLayer {
  145031. leftBounds?: number[] | Float32Array | null;
  145032. rightBounds?: number[] | Float32Array | null;
  145033. source?: HTMLCanvasElement | null;
  145034. }
  145035. interface VRDisplayCapabilities {
  145036. readonly canPresent: boolean;
  145037. readonly hasExternalDisplay: boolean;
  145038. readonly hasOrientation: boolean;
  145039. readonly hasPosition: boolean;
  145040. readonly maxLayers: number;
  145041. }
  145042. interface VREyeParameters {
  145043. /** @deprecated */
  145044. readonly fieldOfView: VRFieldOfView;
  145045. readonly offset: Float32Array;
  145046. readonly renderHeight: number;
  145047. readonly renderWidth: number;
  145048. }
  145049. interface VRFieldOfView {
  145050. readonly downDegrees: number;
  145051. readonly leftDegrees: number;
  145052. readonly rightDegrees: number;
  145053. readonly upDegrees: number;
  145054. }
  145055. interface VRFrameData {
  145056. readonly leftProjectionMatrix: Float32Array;
  145057. readonly leftViewMatrix: Float32Array;
  145058. readonly pose: VRPose;
  145059. readonly rightProjectionMatrix: Float32Array;
  145060. readonly rightViewMatrix: Float32Array;
  145061. readonly timestamp: number;
  145062. }
  145063. interface VRPose {
  145064. readonly angularAcceleration: Float32Array | null;
  145065. readonly angularVelocity: Float32Array | null;
  145066. readonly linearAcceleration: Float32Array | null;
  145067. readonly linearVelocity: Float32Array | null;
  145068. readonly orientation: Float32Array | null;
  145069. readonly position: Float32Array | null;
  145070. readonly timestamp: number;
  145071. }
  145072. interface VRStageParameters {
  145073. sittingToStandingTransform?: Float32Array;
  145074. sizeX?: number;
  145075. sizeY?: number;
  145076. }
  145077. interface Navigator {
  145078. getVRDisplays(): Promise<VRDisplay[]>;
  145079. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  145080. }
  145081. interface Window {
  145082. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  145083. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  145084. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  145085. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145086. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145087. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  145088. }
  145089. interface Gamepad {
  145090. readonly displayId: number;
  145091. }
  145092. type XRSessionMode =
  145093. | "inline"
  145094. | "immersive-vr"
  145095. | "immersive-ar";
  145096. type XRReferenceSpaceType =
  145097. | "viewer"
  145098. | "local"
  145099. | "local-floor"
  145100. | "bounded-floor"
  145101. | "unbounded";
  145102. type XREnvironmentBlendMode =
  145103. | "opaque"
  145104. | "additive"
  145105. | "alpha-blend";
  145106. type XRVisibilityState =
  145107. | "visible"
  145108. | "visible-blurred"
  145109. | "hidden";
  145110. type XRHandedness =
  145111. | "none"
  145112. | "left"
  145113. | "right";
  145114. type XRTargetRayMode =
  145115. | "gaze"
  145116. | "tracked-pointer"
  145117. | "screen";
  145118. type XREye =
  145119. | "none"
  145120. | "left"
  145121. | "right";
  145122. interface XRSpace extends EventTarget {
  145123. }
  145124. interface XRRenderState {
  145125. depthNear?: number;
  145126. depthFar?: number;
  145127. inlineVerticalFieldOfView?: number;
  145128. baseLayer?: XRWebGLLayer;
  145129. }
  145130. interface XRInputSource {
  145131. handedness: XRHandedness;
  145132. targetRayMode: XRTargetRayMode;
  145133. targetRaySpace: XRSpace;
  145134. gripSpace: XRSpace | undefined;
  145135. gamepad: Gamepad | undefined;
  145136. profiles: Array<string>;
  145137. }
  145138. interface XRSessionInit {
  145139. optionalFeatures?: XRReferenceSpaceType[];
  145140. requiredFeatures?: XRReferenceSpaceType[];
  145141. }
  145142. interface XRSession extends XRAnchorCreator {
  145143. addEventListener: Function;
  145144. removeEventListener: Function;
  145145. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  145146. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  145147. requestAnimationFrame: Function;
  145148. end(): Promise<void>;
  145149. renderState: XRRenderState;
  145150. inputSources: Array<XRInputSource>;
  145151. // hit test
  145152. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  145153. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  145154. // legacy AR hit test
  145155. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  145156. // legacy plane detection
  145157. updateWorldTrackingState(options: {
  145158. planeDetectionState?: { enabled: boolean; }
  145159. }): void;
  145160. }
  145161. interface XRReferenceSpace extends XRSpace {
  145162. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  145163. onreset: any;
  145164. }
  145165. type XRPlaneSet = Set<XRPlane>;
  145166. type XRAnchorSet = Set<XRAnchor>;
  145167. interface XRFrame {
  145168. session: XRSession;
  145169. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  145170. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  145171. // AR
  145172. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  145173. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  145174. // Anchors
  145175. trackedAnchors?: XRAnchorSet;
  145176. // Planes
  145177. worldInformation: {
  145178. detectedPlanes?: XRPlaneSet;
  145179. };
  145180. }
  145181. interface XRViewerPose extends XRPose {
  145182. views: Array<XRView>;
  145183. }
  145184. interface XRPose {
  145185. transform: XRRigidTransform;
  145186. emulatedPosition: boolean;
  145187. }
  145188. interface XRWebGLLayerOptions {
  145189. antialias?: boolean;
  145190. depth?: boolean;
  145191. stencil?: boolean;
  145192. alpha?: boolean;
  145193. multiview?: boolean;
  145194. framebufferScaleFactor?: number;
  145195. }
  145196. declare var XRWebGLLayer: {
  145197. prototype: XRWebGLLayer;
  145198. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  145199. };
  145200. interface XRWebGLLayer {
  145201. framebuffer: WebGLFramebuffer;
  145202. framebufferWidth: number;
  145203. framebufferHeight: number;
  145204. getViewport: Function;
  145205. }
  145206. declare class XRRigidTransform {
  145207. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  145208. position: DOMPointReadOnly;
  145209. orientation: DOMPointReadOnly;
  145210. matrix: Float32Array;
  145211. inverse: XRRigidTransform;
  145212. }
  145213. interface XRView {
  145214. eye: XREye;
  145215. projectionMatrix: Float32Array;
  145216. transform: XRRigidTransform;
  145217. }
  145218. interface XRInputSourceChangeEvent {
  145219. session: XRSession;
  145220. removed: Array<XRInputSource>;
  145221. added: Array<XRInputSource>;
  145222. }
  145223. interface XRInputSourceEvent extends Event {
  145224. readonly frame: XRFrame;
  145225. readonly inputSource: XRInputSource;
  145226. }
  145227. // Experimental(er) features
  145228. declare class XRRay {
  145229. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  145230. origin: DOMPointReadOnly;
  145231. direction: DOMPointReadOnly;
  145232. matrix: Float32Array;
  145233. }
  145234. declare enum XRHitTestTrackableType {
  145235. "point",
  145236. "plane"
  145237. }
  145238. interface XRHitResult {
  145239. hitMatrix: Float32Array;
  145240. }
  145241. interface XRTransientInputHitTestResult {
  145242. readonly inputSource: XRInputSource;
  145243. readonly results: Array<XRHitTestResult>;
  145244. }
  145245. interface XRHitTestResult {
  145246. getPose(baseSpace: XRSpace): XRPose | undefined;
  145247. }
  145248. interface XRHitTestSource {
  145249. cancel(): void;
  145250. }
  145251. interface XRTransientInputHitTestSource {
  145252. cancel(): void;
  145253. }
  145254. interface XRHitTestOptionsInit {
  145255. space: XRSpace;
  145256. entityTypes?: Array<XRHitTestTrackableType>;
  145257. offsetRay?: XRRay;
  145258. }
  145259. interface XRTransientInputHitTestOptionsInit {
  145260. profile: string;
  145261. entityTypes?: Array<XRHitTestTrackableType>;
  145262. offsetRay?: XRRay;
  145263. }
  145264. interface XRAnchor {
  145265. // remove?
  145266. id?: string;
  145267. anchorSpace: XRSpace;
  145268. lastChangedTime: number;
  145269. detach(): void;
  145270. }
  145271. interface XRPlane extends XRAnchorCreator {
  145272. orientation: "Horizontal" | "Vertical";
  145273. planeSpace: XRSpace;
  145274. polygon: Array<DOMPointReadOnly>;
  145275. lastChangedTime: number;
  145276. }
  145277. interface XRAnchorCreator {
  145278. // AR Anchors
  145279. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  145280. }